function pviiClassNew(obj, new_style) { 
  obj.className=new_style;
}

// JavaScript Document
function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
		
function TM_UpperCase(strInput,words){
    var theString = strInput.value;
    var strOutput = "";// Our temporary string used to build the function's output
    var sp = " ";
    var small = false;
    var smallWords = words.split(",") //words that shouldn't be  capitalized
    theString = theString.replace(/(\s*)([^\s])/,"$2")//remove leading spaces
    theString = theString.toLowerCase();  
    var inputArray = theString.split(sp);
    strOutput = inputArray[0].slice(0,1).toUpperCase()+inputArray[0].slice(1);
    for (i = 1; i < inputArray.length; i++){ 
        small=false;
        for (ii=0;ii<smallWords.length;ii++){
           if(inputArray[i] == smallWords[ii]) small = true;
           }
        if(!small) inputArray[i] = inputArray[i].slice(0,1).toUpperCase()+inputArray[i].slice(1);
        strOutput = strOutput + sp + inputArray[i];  
        }
    strInput.value = strOutput;
}

var nums=new Array('document.forms[0].contactphone');
function doThis(){
var re= /\D/;
// test for this format: (xxx)xxx-xxxx
// var re2 = /^\({1}\d{2}\)\d{4}-\d{4}/; 
// test for this format: xxx-xxx-xxxx
var re2 = /^\d{2}-\d{4} \d{4}/;
for (i=0; i<nums.length;i++){
var num=eval(nums[i]+'.value');
var newNum;
 if (num != "" && re2.test(num)!=true){
   if (num != ""){
     while (re.test(num)){
     num = num.replace(re,"");
     }
   }
  if (num.length != 10){
    alert('Please enter a 10 digit phone number');
    eval(nums[i]).select();
    break;
    }
   else {
     // for format (xxx)xxx-xxxx
     // newNum = '(' + num.substring(0,2) + ')' + num.substring(2,6) + '-' + num.substring(6,10);
     // for format (xx) xxxx xxxx
     newNum = '(' + num.substring(0,2) + ') ' + num.substring(2,6) + ' ' + num.substring(6,10);
     eval(nums[i]).value=newNum;
     }
   }
  }
}

// the validateForm() function is the brain of the form-validation
// code; you'll have to customize it to fit your form-field needs!
function validateForm(contact)  {
  // validate First & Last Name field
  // begin by stripping leading/trailing blanks
  document.contact.name.value = stripLeadingTrailingBlanks(document.contact.name.value);
  if (isBlank(document.contact.name.value))
    {    alert("Please enter your First & Last Name.");
   document.contact.name.focus();
    return false;    }

  // validate Email field ( the exclamation means "not" )
  // begin by stripping leading/trailing blanks
  document.contact.email.value = stripLeadingTrailingBlanks(document.contact.email.value);
  if(!isEmail(document.contact.email.value))
  	  {	  alert("Invalid email detected.");
      document.contact.email.focus();
  		 // if the browser is Netscape 6 or IE
  if(document.all || document.getElementByID)
  	  {  // change the color of text field
	  document.contact.email.style.background = "#02409C";	
	  document.contact.email.style.color = "#FFFFFF";	  }  
	  // make sure the form is not submitted
  	  return false;	  }	

 // validate Phone field
 // begin by stripping leading/trailing blanks	
document.contact.contactphone.value = stripLeadingTrailingBlanks(document.contact.contactphone.value);
  if (isBlank(document.contact.contactphone.value))
    {
    alert("Please enter a 10 digit phone number  - xx xxxx xxxx.");
   document.contact.contactphone.focus();
    return false;    }	
	
  // validate Room Type field
  if (getCheckedCheckboxes(document.contact.bedroomRequested) == -1)
    {    alert("Please choose a which room you would like to stay in.");
    return false;    }
  else if (getCheckedCheckboxes(document.contact.bedroomRequested).length != 1)
    {    alert("Please choose *exactly* one room type.");
    return false;    }

  // validate Number of Guests field
  if ((getCheckedSelectOptions(document.contact.numberOfGuests) == -1) || 
      (getCheckedSelectOptions(document.contact.numberOfGuests) == 0))
    {    alert("Please tell us how many guests will be with you.");
    return false;    }
	
  return true;   }		

function toForm() {
document.contact.name.focus();
}