//BEGIN Javascript --------------------------------------------------------------------*
var userEng         = true;
var inSort                      ;

function SaveOptSort(optInfo){
	inSort = optInfo.value;
}
	
function GetFileName(form, fromWhere) {
	if (form.optSort[0].checked) {
		inSort = form.optSort[0].value;
	}
	if (form.optSort[1].checked) {
		inSort = form.optSort[1].value;
	}
	if (form.optSort[2].checked) {
		inSort = form.optSort[2].value;
	}
	//if (form.optSort[3].checked) {
	//	inSort = form.optSort[3].value;
	//}

	//optLType = getoptionvalue(form.optLType);
	
	hdrc = form.hdrcode.value;
	optLType = form.prncode.value;
top.location.href = "TECProducts.asp?lType=" + optLType + "&inSort=" + inSort + "&hdrcode=" + hdrc + "&prncode=" + optLType;
   return;
}


function getoptionvalue(group) {
    var valuestring = group.options[group.selectedIndex].value;
    var textstring = group.options[group.selectedIndex].text;
    if (isEmptyStr(valuestring)) {
        return (textstring);
    } else {
        return (valuestring);
    }
}
 

function isEmptyStr (str) {
    str = ltrim(str);
    if (str == null || str == "") {
        return (true);
    } else {
        return (false);
    }
}
function ltrim(str) {
    var i, len;
    for (i=0, len=str.length; i<len; i++) {
	if (str.charAt(i) != " ") {
		break;
	}
    }
    if (i == len) {
	return "";
    } else {
	return str.substring(i, len);
    }
}
//END Javascript ----------------------------------------------------------------------*
function checkForm(form) {  
  var ErrorCheck = 0;  
  var Addmsg = "";  
   if (ltrim(form.userId.value) == ""){
    form.userId.focus();
    form.userId.select();
    Addmsg="Please enter your Customer account number."
	ErrorCheck = 1;
	}

if (ErrorCheck){
	 alert(Addmsg);
	 return false;
  }
}

function checkRegisterForm(form) {  
  var ErrorCheck = 0;  
    var Addmsg = "";  
  if (ltrim(form.CURUSERID.value) > ""){
	if (ltrim(form.SECURITY1.value) == "") {
		form.SECURITY1.focus();
		form.SECURITY1.select();
		Addmsg="Enter your Password twice."
		ErrorCheck = 1;
    } else if (ltrim(form.SECURITY2.value) == "") {
		form.SECURITY2.focus();
		form.SECURITY2.select();
		Addmsg="Enter your Password twice."
		ErrorCheck = 1;
    }
  }else if (ltrim(form.EMAIL.value) == ""){
	  form.EMAIL.focus();
      form.EMAIL.select();
    Addmsg="Please enter your EMAIL address."
	ErrorCheck = 1;
	} else if (ltrim(form.COMP.value) == ""){
	  form.COMP.focus();
      form.COMP.select();
    Addmsg="Please enter your COMPANY name."
	ErrorCheck = 1;
	} else if (ltrim(form.FIRST.value) == ""){
	  form.FIRST.focus();
      form.FIRST.select();
    Addmsg="Please enter your FIRST NAME."
	ErrorCheck = 1;
	} else if (ltrim(form.LAST.value) == ""){
	  form.LAST.focus();
      form.LAST.select();
    Addmsg="Please enter your LAST NAME."
	ErrorCheck = 1;
	} else if (ltrim(form.STREET.value) == ""){
	  form.STREET.focus();
      form.STREET.select();
    Addmsg="Please enter your STREET address."
	ErrorCheck = 1;
	} else if (ltrim(form.CITY.value) == ""){
	  form.CITY.focus();
      form.CITY.select();
    Addmsg="Please enter your CITY."
	ErrorCheck = 1;
	} else if (ltrim(form.ZIP.value) == ""){
	  form.ZIP.focus();
      form.ZIP.select();
    Addmsg="Please enter your ZIPCODE."
	ErrorCheck = 1;
	} else if (ltrim(form.TELEPHONE.value) == ""){
	  form.TELEPHONE.focus();
      form.TELEPHONE.select();
    Addmsg="Please enter your TELEPHONE number."
	ErrorCheck = 1;
	}else if (ltrim(form.SECURITY1.value) == "")  {
	  form.SECURITY1.focus();
      form.SECURITY1.select();
	  Addmsg="Enter your Password twice."
	  ErrorCheck = 1;
	}else if (ltrim(form.SECURITY2.value) == "")  {
	  form.SECURITY2.focus();
      form.SECURITY2.select();
	  Addmsg="Enter your Password twice."
	  ErrorCheck = 1;
    }
 
    if (ErrorCheck){
	 alert(Addmsg);
	 return false;
    }
}

function ltrim(str) {
if (str == null){
return "";
}
    var i, len;
    for (i=0, len=str.length; i<len; i++) {
	if (str.charAt(i) != " ") {
		break;
	}
    }
    if (i == len) {
	return "";
    } else {
	return str.substring(i, len);
    }
}
