﻿//Copyright © Hotel and Travel Index, LLC. All Rights Reserved - code may not be reused in whole or in part without written consent- removal of this section consitutes a copyright violation


var ord = '123456789';var tpwin;var nOnd=0;var sfrL="";var sfrS1="";var sfrS2="";var sfrB1="";var sfrB2="";var sfrSS="";
var pgevt;var div;var divIdx;var nc=new Array();var ajevt=null;var bpaTrack=false;
var lgPID;var istp=false;var acced=false;var last=null;var lastT=null;var lastP=null;var lnk;var pncls='clsPin1'
if (isIE6p()){pncls='clsPin2'}

function appndURL(u,a){if (u.indexOf('?')==-1){u = u + '?'}else{u = u + '&'};u = u + a;return u}

function _SearchType(){var i=readCookie("SearchType");if (i==null){i='DEST_HOT'};return i}
function _sSearchType(v){if (v==""){eraseCookie("SearchType")}else{createCookie("SearchType",v,365)}}
function _SelPlaces(){var i=readCookie("SelPlaces");if (i==null){i=0};return i}
function _sSelPlaces(v){if (v==""){eraseCookie("SelPlaces")}else{createCookie("SelPlaces",v,1)}}
function _UserID(){var i=readCookie("UserKey");if (i==null){i=0};return i}
function _vpr(){var i=readCookie("vpr");if (i==null){i="WM"};return i}
function _Cmpstyle(){var i=readCookie("mapstyle");if (i==null){i='r';}return i}
function _sUserID(v){if (v=="0"){eraseCookie("UserKey")}else{createCookie("UserKey",v,365)}}
function _svpr(v){if (v==""){eraseCookie("vpr")}else{createCookie("vpr",v,365)}}
function _sCmpstyle(v){createCookie("mapstyle",v,365)}

function setFocus(o){if(o){try{o.focus()}catch(e){}}}
function getObj(objID) {if (document.getElementById){return document.getElementById(objID);}else if (document.all){return document.all[objID];}else if (document.layers){return document.layers[objID];}}
function _pgEvt(){var e;try{e=event}catch(err){};return e}
function _cnEvt(evt){try{evt = (evt) ? evt : window.event;evt.returnValue = false;evt.cancelBubble = true;}catch(err){};}
function createCookie(name,value,days) {if (days) {var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}
function readCookie(cookie_name) {var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );  if ( results ){return ( unescape ( results[1] ) )}else{return null}}
function eraseCookie(name) {createCookie(name,"",-1);}
function showError(error) {var stackTrace = error.get_stackTrace();var message = error.get_message();var statusCode = error.get_statusCode();var exceptionType = error.get_exceptionType();var timedout = error.get_timedOut();alert(message);}


function printhis(k){}
function emailthis(k){}
function showVideoInline(){if(document.getElementById('divVid')){document.getElementById('divVid').style.display=''};document.getElementById('imgFull').style.display='none';}
function showVideoInline2(){
if(divVid){divVid.style.display=''};
if(divVT){divVT.style.display='none'}
if(imgFull){imgFull.style.display='none'}
}
function showVTInline2(src,c){
if(divVT){divVT.style.display=''}
if (divVTCaption){divVTCaption.innerHTML=c}
if(divVid){divVid.style.display='none'};
if(imgFull){imgFull.style.display='none'}
LoadTour(src);
}
function showFullSize2(src,t) { 
if(divVid){divVid.style.display='none'};
if(divVT){divVT.style.display='none'}
if(imgFull){imgFull.style.display=''
imgFull.src = src;
imgFull.title=t; 
}
document.getElementById('imgFullDesc').innerHTML=t 
}
function OnFailed2(error){ showError(error);}
function donothing(){}
function disablelink(a){a.disabled=true;a.onclick=dontdo;a.href=''}
function enablelink(a,href){a.disabled=false;a.onclick='';a.href = href;}
function dontdo(){return false}

function dealsnav(a){
var u='/Travel-Deals?loc=' + a.options[a.selectedIndex].value
winloc(u)
}

function showExplore(){};
function winloc(u){//do this to get referer on window.location calls
var a = document.createElement("a"); 
if(!a.click) {window.location = u;  return;} 
a.setAttribute("href", u); 
a.style.display = "none"; 
document.body.appendChild(a); //prototype shortcut
 a.click();
}


function showMapP(a){
try{
var b = $common.getBounds(pnlMapPop);  
var b2 = $common.getBounds(a );  
b.y=b2.y+15
b.x=b2.x 
b.height=340
b.width=331 
$common.setBounds( pnlMapPop,b);
if (ifrMap.src!=a.href + ':Popup-Map'){ifrMap.src=a.href+ ':Popup-Map'}
myTrackEvent('Popup','ShowPopup','Map','')
pnlMapPop.style.display=""
}catch(e){HTIWS.LogJSError( e.description,'showMapP;' + a ,donothing,donothing)}}

function domaploaded(){
pnlLoadingMap.style.display="none"
ifrMap.style.display=""
}
function hideMapP(a){pnlMapPop.style.display="none"}
function intadfr(){
if (sfrL==""){
    try{sfrL=document.getElementById('frEmbedLEADER').src}catch(e){}
    try{sfrS1=document.getElementById('frEmbedWIDESKY1').src}catch(e){}
    try{sfrS2=document.getElementById('frEmbedWIDESKY2').src}catch(e){}
    try{sfrB1=document.getElementById('frEmbedBILLBOARD1').src}catch(e){}
    try{sfrB2=document.getElementById('frEmbedBILLBOARD2').src}catch(e){}
    try{sfrSS=document.getElementById('frEmbedSITESPONSOR').src}catch(e){} 
    }
}

function rotateads(){
try{intadfr();nOnd=nOnd+1; var sOnd="&ond=" + nOnd;}catch(e){}
try{document.getElementById('frEmbedLEADER').src=sfrL+sOnd}catch(e){}
try{document.getElementById('frEmbedWIDESKY1').src=sfrS1+sOnd}catch(e){}
try{document.getElementById('frEmbedWIDESKY2').src=sfrS2 +sOnd}catch(e){}
try{document.getElementById('frEmbedBILLBOARD1').src=sfrB1+sOnd}catch(e){}
try{document.getElementById('frEmbedBILLBOARD2').src=sfrB2+sOnd}catch(e){}
try{document.getElementById('frEmbedSITESPONSOR').src=sfrSS+sOnd}catch(e){}
}

// **************  START GLOBAL SEARCH ********************************************************  
var gsu='';var gst='';var gscntxt='DEST_HOT';var gslastCntx
function chkgssubmit(e){if(e && e.keyCode == Sys.UI.Key.enter){_cnEvt(e);return false;}} 
function gs(e){_cnEvt(e);if (txtGS.value!='' && txtGS.value!='Enter destination name'&& txtGS.value!='Enter hotel name' && txtGS.value!='Enter airport name' && txtGS.value!='Enter attraction name'){if (gsu!='' && gst==txtGS.value){alert(2);winloc(gsu)}else{if (gscntxt=='HOT'){winloc("/Hotels/Search?hn=" + txtGS.value)}else{winloc("/Search?pst=" + txtGS.value + '&typ='+gscntxt)}}}else{window.alert("Please " +  txtGS.value + " and click 'go'")}; return false;}
function disableenter(){$addHandler(document, "keydown", onGSKeyDown)}
function onGSKeyDown(e){
try{if(e && e.keyCode == Sys.UI.Key.enter){var id=e.target.id;var t=e.target.type;if (txtGS.id==id){gs(e)}else if (t!='textarea'&& t!='' && t!='button' ){_cnEvt(e);return false;}}}catch(err){}

}    
function onGSearchItemSelected(s,a){
    var u=a.get_value().split('|')[0]+'?AC=1';
    try{ntptAddPair( 'val',txtGS.value)}catch(e){};    
    try{ntptAddPair( 'val2',gscntxt)}catch(e){};    
    try{ntptAddPair( 'val3',u)}catch(e){};    
    try{ntptEventTag('ev=' + 'AC_'  + gscntxt )}catch(e){};       
    try{pageTracker._trackEvent('AutoC', 'AC_'  + gscntxt,txtGS.value, u)}catch(e){};

    winloc(u)
}  


// **************  START PAGE TRACKING ********************************************************  
function myTrackPageView(u,r){
    try{pageTracker._trackPageview(u);}catch(e){};
    try{ ntptEventTag(u); }catch(e){};    
     if(bpaTrack){
        var _BPAtrk= new Image(1,1)
       _BPAtrk.src="http://secure-us.imrworldwide.com/cgi-bin/m?ci=us-bpaww&cg=0&cc=1&si=http://hotelandtravelindex.travelweekly.com" + escape(u) + "&rnd=" + Math.ceil(Math.random()*1000000000); 
     }
     if (r){window.setTimeout(rotateads,500)}


}
function myTrackEvent(category,action,label, value){
    if (value!='' || label!=''){
        var val=value; if (val==''){val=label};
         try{ntptAddPair( 'val',val)}catch(e){};    
   }
    try{ntptEventTag('ev=' + action )}catch(e){};   
    try{pageTracker._trackEvent(category, action,label, value)}catch(e){};
    
}
// **************  END PAGE TRACKING ********************************************************  
function mgsSetContext(l,c){
try{
if (gslastCntx!=null){gslastCntx.className='cSearchT';}
l=l.parentNode.parentNode.parentNode.parentNode.parentNode;
l.className='cSearchTA'
gslastCntx=l;gscntxt=c;gssetWM();_sSearchType(gscntxt)

if (txtGS.value!=''){
    var bhv=$find('bhvwtrGo');
    if (bhv.get_WatermarkText()!=txtGS.value){
        var o = $find('bhvgsearch'); 
        if (o){
            o._cache = {};
            o._currentPrefix = null;
            o._textBoxHasFocus = true;
            var oldMinimumPrefixLength = o.get_minimumPrefixLength();
            o.set_minimumPrefixLength(0);
            o._onTimerTick(null, null);
            o.set_minimumPrefixLength(oldMinimumPrefixLength);
        }
    }
}
}catch(e){HTIWS.LogJSError( e.description,'mgsSetContext;' + l + ';' + c,donothing,donothing)}}
function gssetWM(){var s='';switch(gscntxt){case 'DEST_HOT':s='Enter destination name'; break;
case 'HOT':s='Enter hotel name'; break;
case 'APT_HOT':s='Enter airport name'; break;        
case 'POI_HOT':s='Enter attraction name'; break;}var bhv=$find('bhvwtrGo');bhv.set_WatermarkText(s);var o = $find('bhvgsearch'); o._contextKey=gscntxt;gsu='';gst=''}
// **************  END GLOBAL SEARCH ********************************************************  



// **************  START LOGIN ********************************************************  
function doLogout(){_sUserID(0); window.location=window.location}
function dologin(q){
try{mShowModalWin('DoLogin','aj','/widgets/Login/widget.aspx' + q,4650  ,850,30,true,false,'Login')
}catch(e){HTIWS.LogJSError( e.description,'dologin;' + q,donothing,donothing)}}
function doProfile(){
try{mShowModalWin('DoProfile','aj','/widgets/user/widget.aspx',4650  ,850,30,true,false,'DoProfile')
}catch(e){HTIWS.LogJSError( e.description,'doProfile' ,donothing,donothing)}}
function hideLogin2(e){  window.setTimeout(hideLogin,25)}//if this is done to quickly on click, it causes an error
function hideLogin(){hideModal('aj')}   

function doSTARLogin(){
try{mShowModalWin('Starlogin','aj','/widgets/StarLogin/widget.aspx',470,550,60,true,false,'STARLogin')
}catch(e){HTIWS.LogJSError( e.description,'doSTARLogin' ,donothing,donothing)}}

// **************  END LOGIN ********************************************************  

// **************  START SIGN UP ********************************************************  
function showSignup(){mShowModalWin('Register','aj','/widgets/User/widget.aspx',4650  ,850,30,true,false,'Register')}
function hideSignup2(e){  window.setTimeout(hideSignup,25)}//if this is done to quickly on click, it causes an error
function hideSignup(){hideModal('aj')} 
function hidePassword2(e){  window.setTimeout(hidePassword,25)}//if this is done to quickly on click, it causes an error
function hidePassword(){hideModal('aj')}  
// **************  END SIGN UP ********************************************************  

// **************  START VIDEO ********************************************************  
function showVideo(url,title,type,h,w){mShowModalWin('Video','aj','/widgets/VideoPlayer/widget.aspx?u=' + escape(url) + '&t=' + type + '&h=' + h + '&w=' +w  + '&title=' +escape(title),550  ,700,30,true,false,'Video')}
function hideVideo2(e){  window.setTimeout(hideVideo,25)}//if this is done to quickly on click, it causes an error
function hideVideo(){hideModal('aj')} 
// **************  END VIDEO ********************************************************  

// **************  START COMMON MAP ********************************************************  
var curmaplink=null;function dogetmapdest(sb){
try{
document.getElementById('pnlMapPlacesP').className='ColumnLinkListRef';
myTrackEvent('HotMap','HotMapNav',sb,'')
HTIWS.GetMapDest(sb,ondogetmapdest,showError)
}catch(e){HTIWS.LogJSError( e.description,'dogetmapdest;'+sb ,donothing,donothing)}}

function ondogetmapdest(s){if(pnlMapPlacesHTML){pnlMapPlacesHTML.style.display='none'};pnlMapPlaces.style.display='';pnlMapPlaces.innerHTML=s;pnlMapPlaces.className='LinkList3';document.getElementById('pnlMapPlacesP').className='';document.getElementById('bkBox').scrollIntoView();if (curmaplink){curmaplink.childNodes[0].className='';curmaplink=null;}}
// **************  END COMMON MAP ********************************************************  

// **************  START USER REVIEW ********************************************************  
function showReviewwin(pk,rid,ct){mShowModalWin('UserRating','aj','/widgets/UserRating/widget.aspx?rid=' + rid + '&ppk='+ pk + '&ct='+ct,650,850,0,true,false,'UserReview') }   
// **************  END USER REVIEWP ********************************************************  

// **************  GUI ELEMENTS ********************************************************  
function showshelp(){mShowModalWin('MapHelp','aj','/widgets/MapHelp/widget.aspx',400  ,700,30,true,false,'SearchHelp')}

function openClassification(){window.open('/HTI-Classifications','HTIClassification','width=1000,height=600,resizable,scrollbars');}
function togVid(a){var divWM=document.getElementById('divWM');var divRM=document.getElementById('divRM');_svpr(a);if (a=='RM'){divRM.style.display="";divWM.style.display="none";}else{divWM.style.display="";divRM.style.display="none";}}
function dogetalldest(u,l,a){
try{document.getElementById('pnlListP').className='ColumnLinkListRef';
if (a){myTrackEvent('Places','APlacesLetter',l,'')}else{myTrackEvent('Places','PlacesLetter',l,'')}
myTrackPageView(u + ':' +l,false)
HTIWS.GetListDest(u,l,a,ondogetalldest,showError)
}catch(e){HTIWS.LogJSError( e.description,'dogetalldest;'+u + ';' + l+ ';' +a ,donothing,donothing)}}
function ondogetalldest(s){pnlListPlaces.innerHTML=s;pnlListPlaces.className='LinkList3';document.getElementById('pnlListP').className='LinkList3';window.setTimeout(rotateads,500)}
function tglStyle(a){if(a.className=='cSlideVHS'){a.className= 'cSlideVH'}else{a.className= 'cSlideVHS'}}
function showmore(){document.getElementById('divMore').className='cMoreS';document.getElementById('lnkMore').className='cMoreH';document.getElementById('lnkLess').className='cMoreS';}
function showless(){document.getElementById('divMore').className='cMoreH';document.getElementById('lnkMore').className='cMoreS';document.getElementById('lnkLess').className='cMoreH'}
function accChanging(s,a){ var idx=a._selectedIndex;rot_pnls[idx].className='';rot_pnls[rot_pnlsL].className='cPanelROff'; rot_pnlsL=idx}
function setTab(a,i,t,s){
try{  if (s!=''){s=s+'_'}
    if (t==false){var _th=0; eval('_th=' + i + 'tabth'); var s='window.clearInterval(' + _th + ')';;eval(s)}
    if (i==null  || i=='undefined'){i=''}
    var _lasttab=0
    eval('_lasttab=' + i + 'lasttab')
    if (_lasttab!=-1){
            var t=document.getElementById(i+"celTab" + _lasttab)
        var c=document.getElementById(i+"divTab" + _lasttab)
        t.className=s+ "clsTabOff"
        c.className=s+ "clsTabContentOff"
        var t=document.getElementById(i+"celTab" + a)
        var c=document.getElementById(i+"divTab" + a)        
        t.className=s+ "clsTabOn"
        c.className=s+ "clsTabContentOn"
    }
    eval(i+ 'lasttab=a')
}catch(e){HTIWS.LogJSError( e.description,'setTab' ,donothing,donothing)}
}
var tabplayer;
function inittabplayer(a){tabplayer=a;eval(a + "tabth=window.setInterval(shownext,7000)")  }
function shownext(){var _lasttab=0;var _tabcount=0;eval('_tabcount=' + tabplayer + 'tabcount');eval('_lasttab=' + tabplayer + 'lasttab');var l=_lasttab+1;if (l>_tabcount){l=1}; setTab(l,tabplayer,true)}


function setSlide(a,i,t){
    if (t==false){var _th=0; eval('_th=' + i + 'tabth'); var s='window.clearInterval(' + _th + ')';;eval(s)}
    if (i==null  || i=='undefined'){i=''}
    var _lasttab=0
    eval('_lasttab=' + i + 'lasttab')
    if (_lasttab!=-1){
            var t=document.getElementById(i+"celTab" + _lasttab)
        var c=document.getElementById(i+"divTab" + _lasttab)
        t.className="clsSlideOff"
        c.className="clsTabContentOff"
        var t=document.getElementById(i+"celTab" + a)
        var c=document.getElementById(i+"divTab" + a)        
        t.className="clsSlideOn"
        c.className="clsTabContentOn"
    }
    eval(i+ 'lasttab=a')
    
 }
 var slideplayer;
 function initslideplayer(a){slideplayer=a;eval(a + "tabth=window.setInterval(shownextslide,7000)")  }
function shownextslide(){var _lasttab=0;var _tabcount=0;eval('_tabcount=' + slideplayer + 'tabcount');eval('_lasttab=' + slideplayer + 'lasttab');var l=_lasttab+1;if (l>_tabcount){l=1}; setSlide(l,slideplayer,true)}


 function pageLoad(s,e) {s
     try{pageLoad_vtab(s,e)}catch(e){}
     try{pageLoad_htab(s,e)}catch(e){}
     try{pageLoad_map(s,e)}catch(e){}
     try{pageLoad_temp(s,e)}catch(e){}
 }
// **************  END COMMON MAP ********************************************************  

// **************  START HOTEL SEARCH ********************************************************  
var hotLURL='/Hotels'
function __rating(){
    var rt=''
    for (var k=0; k<=5; k++)
    {	var ctxt=getObj("chkStar"+k);
        if (ctxt){rt=rt+ ctxt.checked + '|'}
    }   
	return rt
}	      
function rtachecked(b){
var c=getObj('chkStar0')
 if (c){c.checked=true}
	for (var k=1; k<=5; k++)
	{	var ctxt=getObj("chkStar"+k);
	    if (ctxt){ctxt.checked=false}
	}
if (b){try{fchecked()}catch(e){}}
}
function rtchecked(){
var s=false;
	for (var k=1; k<=5; k++)
	{	var ctxt=getObj("chkStar"+k);
	    if (ctxt){s=s || ctxt.checked}
	}
	var c=getObj('chkStar0');
    if (c){c.checked=!s}
	try{fchecked()}catch(e){}
}
function htsearch(e){_cnEvt(e);winloc(hotLURL + '?hn=' + txtNameFilter.value + '&rt=' + __rating())}
// **************  END HOTEL SEARCH ********************************************************  

// **************  START APP MESSAGES ********************************************************  
var TPTOH=0;
function showTPPop(bhv,parentID,evt,md){if (md==null){md=2;}pnlTPMsg.style.display=''; if (parentID!=null){$find(bhv+ 'PopupBehavior').set_parentElement(parentID);} $find(bhv + 'PopupBehavior').set_positioningMode(md);if (parentID==null){ $find(bhv+ 'PopupBehavior').set_y(pHeight()/3); $find(bhv+ 'PopupBehavior').set_x(winWidth()/3)};$find(bhv).showPopup();if (parentID==null){$find(bhv+ 'PopupBehavior').set_y(pHeight()/3); $find(bhv+ 'PopupBehavior').set_x(winWidth()/3)};_cnEvt(evt);}
function hideTPPop(bhv){ var b=$find(bhv+ 'PopupBehavior'); if (b){b._hidePopup();}}
function shTPMsg(parentID,  msg,evt,pos,h,t){if (h==null){h=true};showTPMsg(parentID,  msg,evt,pos) ;if(h){ hideTPMsg(true,t);}}
function showTPMsg(parentID,  msg,evt,md){ if (md==null){md=2}; if (TPTOH>0){window.clearTimeout(TPTOH);TPTOH=0}; document.getElementById('divTPMsg').innerHTML=msg; showTPPop('popTPMsgOn',parentID,evt,md)}
function hideTPMsg(fd,t){if (!t){t=3000};   if (fd){TPTOH=window.setTimeout(hideTPMsgto,t)}else{_cnEvt();hideTPPop('popTPMsgOn');}}
function hideTPMsgto(){pnlTPMsg.style.display='none';  TPTOH=0}
// **************  START END MESSAGES ********************************************************  

// **************  START AJAX POPUP ********************************************************  
var bLastX=-1
function OnAJAXPopDataSucceeded(r, typ){if (r!=''){showdetail(r,typ)}}
function closePAj2(e){  window.setTimeout(closePAj,25)}//if this is done to quickly on click, it causes an error
function closePAjRef(e){window.location=window.location;  }
function closePAj(){ hideModal('aj')}   
function closeAj(){    
    //if (bLastX!=-1){var mybb =  $find('popBhvAj'+ 'PopupBehavior');bLastX=mybb.get_x();}
     b=$find('popBhvAj');if (b){b.hidePopup()}
}
function rAJAXPop(u,typ,arg,e){_cnEvt(e);if (typ=='DEST' ){jumpDest(u)}else{  showdetail('nw',typ,u) }}
function setDetail(c,h){c="<div id=ajTop2></div>"+c;pnlCnt.innerHTML=c;if (isMoz()){pnlCnt.style.height= h + 'px';}else{pnlCnt.style.height= h;}}
function showdetail(r,t,u){ 
_cnEvt()
    mShowModalWin ('HotelQuickView','aj',u,550,720,10,true,false,'HotelQuickView')
}	
function jumpDest(u){
    if (istp){
        if (tpwin){
            try{tpwin.location=u}catch(e){tpwin= window.open(u,'destination')}}
            else{tpwin= window.open(u,'destination')}
        if (!tpwin){alert('Unable to show Destination detail.  Please be sure your popup blockers are disabled.')}else{tpwin.focus();}
    }else{winloc(u)}
}
// **************  END AJAX POPUP ********************************************************  


function showAJAXPop(bhv,evt){$find(bhv).show(); _cnEvt(evt);}
function hideAJAXPop(bhv){$find(bhv).hide()}

// **************  END AJAX POPUP ********************************************************  

// **************  START FUNCTIONS  ********************************************************  
function isDate(dateStr) {
    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?
    return matchArray != null
}
function DateAdd(timeU,byMany,dateObj) {
	var millisecond=1;
	var second=millisecond*1000;
	var minute=second*60;
	var hour=minute*60;
	var day=hour*24;
	var year=day*365;

	var newDate;
	var dVal=dateObj.valueOf();
	switch(timeU) {
		case "ms": newDate=new Date(dVal+millisecond*byMany); break;
		case "s": newDate=new Date(dVal+second*byMany); break;
		case "mi": newDate=new Date(dVal+minute*byMany); break;
		case "h": newDate=new Date(dVal+hour*byMany); break;
		case "d": newDate=new Date(dVal+day*byMany); break;
		case "y": newDate=new Date(dVal+year*byMany); break;
	}
	return newDate;
}
function AND(a, b) {
  var result=0;
  var x=binaryArray(parseInt(a));
  var y=binaryArray(parseInt(b));
  var biggerArray=(x.length>=y.length)?x:y;
  var smallerArray=(biggerArray==x)?y:x;
  var len=biggerArray.length;
  for (var i=0;i<len;i++) {
    biggerArray[i]=(biggerArray[i]&smallerArray[i])?1:0;
    result+=biggerArray[i]*Math.pow(2, i);
  }
  return result;  
}

function binaryArray(num) {
  var arr=new Array();
  var div;
  var mod;
  var n=num;
  var count=0;
  do {
    mod=n%2;
    n=parseInt(n/2);
    arr[count++]=mod;
  } while (n>0)
  return arr;
}

// **************  END FUNCTIONS  ********************************************************  


function mEnablePage(){

    }

function mDisablePage(){
    var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
    var height = document.documentElement.clientHeight + document.documentElement.scrollTop;

    var layer = document.createElement('div');
    layer.style.zIndex = 2;
    layer.id = 'layer';
    layer.style.position = 'absolute';
    layer.style.top = '0px';
    layer.style.left = '0px';
    layer.style.height = document.documentElement.scrollHeight + 'px';
    layer.style.width = width + 'px';
    layer.style.backgroundColor = 'gray';
    layer.style.opacity = '.6';
    layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=60)");
    document.body.style.position = 'static';
    document.body.appendChild(layer);      
    
}

function hideModal(n){ if (document.getElementById('layer')){document.body.removeChild( document.getElementById('layer'));document.body.style.position = ''; document.body.removeChild( document.getElementById(n))}}
function mShowModalWin(name,id,src,h,w,t,trn,cntr,type)
{
_cnEvt();
try{
    var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
    var height = document.documentElement.clientHeight + document.documentElement.scrollTop;
    mDisablePage()
    var size = { 'height':h, 'width': w };
    var i = document.createElement('iframe');
    i.name = name;
    i.id = id;
    i.src = src    
    i.scrolling='no';
    i.style.height = size.height + 'px';
    i.style.width = size.width + 'px';
    t=(document.documentElement.scrollTop-20)+t;
    i.style.position = 'absolute';
    i.style.zIndex = 3;
    if (trn){i.allowTransparency=true}
    else{
      i.style.backgroundColor = 'white';
      i.style.border = '2px solid silver';
    }
    i.frameBorder = 'no';	
   
    if (cntr){i.style.top = '100px'}else{    
    i.style.top = t + 'px'}
    i.style.left = (width / 2) - (size.width / 2) + 'px';		
    document.body.appendChild(i); 
    
    myTrackEvent('Popup','ShowPopup',name, '')
}catch(e){HTIWS.LogJSError( e.description,'mShowModalWin;'+name ,donothing,donothing)}
}

// **************  START BROWSER  ********************************************************  
function pWidth(){var w=winWidth(); if (w>1050){w=1050}else{w=900};return w}   
function pWidth2(){var w=winWidth();if (w>730){w=730};return w;}   
function pHeight2(){var h=winHeight();if (h>600){h=600};return h;}   
function pHeight(){var h=winHeight();return h;}     

function scrollTop(){
  var scr = 0
  if( isMoz()) {
    scr = window.pageYOffset;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    scr = document.documentElement.scrollTop;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    scr = document.body.scrollTop;  
   }
  return scr;
}
function setscrollTop(x){
  if( isMoz()) {
    window.pageYOffset=x;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
     document.documentElement.scrollTop=x;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
     document.body.scrollTop=x
   }
  
}
function winWidth(){
  var myWidth = 0
  if( isMoz()) {
    myWidth = window.innerWidth;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;  }
  
  return myWidth;
}
function isMoz(){return  (typeof( window.innerHeight ) == 'number') }
function isIE(){return !isMoz()}
function isIE7(){if (isIE()){return (navigator.appVersion.indexOf('MSIE 7')!=-1 || navigator.appVersion.indexOf('MSIE 8')!=-1)}else{return false}}
function isIE6p(){if (isIE()){return !(isIE7())}else{return false}}
function winHeight(){
  var myHeight = 0
  if( isMoz()) {
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight; 
}
function f_scrollTop() {
var n=0
	if (window.pageYOffset){n= window.pageYOffset}
	else if(document.documentElement){n= document.documentElement.scrollTop}
	else if(document.body){n= document.body.scrollTop}
return n
}
function s_scrollTop() {
	if (window.pageYOffset){window.pageYOffset=0}
	else if(document.documentElement){document.documentElement.scrollTop=0}
	else if(document.body){document.body.scrollTop=0}
}
function s_scrollLeft() {
	if (window.pageXOffset){window.pageXOffset=0}
	else if(document.documentElement){document.documentElement.scrollLeft=0}
	else if(document.body){document.body.scrollLeft=0}
}

// **************  END BROWSER  ********************************************************  



function rotatingTab(settingarg){
	this.setting=settingarg
	settingarg=null
	var setting=this.setting
	setting.fadeduration=parseInt(setting.fadeduration)
	setting.tabcount=parseInt(setting.tabcount)
	setting.curTab=1
	setting.ispaused=!setting.autoplay[0]
	setting.currentstep=0 //keep track of # of slides tabs has gone through
	setting.totalsteps=setting.tabcount*setting.autoplay[2]
	setting.fglayer=0, setting.bglayer=1 //index of active and background layer (switches after each change of slide)
	setting.oninit=setting.oninit || function(){}
	setting.onTabChange=setting.onTabChange || function(){}
	var tabs=this
	
		var setting=tabs.setting
		tabs.showslide(setting.curTab) //show initial slide
		setting.oninit.call(tabs) //trigger oninit() event
	
}

rotatingTab.prototype={

    showtab: function(idx){
      if (!this.setting.ispaused){this.navigate('pause')}
        this.navigate(idx)
     },
	navigate:function(keyword){
		clearTimeout(this.setting.playtimer)
		this.setting.totalsteps=100000 //if any of the nav buttons are clicked on, set totalsteps limit to an "unreachable" number 
		if (!isNaN(parseInt(keyword))){
			this.showslide(parseInt(keyword))
		}
		else if (/(prev)|(next)/i.test(keyword)){
			this.showslide(keyword.toLowerCase())
		}
		else{ //if play|pause button
			var tabs=this
			if (!this.setting.ispaused){ //if pause Gallery
				this.setting.autoplay[0]=false
			}
			else if (this.setting.ispaused){ //if play Gallery
				this.setting.autoplay[0]=true
				this.setting.playtimer=setTimeout(function(){tabs.showslide('next')}, this.setting.autoplay[1])
			}
			tabs.setting.ispaused=!tabs.setting.ispaused
		}
	},

	showslide:function(keyword){
		var tabs=this
		
		var setting=tabs.setting
		var totaltabs=setting.tabcount
		var tabindex=(keyword=="next")? (setting.curTab<totaltabs? setting.curTab+1 : 1)
			: (keyword=="prev")? (setting.curTab>1? setting.curTab-1 : totaltabs)
			: Math.min(keyword, totaltabs)		
        var t=document.getElementById(setting.wrapperid +"celTab" + setting.curTab)
        var c=document.getElementById(setting.wrapperid +"divTab" + setting.curTab)
        t.className=setting.skin + "clsTabOff"
        c.className=setting.skin + "clsTabContentOff"
        var t=document.getElementById(setting.wrapperid+"celTab" + tabindex)
        var c=document.getElementById(setting.wrapperid+"divTab" + tabindex)        
        t.className=setting.skin + "clsTabOn"
        c.className=setting.skin + "clsTabContentOn"
        

	clearTimeout(setting.playtimer)
				setting.currentstep+=1
				if (setting.autoplay[0]){
					if (setting.currentstep<=setting.totalsteps)
						setting.playtimer=setTimeout(function(){tabs.showslide('next')}, setting.autoplay[1])
					else
						tabs.navigate("play/pause")
				}
		setting.curTab=tabindex

	}
	
	}




