
//*************************************************************************************
// trim - this function deletes spaces around the string.
//*************************************************************************************
String.prototype.trim = function()
{
    // Use a regular expression to replace leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

//*************************************************************************************
// checkSearch - this function checked if  user fill in the search input field.
//*************************************************************************************
function checkSearchForm(obj){
  if(obj.keySearch.value.trim() == ""){
 	alert ("נא למלא מלות מפתח");
 	obj.keySearch.focus();
  }else 
 	obj.submit();
  return false; 
}

function checkMemberForm(obj){
  if(obj.login.value.trim() == ""){
 	alert ("נא למלא שם משתמש")
 	obj.login.focus();
  }else if(obj.password.value.trim() == ""){
 	alert ("נא למלא סיסמה")
 	obj.password.focus();
  }else 
 	obj.submit();
  return false; 
}

function poll_submit(obj){
  var check_radio=false;
  if (obj.answerID){
    for(j=0; j< obj.answerID.length; j++){
      if (obj.answerID[j].checked==true){
        check_radio=true
        break;
      }   
    }
  }
  if (check_radio==false){
     alert('נא לבחור תשובה')
     return false;     
  }else{
 	 obj.submit();
  }
return false;     
}

function GetNumbersAndLetters(){
	var ch=event.keyCode;
	event.returnValue =((ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122));
}

function getNumbers(){
	var ch=event.keyCode;
	event.returnValue =((ch >= 48 && ch <= 57) || ch ==46);
}

function checkEmail(checkThisEmail){
//  return (strEmail.indexOf(".") > 2) && (strEmail.indexOf("@") > 0);
  //return /^\w+@([\w\-]+\.)+\w{2,3}$/.test(strEmail);
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;
// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID
if (myAtSymbolAt < 1 ){myEMailIsValid = false}
// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID
if (myLastDotAt < myAtSymbolAt) {myEMailIsValid = false}
// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID
if (myLength - myLastDotAt <= 2){myEMailIsValid = false}
// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid
if (mySpaceAt != -1) {myEMailIsValid = false}
return myEMailIsValid
}

function DoCal(elTarget,elName){
  if (showModalDialog) {
    var sRtn;
    sRtn = showModalDialog("../include/calendar.asp",elTarget.value,"center=yes; dialogWidth=130pt; dialogHeight=160pt; status=0; help=0;");
    if (sRtn!=""){
       elTarget.value = sRtn;
    }
  } else
    alert("Internet Explorer 4.0 or later is required.")
 return false;
 window.document.focus;   
}

function onclick_action(elem,back_true,back_false){
  if (elem.checked==true)
      elem.style.background=back_true;
  else
      elem.style.background=back_false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}
var browserName = whichBrs();

function onclick_changeHeight(obj,height_change,stepValue){
  var clientHeight=obj.clientHeight+2
  var offsetHeight=obj.offsetHeight
  if (height_change=='+'){
     obj.style.height=eval(clientHeight)+stepValue
  }
  if (height_change=='-' && offsetHeight > stepValue ){
     obj.style.height=eval(clientHeight)-stepValue
  }
}

var printWin
function print_companyComplaint(companyID,compID){
 printWin = window.open('print_companyComplaint.asp?companyID='+ companyID + '&compID='+compID ,'printWin','width=650,height=550, left=0,top=0,screenX=0,screenY=0,outerwidth=500,outerheight=230,resizable=1,status=0,toolbar=1,scrollbars=1');
 printWin.focus();			
 return false;
}

var printWinResponse
function print_companyResponse(companyID,compGUID){
 printWinResponse = window.open('print_companyResponse.asp?companyID='+ companyID + '&compGUID='+compGUID ,'printWinResponse','width=650,height=550, left=0,top=0,screenX=0,screenY=0,outerwidth=500,outerheight=230,resizable=1,status=0,toolbar=1,scrollbars=1');
 printWinResponse.focus();			
 return false;
}
