// Global variables
var newWin

function PrintConfirm() { 
  version=parseInt(navigator.appVersion);
  if (navigator.appVersion.indexOf('5.')>-1) { version=5 }; 
  browser='OTHER'; 
  if (navigator.appName=='Netscape') {
    browser='NS'+version;
  } 
  if (navigator.appName=='Microsoft Internet Explorer') {
    browser='MSIE'+version;
  } 
  if (navigator.appVersion.indexOf('MSIE 3')>0) {
    browser='MSIE3';
  }

  if (browser=='MSIE5' || browser=='NS4') {
    if(confirm("Make sure that the page header and footer are set blank, portrait is selected for orientation, and margins are set " +
"to '0.25 inches' to get the best formatted Bill Of Lading copy" + 
"\n                      CANCEL - change browser setting(Page Setup - header, footer, orientation, margins) or preview" + 
"\n                           OK     - proceed printing")) {
      window.print() 
    }
  }
}

function labelPrintConfirm() { 
  version=parseInt(navigator.appVersion);
  if (navigator.appVersion.indexOf('5.')>-1) { version=5 }; 
  browser='OTHER'; 
  if (navigator.appName=='Netscape') {
    browser='NS'+version;
  } 
  if (navigator.appName=='Microsoft Internet Explorer') {
    browser='MSIE'+version;
  } 
  if (navigator.appVersion.indexOf('MSIE 3')>0) {
    browser='MSIE3';
  }

  if (browser=='MSIE5' || browser=='NS4') {
    if(confirm("Make sure that the page header and footer are set blank, portrait is selected for orientation, and margins are set " +
"to '0.25 inches' to get the best formatted Label copy" + 
"\n                      CANCEL - change browser setting(Page Setup - header, footer, orientation, margins) or preview" + 
"\n                           OK     - proceed printing")) {
      window.print() 
    }
  }
}

//-----------------------------------------
function ChangeLookupNumber(form, select) {
  form.LookupName.options[select].selected = true
  form.LookupLocation.options[select].selected = true
} 

//---------------------------------------
function ChangeLookupName(form, select) {
  form.LookupNumber.options[select].selected = true
  form.LookupLocation.options[select].selected = true
} 

//-------------------------------------------
function ChangeLookupLocation(form, select) {
  form.LookupNumber.options[select].selected = true
  form.LookupName.options[select].selected = true
} 

//-------------------------------------
function randomLookupNumber(form,num) {
  var val = form.LookupNumber[num].value;

  form.access[0].checked = false;
  form.access[1].checked = false;
  form.access[2].checked = false;

  if("Y".indexOf(val.substring(7,8)) != -1) {
    form.access[0].checked = true;
  }
  if("Y".indexOf(val.substring(8,9)) != -1) {
    form.access[1].checked = true;
  }
  if("Y".indexOf(val.substring(9,10)) != -1) {
    form.access[2].checked = true;
  }
} 


//----------------------
function byChild(path) {
//----------------------
window.location.replace(path);
}//  end of byChild()

//---------------------------
function byAssociated(path) {
//---------------------------
window.location.replace(path);
}//  end of byAssociated()

//---------------------------
function ToUpperCase(field) {
//---------------------------
field.value = field.value.toUpperCase()
}

//------------------------
function clearAllText() {
//------------------------
var form = window.document.forms[0]
for(var i=0 ; i<form.elements.length ; i++) {
if(form.elements[i].type == "text" || 
   form.elements[i].type == "textarea" ||
   form.elements[i].type == "password") {
	form.elements[i].value = ""
} // end of if
} // end of for(;;)
}


function cleanText(form)
{
for(var i=0 ; i<form.elements.length ; i++) {
if(form.elements[i].type == "text" || 
   form.elements[i].type == "textarea" ||   
   form.elements[i].type == "password") {
	form.elements[i].value = ""
} // end of if
} // end of for(;;)
}


<!-- Begin
function validate(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only numbers are accepted!");
field.focus();
field.select();
   }
}

function validateWeight(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid weight!  Only whole numbers are accepted!");
field.focus();
field.select();

   }
}

function textAreaLength(txtAreaObj) {
	var txtLineAry = txtAreaObj.value.split('/n');
	var totalChars = 0;
	for (var i = 0; i < txtLineAry.length; i++) {
	  totalChars += txtLineAry[i].length;
	}
	totalChars += txtLineAry.length+1;
	return totalChars; 
}
//  End -->

function debugAlert(alertText) {
	try{
		if(debug) alert(alertText);
	}catch(e){
	}
}

//Below functions added by ranjith for Date Validations
function validateDateFld(obj,type,maxValue)
{
	//alert("validateDateFld");	
		var err = "Please enter the Valid " + type + "\n";		
		var numericExpression = /^[0-9]+$/; // only numeric value		
		if(!isValidStr(obj.value)||!(obj.value).match(numericExpression)||(maxValue==4&&(obj.value.length<maxValue)))
			return err;		
		if(maxValue==2&&(obj.value).length==1)
			obj.value="0"+obj.value;
		if(((obj.value).length)>maxValue)
			obj.value=obj.value.substring(0,maxValue);
		return "";		
	}
function isValidStr(val) {
	val = val.replace(/^\s+|\s+$/g, '');
	if((val==null)) {
		return false;
	}
	if((val=='')||(val.length==0)) {
		return false;
	}
	return true;
}	
function checkPhoneAreaCode(frm,id){
	var areacd = eval('frm.'+id+'1.value');
	if(areacd!=null && areacd.length==3)
		eval('frm.'+id+'2.focus();');
}
function checkPhoneExchange(frm, id){
	var phexh = eval('frm.'+id+'2.value');
	if(phexh!=null && phexh.length==3)
		eval('frm.'+id+'3.focus();');
}
function toReturnTrimmedValue(toTrimmValue)
{
	var x=rtrim(toTrimmValue);
	return ltrim(x);
}	
function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
function validateFld(obj, type,maxlengthValue) 
{
	var err = "Please enter the " + type + "\n";
	if(obj!=null && !isValidStr(obj.value)) 
	{
		return err;		
	}
	if(obj!=null && obj.value.length>maxlengthValue)
	{
		//alert("Entered "+type+" exceeds maximum Length "+maxlengthValue);
		obj.value=obj.value.substring(0,maxlengthValue);
	}
	return "";	
}
function isValidStr(val) {
	val = val.replace(/^\s+|\s+$/g, '');
	if((val==null)) {
		return false;
	}
	if((val=='')||(val.length==0)) {
		return false;
	}
	return true;
}

function validateEml(email) {
	var len = email.length;
	
	atpos = email.indexOf("@");
	if (email.indexOf ( '@', 0) < 1) { 
        return true;
    }
    
	dotpos = email.lastIndexOf(".");
	
	var pos = email.lastIndexOf ( '.', len - 1 ) + 1;
   	if ((len-pos)<2 || (len-pos)>4){
       	return true;
	}	
	if (atpos == -1 || dotpos == -1) {
		return true;
	}
	var	uid = email.substr(0, atpos);
    var domnm = email.substr(atpos + 1, email.length);

    if(uid == null || uid == '' || domnm == null || domnm == '') {
		return true;
	}
	return false;
}

//validate email Id
function validateEml(email) {
	var len = email.length;
	
	atpos = email.indexOf("@");
	if (email.indexOf ( '@', 0) < 1) { 
        return true;
    }
    
	dotpos = email.lastIndexOf(".");
	
	var pos = email.lastIndexOf ( '.', len - 1 ) + 1;
   	if ((len-pos)<2 || (len-pos)>4){
       	return true;
	}	
	if (atpos == -1 || dotpos == -1) {
		return true;
	}
	var	uid = email.substr(0, atpos);
    var domnm = email.substr(atpos + 1, email.length);

    if(uid == null || uid == '' || domnm == null || domnm == '') {
		return true;
	}
	return false;
}