function getAjaxObject() {
    var http_request = false;

    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
            http_request.overrideMimeType('text/xml');
    }
    else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch (failed) { http_request = false; }
        }
    }
    return (http_request);
}

//Normal Items
function GetData(stateid) {
    var dvCon = 'dvContents';
    if (document.getElementById(dvCon) == null) {
        dvCon = 'ctl00_ContentPlaceHolder1_dvContents';
    }
    var xmlHttp = getAjaxObject();
    
    var sURL = window.location.href + "?getCities=true&stateid=" + stateid;
    xmlHttp.open("GET", sURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            document.getElementById(dvCon).innerHTML = xmlHttp.responseText;
        }
    };

    xmlHttp.send(null);

}

function GetSubData(stateid, cityid) {
    var dvCon = 'dvContents';
    if (document.getElementById(dvCon) == null) {
        dvCon = 'ctl00_ContentPlaceHolder1_dvContents';
    }
    var xmlHttp = getAjaxObject();
    var sURL = window.location.href + "?getCompanies=true&stateid=" + stateid + "&cityid=" + cityid;
    xmlHttp.open("GET", sURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            document.getElementById(dvCon).innerHTML = xmlHttp.responseText;
        }
    };

    xmlHttp.send(null);

}

//Normal Items
function GetContentText(pageid) {
    SetContactInfo(pageid);   
    
    var loadingimg = document.getElementById("dvLoading");
    if(loadingimg)
    {
        loadingimg.style.display = "block";
    }
    var xmlHttp = getAjaxObject();
    //alert(window.location.href);
    var sURL = window.location.href + "?getContents=true&pageid=" + pageid;
    var dvCon = 'dvContents';
    if (document.getElementById(dvCon) == null) {
        dvCon = 'ctl00_ContentPlaceHolder1_dvContents';
    }
    xmlHttp.open("GET", sURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {        
        
            document.getElementById(dvCon).innerHTML = xmlHttp.responseText;
                if(loadingimg)
                {
                    loadingimg.style.display = "none";
                }
                $('#imgHeading').hide();
                
                if(pageid=='8')
                {
                    showData('tr1');
                }
               
        }
    };

    xmlHttp.send(null);

}
function SetContactInfo(pageid)
{
    $('#dvBottomInfo').show();
    switch(pageid)
    {
    case '1'://APC        
        $('#contactinfo').attr('src', 'newimages/apcbanner.gif');
        break;
    case '15'://Biotronik        
        $('#contactinfo').attr('src', 'newimages/biotronik.gif');    
        break;
    case '12'://CAE        
        $('#contactinfo').attr('src', 'newimages/cae.gif');    
        break;    
    case '10'://CPC        
        $('#contactinfo').attr('src', 'newimages/cpc.gif');    
        break;    
    case '11'://Cryogine        
        $('#contactinfo').attr('src', 'newimages/cryo.gif');    
        break;    
    case '9'://Delta        
        $('#contactinfo').attr('src', 'newimages/delta.gif');    
        break;    
    case '13'://GMV        
        $('#contactinfo').attr('src', 'newimages/gmv.gif');    
        break;    
    case '4'://HCONS        
        $('#contactinfo').attr('src', 'newimages/hcons.gif');    
        break;    
    case '14'://Hillrom        
        $('#contactinfo').attr('src', 'newimages/hillrom.gif');    
        break;    
    case '3'://MCA        
        $('#contactinfo').attr('src', 'newimages/mca.gif');    
        break;    
    case '6'://OCD        
        $('#contactinfo').attr('src', 'newimages/ocd.gif');    
        break;    
    case '8'://Sankom        
        $('#contactinfo').attr('src', 'newimages/sankom.gif');    
        break;    
    case '5'://Mindray        
        $('#contactinfo').attr('src', 'newimages/mindray.gif');    
        break;    
    case '7'://Volcano        
        $('#contactinfo').attr('src', 'newimages/volcano.gif');    
        break;    
    default:
        $('#dvBottomInfo').hide();
        break;
    }
}
function showData(trid)
{
	//for hiding all other TRs
	for(var i =1; i < 7; i++)
	{
		if(trid != 'tr' + i)
		{
			document.getElementById('tr'+i).style.display = 'none';
		}
	}
		
	var trobj = document.getElementById(trid);
	if(trobj)
	{
		if(trobj.style.display=='none')
		{
			trobj.style.display = 'block';
		}
		else
		{
			trobj.style.display = 'none';
		}
	}
}

function OnSubmitOver(btn)
{
    btn.src = "newimages/a_btnsubmit1.png";
    btn.style.cursor = 'hand';    
}
function OnSubmitOut(btn)
{
    btn.src = "newimages/p_btnsubmit1.png";    
}

function OnResetOver(btn)
{
    btn.src = "newimages/a_btnreset1.png";    
    btn.style.cursor = 'hand';    
}
function OnResetOut(btn)
{
    btn.src = "newimages/p_btnreset1.png";    
}


function doSearch() {
    var frm = document.getElementById('aspnetForm');
    frm.action = "http://search.freefind.com/find.html";
    if (frm) {
        frm.submit();
    }
    return false;
}
function showThis(thisid)
{
    var menuobj = document.getElementById("servicemenu");

    if(thisid == 'srvc1')
    {
        var selected = document.getElementById("manufacturing");
        menuobj.style.display = "none";
        selected.style.display = "block";
    }
    else if(thisid == 'srvc2')
    {
        var selected = document.getElementById("customersupport");
        menuobj.style.display = "none";
        selected.style.display = "block";
    }
}
function showAll()
{
    var menuobj = document.getElementById("servicemenu");
    var selected2 = document.getElementById("customersupport");
    var selected1 = document.getElementById("manufacturing");
    menuobj.style.display = "block";
    selected1.style.display = "none";
    selected2.style.display = "none";
}
function ShowPhotoGallery(sel) {
    var selected = document.getElementById("manufacturing");
    if (sel == '1') {
        var photosel = document.getElementById("gallery");
        photosel.style.display = "block";
        selected.style.display = "none";
    }
    else if (sel == '2') {
        var photosel = document.getElementById("photosel2");
        photosel.style.display = "block";
        selected.style.display = "none";
    }
}
