var isNS6 = document.getElementById && !document.all;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;
  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
 	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n];
 	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  			if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
	
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
	  
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
		 
function changePage(sTabID,sPage){
	var sName =  (document.getElementById && !document.all)? document.getElementById("SerialList"): SerialList;
	window.location=sPage + "?sCurrentAccount="+sName.snList.value+"&iTab="+sTabID;
}
			 
function startAboutTimer() {
	var i, j = 0, isNS6 = (document.getElementById && !document.all);
	nameArray = new Array(); iObj = 0;
	a=startAboutTimer.arguments;
	for(i=0; j<a.length; i++)
	nameArray[i] = a[j++];
	vPicture =  (isNS6)? document.getElementById("aPicture"): document.images['aPicture'];
	vDepartment =  (isNS6)? document.getElementById("aDepartment"):aDepartment;
	vFirstName =  (isNS6)? document.getElementById("aFirstName"): aFirstName;
	aboutTimer = window.setInterval(switchAboutImage, 3000 );
}		 
			 
function stopAboutTimer() {
	window.clearInterval(aboutTimer); 
}		 
	 
function switchAboutImage(){		 		 		 
	if (document.images){			  
		if (iObj > nameArray.length - 1)
			iObj = 0;
		vPicture.src = 'support_files/artwork/employees/'+nameArray[iObj++];
		vFirstName.innerHTML = nameArray[iObj++];
		vDepartment.innerHTML = nameArray[iObj++];
	}
}

	
function showCall(bNewCall){		
	var sCall = isNS6? document.getElementById("newcall"): newcall;
	var sForm = isNS6? document.getElementById("servicecallForm"): servicecallForm;
	var sFormStatus = isNS6? document.getElementById("callFormStat"): callFormStat;
	var sButton =  (isNS6)? document.getElementById("maSend"): document.images['maSend'];
	var dButton =  (isNS6)? document.getElementById("maDele"): document.images['maDele'];
	if (bNewCall){
		sForm.problem.value = "";
		sForm.contact.value = "";
		sForm.phone.value = "";				
		sForm.call.checked = false;
		sFormStatus.innerHTML = "This service call will be placed for:";
		sFormStatus.style.top = "2px";
		sFormStatus.style.textAlign = "left";
		sFormStatus.style.color = "blue";
		sFormStatus.style.font = "bold 13px Verdana";
		sButton.style.visibility = "visible";
		dButton.style.visibility = "hidden";
	}
	else{	
		var callTable = isNS6? document.getElementById("dbtable"): dbtable;
		sFormStatus.innerHTML = "Press delete to remove call";
		sFormStatus.style.top = "1px";
		sFormStatus.style.textAlign = "center";
		sFormStatus.style.color = "red";
		sFormStatus.style.font = "bold 17px Arial";
		sForm.problem.value = callTable.rows[1].cells[2].innerHTML;
		sForm.contact.value = callTable.rows[1].cells[3].innerHTML;
		sForm.call.checked = (sForm.bCall.value == "checked")?true:false;
		sForm.phone.value = sForm.sPhone.value;
		sButton.style.visibility = "hidden";
		dButton.style.visibility = "visible";
	}
	sCall.style.visibility = "visible";
	sForm.problem.focus();	
}
		 
 function EnterSrvCall(iEnter){
	var sForm = isNS6? document.getElementById("servicecallForm"): servicecallForm;
	var sFormStatus = isNS6? document.getElementById("callFormStat"): callFormStat;
	if (iEnter==0){		//cancel action
		sForm.problem.value = "";
		sForm.contact.value = "";
		sForm.phone.value = "";
		if (isNS6){
			document.getElementById("maSend").style.visibility = "hidden";
			document.getElementById("maDele").style.visibility = "hidden";
			document.getElementById("newcall").style.visibility = "hidden";
		}
		else{
			document.images['maSend'].style.visibility = "hidden";
			document.images['maDele'].style.visibility = "hidden";
			newcall.style.visibility = "hidden";
		}
	}
	var bCallFirst = (sForm.call.checked)? "checked":"";
	if (iEnter==1)		//enter new call
		window.location="/proccall.asp?sCA="+sForm.sCA.value+"&T=N"+"&icid="+sForm.icid.value+"&pbm=" + sForm.problem.value + "&ct=" + sForm.contact.value + "&ph=" + sForm.phone.value + "&cl=" +bCallFirst;
	if (iEnter==2)		//delete call
		window.location="/proccall.asp?sCA="+sForm.sCA.value+"&T=D"+"&icid="+sForm.icid.value+"&iscid="+sForm.iscid.value;
 }


function neworder(bShow){
	var sForm = isNS6? document.getElementById("orderForm"): orderForm;
	var sFormStatus = isNS6? document.getElementById("orderFormStat"): orderFormStat;
	var sButton =  (isNS6)? document.getElementById("maOrderSend"): document.images['maOrderSend'];
	var dButton =  (isNS6)? document.getElementById("maOrderDele"): document.images['maOrderDele'];
	var sTable =  document.getElementById("dbordertable2");
	if (bShow){
		sFormStatus.innerHTML = "This order will be placed for:";
		sFormStatus.style.top = "6px";
		sFormStatus.style.color = "black";
		sFormStatus.style.font = "bold 75% Verdana";
		sButton.style.visibility = "visible";
		dButton.style.visibility = "hidden";
	}
	else{	
		var callTable = isNS6? document.getElementById("dbtable"): dbtable;
		sFormStatus.innerHTML = "Press delete to cancel order";
		sFormStatus.style.top = "0px";
		sFormStatus.style.color = "red";
		sFormStatus.style.font = "bold 110% Verdana";
		sForm.po.value = document.getElementById('dbordertable').rows[1].cells[2].innerHTML;
		//sForm.contact.value = document.getElementById('dbtable').rows[1].cells[3].innerHTML;
		sButton.style.visibility = "hidden";
		dButton.style.visibility = "visible";
	}
	if (isNS6)
		document.getElementById("supplyOrder").style.visibility = "visible";
	else
		supplyOrder.style.visibility = "visible";
	//Form.problem.focus();	
}

 function EnterOrder(iEnter){
	var sForm = isNS6? document.getElementById("orderForm"): orderForm;
	var sFormStatus = isNS6? document.getElementById("orderFormStat"): orderFormStat;
	if (iEnter==0){		//cancel action
		sForm.po.value = "";
		//sForm.contact.value = "";
		//sForm.phone.value = "";
		if (isNS6){
			document.getElementById("maOrderSend").style.visibility = "hidden";
			document.getElementById("maOrderDele").style.visibility = "hidden";
			document.getElementById("supplyOrder").style.visibility = "hidden";
		}
		else{
			document.images['maOrderSend'].style.visibility = "hidden";
			document.images['maOrderDele'].style.visibility = "hidden";
			supplyOrder.style.visibility = "hidden";
		}
	}
	//var sName =  (document.getElementById && !document.all)? document.getElementById("SerialList"): SerialList;
	//if (iEnter==1)		//enter new call
		//window.location="/proccall.asp?sCA="+sName.snList.value+"&T=N" + "&iid=" + sForm.iid.value + "&pbm=" + sForm.problem.value + "&ct=" + sForm.contact.value + "&ph=" + sForm.phone.value + "&cf=" + sForm.call.value;
	//if (iEnter==2)		//delete call
		//window.location="/proccall.asp?sCA="+sName.snList.value+"&sic=" + sForm.sid.value + "&T=D";
 }

function newMan(){
	var sFormSL = isNS6? document.getElementById("frmSupportList"): frmSupportList;
	var sSelectString = '/support.asp?iSM='+sFormSL.Manufacturer.value+'0';
	window.location=sSelectString
}

function selectedMod(){
	var sFormSL = isNS6? document.getElementById("frmSupportList"): frmSupportList;
	var sSelectString = '/support.asp?iSM='+sFormSL.Manufacturer.value+sFormSL.Model.value;
	window.location=sSelectString
}

function chkNumber(){
	var code =  event.keyCode;
	window.event.returnValue = false;	
	if (code > 47 && code < 58 ||code > 95 && code < 106||code == 8||code == 9)
		window.event.returnValue = true;
	if (code == 46)
		window.event.returnValue = true;
}

function openNewWindow(sLocation){
	window.open(sLocation);
}

function cameraSubmit(){
	var sForm = isNS6? document.getElementById("ContactForm"): ContactForm;
	var isIncomplete = 0;
	if(trimAll(sForm.email.value) == ""){
		sForm.email.value = ""
		sForm.email.focus()
		isIncomplete = 1;}
	if(trimAll(sForm.company.value) == ""){
		sForm.company.value = ""
		sForm.company.focus()
		isIncomplete = 1;}
	if(trimAll(sForm.contact.value) == ""){
		sForm.contact.value = ""
		sForm.contact.focus()
		isIncomplete = 1;}
	if(isIncomplete > 0){
		alert("Your Name, Company Name, and Email fields can not be blank.");
		window.event.returnValue = false;
		}
}

function trimAll(sString){
while (sString.substring(0,1) == ' '){
	sString = sString.substring(1, sString.length);
	}
while (sString.substring(sString.length-1, sString.length) == ' '){
	sString = sString.substring(0,sString.length-1);
	}
return sString;
}


function drawing(){
	var sFormSL = isNS6? document.getElementById("frmId"): frmId;
	var iCA = sFormSL.Id.value;
	window.location="/cameradrawing.asp?sID="+iCA;
}
		
         var count = 58;
		 var itop = 140;
		 var iloops = 0;
         var direction = 1;
		 var timer1		 
         function start() 
         {
		 	color.style.left = 58;
		 	mono.style.left = 58;
			referb.style.left = 58;
			referb.style.top = 140;
			printer.style.top = 140;
			fax.style.top = 140;
           timer1 = window.setInterval( "run()", 5 );
         }

         function run() 
         {
		 	iloops ++
		 	count += 10;
			//itop += 2;
            color.style.left = (count > 258) ?color.style.left = 258 :color.style.left = count;
            mono.style.left = (count > 458) ?mono.style.left = 458 :mono.style.left = count; 
			if (iloops < 20) 
				fax.style.top = 140 + (iloops * (167 / 20));
            //fax.style.top = (itop > 307) ?fax.style.top = 307 :fax.style.top = itop; 
            printer.style.left = (count > 258) ?printer.style.left = 258 :printer.style.left = count; 
			if (iloops < 40)
            	printer.style.top = 140 + (83 * (iloops / 20)); 
            //	printer.style.top = 140 + (167 * (iloops / 40)); 
            referb.style.left = (count > 458) ?referb.style.left = 458 :referb.style.left = count; 
			referb.style.top = 140 + (200 * (iloops / 50));
			//referb.style.top = 140 + (167 * (iloops / 81));
           // referb.style.top = (itop > 307) ?referb.style.top = 307 :referb.style.top = itop;
			if (count > 460 )
				window.clearInterval(timer1); 
         }

function sTechSel(){
	var sButton =  (isNS6)? document.getElementById("DM"): document.images['DM'];
	var dButton =  (isNS6)? document.getElementById("sTech"): document.images['sTech'];
	if(document.forms[0].DM[2].checked) {
		document.forms[0].sTech.style.visibility = "visible";
	}
	else {
		document.forms[0].sTech.style.visibility = "hidden";
	}
	//dButton.style.visibility = "visible";
	//var sFormSL = isNS6? document.getElementById("frmSupportList"): frmSupportList;
	//var sSelectString = '/support.asp?iSM='+sFormSL.Manufacturer.value+'0';
	//window.location=sSelectString
}


