    var theWaitWindow = null;     // temporarily window while calling a script
        
    function viewpage(url,width,height) {
      options = "toolbar=0,status=0,menubar=0,scrollbars=1," +
                "resizable=1,width=" + width + ",height=" + height ;
       var mywin = window.open(url,"", options);
    }
    
    
    function _JSWait(msg){
  	  var option = "width=400, height=150," +
			 "resizable=yes,"+
			 "menubar=no," +
			 "toolbar=no," +
			 "location=no," +
			 "status=no, " + 
			 "left=80, " +
			 "top=80 ";
  	  var newWin = window.open('../pwait.php?msg='+ msg,'waitWin',option);
  	  newWin.focus();
  	  return newWin;
    }
    
    var max_len = 225;
    function count(desc){
       var desc_len = desc.value.length;
       if(desc_len < max_len){
          var cnt_id = document.getElementById("maxchar");
          cnt_id.innerHTML = (max_len - desc_len);
       }else{
          alert("You may only type 255 characters in this box");
          desc.focus();
       }
    }
  function _clear(obj){
	 return obj.innerText =""; 
  }  
 function select(obj,msg){
          obj.focus();
          obj.select();
          alert(msg);
          return false;
    }
    
    function select_menu(obj,msg){
          obj.focus();
          alert(msg);
          return false;
    }    
    function firstUpper(str){
       var b = str.charAt(0).toUpperCase();
       var b = b + str.slice(1,str.length).toLowerCase();
       return b;
    }
    
 
    function is_valid(obj) {
       var invalid = "!\"#%&\'()$;<=>?[\\]*+,-./:^";
       for(i=0;i <invalid.length;i++){
           if(obj.value.indexOf(invalid.charAt(i)) >= 0){
              return false;
           }
       }
       return true;
    }
    
    function is_digit(obj) { 
      var isValid = 1;
      for(i=0;i<obj.value.length;i++){
        var ch = obj.value.charCodeAt(i);
        isvalid = (ch >= 48 && ch <= 57);
        if(!isValid) return false;
      }
      isvalid = !isNaN(obj.value);
      return isvalid;
    }

  function is_empty(obj) {
        obj.value = L_trim(obj);
        obj.value = R_trim(obj);
      	if ((obj.value.length==0) || (obj.value==null)) {
         return true;
        }else{
           return false;
        }
    }
    
    function L_trim(obj){
       var hasChar = false;
       var tempObjVlaue = "";
       for(i = 0; i < obj.value.length ; i++){
          cur_char = obj.value.charCodeAt(i);
          if(cur_char != 32)
            hasChar = true;
            
          if(hasChar)
             return obj.value.substr(i);
       }
       return obj.value;
    }
    

    function R_trim(obj){
       var hasChar = false;
       var tempObjVlaue = "";
       var cur_char = "";
       for(i = obj.value.length; i >= 0 ; i--){
          cur_char = obj.value.charCodeAt(i-1);
          if(cur_char != 32)
            hasChar = true;
            
          if(hasChar){
             return obj.value.substr(0,i);
          }   
       }
       return obj.value;
    }
    
    function isValidPhone(phone) {
	   var valid = true;
		filterPhone= /^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}( x\d{0,})?/
		///(^(\+?\-? *[0-9]+)-([,0-9 ]*)-([0-9 ])*$)|(^ *$)/
	   if(filterPhone.test(phone) != true){
	   	valid = false;
	   }
	   return valid; 
    }
    
    function isValidEmail(str) {
       // are regular expressions supported?
	var flag = true;
      filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)!= true){
		flag = false;
    } 
    	return flag;
    }
    
    //Wait Window to be close onloead
    function _wait_window(){
      if(theWaitWindow != null)
        theWaitWindow.close();
   }
    function loadPicture(id,f){
     document.images[id].src = f; 
  }
  
 
     function ValidateComment()
	 {
		 if (is_empty(document.commentFrm.comment))
	 	 {
    		return select( document.commentFrm.comment, "Please enter your comment!");
    	 }
  		 if (document.commentFrm.toname.value==5)
   		 {
    		alert("please select a recipient!");
    		return false;
    	 }
	  }
      function printWindow(){
	      bV = parseInt(navigator.appVersion)
	      if (bV >= 4) window.print()
      }	  


function PrintThisPage() 
{ 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById('contentstart').innerHTML; 
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><body>'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
      winprint.focus(); 
}
function submit_search(frm){
   var make_name  = frm.make.options[frm.make.selectedIndex].text;
   var model_name = frm.model.options[frm.model.selectedIndex].text;
   frm.make_name.value = make_name;
   frm.model_name.value  = model_name;
   return true;
}


