function isEmpty(s)
{ return ((s == null) || (s.length == 0)) }
// Returns true if string s is empty or 
// whitespace characters only.
function isWhitespace (s)
{   var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {
       var c = s.charAt(i);
        if (c != " ") return false;
    }
    return true;
}


function blnInptRequired_Alert(objInpt,ttleName,optMsgText){
var currVal = objInpt.value;
var strMsgText = "Please fill "
  if(optMsgText!="" && optMsgText!=null){strMsgText = optMsgText}
  if (currVal=="" || currVal<0){ 
      myAlert(strMsgText,ttleName,"")
      objInpt.focus();
      return false;
  }
  else{
    return true;
  }  
}

function blnCheckItemMustChoose_msgBox(inptName,ttleName,optMsgText){
//var currVal = jsTrim(document.getElementById(inptName).value);
var currVal = document.getElementById(inptName).value;
var strMsgText = "Please fill "
  if(optMsgText!="" && optMsgText!=null){strMsgText = optMsgText}
  if (currVal=="" || currVal<0){ 
      myAlert(strMsgText,ttleName,"")
      document.getElementById(inptName).focus();
      return false;
  }
  else{
    return true;
  }  
}

function blnCheckItemMustFilled_msgBox(inptName,ttleName){
var strVal = document.getElementById(inptName).value;
  if (isWhitespace(strVal)==true)
    { 
      alert("Please fill " + " " + ttleName)
      document.getElementById(inptName).focus();
      return false;
    }
  else
   {
    return true;
   }  
}

function checkIsNum_keyPress(){
   if ((event.keyCode < 48 ||event.keyCode > 57) & (event.keyCode != 13)) event.returnValue = false;
 } 
 function checkInpt_tel_keyPress(){
  if ((event.keyCode < 45 || event.keyCode > 57) & (event.keyCode != 13)) event.returnValue = false;
 }
 function checkIsPrice_keyPress(){
  if ((event.keyCode < 45 || event.keyCode > 57) & (event.keyCode != 13)) event.returnValue = false;
 }
 
 function checkIsTime_msgBox_JS(inVal){
 }
 
 function checkIsTime_keyPress(){
   if ((event.keyCode < 46 ||event.keyCode > 58) & (event.keyCode != 13)) event.returnValue = false;
 } 

function myAlert(MsgDescr,addDescr,blnBig){
var strMsg = MsgDescr
if(addDescr!=""){strMsg=strMsg + " '" + addDescr + "'"}
 alert(strMsg)
}

function myConfirm(MsgDescr,addDescr,blnBig){
//return false or true
}


function get_tmpCashe(){
   var now = new Date()
   var hours = now.getHours()
   var minutes = now.getMinutes()
   var seconds = now.getSeconds()
   return hours + "_" + minutes + "_" + seconds;
}
function jsIsNumeric(inVal){
}

function isZip(inVal,country){
	var regExpZip = '';
	//if (country==null) country = "US";
	if (country==null || country=='') return false;
	inVal = inVal.toUpperCase();
	switch (country.toLowerCase())
	{
	  case "canada":  case "ca":
	        //M2R 1P1
			if (inVal.length == 6) inVal = inVal.substr(0,3) + " " + inVal.substr(3);
	        regExpZip = /^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d$/
	        break;
	  case "us":
			// U.S. ZIP codes have 5 or 9 digits.
			// They are formatted as 12345 or 12345-6789.
	        regExpZip = /^\d{5}(-\d{4})?$/
	        break;
	}
	
	if (regExpZip=='') return false;
	if(inVal.match(regExpZip)){
		return true;
	}else{
		return false;
	}
}

function isZipFix(objInput,country){
	//fix the postal/zip code input e.g spaces, trim etc...
	var regExpZip = '';
	//if (country==null) country = "US";
	if (country==null || country=='') return false;
	var inVal = objInput.value;
	inVal = inVal.toUpperCase();
	switch (country.toLowerCase())
	{
	  case "canada":  case "ca":
	        //M2R 1P1
			if (inVal.length == 6){
					inVal = inVal.substr(0,3) + " " + inVal.substr(3);
					objInput.value = inVal;
			}
	        regExpZip = /^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d$/
	        break;
	  case "us":
			// U.S. ZIP codes have 5 or 9 digits.
			// They are formatted as 12345 or 12345-6789.
	        regExpZip = /^\d{5}(-\d{4})?$/
	        break;
	}
	if (regExpZip=='') return false;
	if(inVal.match(regExpZip)){
		return true;
	}else{
		return false;
	}
}

function isDate(inputDate){ 
  var d = new Date(inputDate); 
  return d.getMonth() + 1 == inputDate.split("/")[0] && d.getDate() == inputDate.split("/")[1] && d.getFullYear() == inputDate.split("/")[2]; 
 } 