﻿// JScript File


function nothing(id){return false;}
function trim(str)
{return str.replace(/^[ ]*(.*[^ ])*[ ]*$/ig,"$1");}

function Val(str)
{
 str=trim(str);
 if(str.match(/^(-){0,1}\d{0,}(.){0,1}\d{1,}$/))
   return eval(str)
 else
   return 0;
}
function isInteger(str)
{
 if(str.match(/^\d+$/))
    return true
 return false
}
 
function isDate(str)
{
 str=trim(str);
 if(str.match(/^([0]{0,1}[1-9]|[1][0-2])\/([1-9]|[0-2][0-9]|[3][01])\/[1-2][0-9]{3}$/))
    return true
 return false
}


function IsValedEMail(sEmail)
{var strRegExp=/[\w]{1}[\w+-.]{1,}[@][\w]{2,}[.][\W\w]{1,}$/i;
 return sEmail.search(strRegExp)==0;
}

function IsValedEMails(sEmail)
 {
  sEmail+=',';
  sEmail=sEmail.replace(/(,,)/g,',')
  var strRegExp=/([\w]{1}[\w+-.]{1,}[@][\w]{2,}[.][[\w]{1,}){1}((,)(1)([\w]{1}[\w+-.]{1,}[@][\w]{2,}[.][\w]{1,}){1}){0,}/i;
  strRegExp=/^((\s){0,}[\w]{1}[\w+-.]{1,}[@][\w]{2,}[.][[\w]{1,}(\s){0,}[,]){1,}$/i;
  return sEmail.search(strRegExp)==0;
 }
 
function getkeyCode(e)
{ var keyPressed;
   if(document.all)
       {keyPressed = window.event.keyCode;}
    else
       {if(e.which) keyPressed= e.which;
        else keyPressed = e.keyCode;}
    return keyPressed;
}
if(document.captureEvents)
   document.captureEvents(Event.KEYPRESS);

function NumericTextBox_onkeypress(e)
{
 //var tbBox=e?e.target:event.srcElement;
  var tbBox; 
 if((typeof e)=='undefined')
   tbBox= event.srcElement;
 else
   tbBox= e.target;
   
 var evt=document.all?event:e;
 var key=0;
 key=getkeyCode(evt) 
 if(key==8 || key==0)return true;   
 if(key==39 || key==37)return true;
 if(key>=48 && key <=57)
    {return true;}
   if(key==46)
      {if(tbBox.value.indexOf('.')==-1)
           return true}      
 evt.cancelBubble=true     
 return false; 
}

function throwVerifyContactFormError(ctrlName,msg)
{
 if(msg==null || msg=='')
    msg='Please fill the contact information';
 alert(msg);
 return false;
}

function VerifyContactForm(form)
{ 
  //ContactForm  
  //Name 
  var ctrlName='textfield';
  if(trim(form.elements[ctrlName].value)=='')
     return throwVerifyContactFormError(ctrlName,null);

  //Phone 
  ctrlName='textfield2';
  if(trim(form.elements[ctrlName].value)=='')
     return throwVerifyContactFormError(ctrlName,null);

  //Email 
  ctrlName='textfield3';
  if(trim(form.elements[ctrlName].value)=='')
     return throwVerifyContactFormError(ctrlName,null);
     
//Comments 
//  ctrlName='textarea';
//  if(trim(form.elements[ctrlName].value)=='')
//     return throwVerifyContactFormError(ctrlName,null); 

return true;


}
