var http = createRequestObject(); 
var return_content = "";
var img_expand = "";

function createRequestObject()
{
    var request_o;
    var browser = navigator.appName;
  
    if(browser == "Microsoft Internet Explorer")
        request_o = new ActiveXObject("MSXML2.XMLHTTP.3.0");
    else
        request_o = new XMLHttpRequest();	
	
    return request_o;
}

function handleState()
{
    if(http.readyState == 4)
    {
        var response = http.responseText;        
        return_content.innerHTML = response;
    }
}

function getArchives(type_id)
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "Loading..."; 
    posturl = 'tp=' + escape(type_id);        
    http.open('post', 'includes/process_archives.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);    
}

function getGalleryArchives()
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "Loading..."; 
    posturl = '';    
    http.open('post', 'includes/process_gallery.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);    
}

function getPortFolio(rider_id)
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "Loading..."; 
    posturl = 'rider=' + escape(rider_id);    
    http.open('post', 'includes/process_portfolio.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);    
}

function getResults(event_id,element_id,elementbutton_id)
{
    img_expand = document.getElementById(elementbutton_id);
    img_expand.src = "images/shrink.gif";
    img_expand.onclick = function() {clear_results_content(event_id,element_id,elementbutton_id)}
        
    return_content = document.getElementById(element_id)
    return_content.innerHTML = "Loading..."; 
    posturl = 'event=' + escape(event_id);    
    http.open('post', 'includes/process_event_results.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);    
}

function clear_content() {
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "";
}

function clear_results_content(event_id,element_id,elementbutton_id) {    
    var content = "";
    content = document.getElementById(element_id);
    content.innerHTML = "";

    var img_button = "";
    img_button = document.getElementById(elementbutton_id);
    img_button.src = "images/expand.gif";
    img_button.onclick = function(){getResults(event_id,element_id,elementbutton_id);}           
}

function sendEmail(type_of_query,first_name,last_name,email_address,phone_number,fax_number,company,message)
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "<B>Please wait...</B>"; 
    posturl = 'type_of_query=' + escape(type_of_query) + '&first_name=' + escape(first_name) + '&last_name=' + escape(last_name) + '&email_address=' + escape(email_address) + '&phone_number=' + escape(phone_number) + '&fax_number=' + escape(fax_number) + '&company=' + escape(company) + '&message=' + escape(message);
    
    http.open('post', 'includes/process_email.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);   
}

function sendRiderEmail(rider,first_name,last_name,email_address,phone_number,fax_number,company,message)
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "<B>Please wait...</B>"; 
    posturl = 'rider=' + escape(rider) + '&first_name=' + escape(first_name) + '&last_name=' + escape(last_name) + '&email_address=' + escape(email_address) + '&phone_number=' + escape(phone_number) + '&fax_number=' + escape(fax_number) + '&company=' + escape(company) + '&message=' + escape(message);
    
    http.open('post', 'includes/process_rider_email.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);   
}

function getProfile(profile_id)
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "Loading..."; 
    posturl = 'profile=' + escape(profile_id);    
    http.open('post', 'includes/process_management_profiles.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);    
}

function subscribeEmail(first_name,email,type)
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "Please wait..."; 
    posturl = 'first_name=' + escape(first_name) + '&email=' + escape(email) + '&type=' + escape(type);
    
    http.open('post', 'includes/process_subscribe.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);   
}
function unsubscribeEmail(email,type)
{
    return_content = document.getElementById("return_content")
    return_content.innerHTML = "Please wait..."; 
    posturl = 'email=' + escape(email) + '&type=' + escape(type);
    
    http.open('post', 'includes/process_subscribe.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);   
}
function getTeamYears()
{
    return_content = document.getElementById("return_content_options")
    return_content.innerHTML = "Loading..."; 
    posturl = '';        
    http.open('post', 'includes/process_teamyears.asp', true);
    http.onreadystatechange = handleState;
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);    
}

/*
function doSomething(vfname,vemail,vcontact_no,vcountry,vsubject,vmessage)
{
    //the posting to yourASPFile.asp, escape url encodes it...so decode inn your asp file 
	var posturl = 'fname=' + escape(vfname) + '&email=' + escape(vemail) + '&contact_no=' + escape(vcontact_no) + '&country=' + escape(vcountry) + '&subject=' + escape(vsubject) + '&message=' + escape(vmessage);
    
    //the html result (where you want the asp file to print to)
    //theResult being the elements id
    result = document.getElementById('theResult'); 

    http.open('post', '/Main/contactemail.asp', true);
    http.onreadystatechange = handleState; //the above function
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    http.send (posturl);
}
*/