
// creates an XMLHttpRequest instance
function createXmlHttpRequestObject()
{
    // will store the reference to the XMLHttpRequest object
    var xmlHttp;
    // create the XMLHttpRequest object
    try
    {
        // assume IE7 or newer or other modern browsers
        xmlHttp = new XMLHttpRequest();
    }
    catch(e)
    {
        // assume IE6 or older
        var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0',
                                        'MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP');
        // try every prog id until one works
        for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
        {
            try
            {
                // try to create XMLHttpRequest object
                xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
            }
            catch (e) {} // ignore potential error
        }
    }
    // return the created object or display an error message
    if (!xmlHttp)
    {
        alert("Error creating the XMLHttpRequest object.");
        return false;
    }
    else
        return xmlHttp;
}

function makerequest(serverPage, objID)
{
    // holds an instance of XMLHttpRequest
    var xmlhttp = createXmlHttpRequestObject();
    var obj = document.getElementById(objID);
    xmlhttp.open("GET",serverPage);
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            obj.innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}


function swaplink(id,state)
{
    var imgswap = document.getElementById("leftMenuImg");
    var tmpStr="/images/leftMenu/leftmenu"+((state==1)?"":id)+ ".png";
    imgswap.src=tmpStr;
    counter++;
}

function slideShow()
{
    //Set the opacity of all images to 0
    $('#header a').css({opacity: 0.0});
    //Get the first image and display it (set it to full opacity)
    $('#header a:first').css({opacity: 1.0});
    //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('header()',5000);
}

function header()
{
    //if no IMGs have the show class, grab the first image
    var current = ($('#header a.show')?  $('#header a.show') : $('#header a:first'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#header a:first') :current.next()) : $('#header a:first'));

    //Set the fade in effect for the next image, show class has higher z-index
    next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 3000);

    //Hide the current image
    current.animate({opacity: 0.0}, 3000).removeClass('show');
}

function slideShowForLogos()
{
    //Set the opacity of all images to 0
    $('#logo a').css({opacity: 0.0});
    //Get the first image and display it (set it to full opacity)
    $('#logo a:first').css({opacity: 1.0});
    //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('logo()',4000);
}

function logo()
{
    //if no IMGs have the show class, grab the first image
    var current = ($('#logo a.show')?  $('#logo a.show') : $('#logo a:first'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#logo a:first') :current.next()) : $('#logo a:first'));

    //Set the fade in effect for the next image, show class has higher z-index
    next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 3000);

    //Hide the current image
    current.animate({opacity: 0.0}, 3000).removeClass('show');
}
function getTopPosition(el)
{
    var obj = document.getElementById(el);
    var posY = obj.offsetTop;
    while(obj.offsetParent)
    {
        posY=posY+obj.offsetParent.offsetTop;
        if(obj==document.getElementsByTagName('body')[0]){break}
        else{obj=obj.offsetParent;}
    }
    return posY;
}

function showTextbox()
{
    var txtbx = document.getElementById('msgWhereHeardOther');
    var lbl=document.getElementById('msgWhereHeardOtherLabel');
    var slct = document.getElementById('msgWDYHAU');
    if (slct.options[slct.selectedIndex].value == '10')
    {
        txtbx.style.display='inline';
        txtbx.value="";
        lbl.style.display='inline';
    }else
    {
        txtbx.style.display='none';
        lbl.style.display='none';
    }
}
