function fnValInv(FieldRef)

{
	if (isNaN(document.getElementById(FieldRef).value)){
	alert ("Please enter a NUMERICAL value in this field.");
	document.getElementById(FieldRef).value=""
	document.getElementById(FieldRef).focus();
	}
	if ((document.getElementById(FieldRef).value)< 0){
	alert ("Please enter a POSITIVE Numerical value in this field.");
	document.getElementById(FieldRef).value=""
	document.getElementById(FieldRef).focus();
	}
}



function fnUpdateFromDay()	{
	document.frmQuotations.hdnFromDay.value = document.frmQuotations.FromDay.options.selectedIndex;
}
function fnUpdateFromDay2()	{
	document.frmQuotations.hdnFromDay2.value = document.frmQuotations.FromDay2.options.selectedIndex;
}
function fnUpdateToDay()	{
	document.frmQuotations.hdnToDay.value = document.frmQuotations.ToDay.options.selectedIndex;
}
function fnUpdateToDay2()	{
	document.frmQuotations.hdnToDay2.value = document.frmQuotations.ToDay2.options.selectedIndex;
}

//Obtain the month length
function fnToggleMonthLen(DayID,MonthID,HdnID){

var option = new Option("29",29);
document.getElementById(DayID).options[29] = option;

var option = new Option("30",30);
document.getElementById(DayID).options[30] = option;

var option = new Option("31",31);
document.getElementById(DayID).options[31] = option;

if (document.getElementById(MonthID).value=="1")
{
	if (document.getElementById(DayID).options[31].text == "31")
	{
	document.getElementById(DayID).options[31] = null
	}
	if (document.getElementById(DayID).options[30].text == "30")
	{
	document.getElementById(DayID).options[30] = null
	}
	var varCurrentYear = document.frmQuotations.hdnCurYear.value
	if (varCurrentYear != 2008 || varCurrentYear != 2012 || varCurrentYear != 2016)
	{
		if (document.getElementById(DayID).options[29].text == "29")
		{
		document.getElementById(DayID).options[29] = null
		}
	}
}
if (document.getElementById(MonthID).value=="3")
{
	if (document.getElementById(DayID).options[31].text == "31")
	{
	document.getElementById(DayID).options[31] = null
	}
}
if (document.getElementById(MonthID).value=="5")
{
	if (document.getElementById(DayID).options[31].text == "31")
	{
	document.getElementById(DayID).options[31] = null
	}
}
if (document.getElementById(MonthID).value=="8")
{
	if (document.getElementById(DayID).options[31].text == "31")
	{
	document.getElementById(DayID).options[31] = null
	}
}
if (document.getElementById(MonthID).value=="10")
{
	if (document.getElementById(DayID).options[31].text == "31")
	{
	document.getElementById(DayID).options[31] = null
	}
}
document.getElementById(DayID).options.selectedIndex = document.getElementById(HdnID).value;
}

function Stonkthrop()
{
return false
}


function fnMoveSMobCursor()

	{
	if ((document.frmQuotations.SMobAC.value.length)==4){
	document.frmQuotations.SMob.focus();
	}
	}
	
	
	function fnNumErr(FieldID)
{
if (isNaN(document.getElementById(FieldID).value)) {
	 alert ("Please enter a NUMERICAL value only in this field. Do not use ( , - or any other signs. ")
    document.getElementById(FieldID).style.borderColor="red";
	document.getElementById(FieldID).focus()
	return false
	}
	document.getElementById(FieldID).style.borderColor="#A0A0A0";
	if (document.getElementById(FieldID).value < 0 ){
	 alert ("Please enter a POSITIVE Numerical value in this field.")
	 document.getElementById(FieldID).style.borderColor="red";
   document.getElementById(FieldID).focus()
	return false
	}
}



function check(frmQuotations)
{
	
	if (document.frmQuotations.FromSuburb.value =="") {
	 alert ("Please enter a Pickup Suburb in this field.")
		 document.frmQuotations.FromSuburb.focus()
	return false
	}

	if (document.frmQuotations.SEmail.value =="") {
	 alert ("Please enter a valid Email Address.")
	 document.frmQuotations.SEmail.focus()
	return false
	
	}
	
	var varsmail
	varsmail = document.frmQuotations.SEmail.value
	if (varsmail.substr(-3)==".ru") {
	 alert ("Please enter a valid Email Address.")
	 document.frmQuotations.SEmail.focus()
	return false
	
	}
	
 
	  invalidChars = "/:,;%@<>!.\$^&*()-+=|?~"
	  
	  for (i=0; i<invalidChars.length;i++){
	  badChar = invalidChars.charAt(i)
		  if (document.frmQuotations.UPassword.value.indexOf(badChar,0)>-1)
		  {
	
		 alert ("Please enter a valid Passwords. ( /:,;%@<>!.\$^&*()-+=|?~ not permitted in Passwords.)")
		 document.frmQuotations.UPassword.focus()

		  return false
		  }
	  }
	  invalidChars = "/:,;"
	  
	  for (i=0; i<invalidChars.length;i++){
	  badChar = invalidChars.charAt(i)
		  if (document.frmQuotations.SEmail.value.indexOf(badChar,0)>-1)
		  {
	
		 alert ("Please enter a valid Email Address. ( /:,; not permitted in Email Addresses.)")
		 document.frmQuotations.SEmail.focus()

		  return false
		  }
	  }
	  
  	  validChars = "@."
	  intgood = 0
	  
	  for (i=0; i<validChars.length;i++){
	  goodChar = validChars.charAt(i)
		  if (document.frmQuotations.SEmail.value.indexOf(goodChar,0)>-1)
		  {
	  
		  intgood = intgood -1
		 
		  }
	  }
    	
	if (intgood ==0)  {
	 alert ("Please enter a valid Email Address.")
	 document.frmQuotations.SEmail.focus()
	return false
	
	}
	
	if (intgood ==-1)  {
	 alert ("Please enter a valid Email Address.")
	 document.frmQuotations.SEmail.focus()
	return false
	
	}
	
document.frmQuotations.submit();
return true
}

function fnIncr(ItemRef,SVC)  {
  var varItemValue
  if (document.getElementById(ItemRef).value=="")  {
    varItemValue=parseInt(0)
    if(SVC=="PX")  {
      document.getElementById(ItemRef).value=varItemValue+.1;
	}
    else {
      document.getElementById(ItemRef).value=varItemValue+parseInt(+1);
    }
  }
  else  {
    if(SVC=="PX")  {
      varItemValue=parseFloat(document.getElementById(ItemRef).value);
      document.getElementById(ItemRef).value=(varItemValue+.1).toFixed(1);
	}
    else {
      varItemValue=parseInt(document.getElementById(ItemRef).value);
      document.getElementById(ItemRef).value=varItemValue+parseInt(+1);
    }
  }
}

function fnGetVal(FieldRef)  {
  var str
  try  { 
	str = FieldRef + "=" + document.getElementById(FieldRef).value + ",";
  }
  catch(err)  {
    str = FieldRef + "=,";
  }
  return str;
}

function makeCookies(svc)  {
  var InventList = "";
  InventList = InventList + fnGetVal('A1');
  InventList = InventList + fnGetVal('A2');
  InventList = InventList + fnGetVal('A3');
  InventList = InventList + fnGetVal('A4');
  InventList = InventList + fnGetVal('A5');
  InventList = InventList + fnGetVal('B1');
  InventList = InventList + fnGetVal('B2');
  InventList = InventList + fnGetVal('B3');
  InventList = InventList + fnGetVal('B4');
  InventList = InventList + fnGetVal('B5');
  InventList = InventList + fnGetVal('C1');
  InventList = InventList + fnGetVal('C2');
  InventList = InventList + fnGetVal('C3');
  InventList = InventList + fnGetVal('C4');
  InventList = InventList + fnGetVal('C5');
  InventList = InventList + fnGetVal('D1');
  InventList = InventList + fnGetVal('D2');
  InventList = InventList + fnGetVal('D3');
  InventList = InventList + fnGetVal('D4');
  InventList = InventList + fnGetVal('D5');
  InventList = InventList + fnGetVal('E1');
  InventList = InventList + fnGetVal('E2');
  InventList = InventList + fnGetVal('E3');
  InventList = InventList + fnGetVal('E4');
  InventList = InventList + fnGetVal('E5');
  InventList = InventList + fnGetVal('F1');
  InventList = InventList + fnGetVal('F2');
  InventList = InventList + fnGetVal('F3');
  InventList = InventList + fnGetVal('F4');
  InventList = InventList + fnGetVal('F5');
  InventList = InventList + fnGetVal('G1');
  InventList = InventList + fnGetVal('G2');
  InventList = InventList + fnGetVal('G3');
  InventList = InventList + fnGetVal('G4');
  InventList = InventList + fnGetVal('G5');
  InventList = InventList + fnGetVal('H1');
  InventList = InventList + fnGetVal('H2');
  InventList = InventList + fnGetVal('H3');
  InventList = InventList + fnGetVal('H4');
  InventList = InventList + fnGetVal('H5');
  InventList = InventList + fnGetVal('I1');
  InventList = InventList + fnGetVal('I2');
  InventList = InventList + fnGetVal('I3');
  InventList = InventList + fnGetVal('I4');
  InventList = InventList + fnGetVal('I5');
  InventList = InventList + fnGetVal('J1');
  InventList = InventList + fnGetVal('J2');
  InventList = InventList + fnGetVal('J3');
  InventList = InventList + fnGetVal('J4');
  InventList = InventList + fnGetVal('J5');
  InventList = InventList + fnGetVal('K1');
  InventList = InventList + fnGetVal('K2');
  InventList = InventList + fnGetVal('K3');
  InventList = InventList + fnGetVal('K4');
  InventList = InventList + fnGetVal('K5');
  InventList = InventList + fnGetVal('L1');
  InventList = InventList + fnGetVal('L2');
  InventList = InventList + fnGetVal('L3');
  InventList = InventList + fnGetVal('L4');
  InventList = InventList + fnGetVal('L5');
  InventList = InventList + fnGetVal('M1');
  InventList = InventList + fnGetVal('M2');
  InventList = InventList + fnGetVal('M3');
  InventList = InventList + fnGetVal('M4');
  InventList = InventList + fnGetVal('M5');
  
  switch(svc)  {
    case "OR":
	  setCookie('InventListOR',InventList,'5');
	  break;
    case "PX":
	  setCookie('InventListPX',InventList,'5');
	  break;
  case "TT":
	  setCookie('InventListTT',InventList,'5');
	  break;
  
    default:
	  setCookie('InventListFR',InventList,'5');
	  break;
  }
  
   
    try  { 
    setCookie('UPassword',document.getElementById("UPassword").value,'5');
  }
  catch(err)  {
  }

    try  { 
    setCookie('SEmail',document.getElementById("SEmail").value,'5');
  }
  catch(err)  {
  }

  try  { 
    setCookie('AdditItems',document.getElementById("AdditItems").value,'5');
  }
  catch(err)  {
  }
  try  {     
	setCookie('FromSub',document.getElementById("FromSub").value,'5');
  }
  catch(err)  {
  } 
  try  {  	
	setCookie('FromState',document.getElementById("FromState").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('FromFloors',document.getElementById("FromFloors").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	if (document.getElementById("FromLift").checked)  {
	  setCookie('FromLift',document.getElementById("FromLift").value,'5');
	}
	else  {
	  setCookie('FromLift','0','5');
	}
  }
  catch(err)  {
  }     
  try  {  
	setCookie('ToSub',document.getElementById("ToSub").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('ToState',document.getElementById("ToState").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('ToFloors',document.getElementById("ToFloors").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	if (document.getElementById("ToLift").checked)  {
	  setCookie('ToLift',document.getElementById("ToLift").value,'5');
	}
	else  {
	  setCookie('ToLift','0','5');
	}
  }
  catch(err)  {
  } 
  try  {  
	setCookie('FromPickups',document.getElementById("AddPickup").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('FromAccess',document.getElementById("FromAccess").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('ToDeliveries',document.getElementById("AddDel").value,'5');
  }
  catch(err)  {
  }    
  try  {  
    setCookie('ToAccess',document.getElementById("ToAccess").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('OtherComments',document.getElementById("OtherComments").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('MVqty',document.getElementById("MVqty").value,'5');
  }
  catch(err)  {
  }     
  try  {  
	setCookie('RVqty',document.getElementById("RVqty").value,'5');
  }
  catch(err)  {
  } 	
  try  {  
	setCookie('StorageYN',document.getElementById("StorageYN").value,'5');
  }
  catch(err)  {
  } 
  try  {  
	setCookie('SMobAC',document.getElementById("SMobAC").value,'5');
  }
  catch(err)  {
  } 
  try  {  
	setCookie('SMob',document.getElementById("SMob").value,'5');
  }
  catch(err)  {
  } 
  try  {  
	setCookie('FromDay',document.getElementById("FromDay").value,'5');
  }
  catch(err)  {
  } 
  try  {  
	setCookie('FromDay2',document.getElementById("FromDay2").value,'5');
  }
  catch(err)  {
  } 
  try  {  
	setCookie('FromMonth',document.getElementById("FromMonth").value,'5');
  }
  catch(err)  {
  } 
  try  {  
	setCookie('FromMonth2',document.getElementById("FromMonth2").value,'5');
  }
  catch(err)  {
  } 
  try  {  
	if (document.getElementById("AnytimeYN").checked)  {
	  setCookie('AnytimeYN',document.getElementById("AnytimeYN").value,'5');
	}
	else  {
	  setCookie('AnytimeYN','0','5');
	}
  }
  catch(err)  {
  } 	
}

function setCookie(c_name,value,expiredays)  {
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}