﻿// JScript File

function NumericTextBox_onkeypress(e)
{
 var tbBox=e?e.target:event.srcElement;
 var evt=document.all?event:e;
 var key=0;
 if(window.getkeyCode)
   {
   key=getkeyCode(e)
   }
   else
   {
    if(document.all)
		{
		  key=event.keyCode;
		}   
	else
		{
		  key=e.which;
		}
   }  
   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 Val(str)
{
 str=trim(str);
 if(str.match(/^(-){0,1}\d{0,}(.){0,1}\d{1,}$/))
   return eval(str)
 else
   return 0;
}

function toMoney(Amount)
{
   Amount=Amount.toString();
   if(Amount.indexOf('.')==-1)
     Amount+=".00";
   else
    {
     var index=Amount.indexOf('.');
     var len=Amount.substring(index+1).length;
     if(len==1)
       Amount+='0';
     else if (len>2)
       Amount=Amount.substring(0,index+3)
   }
   return '$'+Amount;
}


function setButtonMouseMoveEvents(button)
{
  button.style.color='#808080';
  button.onmouseover=function(){this.style.color='#808080'}; 
  button.onmouseout=function(){this.style.color='#000000';};
}

function setEnterSubmitForTextBox(TextBox,CommandButtonName)
{
  if(document.captureEvents)
     document.captureEvents(Event.KEYPRESS);
  if(typeof TextBox =='string')TextBox=document.getElementById(TextBox)     
  TextBox.onkeypress=function(e)
     {
       if(getkeyCode(e)==13)
          {
           if(typeof CommandButtonName =='string')      
               __doPostBack(CommandButtonName,'');
           else (typeof CommandButtonName =='object') 
             {
              if(CommandButtonName.onclick)
                 if(CommandButtonName.onclick()==false)
                    return false;     
              if(CommandButtonName.tagName.toUpperCase()=='A')
                 {if(CommandButtonName.href!='')
                     document.location.href=CommandButtonName.href;}
              }
             
          }
     }   
}

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;
}



function IsValedEMail(sEmail)
{var strRegExp=/[\w]{1}[\w+-.]{1,}[@][\w]{2,}[.][\W\w]{1,}$/i;
 return sEmail.search(strRegExp)==0;
}
function IsValedZipCode(sZipCode)
{var strRegExp=/\d{5}((-\d{4})|[.]{0})$/i;
 return sZipCode.search(strRegExp)==0;
}
function IsValedPhoneNumber(sPhone)
{if(!(sPhone.length==10 || sPhone.length==12))return false;
 var strRegExp=/^([0-9]{3}[-]{0,1}){2}[0-9]{4}$/i;
 return sPhone.search(strRegExp)==0;
}


function trim(str)
{return str.replace(/^[ ]*(.*[^ ])*[ ]*$/ig,"$1");}


var OnloadEvens=new Array();

  ///////////////////////////////
////////////////////////////////
var TRS_Array=new Array();
function HideMessages()
{
  for(var i=0;i<TRS_Array.length;i++)
  {
   var tr=document.getElementById(TRS_Array[i]);
   if(tr)
      {
       var attr=tr.getAttribute('hideit');       
       if(attr!='true')
          {tr.setAttribute('hideit','true');
          }
       else
          {
           tr.style.display='none';
          }
      }
  }
}
setInterval('HideMessages()',3000);
/////////////////////////////////
////////////////////////////////


function doCancel(url)
{
 location.href=url
}