var popUp; 

function OpenSchedule(idname, postBack,AppID)
{
	popUp = window.open('../Schedule/Make_Appointment_Panel.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack + '&AppointmentID=' + AppID, 
		'popupcal', 
		'width=900,height=650,left=100,top=50,scroll=yes,resizable=yes');
}

function OpenCalendar(idname, postBack)
{
	popUp = window.open('../PopCalendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=200,height=280,left=350,top=200');
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}

function OpenPackage(idname, postBack,whichform, OrderNo)
{
	if (whichform == "Packages") {
	popUp = window.open('../Packages/Packages.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'Packages', 
		'width=900,height=600,left=100,top=100,resizable,scrollbars');
	}
	else
	{
		popUp = window.open('../Parts/PartTableView.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack + '&OrderNo=' + document.forms[0].elements[OrderNo].value, 
		'Parts', 
		'width=900,height=500,left=100,top=100,resizable,scrollbars');
	}
}

function OpenParts(idname, postBack)
{
	popUp = window.open('../Packages/Packages.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'Parts', 
		'width=800,height=500,left=100,top=100');
}

function SetValue(formName, id, newValue, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newValue;
	if (postBack)
		__doPostBack(id,newValue);
}

function OpenForWorkOrder(idname, postBack,whichform, CustomerID)
{
	if (whichform == "Vehicle") 
	{
		popUp = window.open('../Vehicles/VehicleTableView.aspx?OWNER=Customer&formname=' + document.forms[0].name + 
		'&id=' + idname + '&OrderID=' + document.forms[0].elements[idname].value + '&postBack=' + postBack + '&CustomerID=' + CustomerID, 
		'Vehicle', 
		'width=980,height=650,left=100,top=50,resizable,scrollbars');
	}
	else
	{
		popUp = window.open('../Customers/Customer_Add_Edit.aspx?From=WO&formname=' + document.forms[0].name + 
		'&id=' + idname + '&OrderID=' + document.forms[0].elements[idname].value + '&postBack=' + postBack + '&CustomerID=' + CustomerID, 
		'Customer', 
		'width=850,height=630,left=100,top=50,resizable,scrollbars');
	}
}

function SyncParts(idname, postBack,whichform, OrderID)
{
	if (whichform == "SyncPart") 
	{
		popUp = window.open('../Parts/Sync_Parts.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack + '&OrderID=' + OrderID, 
		'SyncPart', 
		'width=600,height=400,left=300,top=250,resizable,scrollbars');
	}
}

function InvokePostBack(formName, id,newValue,postBack)	
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	if (postBack)
		__doPostBack(id,newValue);
}	



function editKeyBoard(objForm) {
	
	strWork = "1234567890.-"
	blnValidChar = false;		
	

	if(!blnValidChar)
		for(i=0;i < strWork.length;i++)
			if(window.event.keyCode == strWork.charCodeAt(i)) {
				blnValidChar = true;

				break;
			}

	if(!blnValidChar) {
	
		window.event.returnValue = false;		
		objForm.focus();					
	}
}

function formatPostal(str,textbox,e){
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 8 || whichCode == 46 || whichCode == 37 || whichCode == 39) return true;
var i=str.length

	 if (i == 3){
	  if (str.substring(i, i+1) != '-'){
	   str = str + ' '
	 }
	}
   textbox.value =str.toUpperCase()
}

function toUpperCase(str,textbox,e){
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 8 || whichCode == 46 || whichCode == 37 || whichCode == 39) return true;
var i=str.length

   textbox.value =str.toUpperCase()
}


function OpenHelp(filepath,width,height)
{
	var screenwidth = width;
    var screenheight = height;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,scrollbars,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
	popUp = window.open(filepath ,'Help',windowFeatures);
}

