var popUp;
var bOneTime=0;


//function PopMasterSelection()
//{
//	var szFeatures;
//	var result;
//	szFeatures = 'dialogWidth:400px; dialogHeight:300px; center:yes; status:no; help:no; scroll:no; resize:no;';
//	result = window.showModalDialog("MasterSelection.aspx",window, szFeatures)
//	return (result)
//}
	
function MaxLen(inField, maxLen)
{
    txt = document.forms[0].elements[inField].value;
    if (txt.length > maxLen)
    {
        alert("The text length(" + txt.length + ") exceeds the maximum length of " + maxLen+ " characters.");
        document.forms[0].elements[inField].focus();
        return false;
    }
    return true;
}


function ClearText(controlID)
{
    if (bOneTime == 0)
    {
        bOneTime=1;
        if (document.forms[0].elements[controlID].value == "[Type search value here]")
        {
            document.forms[0].elements[controlID].value="";
        }
    }
    return false;
}

function SetControlValue(controlID, newDate, isPostBack)
{
    popUp.close();
    document.forms[0].elements[controlID].value=newDate;
    __doPostBack(controlID,'');
}

function OpenPopupPage (pageUrl, controlID, isPostBack)
{
	//var result;
	//szFeatures = 'dialogWidth:250px; dialogHeight:300px; center:yes; status:0; help:0; scroll:no; resize:no;';
	//window.open(pageUrl+'?controlID='+controlID+'&isPostBack='+ isPostBack,'popupcal', szFeatures)
	//return (result)
   popUp=window.open(pageUrl+'?controlID='+controlID+'&isPostBack='+ isPostBack,'popupcal', 'width=250,height=300'); //,left=200,top=250
}
		                         
 
function hideshow(obj, obj2) 
{ 
    //alert(document.getElementById(<%=trCompany.ClientID%>).name);
    document.getElementById(obj).style.display = "block"; 
    document.getElementById(obj2).style.display = "none"; 
    return;
} 

function cancelorder(sOrderNumber,controlID)
{
    if(confirm('Are you sure you want to cancel this order: ' + sOrderNumber + '?'))
    {
        document.getElementById(controlID).value = sOrderNumber; 
        __doPostBack(controlID,sOrderNumber);
    }

}

function fnTrapKP(btnName){
	if (event.keyCode == 13)
	{
	    var btn = document.getElementById(btnName);
	    event.returnValue=false;
	    event.cancelBubble = true;
	    btn.click();
	}
}

function pingServer(inIP,inLabel)
{
 
    if (AjaxMethod.Ping(inIP) != '1')
    {
        alert('It appears that the remotes server is down.');
        document.getElementById(inLabel).style.display = "none"; 
    }   
}
