
function init(){ 
  if(chckcrnr()){ 
    //rndd("div#srchbx","top","#fff","#adceae","smooth border #5a965a");
    //rndd("div.rmpnltr","tr","#fff","#adceae","smooth border #5a965a");  
    rndd("div#searchbottom","bottom","#fff","#cfe2cf","smooth border #3f693f");
    rndd("div.hotelguideheader","top","#fff","#069","smooth border #069");  
    rndd("div.exploreheader","top","#fff","#069","smooth border #069");  
    //rndd("div.publshrmap","top","#fff","#069","smooth border #069");  
    rndd("div.publshrhtl","top","#fff","#3f693f","smooth border #3f693f"); 
    rndd("div.filterSelect","all","#fff","#F6FAF4","smooth border #BFD8AD");
    rndd("div.rmpnltr","all","#fff","#F6FAF4","smooth border #BFD8AD");
    rndd("div.bx1","all","#dee5ef","#fff","smooth border #91ABC2");
    rndd("div.slnkslft","tl bl","#fff","#dee5ef","small");
    rndd("div.slnksrght","tr br","#fff","#dee5ef","small");
    rndd("div.sbmt","all","#fff","#e6ff80","smooth border #e6ff80");
    rndd("div#sortby","all","#fff","#069","smooth border #069");
    rndd("div.ddtcrtlst","all","#efefef","#e7f1e0","smooth border #2c4a2c"); 
    rndd("div.tckts","top","#cfe2cf","#9d9071","smooth border #9d9071"); 
    rndd("div.bktfrmhdr","top","#fff","#3f693f","smooth border #3f693f"); 
    rndd("div.bkitfrm","bottom","#fff","#e7f1e0","smooth border #2c4a2c"); 
    rndd("div.bktfrm2hdr","top","#fff","#cfe2cf","smooth border #2c4a2c"); 
    rndd("div.bkppnl","bottom","#fff","#cfe2cf","smooth border #2c4a2c"); 
    rndd("div#ndxsrchbx","bottom","#fff","#cfe2cf","smooth border #3f693f");      
    rndd("div.hrestp","top","#fff","#3f693f","smooth border #3f693f");
    rndd("div.hwrap","all","#dee5ef","#fff","smooth border #91abc2");
    rndd("div.orl","top","#fff","#069","smooth border #069");
    rndd("div.orl","bottom","#fff","#069","smooth border #069"); 
    
  }
  
 // addbgcolorchange();

  
}


function addbgcolorchange(){
 var lst=document.getElementsByTagName('td');
 var count=0;
 for(var i=0;i<lst.length;i++){
  if(/rt/.test(lst[i].className)){
  lst[i].parentNode.onmouseover=function(){this.className='rowin';};
  lst[i].parentNode.onmouseout=function(){this.className='rowout';};
  }
 }
}



function showhide(x){
  var e1 = document.getElementById("tdsplydesc_"+x);
  var x1 = document.getElementById("xpnd"+x);
  var vw = (navigator.appName.indexOf("Microsoft") > -1) ? 'block':'table-row'; 
  if((e1.style.display == 'none')) e1.style.display = vw; 
  else e1.style.display = 'none';
  x1.innerHTML = (x1.innerHTML=="[-]") ? "[+]": "[-]";
}




function srtby(type){
  var url = document.sortby.action+"?sort="+type; 
  document.sortby.action = url;
  document.sortby.submit();
}

function currchange(){
  var base = document.sortby;
  var i = base.crrcnhg.selectedIndex;
  var code = new String(base.crrcnhg[i].text).before(" -").toLowerCase();
  if(!(document.sortby.action).contains("http://")) location.href = "http://"+document.domain+"/"+document.sortby.action+"?crr="+code; 
  else location.href = document.sortby.action+"?crr="+code;  
}

function issuenumrqrd(x){
  var ir = document.getElementById("issuenumrqrd");
  var vw = (navigator.appName.indexOf("Microsoft") > -1) ? 'block':'table-row'; 
  var isReq=false;
  var i = x[x.selectedIndex].value;
  switch(i.toUpperCase()){case "S":isReq=true;break;case "O":isReq=true;break;case "TO":isReq=true;break;}
  if(isReq) ir.style.display = vw; 
  else ir.style.display = 'none';
  return("");
}

function bkit(str1,str2,str3){
  var rt = document.rsrv;
  rt.room.value=str1;
  rt.roomdesc.value=str2;
  rt.ratecode.value=str3;
  document.rsrv.submit();
}

function email(src) {
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(src);
}
var clckd_nxt = 0;
function cmplt(){
  var clr = "#ffff99";
  var which=document.details.elements;
  for(var i=0;i<which.length;i++){
    if(which[i].name!="cmpltbttn") which[i].onblur = function(){ this.style.backgroundColor="#fff";}
    if(which[i].name.search("fname_room_")>-1){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter the First Name for your Room Preference");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name.search("lname_room_")>-1){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter the Last Name for your Room Preference");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="email"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter your Email address");
        which[i].focus();
        return(false);
      }else if((email(which[i].value) == false)){
        which[i].style.backgroundColor = clr;       
        alert("your email address seems incorrect");
        which[i].focus(); 
        return false;
      }
    }else if(which[i].name=="firstname"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter your billing First Name");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="lastname"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter your billing Last Name");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="add1"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter your billing Address");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="city"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter your billing City/Town");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="zip"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter your billing Zip/Postal Code");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="state"){
      if((document.details.country[document.details.country.selectedIndex].value=="US") || (document.details.country[document.details.country.selectedIndex].value=="CA") || (document.details.country[document.details.country.selectedIndex].value=="AU"))
        if(which[i].selectedIndex==0){
          which[i].style.backgroundColor = clr;
          alert("Please select your billing State");
          which[i].focus();
          return(false);
        }
    }else if(which[i].name=="phone"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter a Home Phone number");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="businessphone"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;
        alert("Please enter an Alternative Phone number (e.g. work, cell/mobile)");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="ctype"){
      if(which[i].selectedIndex==0){
        which[i].style.backgroundColor = clr;        
        alert("Please select your Credit Card Type");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="ccnum"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;        
        alert("Please enter your Credit Card number");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="expmonth"){
      if(which[i].selectedIndex==0){
        which[i].style.backgroundColor = clr;        
        alert("Please select your Card Expiration Month");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="expyear"){
      if(which[i].selectedIndex==0){
        which[i].style.backgroundColor = clr;        
        alert("Please select your Card Expiration Year");
        which[i].focus();
        return(false);
      }
    }else if(which[i].name=="cvv"){
      if(which[i].value==""){
        which[i].style.backgroundColor = clr;        
        alert("Please provide your Card Security Code");
        which[i].focus();
        return(false);
      }
    }
  }
  tmp=String(document.details.ctype[document.details.ctype.selectedIndex].value).toUpperCase();
  if((tmp=="S")||(tmp=="O")||(tmp=="TO")){   
    if(document.details.issuenum.value==""){
      if((document.details.startmonth.selectedIndex==0) || (document.details.startyear.selectedIndex==0)){
        alert("Please provide an Issue Number or Start Date for your card");
        return(false);
      }
    }    
  }
   
  if(document.details.agree.checked==false){
    alert("Please confirm you agree to the Cancellation Policy");
    document.details.agree.focus();
    return(false);
  }

  if((clckd_nxt++)==0) return(true); 
  else return(false); 
  return(true);
}


function catchUp(){
  document.search.mnthen.selectedIndex = document.search.mnthst.selectedIndex;
}

var slctCrr = "";

function changecurrency(url){
  location.href = url+"?crr="+slctCrr.toLowerCase();
}

function hndx(){
 var frm = document.search;
 var top = 0;
 if(frm.city){
   top = frm.city.length;
 }

 var url;
 var found = false;
 if((document.search.ctysrch.value!=""))
 for(var i=0;i<top;i++){
   if(frm.city[i].checked==true){
     url=frm.city[i].value.split("!")[1];
     found=true;
     frm.which.value="hrates";
     frm.action=url;
   }
 }

 if(found==false){
   if(document.search.ctysrch.value==""){
     alert("Please enter a city/town");     
     focusandhighlight(frm.ctysrch,"ctysrch","search");
     return(false);
   }
   frm.which.value="hndxsrch";
 }
 if(htlSrch()==false) return(false);
 return(true);
}

function hndxchngcty(i){
  var frm = document.search;
  frm.ctysrch.value=frm.city[i].value.split("!")[0];
  frm.city[i].checked=true;
}

function hndxchngctysrch(which){
  var frm = document.search;
  var top = frm.city.length;
  for(var i=0;i<top;i++){
   frm.city[i].checked=false;
  }
}

function clcksrt(url){
  document.location = url;
}

function rmvrndd(selector){
  getElementsBySelector(selector).className="";
}

function filter (which) {
  var fltr = which[which.selectedIndex].value;
  if(fltr!="") fltr+="/";
  document.qck.action = document.qck.domain.value+document.qck.thisPage.value+fltr;
  document.qck.submit();
}


function nw(which) {
  var str = document.getElementById(which).value;
  str=unescape(str);
  var nw = window.open('','','menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,width=640,height=480');
  nw.document.write(str);
  nw.document.close();
  return(false);
}

function nw1 (which,w,h) {
  var str = document.getElementById(which).value;
  str=unescape(str);
  var nw = window.open('','','menubar=no,toolbar=no,resizable=no,scrollbars=yes,width='+w+',height='+h);
  nw.document.writeln(str);
  nw.document.close();
  return(false);

}


function rvwmlr(url,title){
  var s1 = "reviews";
  var s2 = "und";
  var s3 = "ercover";
  var s4 = "tourist.";
  var s5 = "com";
  title=escape(title);
  return("<a href=\"mailto:"+s1+"@"+s2+s3+s4+s5+"?subject="+title+" ["+url+"]\">Submit a Review</a>");
}
function mlddrss(str){
  var prt1 = "mail";var prt2 = "to:";var prt3 = "info";var prt4 = "@";var prt5 = "undercovertourist";var prt6 = ".com";var str = "<sup><a href=\""+prt1+prt2+prt3+prt4+prt5+prt6+"\" title=\"Email your comments\">[%FILL%]</a></sup>";
  var img = "<img src=\"images/feedback/speech.gif\" width=\"14\" height=\"12\" alt=\"comment\" title=\"Email us your comments and feedback\" />";
  var fill = "";
  if(str=="")str=str.replace("[%FILL%]",img);
  else str=str.replace("[%FILL%]",str);
  
  document.write(str);
}


var names="";
var srtflg=0;

var crrntpic = "";
var maxpics;

function showPic (pc) {
 if (document.getElementById) { 
   var np = document.getElementById('imgrot');var ttl = pc.title;np.src = pc.href;np.setAttribute('title',ttl);np.setAttribute('alt',ttl);crrntpic=pc.href;
   //alert(document.getElementById('imgrot').offsetWidth);
   //showPreview(pc);
   
   return false;
 } else return true;
}

function showPicPrv (pc) {
 if(document.getElementById) { 
   var np = document.getElementById('imgrot');
   var i = crrntpic.search("_");
   var j = crrntpic.search(".jpg");
   var index = parseInt(crrntpic.substring(i+1,j+1),10)-1;
   if(index<0) index=(maxpics-1);
   crrntpic = crrntpic.substring(0,i+1)+(index)+crrntpic.substring(j,crrntpic.length);
   np.src = crrntpic;
	  currentActiveImage = pc.getElementsByTagName('IMG')[0];
	  currentActiveImage.className='activeImage';
 }
}

function showPicNxt (pc) { 
 if(document.getElementById) { 
   var np = document.getElementById('imgrot');
   var i = crrntpic.after("_").before(".");
   var index = parseInt(i,10)+1; 
   if(index==maxpics) index=0;
   crrntpic = crrntpic.before("_")+"_"+index+".jpg";
   np.src = crrntpic;
 }
}
