var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"

function openPopWin(winURL, winWidth, winHeight, winFeatures){
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length == 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  popWin = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)
  }

function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
  }


function getuserlog(){
  var usercookie=ReadCookie("USERNAME") ;
  document.logged.UserName.value = usercookie;
  var passuser = document.logged.UserName.value;
  if (passuser=="" || passuser==" ") {
    alert('No valid user Name') }
}
function getuserfwq2(){
  var usercookie=ReadCookie("USERNAME") ;
  document.fwq2.UserName.value = usercookie;
  var passuser = document.fwq2.UserName.value;
  if (passuser=="" || passuser==" ") {
    alert('No valid user Name') }
  }
function getuserpod(){
  var usercookie=ReadCookie("USERNAME") ;
  document.fwpod.UserName.value = usercookie;
  var passuser = document.fwpod.UserName.value;
  if (passuser=="" || passuser==" ") {
    alert('No valid user Name') }
  window.status = 'Loading POD image page....';
}
function getusermenu(){
  var usercookie=ReadCookie("USERNAME") ;
  document.menu.UserName.value = usercookie;
  var passuser = document.menu.UserName.value;
  if (passuser=="" || passuser==" ") {
    alert('No valid user Name') }
  }
function getuserq(){
  var usercookie=ReadCookie("USERNAME") ;
  document.fwq3n.UserName.value = usercookie;
  var passuser = document.fwq3n.UserName.value;
  if (passuser=="" || passuser==" ") {
    alert('No valid user Name') }
  }

function getuser(){
  var usercookie=ReadCookie("USERNAME") ;
  document.enterWB.UserName.value = usercookie;
  var passuser = document.enterWB.UserName.value;
  if (passuser=="" || passuser==" ") {
    alert('No valid user Name') }
}
function getuser1(){
  var usercookie=ReadCookie("USERNAME") ;
  document.enterColl.UserName.value = usercookie;
  var passuser = document.enterColl.UserName.value;
}

function getuser2(){
  var usercookie=ReadCookie("USERNAME") ;
  document.enterParms.UserName.value = usercookie;
  var passuser = document.enterParms.UserName.value;
}
function getuser3(){
  var usercookie=ReadCookie("USERNAME") ;
  document.nextWB.UserName.value = usercookie;
  var passuser = document.nextWB.UserName.value;
}

function getuser4(){
  var usercookie=ReadCookie("USERNAME") ;
  document.custInvoice.UserName.value = usercookie;
  var passuser = document.custInvoice.UserName.value;
}

function getuser5(){
  var usercookie=ReadCookie("USERNAME") ;
  document.custStatement.UserName.value = usercookie;
  var passuser = document.custStatement.UserName.value;
}

function getuser6(){
  var usercookie=ReadCookie("USERNAME") ;
  document.collEnq.UserName.value = usercookie;
  var passuser = document.collEnq.UserName.value;
}
function getuser7(){
  var usercookie=ReadCookie("USERNAME") ;
  document.collVerify.UserName.value = usercookie;
  document.collVerify.orderAcceptedYn.value = 'Y';
}
function ReadCookie(cookieName) {

 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);

 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
 
function servuser() {
        getuser();
        window.document.enterWB.myswitch.value = 'Y';
	document.enterWB.action = "http://www.bercoexpress.co.za/berco/servmail";
}
function servuserp() {
        window.document.enterWB.myswitch.value = 'Y';
	document.enterWB.action = "http://www.bercoexpress.co.za/berco/servmail";
}
  
function required() {	
        getuser()
        var sw = window.document.enterWB.myswitch.value;
        if (sw <= " "){
  	
		var itemsEntered = 0
  
  		if (!window.document.enterWB.waybillNo.value == " ") {
			itemsEntered += 1 }
				
	  	if (!window.document.enterWB.xrefNo.value == " ") {
			itemsEntered += 1 }
	  	if (!window.document.enterWB.parcelNo.value == " ") {
			itemsEntered += 1 }

	  	if (!itemsEntered == 1) {
  			if (itemsEntered == 0) {
  				alert("Please enter a waybill number\nor customer reference number") ;
                        	return(false)}
  			else {
  				alert("You MAY NOT enter a waybill number\nAND customer reference number\nAND a collection request number") ;
                        	return (false)} 		
  		}

	}
	window.status = 'Please wait while waybill information is being retrieved...'
}
function requiredp() {	
        var sw = window.document.enterWB.myswitch.value;
        if (sw <= " "){
  	
		var itemsEntered = 0
  
  		if (!window.document.enterWB.waybillNo.value == " ") {
			itemsEntered += 1 }
				
	  	if (!window.document.enterWB.xrefNo.value == " ") {
			itemsEntered += 1 }

	  	if (!window.document.enterWB.parcelNo.value == " ") {
			itemsEntered += 1 }

	  	if (!itemsEntered == 1) {
  			if (itemsEntered == 0) {
  				alert("Please enter a waybill number\nor customer reference number\nor parcel number") ;
                        	return(false)}
  			else {
  				alert("You MAY NOT enter more than one value") ;
                        	return (false)} 		
  		}

	}
	window.status = 'Please wait while waybill information is being retrieved...'
}
function cvalid(selvalue, sel2value, sel3value, sel4value){
  getuser1();
  var selectedOptionValue = null;
  var selectedOptionText = null;
  var myfromPost = null;
  var mytoPost = null;
  var mymass = null;
  var myvol = null;
  var myqty = null;
  var mysenAdd1 = null;
  var mysenCon = null;
  var mysenTel = null;
  var mysenTelCode = null;
  var myRecCon = null;
  var myrecAdd1 = null;
  var myrecAdd5 = null;
  var myrecCon = null;
  var myrecTel = null;
  var myrecTelCode = null;

  selectedOptionValue = selvalue.options[selvalue.selectedIndex].value;
  selectedOptionText = selvalue.options[selvalue.selectedIndex].text;
   
  myfromPost = document.enterColl.senAdd5.value;
  if (selectedOptionText=='Select'&&(myfromPost==""||myfromPost==" ")){
    alert('Please select a Collection site or enter the Collection site details');
    document.enterColl.sendSite.focus() ;
    return(false);}
  if (selectedOptionText=='Select'){
    if (!myfromPost == "") {
      if (!myfromPost == " ") {
        mysenAdd1 = document.enterColl.senAdd1.value;
        mysenCon = document.enterColl.senContact.value;
        mysenTelCode = document.enterColl.senTelNoCode.value;
        mysenTel = document.enterColl.senTelNo.value;
        if (mysenAdd1==""||mysenAdd1==" "){
           alert('Please enter a collection address');
           document.enterColl.senAdd1.focus() ;
           return(false);}
        if (mysenCon==""||mysenCon==" "){
           alert('Please enter a contact person');
           document.enterColl.senContact.focus() ;
           return(false);}
        if (mysenTelCode==""||mysenTelCode==" "){
           alert('Please enter a contact telephone dailing number');
           document.enterColl.senTelNoCode.focus() ;
           return(false);}
        if (mysenTel==""||mysenTel==" "){
           alert('Please enter a contact telephone number');
           document.enterColl.senTelNo.focus() ;
           return(false);}
      }
    }
  }
  selectedOptionValue = sel2value.options[sel2value.selectedIndex].value;
  selectedOptionText = sel2value.options[sel2value.selectedIndex].text;
   
  myrecAdd1 = document.enterColl.recAdd1.value;
  myrecAdd5 = document.enterColl.recAdd5.value;
  if (selectedOptionText=='Select'&&(myrecAdd5==""||myrecAdd5==" ")){
    alert('Please select a Receiving site or enter the Receiving site details');
    document.enterColl.recSite.focus() ;
    return(false);}
  if (!selectedOptionText=='Select'){
    if ( !myrecAdd5 == "" || !myrecAdd5 == " "){
      alert('Enter only a Receiving site or Receiving details');
      document.enterColl.recSite.focus() ;
      return(false);}
  }
  if (selectedOptionText=='Select'){
    if ( !myrecAdd5 == "" || !myrecAdd5 == " "){
      myrecCon = document.enterColl.recName.value;
      if (myrecAdd1==""||myrecAdd1==" "){
         alert('Please enter a receiving address');
         document.enterColl.recAdd1.focus() ;
         return(false);}
      if (myrecCon==""||myrecCon==" "){
         alert('Please enter a contact person');
         document.enterColl.recName.focus() ;
         return(false);}
        myrecTelCode = document.enterColl.recTelNoCode.value;
        myrecTel = document.enterColl.recTelNo.value;
        if (myrecTelCode==""||myrecTelCode==" "){
           alert('Please enter a receiving telephone dailing number');
           document.enterColl.recTelNoCode.focus() ;
           return(false);}
        if (myrecTel==""||myrecTel==" "){
           alert('Please enter a receiving telephone number');
           document.enterColl.recTelNo.focus() ;
           return(false);}
    }
  }
  selectedOptionValue = sel3value.options[sel3value.selectedIndex].value;
  selectedOptionText = sel3value.options[sel3value.selectedIndex].text;
  if (selectedOptionText=='Select'){
    alert('Please select a Collection date');
    document.enterColl.dateOrderA.focus() ;
    return(false);}
  selectedOptionValue = sel4value.options[sel4value.selectedIndex].value;
  selectedOptionText = sel4value.options[sel4value.selectedIndex].text;
  if (selectedOptionText=='Select'){
    alert('Please select a Service Type');
    document.enterColl.serviceType.focus() ;
    return(false);}
  /* mymass = document.enterColl.itemMassA.value;
  if ( mymass == "" || mymass == " "|| !isval(mymass)){
    alert('Please enter actual mass');
    document.enterColl.itemMassA.focus() ;
    return(false);} */
  myqty = document.enterColl.itemQtyA.value;
  if ( myqty == "" || myqty == " "|| !isnum(myqty)){
    alert('Please enter the number of parcels');
    document.enterColl.itemQtyA.focus() ;
    return(false);}
  if (document.enterColl.TTval.value == "N"){
   alert('Please accept the Standard Trading Terms and Conditions before continuing');
   document.enterColl.TT.focus();
   return(false);
  }
  window.status = 'Loading Collection confirmation page...';
}


 
function invvalid() {	
	getuser2()
	
  	if (window.document.enterParms.invoiceNo.value <= " ") {
		alert("You MUST enter a valid Invoice Number or contact\nthe System Administrator for assistance") ;
		document.enterParms.invoiceNo.focus() ;
		return(false)}
  window.status = 'Loading invoice page....';
}

function collenq() {	

        getuser6()
	window.document.collEnq.ordNo.value = window.document.collEnq.ordNo.value.toUpperCase()
  	if (window.document.collEnq.ordNo.value <= " ") {
		alert("You MUST enter a valid Collection Request Number or contact\nthe System Administrator for assistance") ;
		document.collEnq.ordNo.focus() ;
		return(false)}
}

function ccvalid() {	
        
	getuser2();
	var startdate = "";
	var enddate = "";
	
  		
  	startdate = window.document.enterParms.startDate.value 
  	if (startdate == ""||startdate == " "||!isnum(startdate)) {
		alert("Please enter a start date in the format YYYYMMDD");
		document.enterParms.startDate.focus() ;
		return(false)}

  	enddate = window.document.enterParms.endDate.value 
  	if (enddate == ""||enddate == " "||!isnum(enddate)) {
		alert("Please enter an end date in the format YYYYMMDD") ;
		document.enterParms.endDate.focus() ;
		return(false)}
    window.status = 'Loading Spend by Cost Center Report....';
}
 
function servvalid() {	
	getuser2()
	var startdate = "";
	var enddate = "";
	
  		
  	startdate = window.document.enterParms.startDate.value; 
  	if (startdate == ""||startdate == " "||!isnum(startdate)) {
		alert("Please enter a start date in the format YYYYMMDD") ;
		document.enterParms.startDate.focus() ;
		return(false)}

  	enddate = window.document.enterParms.endDate.value; 
  	if (enddate == ""||enddate == " "||!isnum(enddate)) {
		alert("Please enter an end date in the format YYYYMMDD") ;
		document.enterParms.endDate.focus() ;
		return(false)}
    window.status = 'Loading Spend by Service Type Report....';
}
 
function statvalid() {	
	var statdate = "";
	getuser2();
	
  	if (window.document.enterParms.custCode.value <= " ") {
		alert("You MUST enter a valid Account Code or contact\nthe System Administrator for assistance") ;
		document.enterParms.custCode.focus() ;
		return(false)}
	
  	statdate = window.document.enterParms.statementPeriod.value;
  	if (statdate == ""||statdate == " "||!isnum(statdate)) {
		alert("Please enter statement period in the format YYYYMM") ;
		document.enterParms.statementPeriod.focus() ;
		return(false)}
    window.status = 'Loading statement page....';
}
 
function destvalid() {	
	getuser2()
	var startdate = "";
	var enddate = "";
	
  		
  	startdate = window.document.enterParms.startDate.value;
  	if (startdate == ""||startdate == " "||!isnum(startdate)) {
		alert("Please enter a start date in the format YYYYMMDD") ;
		document.enterParms.startDate.focus() ;
		return(false)}

  	enddate = window.document.enterParms.endDate.value 
  	if (enddate == ""||enddate == " "||!isnum(enddate)) {
		alert("Please enter an end date in the format YYYYMMDD") ;
		document.enterParms.endDate.focus() ;
		return(false)}
    window.status = 'Loading Spend by Destination Report....';
}
function drop(selvalue, sel2value, sel3value, sel4value){
  getuserfwq2();
  var selectedOptionValue = null;
  var selectedOptionText = null;
  var myfromPost = null;
  var mytoPost = null;
  var mymass = null;
  var myvol = null;
  var myqty = null;
  var myval = null;
  var lines = null;

   selectedOptionValue = selvalue.options[selvalue.selectedIndex].value;
   selectedOptionText = selvalue.options[selvalue.selectedIndex].text;
   
  myfromPost = document.fwq2.fromPost.value;
  if (selectedOptionText=='Select'&&(myfromPost==""||myfromPost==" ")){
    alert('Please select a Collection site or enter a Collection postal code');
    document.fwq2.senSite.focus() ;
    return(false);}
  

  selectedOptionValue = null;
  selectedOptionText = null;
  selectedOptionValue = sel2value.options[sel2value.selectedIndex].value;
  selectedOptionText = sel2value.options[sel2value.selectedIndex].text;
  mytoPost = document.fwq2.toPost.value;
  if (selectedOptionText=='Select'&&(mytoPost==""||mytoPost==" ")){
    alert('Please select a Receiving site or enter a Receiving postal code');
    document.fwq2.recSite.focus() ;
    return(false);}
  
  selectedOptionValue = null;
  selectedOptionText = null;
  selectedOptionValue = sel3value.options[sel3value.selectedIndex].value;
  selectedOptionText = sel3value.options[sel3value.selectedIndex].text;
  if (selectedOptionText=='Select'){
    alert('Please select a Collection date');
    document.fwq2.colDate.focus() ;
    return(false);}


  selectedOptionValueS = null;
  selectedOptionText = null;
  selectedOptionValueS = sel4value.options[sel4value.selectedIndex].value;
  selectedOptionText = sel4value.options[sel4value.selectedIndex].text;
  if (selectedOptionText=='Select'){
    alert('Please select a Service type');
    document.fwq2.serType.focus() ;
    return(false);}

  myval = document.fwq2.itemValDeclA.value
  if (document.fwq2.chinsurance.checked){
    if (myval ==""||myval == " "){
        alert('Please enter a declared value for insurance');
        document.fwq2.itemValDeclA.focus() ;
        return(false);}
  }
  if (myval > " "){
    if (!isval(myval)){
      alert('Please enter declared value correctly');
      document.fwq2.itemValDeclA.focus() ;
      return(false);}
  }
  mymass = document.fwq2.itemMassA.value;
  if (mymass==""||mymass==" "||mymass=="."|| !isval(mymass)){
    alert('Please enter an actual mass in kg');
    document.fwq2.itemMassA.focus() ;
    return(false);}


  var prod = null;
  var totqty = null;
  var one = null;
  var two = null;
  var three = null;
  var four = null;
  var five = null;
  var lines = 'n';

  for (var ii=1;ii < 11;ii++){
    one = document.fwq2['Q' + (ii)].value;
    if (!one.length == 0){
       for (var i=0;i < one.length;i++){
         if ((one.substring(i,i+1) < '0') || (one.substring(i,i+1) > '9'))
         {
           alert('Please enter only numbers');
           document.fwq2['Q' + (ii)].focus();
           return(false);
         }
       }
      lines='y';
    }
    two = document.fwq2['L' + (ii)].value;
    if (!one.length == 0){
    if (two.length == 0){
      alert('Please enter a length');
      document.fwq2['L'+(ii)].focus();
      return(false);
    }
    for (var i2=0;i2 < two.length;i2++){
      if ((two.substring(i2,i2+1) < '0') || (two.substring(i2,i2+1) > '9')){
        alert('Please enter only numbers');
        document.fwq2['L'+(ii)].focus();
        return(false);
      }
    }
    }
    three = document.fwq2['B'+(ii)].value;
    if (!one.length == 0){
    if (three.length == 0){
      alert('Please enter a breath');
      document.fwq2['B'+(ii)].focus();
      return(false);
    }
    for (var i3=0;i3 < three.length;i3++){
      if ((three.substring(i3,i3+1) < '0') || (three.substring(i3,i3+1) > '9')){
        alert('Please enter only numbers');
        document.fwq2['B'+(ii)].focus();
        return(false);
      }
    }
    }
    four = document.fwq2['H'+(ii)].value;
    if (!one.length == 0){
    if (four.length == 0){
      alert('Please enter a height');
      document.fwq2['H'+(ii)].focus();
      return(false);
    }
    for (var i4=0;i4 < four.length;i4++){
      if ((four.substring(i4,i4+1) < '0') || (four.substring(i4,i4+1) > '9')){
        alert('Please enter only numbers');
        document.fwq2['H'+(ii)].focus();
        return(false);
      }
    }
    }
    prod = prod + ( one * two * three * four);
    totqty = totqty + (one * 1);
    document.fwq2.itemVolA.value = prod;
    document.fwq2.itemQtyA.value = totqty;
  }
  if (lines == 'n'){
    alert('Please enter at least one line item');
    document.fwq2.Q1.focus();
    return(false);
  }
}
function isnum(n){

	for (i=0;i<n.length;i++){
		c=n.charAt(i);
		if((c > "9" || c < "0") && c != " " )
		  {return false}
		}
	return true;
}
function isval(n){

	for (i=0;i<n.length;i++){
		c=n.charAt(i);
		if((c > "9" || c < "0") && c != " " ){
		  if (c != "."){return false}}
		}
	return true;
}
function updateQfrom(selvalue,count){

  var selectedOptionValue = null;
  var selectedOptionText = null;
  var data = null;
  var pos = null;

  selectedOptionValue = selvalue.options[selvalue.selectedIndex].value;
  pos = selectedOptionValue.indexOf('_',0);
  pos1 = selectedOptionValue.indexOf('_',pos+1);
  pos2 = selectedOptionValue.indexOf('_',pos1+1);
  pos3 = selectedOptionValue.indexOf('_',pos2+1);
  pos4 = selectedOptionValue.indexOf('_',pos3+1);
  pos5 = selectedOptionValue.indexOf('_',pos4+1);
  pos6 = selectedOptionValue.indexOf('_',pos5+1);
  pos7 = selectedOptionValue.indexOf('_',pos6+1);
  pos8 = selectedOptionValue.indexOf('_',pos7+1);
  data = selectedOptionValue.substring(0,pos);
  data1 = selectedOptionValue.substring(pos + 1,pos2);
  data2 = selectedOptionValue.substring(pos1 + 1,pos2);
  data3 = selectedOptionValue.substring(pos2 + 1,pos3);
  data4 = selectedOptionValue.substring(pos3 + 1,pos4);
  data5 = selectedOptionValue.substring(pos4 + 1,pos5);
  data6 = selectedOptionValue.substring(pos5 + 1,pos6);
  data7 = selectedOptionValue.substring(pos6 + 1,pos7);
  data8 = selectedOptionValue.substring(pos7 + 1,pos8);
  document.fwq2.fromPost.value = data5;
  
}
function updateQto(selvalue,count){

  var selectedOptionValue = null;
  var selectedOptionText = null;
  var data = null;
  var pos = null;

  selectedOptionValue = selvalue.options[selvalue.selectedIndex].value;
  pos = selectedOptionValue.indexOf('_',0);
  pos1 = selectedOptionValue.indexOf('_',pos+1);
  pos2 = selectedOptionValue.indexOf('_',pos1+1);
  pos3 = selectedOptionValue.indexOf('_',pos2+1);
  pos4 = selectedOptionValue.indexOf('_',pos3+1);
  pos5 = selectedOptionValue.indexOf('_',pos4+1);
  pos6 = selectedOptionValue.indexOf('_',pos5+1);
  pos7 = selectedOptionValue.indexOf('_',pos6+1);
  pos8 = selectedOptionValue.indexOf('_',pos7+1);
  data = selectedOptionValue.substring(0,pos);
  data1 = selectedOptionValue.substring(pos + 1,pos1);
  data2 = selectedOptionValue.substring(pos1 + 1,pos2);
  data3 = selectedOptionValue.substring(pos2 + 1,pos3);
  data4 = selectedOptionValue.substring(pos3 + 1,pos4);
  data5 = selectedOptionValue.substring(pos4 + 1,pos5);
  data6 = selectedOptionValue.substring(pos5 + 1,pos6);
  data7 = selectedOptionValue.substring(pos6 + 1,pos7);
  data8 = selectedOptionValue.substring(pos7 + 1,pos8);
  document.fwq2.toPost.value = data5;
  
}
function collrrotrue(){
     document.enterColl.recName.readOnly = true;
     document.enterColl.recAdd1.readOnly = true;
     document.enterColl.recAdd2.readOnly = true;
     document.enterColl.recAdd3.readOnly = true;
     document.enterColl.recAdd4.readOnly = true;
     document.enterColl.recAdd5.readOnly = true;
}
function collrrofalse(){
     document.enterColl.recName.readOnly = false;
     document.enterColl.recTelNo.readOnly = false;
     document.enterColl.recTelNoCode.readOnly = false;
     document.enterColl.recContact.readOnly = false;
     document.enterColl.recAdd1.readOnly = false;
     document.enterColl.recAdd2.readOnly = false;
     document.enterColl.recAdd3.readOnly = false;
     document.enterColl.recAdd4.readOnly = false;
     document.enterColl.recAdd5.readOnly = false;
}
function collsrotrue(){
     document.enterColl.senName.readOnly = true;
     document.enterColl.senAdd1.readOnly = true;
     document.enterColl.senAdd2.readOnly = true;
     document.enterColl.senAdd3.readOnly = true;
     document.enterColl.senAdd4.readOnly = true;
     document.enterColl.senAdd5.readOnly = true;
//     document.enterColl.senContact.readOnly = true;
//     document.enterColl.senTelNo.readOnly = true;
}
function collsrofalse(){
     document.enterColl.senName.readOnly = false;
     document.enterColl.senAdd1.readOnly = false;
     document.enterColl.senAdd2.readOnly = false;
     document.enterColl.senAdd3.readOnly = false;
     document.enterColl.senAdd4.readOnly = false;
     document.enterColl.senAdd5.readOnly = false;
     document.enterColl.senContact.readOnly = false;
     document.enterColl.senTelNo.readOnly = false;
     document.enterColl.senTelNoCode.readOnly = false;
}
function updateCto(selvalue,count){

  var selectedOptionValue = null;
  var selectedOptionText = null;
  var data = null;
  var pos = null;

  selectedOptionValue = selvalue.options[selvalue.selectedIndex].value;
  selectedOptionText = selvalue.options[selvalue.selectedIndex].text;
  pos = selectedOptionValue.indexOf('_',0);
  pos1 = selectedOptionValue.indexOf('_',pos+1);
  pos2 = selectedOptionValue.indexOf('_',pos1+1);
  pos3 = selectedOptionValue.indexOf('_',pos2+1);
  pos4 = selectedOptionValue.indexOf('_',pos3+1);
  pos5 = selectedOptionValue.indexOf('_',pos4+1);
  pos6 = selectedOptionValue.indexOf('_',pos5+1);
  pos7 = selectedOptionValue.indexOf('_',pos6+1);
  pos8 = selectedOptionValue.indexOf('_',pos7+1);
  pos9 = selectedOptionValue.indexOf('_',pos8+1);
  data = selectedOptionValue.substring(0,pos);
  data1 = selectedOptionValue.substring(pos + 1,pos1);
  data2 = selectedOptionValue.substring(pos1 + 1,pos2);
  data3 = selectedOptionValue.substring(pos2 + 1,pos3);
  data4 = selectedOptionValue.substring(pos3 + 1,pos4);
  data5 = selectedOptionValue.substring(pos4 + 1,pos5);
  data6 = selectedOptionValue.substring(pos5 + 1,pos6);
  data7 = selectedOptionValue.substring(pos6 + 1,pos7);
  data8 = selectedOptionValue.substring(pos7 + 1,pos8);
  data9 = selectedOptionValue.substring(pos8 + 1,pos9);
  document.enterColl.recName.value = data6;
  document.enterColl.recAdd1.value = data1;
  document.enterColl.recAdd2.value = data2;
  document.enterColl.recAdd3.value = data3;
  document.enterColl.recAdd4.value = data4;
  document.enterColl.recAdd5.value = data5;
  document.enterColl.recContact.value = data7;
  document.enterColl.recTelNoCode.value = data8;
  document.enterColl.recTelNo.value = data9;
  if (selectedOptionText == 'Select'){
    collrrofalse();
    document.enterColl.recName.value = '';
    document.enterColl.recContact.value = '';
    document.enterColl.recTelNo.value = '';
    document.enterColl.recTelNoCode.value = '';
    document.enterColl.recAdd1.value = '';
    document.enterColl.recAdd2.value = '';
    document.enterColl.recAdd3.value = '';
    document.enterColl.recAdd4.value = '';
    document.enterColl.recAdd5.value = '';}
  else {
    collrrotrue();}
  
}
function updateCfrom(selvalue,count){

  var selectedOptionValue = null;
  var selectedOptionText = null;
  var data = null;
  var pos = null;

  selectedOptionValue = selvalue.options[selvalue.selectedIndex].value;
  selectedOptionText = selvalue.options[selvalue.selectedIndex].text;
  pos = selectedOptionValue.indexOf('_',0);
  pos1 = selectedOptionValue.indexOf('_',pos + 1)
  pos2 = selectedOptionValue.indexOf('_',pos1+1);
  pos3 = selectedOptionValue.indexOf('_',pos2+1);
  pos4 = selectedOptionValue.indexOf('_',pos3+1);
  pos5 = selectedOptionValue.indexOf('_',pos4+1);
  pos6 = selectedOptionValue.indexOf('_',pos5+1);
  pos7 = selectedOptionValue.indexOf('_',pos6+1);
  pos8 = selectedOptionValue.indexOf('_',pos7+1);
  pos9 = selectedOptionValue.indexOf('_',pos8+1);
  data = selectedOptionValue.substring(0,pos);
  data1 = selectedOptionValue.substring(pos + 1,pos1);
  data2 = selectedOptionValue.substring(pos1 + 1,pos2);
  data3 = selectedOptionValue.substring(pos2 + 1,pos3);
  data4 = selectedOptionValue.substring(pos3 + 1,pos4);
  data5 = selectedOptionValue.substring(pos4 + 1,pos5);
  data6 = selectedOptionValue.substring(pos5 + 1,pos6);
  data7 = selectedOptionValue.substring(pos6 + 1,pos7);
  data8 = selectedOptionValue.substring(pos7 + 1,pos8);
  data9 = selectedOptionValue.substring(pos8 + 1,pos9);
  document.enterColl.senAdd1.value = data1;
  document.enterColl.senAdd2.value = data2;
  document.enterColl.senAdd3.value = data3;
  document.enterColl.senAdd4.value = data4;
  document.enterColl.senAdd5.value = data5;
  document.enterColl.senName.value = data6;
  document.enterColl.senContact.value = data7;
  document.enterColl.senTelNoCode.value = data8;
  document.enterColl.senTelNo.value = data9;
  if (selectedOptionText == 'Select'){
    collsrofalse();}
  else {
    collsrotrue();}
}
function insurancecheck(){
  if (document.fwq2.insbox.value == 'n'){
    document.fwq2.insbox.value = 'y';
    document.fwq2.itemValDeclA.focus();
  }
  else {
  if (document.fwq2.insbox.value == 'y'){
    document.fwq2.insbox.value = 'n';
    document.fwq2.itemValDeclA.value = '';
    document.fwq2.chinsurance.focus();
  }
  }
}
