function GetXmlHttpObject(handler)
{ 
    var objXmlHttp=null
    if (navigator.userAgent.indexOf("MSIE")>=0)
    { 
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        } 
        try
        { 
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler 
            return objXmlHttp
        } 
        catch(e)
        { 
            alert("Error. Scripting for ActiveX might be disabled") 
            return 
        } 
    } 
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler 
        return objXmlHttp
    }
}

//Global stock text vars
var CurrentLabelID = "";

function GetStockText(labelID, itemID, dim1ID, dim2ID, dim3ID, lid)
{
    //Set the global label var
    CurrentLabelID = labelID;
    
    //Find the dropdowns
    var dim1 = document.getElementById(dim1ID);
    var dim2 = document.getElementById(dim2ID);
    var dim3 = document.getElementById(dim3ID);
    
    //Find all the values
    var dim1value = '0';
    if (dim1) dim1value = dim1.value;
    
    var dim2value = '0';
    if (dim2) dim2value = dim2.value;
    
    var dim3value = '0';
    if (dim3) dim3value = dim3.value;
    
    //Build the URL
    var url = "./Controls/Toolbox/GetStockText.aspx?ItemID=" + itemID + "&Dim1=" + dim1value + "&Dim2=" + dim2value + "&Dim3=" + dim3value + "&LID=" + lid;
    
    //Perform the request
    xmlHttp = GetXmlHttpObject(GetStockTextReturn);
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function GetStockTextReturn() 
{
    //If xml http req is ready then inject
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById(CurrentLabelID).innerHTML = xmlHttp.responseText;
    }
}

function openImageWindow(itemID)
{
	win = window.open('Image.aspx?itemID='+itemID,'Preview', 'width=600,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0'); 
	win.focus;			
	
}
			
function openFileWindow(itemID)
{
	win = window.open('ViewFile.aspx?itemID='+itemID,'Preview', 'width=650,height=650,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=0'); 
	win.focus;			
}

function openLinkWindow(itemID)
{
	win = window.open('Redirect.aspx?itemID='+itemID,'Preview', 'width=650,height=650,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=0'); 
	win.focus;			
}

function SwitchArea(id) {

         if(!document.getElementById) return;

         var Area= document.getElementById(id);

         if(Area.className=='Area_on') {

                 Area.className='Area_off';

         }

         else if(Area.className=='Area_off') {

                 Area.className = 'Area_on';

         }

}



