﻿// JScript File

var div;var divIdx;var nc=new Array();var map2;var bOnDemand=false;var cfu='';var cfnt='';var cfk=0;var cfty='';var asl=null;var lact=null;
var pgevt;var div;var divIdx;var nc=new Array();var ajevt=null;var addTree;var addfld;var addkeys;var rName='';
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 _Cmpstyle(){var i=readCookie("mapstyle");if (i==null){i='r';}return i}
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 showFullSize2(src,t) { if(document.getElementById('divVid')){document.getElementById('divVid').style.display='none'};document.getElementById('imgFull').style.display=''; document.getElementById('imgFull').src = src;document.getElementById('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}

// **************  START GLOBAL SEARCH ******************************************************** 

function chkcssubmit(e){if(e && e.keyCode == Sys.UI.Key.enter){ncfTry=0;wtrsearch(e)}}
function onWTRNameSelected(s,a){cfnt=a.get_text();cfnk=a.get_value().split('|')[1];cfu=a.get_value().split('|')[0];cfk=a.get_value().split('|')[1];cfty=a.get_value().split('|')[2];wtrsearch()}   


function mpNoResults(){ alert("Cannot find any results for  '" + txtWTRSName.value + "'.");try{mpNoResults2()}catch(err){};}
function mpResults(){try{hidestarFind()}catch(err){};  try{mpResults2()}catch(err){};}
function wtrsearch(e){
    _cnEvt(e) ;var loc='';
    if (cfu!='' && cfnt==txtWTRSName.value){
        window.location=cfu
    }else if (txtWTRSName.value!='' ){
        showsearchwait();
        ContentHandler.SearchKeyword2(txtWTRSName.value, 'DEST', showcsnpop, onCSFailed);
   }
   }
function showsearchwait(){pnlwtrsearchR.innerHTML='<div class=clsWaiting><img src="/i/waiting.gif"/> Searching...</div>';$find('popSiteSearch').show()}
function showcsnpop(results, eventArgs){pnlwtrsearchR.innerHTML=results;}
function hidecspopup(){$find('popSiteSearch').hide()}
function onCSFailed(error){ncfTry++;if (ncfTry<5){wtrsearch();}else{ showError(error) }}

// **************  END GLOBAL SEARCH ********************************************************  


// **************  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)}
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 ********************************************************  
function fPop(h,k,ty,t,l){ return h}
// **************  END COMMON MAP ********************************************************  
// **************  GUI ELEMENTS ********************************************************  

function openprint(u){var win= window.open(u,'starprintwin'); if (!win){alert('Unable to show Print window.  Please be sure your popup blockers are disabled.')}else{win.focus();}}
function riskwhat(){var win= window.open('/tools/risklevels.aspx');if (!win){alert('Unable to show Risk Level definitions.  Please be sure your popup blockers are disabled.')}else{setFocus(win);}}
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 hidewait(){$find('popBhvWait').hide();}
function showwait(msg){if (!msg){msg='Applying Changes'} document.getElementById('spnWaitMsg').innerHTML=msg +'...';$find('popBhvWait').show();}
// **************  END COMMON MAP ********************************************************  

// **************  START APP MESSAGES ********************************************************  
function showTPPop(bhv,parentID,evt,md){if (md==null){md=2;}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){if (h==null){h=true};showTPMsg(parentID,  msg,evt,pos) ;if(h){ hideTPMsg(true);}}
function showTPMsg(parentID,  msg,evt,md){
if (md==null){md=2}; 
$find('popTPMsgOff').get_OnClickBehavior().get_animation().stop();    
document.getElementById('divTPMsg').innerHTML=msg;   
pnlTPMsg.style.display='';  
showTPPop('popTPMsgOn',parentID,evt,md)
}
function hideTPMsg(fd){if (fd){$find('popTPMsgOff').OnClick();}else{_cnEvt();hideTPPop('popTPMsgOn');}}
// **************  START END MESSAGES ********************************************************  

// **************  START AJAX POPUP ********************************************************  
var bLastX=-1

function closePAj2(e){  window.setTimeout(closePAj,25)}//if this is done to quickly on click, it causes an error
function closePAj(){ hideModal('aj')}   
function closeAj(){closePAj()}
function rAJAXPop(p,typ,arg,e){_cnEvt(e);if (typ=='DEST' ){jumpDest(p)}else{  showdetail('',typ,p) }}
function showdetail(r,t,p){   
    var ha=40;
    var h=550;
    var w=810;  
    if (t=='POI'||t=='DIN'||t=='TRN'||t=='SVC'){
        if (h>500){h=500}
        if (w>500){w=500} 
    }
    var h2=h-70;var h3=h2-120+ha
    p='/widgets/HotelPopup/widget.aspx?pk=' + p + '&ssid=' + ssid
    mShowModalWin('Hotel','aj',p,h,w,10,true,true)
}	
// **************  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 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)
{
    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);  
    var size = { 'height':h, 'width': w };
    var iframe = document.createElement('iframe');
    iframe.name = name;
    iframe.id = id;
    iframe.src = src    
     iframe.scrolling='no'
    iframe.style.height = size.height + 'px';
     iframe.style.width = size.width + 'px';
    if (isIE6p()){iframe.style.position = 'absolute'}else{iframe.style.position = 'fixed';}
    iframe.style.zIndex = 3;
    
    if (trn){iframe.allowTransparency=true}
    else{
      iframe.style.backgroundColor = 'white';
      iframe.style.border = '2px solid silver';
    }
    iframe.frameBorder = 'no';	
    if (cntr){
       iframe.style.top = 0 + 'px'// iframe.style.top = ((height + document.documentElement.scrollTop) / 2) - (size.height / 2) + 'px';
    }else{iframe.style.top = t + 'px'}
    iframe.style.left = (width / 2) - (size.width / 2) + 'px';		
    document.body.appendChild(iframe);  
}

// **************  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.0')!=-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 _sendremind(){
if (txtFromName.value==''){alert('Please enter Your Name');return false}
if (txtFromEmail.value==''){alert('Please enter Your E-mail');return false}
if (txtToEmail.value==''){alert('Please enter Recipient E-mail');return false}
ContentHandler.SendRemindEmail(txtFromName.value, txtFromEmail.value,txtToEmail.value,onsendremin,onsendremindfail)
}    
function onsendremin(r){if (r==''){alert('Your message has been sent. Thank you!');hidesubnoticemsg()}else{alert(r)}}
function onsendremindfail(error){ showError(error);}


var WindPropimages = "height=630,width=625,left=10,top=10,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes"
function openPreview(g,prev,download){
    if (download){window.location='/pickup/download.aspx?rid=' + g}else{
    var url='/pickup/wait.aspx?rid=' + g
      
       var win=	window.open(url,'PrintPreview','width=980,height=700,resizable,scrollbars,toolbar,menubar');
        if (!win){alert('Unable to show Report Preview.  Please be sure your popup blockers are disabled for Weissmann.com.')}else{setFocus(win);}
}   
  }
function openPostcardPreview(g,prev){
    var win=	window.open('/pickup/pcwait.aspx?rid=' + g,'PCPreview','width=550,height=400,resizable=false,scrollbars=false,toolbar=false,menubar=false');
    if (!win){alert('Unable to show Postcard Preview.  Please be sure your popup blockers are disabled for Weissmann.com.')}else{setFocus(win);}
}
function newwindow(url) {var pWin;var pname;pWin = window.open(url, pname, WindPropimages);}


function seladdtofolder(){}
function showaddto(kys,allownew,evt){mShowModalWin('AddToFolder','aj','/widgets/AddTo/widget.aspx?keys=' + escape(kys) + '&an='+allownew,500,650,60,true,false)}
function showmoveto(selfld,movetype,fldnm,selkeys,selcnt,evt){mShowModalWin('AddToFolder','aj','/widgets/AddTo/widget.aspx?keys=' + escape(selkeys) + '&selfld='+selfld + '&mt='+movetype + '&nm='+ escape(fldnm) + '&sel='+selcnt ,500,650,60,true,false)}
function newfolder2(f,t){addTree=t;addfld=f;_cnEvt();divNewFolder.style.display='';setFocus(txtNewFolder) }
function checknewfldr(e){try{if(e && e.keyCode == Sys.UI.Key.enter){savenewfld();_cnEvt(e);}}catch(err){}}
function hidenewfld(){divNewFolder.style.display='none'}
function savenewfld(){hidenewfld();var s=txtNewFolder.value;ContentHandler.AddNewFolder(s,addfld,onaddfolder2,OnFailed2,addfld)}
function onaddfolder2(n,f){
        addTree.beginUpdate();var sName= n.split('|')[1];var sKey= n.split('|')[0];var nn = new ComponentArt.Web.UI.TreeViewNode();
        nn.set_text(sName + "&nbsp;&nbsp;<img src='/i/newfldr.gif' onclick='newfolder2(" + sKey + ",window." + addTree.get_id() + ");return false' Title='Add New Subfolder'  border=0 />");
        nn.set_value(sKey);nn.set_id('fld' + sKey);nn.set_imageUrl('/i/folder2.gif');nn.set_labelPadding(4);
        var p=addTree.findNodeById('fld'+f);p.get_nodes().add(nn);addTree.endUpdate();nn.select();nn.expandAncestors();  
}

function savetmp(){

    try{hidetemplate()}catch(e){}
    try{showwait('Saving Outline')}catch(e){}
    if ( txtTemplateName.value==''){
        try{hidewait()}catch(e){}        
        try{showTemplate()}catch(e){}
        window.alert('Please enter a Outline Name to save')      
        return false;
   }
   var itms=getchecked()
   ContentHandler.SaveContentTemplate(tid, txtTemplateName.value, txtTemplateDescription.value, itms,onsavetmp,onsavetmperr)
}
function onsavetmp(r){
try{hidewait()}catch(e){}
window.alert("Report Outline '" + txtTemplateName.value + "' has been saved.")
try{notifynewtemplate(r)}catch(e){}
}

function onsavetmperr(r){
try{hidewait()}catch(e){}
window.alert("There was an errot saving Report Outline '" + txtTemplateName.value + "'.  Please try again or contact technical support.")
}
