// *** CROSS-BROWSER COMPATIBILITY ***

var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS6=document.getElementById && (navigator.appName=="Netscape")?true:false;
var isDyn = (isDOM || isIE4 || isNS4 || isNS6 );
if(isDOM && !isNS6)
		{
		winName = "top.hiddenFrame.waitWin.main";
		}
		else
		{
		winName = "top.hiddenFrame.waitWin";
		}
function getRef(id)
{
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
}

function getSty(id)
{

 return (isNS4 ? getRef(id) : getRef(id).style);
 
} 


function openhelpWindow(menuAction,helpAction)
{
var openAction="dsp_helpFunction.cfm?menuAction="+menuAction+"&helpAction="+helpAction;
submitWindow = open(openAction,'helpWindow', 'width=300,height=300,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );

}
function submitForm(jobNumber,ReportType,siteStyle){

document.frmReport.AGRILABACTION.value="";
document.frmReport.AGRILABACTION.value=ReportType;
if(jobNumber !="None"){
	document.frmReport.JOBNUM.value="";
	document.frmReport.JOBNUM.value=jobNumber;
	}

parent.hiddenFrame.waitWinOpen(siteStyle)
document.frmReport.submit();
}
function submitInvForm(invNo,siteStyle){


if(invNo !="None"){
	document.frmReport.invoiceNo.value="";
	document.frmReport.invoiceNo.value=invNo;
	}

parent.hiddenFrame.waitWinOpen(siteStyle)
document.frmReport.submit();
}
function wordWrap(switchVal,ReportType,jobNumber,siteStyle)
{
if(jobNumber !="None"){
	document.frmReport.JOBNUM.value="";
	document.frmReport.JOBNUM.value=jobNumber;
	}
document.frmReport.AGRILABACTION.value="";
document.frmReport.AGRILABACTION.value=ReportType;
document.frmReport.WIDTHRESTRICT.value="";
document.frmReport.WIDTHRESTRICT.value=switchVal;
parent.hiddenFrame.waitWinOpen(siteStyle)
document.frmReport.submit();

}

function sortSelection(switchVal,ReportType)
{
//if(jobNumber !="None"){
//	document.frmReport.JOBNUM.value="";
//	document.frmReport.JOBNUM.value=jobNumber;
//	}
document.frmReport.AGRILABACTION.value="";
document.frmReport.AGRILABACTION.value=ReportType;
document.frmReport.SORTORDER.value= switchVal;
document.frmReport.submit();

}



function clientFilled(){
//alert(document.frmReport.client_list.value.length)
if(document.frmReport.client_list.value.length > 0){
	var x= document.frmReport.client_list_apply.selectedIndex;
	var newVal= document.frmReport.client_list_apply.options[x].value; 
//alert("X is "+x+"\nNewVal is "+newVal)

	if(newVal=='None'){
	alert('You must identify what the List applies to');
	document.frmReport.client_list_apply.focus();
	return false;
		
		}
		else
		{
		return true;
		}
	}
	else
	{
	return true;
	}
}
function validateForm(){

var y=true;
//alert(y)clientFilled();
return(y)
}
function ChangeControls(thisCode){


	var arrayName="shortName";
	switch(thisCode){
		case "C":
		arrayName="shortName";
		break;
		case "N":
		arrayName="cName";
		break;
		case "D":
		arrayName="dairyReg";
		break;
		case "M":
		arrayName="meatReg";
		break;
	
	}
if(typeof(eval(arrayName)) == "object"){
	var lcarrayname= arrayName.toLowerCase();	
	var j= eval(arrayName+"."+lcarrayname+".length")
		with (document.frmReport){
			client_list_apply.value="";
			client_list_apply.value= thisCode;
		//if(j>2){User_list.size="3"}
			client_listSel.options.length = 0;
			var NewOptStart = new Option
			NewOptStart.value = "None";
			NewOptStart.text="==============Loading============";
			client_listSel.options[0]=NewOptStart;
			
			for (var i=1; i < j; i++){
			var NewOpt = new Option;
		//eval("shortName"+"."+"shortname"+"["+5+"]")
					
					NewOpt.value=	eval(arrayName+"."+lcarrayname+"["+i+"]");
					NewOpt.text=	eval(arrayName+"."+lcarrayname+"["+i+"]");
				
			client_listSel.options[client_listSel.options.length]= NewOpt;
			}
			if(j<1){
			client_listSel.options[0].text ="List Empty...   "
			}
			else
			{
			client_listSel.options[0].text ="Choose item...   "	
			}
		}
	}
}