// ----------- Jim Stiles' code ------------------------------------------------
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Jim Stiles | www.jdstiles.com */
function startCalc(){
  interval = setInterval("calc()",1);
}

function format(box){
  var num = (document.getElementById(box).value * 1);
	document.getElementById(box).value = num.toFixed(2);
}

function calc(){
	var total = 0;
	var field;
	var els = document.payonetime.elements;
  for(i = 0; i < els.length; i++){
	  field = els[i];
		
		if('text' == field.type && /amount/.test(field.name)){
	  	total += +field.value;
		}
	}
	total = total.toFixed(2);
	document.getElementById("amount").value = total;
	document.getElementById("sum_total").innerHTML = total;
}
function stopCalc(){
  clearInterval(interval);
}
//-------------------- End Jim Stiles' code ------------------------------------

	function dropdown_empty(ss){
    for(var i = 0; i < ss.length; i++) {
  	if(ss[i].selected) {
	  	if(ss[i].value.length) { return false; }
		  }
	  }
    return true;
	}
	
  function disableForm(){
    document.getElementById("theform").style.visibility = "hidden";
  }

	function form_error_msg(msg){
	  document.getElementById("form_error_msg").innerHTML = msg;
	}
	
	function jersey_ave_calc(index,rate){
	  var num = document.getElementById('permits_authorized-'+index).value * rate;
    document.getElementById('amount-'+index).value = num;
    document.getElementById('jamount-'+index).value = num;
	  format('amount-'+index);
    calc();
	}
	
	// ----------- validation functions ------------------------------------------
	
	function  validateNumeric( strValue ) {
  /*****************************************************************
  DESCRIPTION: Validates that a string contains only valid numbers.

  PARAMETERS:
     strValue - String to be tested for validity

  RETURNS:
     True if valid, otherwise false.
  ******************************************************************/
    var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

    //check for numeric characters
    return objRegExp.test(strValue);
  }
	
	function  validateCurrency( strValue ) {
  /*****************************************************************
  DESCRIPTION: Validates that a string contains only valid numbers 
	with currency float to 2 decimals.

  PARAMETERS:
     strValue - String to be tested for validity

  RETURNS:
     True if valid, otherwise false.
  ******************************************************************/
    var objRegExp  = /^(\d*)(\.\d{0,2})?$/;

    //check for numeric characters
    return objRegExp.test(strValue);
  }

function validateDate( strValue ) {
/************************************************
DESCRIPTION: Validates that a string contains only
    valid dates with 2 digit month, 2 digit day,
    4 digit year. Date separator can be ., -, or /.
    Uses combination of regular expressions and
    string parsing to validate date.
    Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS:
   Avoids some of the limitations of the Date.parse()
   method such as the date separator character.
*************************************************/
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
 
  //check to see if in correct format
  if(!objRegExp.test(strValue)){
    return false; //doesn't match pattern, bad date
	}
  else{
    var strSeparator = strValue.substring(2,3);
    var arrayDate = strValue.split(strSeparator); 
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,'03' : 31, 
                        '04' : 30,'05' : 31,
                        '06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,
                        '10' : 31,'11' : 30,'12' : 31};
    var intDay = parseInt(arrayDate[1],10); 

    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] !== null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay !== 0){
        return true; //found in lookup table, good date
			}
    }
    
    //check for February (bugfix 20050322)
    //bugfix  for parseInt kevin
    //bugfix  biss year  O.Jp Voutat
    var intMonth = parseInt(arrayDate[0],10);
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if (intDay > 0 && intDay < 29) {
           return true;
       }
       else if (intDay == 29) {
         if ((intYear % 4 === 0) && (intYear % 100 !== 0) || 
             (intYear % 400 === 0)) {
              // year div by 4 and ((not div by 100) or div by 400) ->ok
             return true;
         }   
       }
    }
  }  
  return false; //any other values, bad date
}	

function validateZip( strValue ) {
/************************************************
DESCRIPTION: Validates that a string a United
  States zip code in 5 digit format or zip+4
  format. 99999 or 99999-9999

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

*************************************************/
var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;

  //check for valid US Zipcode
  return objRegExp.test(strValue);
}

// checks whether or not date passed is in the past (before today's date)
function dateExpired(strDate){
  // Assuming that the date was in the correct format, this is our separator
  var separator = strDate[2];
	var arrDate = strDate.split(separator);

	var checkDate = new Date();
	checkDate.setFullYear(arrDate[2],arrDate[0]-1,arrDate[1]);

	var expDate=new Date();
  expDate.setDate(expDate.getDate());
	
	if (checkDate < expDate){
	  return true;
	}
	else {
	  return false;
	}
}

function cardExpired(strDate){
	var arrDate = strDate.split("/");

	var checkDate = new Date();
	checkDate.setFullYear(arrDate[1],arrDate[0]-1,31);

	var expDate=new Date();
  expDate.setDate(expDate.getDate());
	
	if (checkDate < expDate){
	  return true;
	}
	else {
	  return false;
	}
}

// Use for checking "pay-violations" envelope date
function notExpired(strDate){

	// Assuming that the date was in the correct format, this is our separator
  var separator = strDate.charAt(2);
	var arrDate = strDate.split(separator);

	var checkDate = new Date();
	checkDate.setFullYear(arrDate[2],arrDate[0]-1,arrDate[1]);
	
	// Expiration date ( - # of days passed)
	var expDate=new Date();
  expDate.setDate(expDate.getDate()-8);
	
	if (checkDate > expDate){
	  return true;
	}
	else {
	  return false;
	}
}

function validateEmail( strValue) {
/************************************************
DESCRIPTION: Validates that a string contains a
  valid email pattern.

 PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS: Accounts for email with country appended
  does not validate that email contains valid URL
  type (.com, .gov, etc.) or valid country suffix.
*************************************************/
//var objRegExp = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
var objRegExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

  //check for valid email
  return objRegExp.test(strValue);
}

  function check_applynow(){
    var error = false;
    var addr1 = document.applynow.addr1.value;
    var city = document.applynow.city.value;
    var zip = document.applynow.zip.value;
    var first_name = document.applynow.first_name.value;
    var last_name = document.applynow.last_name.value;
    var email = document.applynow.email.value;
    var phone1 = document.applynow.phone1.value;
    var phone2 = document.applynow.phone2.value;
    var phone3 = document.applynow.phone3.value;
    var candidate_resume = document.applynow.candidate_resume.value;
		
    // Drop-downs
    var state = document.applynow.state;
		
		var error_msg = "";
    
    if(first_name === "" || last_name === "" ||  addr1 === "" || city === "" || state === "" || zip === "" || email === "" || phone1 === "" || phone2 === "" || phone3 === "" || candidate_resume === "")
		{ 
      error_msg = "<li>Please make sure all required fields are filled in.</li>";
		  error = true;
		}

		if(!validateEmail(email)){
      error_msg = error_msg + "<li>Please enter a valid <b>E-Mail</b>.</li>";
		  error = true;
		}
		
	  if ((phone1.length < 3)||(phone2.length < 3)||(phone3.length < 4)||(!validateNumeric(phone1))||(!validateNumeric(phone2))||(!validateNumeric(phone3))){
      error_msg = error_msg + "<li>Please enter a valid numerical <b>Phone Number</b>.</li>";
      error = true;
		}
		
    if(dropdown_empty(state)){
      error_msg = error_msg + "<li>Please select your <b>State</b>.</li>";
		  error = true;
		}

		if(!validateZip(zip)){
      error_msg = error_msg + "<li>Please enter a valid <b>Zip</b>.</li>";
		  error = true;
		}

		error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
			document.getElementById("cc_submit").disabled = true;
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
	}

	function check_autopay(){
    var error = false;
    var permits_authorized = new Array();
		
		var field1;
		var permits_index = 0;
	  var els1 = document.payonetime.elements;
    for(i = 0; i < els.length; i++){
	    field = els1[i];

		  if(/permits_authorized/.test(field1.name)){
	  	  permits_authorized[permits_index] = field1;
				permits_index++;
		  }
	  }

    var invoice_number = new Array();
    var amount = new Array();
		
		var field2;
		var invoice_index = 0;
		var amount_index = 0;
	  var els2 = document.payonetime.elements;
    for(i = 0; i < els2.length; i++){
	    field2 = els2[i];

		  if(/invoice_number/.test(field2.name)){
	  	  invoice_number[invoice_index] = field2.value;
				invoice_index++;
		  }
		
		  if(/amount/.test(field2.name)){
	  	  amount[amount_index] = field2.value;
				amount_index++;
		  }
	  }
		
    var error_msg = "";

		for(i = 0; i < permits_authorized.length; i++){
      if(dropdown_empty(permits_authorized[i])){
        error_msg = error_msg + "<li>Please select your <b>Permits Authorized</b>.</li>";
  		  error = true;
				break;
			}
    }
		
		for(i = 0; i < invoice_number.length; i++){
      if(invoice_number[i] === ""){ 
        error_msg = error_msg + "<li>Please enter your <b>Invoice Number(s)</b>.</li>";
		  	error = true;
				break;
			}
    }

		for(i = 0; i < amount.length; i++){
      if((amount[i] === "")||!(validateCurrency(amount[i]))){
        error_msg = error_msg + "<li>Please enter a numeric value for all <b>Amount</b>.</li>";
		  	error = true;
				break;
			}
    }

		error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
	}

  function check_billing(){
    var error = false;
    var credit_addr1 = document.creditcard.credit_addr1.value;
    var credit_city = document.creditcard.credit_city.value;
    var credit_zip = document.creditcard.credit_zip.value;
    var credit_first_name = document.creditcard.credit_first_name.value;
    var credit_last_name = document.creditcard.credit_last_name.value;
    var credit_number = document.creditcard.credit_number.value;
    var credit_code = document.creditcard.credit_code.value;
		
    // Drop-downs
		var credit_type = document.creditcard.credit_type;
    var credit_expiration_month = document.creditcard.credit_expiration_month;
    var credit_expiration_year = document.creditcard.credit_expiration_year;
    var credit_state = document.creditcard.credit_state;
		
		var error_msg = "";
    
    if(credit_first_name === "" || credit_last_name === "" || 
		   credit_addr1 === "" || credit_city === "" || 
			 credit_state === "" || credit_zip === "" || 
			 credit_number === "" || credit_expiration_month === "" ||
			 credit_expiration_year === "" || credit_code === "")
		{ 
      error_msg = "<li>Please make sure all required fields are filled in.</li>";
		  error = true;
		}

    if(dropdown_empty(credit_type)){
      error_msg = error_msg + "<li>Please select a <b>Card Type</b>.</li>";
		  error = true;
		}

		var credit_month = "";
    if(dropdown_empty(credit_expiration_month)){
      error_msg = error_msg + "<li>Please select your <b>Card Expiration Month</b>.</li>";
		  error = true;
		}
		else{
		  for(var i = 0; i < credit_expiration_month.length; i++) {
  	    if(credit_expiration_month[i].selected) {
	  	    credit_month = credit_expiration_month[i].value;
			  }
			}
		}

		var credit_year = "";
    if(dropdown_empty(credit_expiration_year)){
      error_msg = error_msg + "<li>Please select your <b>Card Expiration Year</b>.</li>";
		  error = true;
		}
    else{
		  for(var j = 0; j < credit_expiration_year.length; j++) {
  	    if(credit_expiration_year[j].selected) {
	  	    credit_year = credit_expiration_year[j].value;
			  }
			}
		}		
		
		if ((credit_month.length > 0)&&(credit_year.length > 0)){
			var credit_date = credit_month + "/" + credit_year;
			
			if(cardExpired(credit_date)){
			  error_msg = error_msg + "<li>Your card has expired.</li>";
				error = true;
			}
		}

		if(!validateNumeric(credit_code)){
      error_msg = error_msg + "<li>Please enter a numeric value for <b>CCV Code</b>.</li>";
		  error = true;
		}
		
    if(dropdown_empty(credit_state)){
      error_msg = error_msg + "<li>Please select your <b>State</b>.</li>";
		  error = true;
		}

		if(!validateZip(credit_zip)){
      error_msg = error_msg + "<li>Please enter a valid <b>Zip</b>.</li>";
		  error = true;
		}

		error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
			document.getElementById("cc_submit").disabled = true;
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
  }

  function check_contactus(){
    var error = false;
				var first_name = document.contactus.first_name.value;
    var last_name = document.contactus.last_name.value;
    var email = document.contactus.email.value;
    var question = document.contactus.question.value;
				/*
				var addr1 = document.contactus.addr1.value;
    var city = document.contactus.city.value;
    var zip = document.contactus.zip.value;
    var phone1 = document.contactus.phone1.value;
    var phone2 = document.contactus.phone2.value;
    var phone3 = document.contactus.phone3.value;
				*/
		
    // Drop-downs
    var state = document.contactus.state;
		var department = document.contactus.department;
		
		var error_msg = "";
    
    if(first_name === "" || last_name === "" || question === "")
  		{ 
      error_msg = "<li>Please make sure all required fields are filled in.</li>";
		    error = true;
		  }

    if(dropdown_empty(department)){
      error_msg = error_msg + "<li>Please select a NBPA <b>Department</b> where this inquiry will be directed to.</li>";
		    error = true;
		  }
		
		  if(!validateEmail(email)){
      error_msg = error_msg + "<li>Please enter a valid <b>E-Mail</b>.</li>";
		    error = true;
		  }
		
		  /*
	   if ((phone1.length < 3)||(phone2.length < 3)||(phone3.length < 4)||(!validateNumeric(phone1))||(!validateNumeric(phone2))||(!validateNumeric(phone3))){
      error_msg = error_msg + "<li>Please enter a valid numerical <b>Phone Number</b>.</li>";
      error = true;
  		}
    if(dropdown_empty(state)){
      error_msg = error_msg + "<li>Please select your <b>State</b>.</li>";
		    error = true;
		  }
		  if(!validateZip(zip)){
      error_msg = error_msg + "<li>Please enter a valid <b>Zip</b>.</li>";
		    error = true;
		  }
				*/

		  error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
			   document.getElementById("cc_submit").disabled = true;
      return true;
    }else{
      $('#errors').show('slow');
		    form_error_msg(error_msg);
			   window.scrollTo(0,0);
      return false;
    }    
  }

	function check_editinfo(){
    error = false;
    var first_name = document.editinfo.first_name.value;
    var last_name = document.editinfo.last_name.value;
    var addr1 = document.editinfo.addr1.value;
    var city = document.editinfo.city.value;
    var state = document.editinfo.state.value;
    var zip = document.editinfo.zip.value;
    
    if(first_name === "" || last_name === "" || addr1 === "" || city === "" || state === "" || zip === ""){ 
      error = true;
    }
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
			window.scrollTo(0,0);
      return false;
    }
	}

	function check_envelope(){
    var error = false;
		var disable = false;
    var violation = document.payenvelope.violation_number.value;
    var date = document.payenvelope.violation_date.value;
    var license = document.payenvelope.license_plate.value;
    //var meter = document.payenvelope.meter_number.value; // changed as per Web Maintenance 2008 request
    var lot = document.payenvelope.lot_facility.value;
    var amount = document.payenvelope.amount.value;
    var error_msg = "";
		
    //if(violation === "" || date === "" || license === "" || meter === "" || lot === "" || amount === ""){ 
    if(violation === "" || date === "" || license === "" || lot === "" || amount === ""){ 
      error_msg = "<li>Please make sure all required fields are filled in.</li>";
			error = true;
    }

		if(validateDate(date)){
		  if(!notExpired(date)){
		    error_msg = "<li>8 days has passed since the issuing of your Violation Envelope, please visit New Brunswick Parking Authority and submit your payment in person.</li>";
			  disable = true;
        disableForm();
			  error = true;
		  }
		}
		else{
      error_msg = error_msg + "<li>Please enter a date in the format MM/DD/YYYY for <b>Envelope Date</b>.</li>";
		  error = true;
		}
		
		if (!disable){		
		  if(!validateNumeric(amount)){
        error_msg = error_msg + "<li>Please enter a numeric value for <b>Amount</b>.</li>";
		    error = true;
		  }
		}
		
		error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
	}
	
	function check_jerseyave_onetime(){
    var error = false;
    var permits_authorized = new Array();
		
		var field;
		var permits_index = 0;
	  var els = document.payonetime.elements;
    for(i = 0; i < els.length; i++){
	    field = els[i];

		  if(/permits_authorized/.test(field.name)){
	  	  permits_authorized[permits_index] = field;
				permits_index++;
		  }
	  }
		
    var error_msg = "";

		for(i = 0; i < permits_authorized.length; i++){
      if(dropdown_empty(permits_authorized[i])){
        error_msg = error_msg + "<li>Please select your <b>Permits Authorized</b>.</li>";
  		  error = true;
				break;
			}
    }
		
		error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
	}
	
	function check_mailinglist(){
	  var error = false;
		var email = document.mailinglist.email.value;

		if((!validateEmail(email))||(email === "")){
      error_msg = "<li>Please enter a valid <b>E-Mail</b>.</li>";
		  error = true;
		}

		error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
	}

	function check_onetime(){
    var error = false;
    var invoice_number = new Array();
    var invoice_date = new Array();
    var amount = new Array();
		
		var field;
		var invoice_index = 0;
		var invoice_date_index = 0;
		var amount_index = 0;
	  var els = document.payonetime.elements;
    for(i = 0; i < els.length; i++){
	    field = els[i];

		  if(/invoice_number/.test(field.name)){
	  	  invoice_number[invoice_index] = field.value;
				invoice_index++;
		  }
		  
		  if(/invoice_date/.test(field.name)){
	  	  invoice_date[invoice_date_index] = field.value;
				invoice_date_index++;
		  }
		
		  if(/amount/.test(field.name)){
	  	  amount[amount_index] = field.value;
				amount_index++;
		  }
	  }
		
    var error_msg = "";
		
		for(i = 0; i < invoice_number.length; i++){
      if((invoice_number[i] === "")&&(invoice_date[i] === "")){ 
        error_msg = error_msg + "<li>Please enter your <b>Invoice Number(s)</b> or <b>Invoice Date(s)</b>.</li>";
		  	error = true;
				break;
			}
    }

		for(i = 0; i < amount.length; i++){
      if((amount[i] === "")||!(validateCurrency(amount[i]))){
        error_msg = error_msg + "<li>Please enter a numeric value for all <b>Amount</b>.</li>";
		  	error = true;
				break;
			}
    }
		
		error_msg = "<ul>" + error_msg + "</ul>";
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
	}

	function check_permit(){
    var error = false;
    var first_name = document.permit.first_name.value;
    var last_name = document.permit.last_name.value;
		var email = document.permit.email.value;
    var permit_type = document.permit.permit_type.value;
    var error_msg = "";
		
    if(first_name === "" || last_name === "" || email === "" || permit_type === ""){ 
      error_msg = "<li>Please make sure all required fields are filled in.</li>";
			error = true;
    }
		
		switch(permit_type)
		{
		  case "apply-for-business-permit":
    		var company = document.permit.company.value;
			   var num_permits = document.permit.num_permits.value;
				  if (company === ""){
				    error_msg = error_msg + "<li>Please tell us the name of your company.</li>";
				 	  error = true;
				  }
				  if (num_permits === ""){
				    error_msg = error_msg + "<li>Please tell us how many permits you require.</li>";
					   error = true;
				  }
			   break;
		  case "apply-for-loading-permit":
   	 	var company = document.permit.company.value;
				  if (company === ""){
				    error_msg = error_msg + "<li>Please tell us the name of your company.</li>";
					   error = true;
				  }
				  break;
		  case "apply-for-handicap-permit":
			   var pdf_application = document.permit.pdf_application.value;
				  if (pdf_application === ""){
				    error_msg = error_msg + "<li>Please fill out the Handicap Zone Application Form and upload it.</li>";
					   error = true;
				  }
			   break;
		}

		error_msg = "<ul>" + error_msg + "</ul>";

    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
		  form_error_msg(error_msg);
			window.scrollTo(0,0);
      return false;
    }
	}
	
  function check_personals(){
    error = false;
    var first_name = document.register.first_name.value;
    var last_name = document.register.last_name.value;
    var addr1 = document.register.addr1.value;
    var city = document.register.city.value;
    var state = document.register.state.value;
    var zip = document.register.zip.value;
		var current = document.register.current_tag_or_permit;
		var agreement = document.register.agreement;
    
    if(first_name === "" || last_name === "" || addr1 === "" || city === "" || state === "" || zip === ""){ 
      error = true;
    }
    
		radio_check = false;
    for (var i=0; i < current.length; i++){
      if(current[i].checked){
        radio_check = true;
			}
    }
		if(!radio_check){error = true;}
		if(!agreement.checked){error = true;}
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
			window.scrollTo(0,0);
      return false;
    }
  }
	
  function check_username(){
    error = false;
    var email = document.register.email.value;
    var password = document.register.password.value;
    var password_confirm = document.register.password_confirm.value;
    
    if(email === "" || password === "" || password_confirm === ""){ 
      error = true;
    }else{
      if(password !== password_confirm){
        error = true;
      }else{
        if(password.length < 5){
          error = true;
        }
      }
    }
      
    if(!error){
      $('#errors').hide('fast');
      return true;
    }else{
      $('#errors').show('slow');
			window.scrollTo(0,0);
      return false;
    }
  }
  
  function login(){
    //document.login.location.value = document.location;
    document.login.submit() ;
  }

  function openWindow(url,width,height){
    var awidth = width;
    var aheight = height;
				if (width == ""){
				  awidth=500;
				}
				if (height == ""){
				  aheight=425;
				}
    popupWin = window.open(url, 'remote', 'toolbar,scrollbars,resizable,width=' + awidth + ',height=' + aheight + ',left=0,top=0');
    popupWin.focus();
  }

  function reset_search(input){
    if(!input.value){
      input.value = "Search";
		} 
    else{
      input.value = "";
		}
    //else if(input.value === ""){
    //  input.value = "Search &raquo;";
		//}
  }