
 /* Thickbox 1.0 - One box to rule them all.
 * By Cody Lindley (http://www.codylindley.com)
 * Under an Attribution, Share Alike License
 * Thickbox is built on top of the very light weight jquery library.
 */
 var $;

 if(typeof(jQuery) != 'undefined')
	$ = jQuery.noConflict();

//on page load call TB_init
$(document).ready(TB_init);
TB_HEIGHTSPEC ='';
WRAPPERID='';
SCROLL ='';
SrcUrl="";



//add thickbox to href elements that have a class of .thickbox
function TB_init(){
	
 if(typeof(jQuery) != 'undefined')
	$ = jQuery.noConflict();
	$("a.thickbox").click(function(){
	var t = this.title || this.innerHTML || this.href;
	TB_show(t,this.href,this.href);
	this.blur();
	return false;
	});
}

function TB_show(caption, url, imgUrl) {//function called when the user clicks on a thickbox link
	try {
                SrcUrl=url;
	    var noOfSelectTags,i;
		noOfSelectTags = document.getElementsByTagName("SELECT");
        for(i = 0; i < noOfSelectTags.length; i++){
        noOfSelectTags[i].style.visibility="hidden";
        }	
		$("body")
		.append("<div id='TB_overlay'></div><div id='TB_window'></div>");
		//$("#TB_overlay").click(TB_remove);
		$(window).resize(TB_position);	
		//$(window).scroll(TB_position);	
 		
		$("#TB_overlay").show();
		$("body").append("<div id='TB_load'><div id='TB_loadContent'><img src='"+imgUrl+"' /></div></div>");
		
	
		var urlString = /\.jpg|\.jpeg|\.png|\.gif|\.html|\.htm|\.php|\.cfm|\.asp|\.aspx|\.jsp|\.jst|\.rb|\.txt/g;
		var urlType = url.match(urlString);
		
		
		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif'){//code to show images

			var imgPreloader = new Image();
			imgPreloader.onload = function(){
				
			// Resizing large images added by Christian Montoya

			var pagesize = getPageSize();
			var x = pagesize[0] - 100;
			var y = pagesize[1] - 100;

			if(imgPreloader.width > x) { 
				imgPreloader.height = imgPreloader.height * (x/imgPreloader.width); 
				imgPreloader.width = x; 
				if(imgPreloader.height > y) { 
					imgPreloader.width = imgPreloader.width * (y/imgPreloader.height); 
					imgPreloader.height = y; 
				}
			} 

			else if(imgPreloader.height > y) { 
				imgPreloader.width = imgPreloader.width * (y/imgPreloader.height); 
				imgPreloader.height = y; 
				if(imgPreloader.width > x) { 
					imgPreloader.height = imgPreloader.height * (x/imgPreloader.width); 
					imgPreloader.width = x;
				}
			}

			// End Resizing
			
			TB_WIDTH = imgPreloader.width + 0;
			TB_HEIGHT = imgPreloader.height + 60;
			$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imgPreloader.width+"' height='"+imgPreloader.height+"' alt='"+caption+"'/></a>"
								 + "<div id='TB_caption'>"+caption+"</div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton'>close</a></div>"); 
			$("#TB_closeWindowButton").click(TB_remove);
			if(typeof(SCROLL) == 'undefined' || SCROLL== '' || SCROLL != '0'){
				if(typeof(jQuery) != 'undefined')
					$ = jQuery.noConflict();
			   $(window).scroll(TB_position);
	        }else{
	            window.onscroll =null;
	            window.scroll(0,0); //position from page top
		    }
			TB_position();
			$("#TB_load").remove();
			$("#TB_ImageOff").click(TB_remove);
			$("#TB_window").slideDown("normal");
			}
	  
			imgPreloader.src = url;
		}
		
		if(urlType=='.htm'||urlType=='.html'||urlType=='.php'||urlType=='.asp'||urlType=='.aspx'||urlType=='.jsp'||urlType=='.jst'||urlType=='.rb'||urlType=='.txt'||urlType=='.cfm'){//code to show html pages
			
			var queryString = url.replace(/^[^\?]+\??/,'');			
			var params = parseQuery( queryString );
			var htmlContent="";
			var pagesize = getPageSize();
			
			TB_WIDTH = (params['width']*1) + 0;
			TB_HEIGHT = (params['height']*1) + 50;
			RESOURCE =params['resource'];
			CLOSE_WIN = params['closewin'];	
			SCROLL = params['scroll'];	
			OPACITY = params['setopacity'];
			
			ajaxContentW = TB_WIDTH - 0;
			ajaxContentH = TB_HEIGHT - 45;
			$("#TB_window").append("<div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
			$("#TB_closeWindowButton").click(TB_remove);
			
			
			if(typeof(RESOURCE) != 'undefined' && RESOURCE!= '')
			{			 
			    TB_HEIGHTSPEC =160   
			    htmlContent = "<div class='LoginMessageContent'><div class='LoginHeader'><div class='SampleCross'><a href='javascript:TB_remove();' class='CloseWindow'>X</a></div></div><div class='PopupMsgContent'>" + RESOURCE+"</div></div>";			   
			    if(typeof(SCROLL) == 'undefined' || SCROLL== '' || SCROLL != '0'){
				if(typeof(jQuery) != 'undefined')
						$ = jQuery.noConflict();
			        $(window).scroll(TB_position);
	            }else{
	               
	                window.scroll(0,0); //position from page top
		        }
			    TB_position();
			     $("#TB_load").remove();
			     $("#TB_window").slideDown("normal");
			     document.getElementById("TB_ajaxContent").innerHTML=htmlContent;
			}
			else
			{
			     $("#TB_ajaxContent").load(url, function(){
			      if((typeof(SCROLL) == 'undefined' || SCROLL== '' || SCROLL != '0') && pagesize[1] > (TB_HEIGHT+40)){
			        if(typeof(jQuery) != 'undefined')
					$ = jQuery.noConflict();
					$(window).scroll(TB_position);
				
	               }else{
	                //window.onscroll =null;
			  SCROLL = '0';
			 $(window).unbind('scroll',TB_position);
	                window.scroll(0,0); //position from page top
		         }
			     TB_position();
			     $("#TB_load").remove();
			     $("#TB_window").slideDown("normal");
			     });
			}
		}
		
		if(typeof(OPACITY) != 'undefined' && OPACITY== 1)
		{
		    document.getElementById('TB_overlay').className='SpecificOpacity';
		}
		
		
	} catch(e) {
		alert( e );
	}

	try{
	   showhide()
	   }
	catch(e){}

	    }

//helper functions below

function TB_remove() {
        var noOfSelectTags,i;
	    noOfSelectTags = document.getElementsByTagName("SELECT");
        for(i = 0; i < noOfSelectTags.length; i++){
        noOfSelectTags[i].style.visibility="visible";    
        }
    
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay').remove();});
	$("#TB_load").remove();	
		try{
			hide()
		   }
		catch(e){}
			//return false;
			//CBWEB-86 - To close window after closing the popup
			if((typeof(CLOSE_WIN) != 'undefined') && CLOSE_WIN == '1')
			{
			     var oMe = window.self;oMe.open('','_self',''); oMe.close();
			}
		   }

function TB_position() {

	var pagesize = getPageSize();
	var xScroll;
  
  	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}

	if (window.innerWidth && window.scrollMaxX) {	
		xScroll = window.innerWidth + window.scrollMaxX;	      
	} else if (document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;		
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;		
  	}

	var arrayPageScroll = getPageScrollTop();
	var wheight;
	
	if(TB_HEIGHTSPEC!='')
	    wheight = TB_HEIGHTSPEC;
	else
	    wheight =260;
	
	var topSpacing1 = (arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2));
		
		if(topSpacing1 < 20)
			topSpacing1 = 40
		else
			topSpacing1 = (arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2))

	
	$("#TB_window").css({width:TB_WIDTH+"px",height:wheight+"px",	
	left: ((pagesize[0] - TB_WIDTH)/2)+"px", top: topSpacing1 +"px" });

	
	    
	if(typeof(SCROLL) != 'undefined' && SCROLL!= '' && SCROLL=='0'){ 
        
	   if(SrcUrl.toLowerCase().indexOf('/backpacking/') != -1 && pagesize[1] < (TB_HEIGHT+40) && yScroll > TB_HEIGHT)
	    {
		var topSpacing = (yScroll-TB_HEIGHT)/2;
		
		if(topSpacing < 20)
			topSpacing = 40
		else
			topSpacing = (yScroll-TB_HEIGHT)/2
	       
	        $("#TB_window").css({width:TB_WIDTH+"px",height:wheight+"px",	
	            left: ((xScroll - TB_WIDTH)/2)+"px", top: (topSpacing) +"px" });
	    }
	   else if((arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2)) < 0 )
            {
	            if(xScroll > pagesize[0])
                {
	               $("#TB_window").css({width:TB_WIDTH+"px",height:wheight+"px",	
	                left: ((xScroll - TB_WIDTH)/2)+"px", top: 40 +"px" });    
	            }
	            else
	            {
	                 $("#TB_window").css({width:TB_WIDTH+"px",height:wheight+"px",	
	                left: ((pagesize[0] - TB_WIDTH)/2)+"px", top: 40 +"px" }); 
	            }   
	    }
	}else
	{
		if((arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2)) < 10)
        {
	           $("#TB_window").css({width:TB_WIDTH+"px",height:wheight+"px",	
	            left: ((pagesize[0] - TB_WIDTH)/2)+"px", top: 40 +"px" });     
	    }
	
	}
	 

	if(yScroll!=0)
	{
	    if(TB_HEIGHT > yScroll)
	       yScroll = TB_HEIGHT+40;

	    if(yScroll < pagesize[1])
		yScroll = pagesize[1];
	    
	    $("#TB_overlay").css("height",yScroll +"px");
	}

}

function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}


function getPageScrollTop(){
	var yScrolltop;
	if (self.pageYOffset) {
		yScrolltop = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScrolltop) 
	return arrayPageScroll;
}

function getPageSize(){
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}

function showhide()
{
    var div1 = document.getElementById('FlashFile')
    div1.style.visibility="hidden";
    div1.style.display="none";
    var div2=document.getElementById('FlashImg')
    div2.style.visibility="visible";
    div2.style.display="block";
}

function hide()
{
    var div1 = document.getElementById('FlashFile')
    div1.style.visibility="visible";
    div1.style.display="block";
    var div2=document.getElementById('FlashImg')
    div2.style.visibility="hidden";
    div2.style.display="none";
}

function OpenWindow()
        {
		var BrowserName = navigator.appName;
		//alert(BrowserName);
	     	if (BrowserName == "Netscape")
		{
			var newWin = window.open("","printWin","height=280,width=400,left=10,top=10,status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=no");
		}
		else
		{
			var newWin = window.open("","printWin","height=290,width=417,left=10,top=10,status=yes,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=no");
		}
            	newWin.location.href="../PopUp/ForgotPassword.aspx";
            	newWin.focus();
        }



function TB_removebookingconditions() {
        var noOfSelectTags,i;
	    noOfSelectTags = document.getElementsByTagName("SELECT");
        for(i = 0; i < noOfSelectTags.length; i++){
        noOfSelectTags[i].style.visibility="visible";    
        }   
		try{	
		    var expires = new Date();
            expires.setUTCFullYear(expires.getUTCFullYear() - 1);            
            document.cookie = 'PaxInfo=; expires=' + expires.toUTCString() + '; path=/';            	                
			window.location.href='/MyProfile/Logins.aspx?Err=01';	
			$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay').remove();});
	        $("#TB_load").remove();			
		   }
		catch(e){}
			//return false;
		   }


function TB_MPPshow(wrapperId,width,height,scroll)
{
	   var noOfSelectTags,i;
     var wrappedSelectTags,j;
     var isInList = false;
     var adjust = false;
		noOfSelectTags = document.getElementsByTagName("SELECT");
		wrappedSelectTags = document.getElementById(wrapperId).getElementsByTagName("SELECT");
		
		if(scroll=="12")
		{
		    scroll = "0";
		    adjust = true;
		}
		
		
        for(i = 0; i < noOfSelectTags.length; i++){
             for(j = 0; j < wrappedSelectTags.length; j++){
                if(noOfSelectTags[i].id == wrappedSelectTags[j].id)
                    isInList = true;
                else
                    isInList = false;
               
                if(isInList)
                    break;
             }
             if(!isInList)
                noOfSelectTags[i].style.visibility="hidden";
        }
      TB_WIDTH = width;
	  TB_HEIGHT =height;
	  WRAPPERID=wrapperId
    
     if(document.getElementById('MPPTB_overlay') == null)
     {
      $("body")
		        .append("<div id='MPPTB_overlay'></div>");
            $("#MPPTB_overlay").show(); 
     } 

            if(scroll=='1'){
				$(window).resize(MPPTB_position);	
			        $(window).scroll(MPPTB_position);
			          MPPTB_position();
	       }else{
	                 SCROLL = '0';
			 //$(window).unbind('scroll',MPPTB_position);
	                window.scroll(0,0); //position from page top
	                TB_SETPosition()
	        }

		  
		   var opacityStr,opacityVal; 
	       if(document.body.filters){
	            opacityStr="filter";opacityVal="100"
	       }else{
	            opacityStr="opacity";opacityVal="1"}
		  
		    $("#"+WRAPPERID).slideDown("normal");
		 if(adjust == true)
		      setTimeout(" if(document.getElementById('"+WRAPPERID+"').style!=null){$('#"+WRAPPERID+"').css('visibility', 'visible');}",800);	   	    	   
		 else
		    setTimeout("if(document.getElementById('"+WRAPPERID+"').style!=null){var style1=document.getElementById('"+WRAPPERID+"').getAttribute('style').toString();style1 = style1.replace(/overflow: hidden;/g,'');document.getElementById('"+WRAPPERID+"').setAttribute('style',style1);}$('#"+WRAPPERID+"').css('" + opacityStr + "', '" + opacityVal + "');",800);	    	   

		
}


function TB_SETPosition()
{
	var pagesize = getPageSize();
	var xScroll;
  
  	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}

	if (window.innerWidth && window.scrollMaxX) {	
		xScroll = window.innerWidth + window.scrollMaxX;	      
	} else if (document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;		
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;		
  	}
	
	
	var arrayPageScroll = getPageScrollTop();
	var wheight;
	
	if(TB_HEIGHTSPEC!='')
	    wheight = TB_HEIGHTSPEC;
	else
	    wheight =260;
	
	var topSpacing1 = (arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2));
		
		if(topSpacing1 < 20)
			topSpacing1 = 40
		else
			topSpacing1 = (arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2))

	
	$("#"+WRAPPERID).css({width:TB_WIDTH+"px",height:wheight+"px",	
	left: ((pagesize[0] - TB_WIDTH)/2)+"px", top: topSpacing1 +"px" });
	    
	if(typeof(SCROLL) != 'undefined' && SCROLL!= '' && SCROLL=='0'){ 

	  if((SrcUrl.toLowerCase().indexOf('/backpacking/') != -1 || SrcUrl.toLowerCase().indexOf('/parents/') != -1 ) && pagesize[1] < (TB_HEIGHT+40) && yScroll > TB_HEIGHT)
	    {
		var topSpacing = (yScroll-TB_HEIGHT)/2;
		
		
		if(topSpacing < 20)
			topSpacing = 40
		else
			topSpacing = (yScroll-TB_HEIGHT)/2
	       
	        $("#"+WRAPPERID).css({width:TB_WIDTH+"px",height:wheight+"px",	
	            left: ((xScroll - TB_WIDTH)/2) + "px", top: (topSpacing) + "px" });
	    }
	   else if((arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2)) < 0 )
            {
	            if(xScroll > pagesize[0])
                {
	               $("#"+WRAPPERID).css({width:TB_WIDTH+"px",height:wheight+"px",	
	                left: ((xScroll - TB_WIDTH)/2) + "px", top: 40 + "px" });    
	            }
	            else
	            {
	                 $("#"+WRAPPERID).css({width:TB_WIDTH+"px",height:wheight+"px",	
	                left: ((pagesize[0] - TB_WIDTH)/2) + "px", top: 40 + "px" }); 
	            }   
		
	    }
	}else
	{
		if((arrayPageScroll[1] + ((pagesize[1]-TB_HEIGHT+70)/2)) < 10)
        {
	           $("#"+WRAPPERID).css({width:TB_WIDTH+"px",height:wheight+"px",	
	            left: ((pagesize[0] - TB_WIDTH)/2)+"px", top: 40 + "px" });     
	    }
	
	}
	 
	if(yScroll!=0)
	{
	    if(parseInt(TB_HEIGHT) > yScroll)
	       yScroll = parseInt(TB_HEIGHT) + 40;
	
	    
	    if(yScroll < pagesize[1])
		yScroll = pagesize[1];
	    
	    $("#MPPTB_overlay").css("height",yScroll +"px");
	}
}

function MPPTB_position() {

if(WRAPPERID != 'EmailFrame' && WRAPPERID != 'NewsletterFrameBlock')
{
	var pagesize = getPageSize();
  
  	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}
	var arrayPageScroll = getPageScrollTop();
	var wheight;
	
	wheight=TB_HEIGHT
	
	
	$("#"+WRAPPERID).css({width:TB_WIDTH+"px",height:wheight+"px",	
	left: ((pagesize[0] - TB_WIDTH)/2)+"px", top: (arrayPageScroll[1] + (((pagesize[1]-TB_HEIGHT+70)/2))-5)+"px" });

	if(yScroll!=0)
		$("#MPPTB_overlay").css("height",yScroll +"px");
}
}
function TB_MPPHide(wrapperId)
{
    WRAPPERID=wrapperId;
	var noOfSelectTags,i;

	    noOfSelectTags = window.parent.document.getElementsByTagName("SELECT");
	//alert(noOfSelectTags.length);
        for(i = 0; i < noOfSelectTags.length; i++){
	//alert(noOfSelectTags[i].id);
        noOfSelectTags[i].style.visibility="visible";   
 }
 
 
 
   if(document.getElementById('UGPopupWindow')!=null){
     document.getElementById('UGPopupWindow').style.display='none';
     $('#MPPTB_overlay').fadeOut("fast",function(){$('#MPPTB_overlay').remove();});
     
 }else{
      $('#MPPTB_overlay', window.parent.document).fadeOut("fast",function(){$('#MPPTB_overlay', window.parent.document).remove();});
     $('#'+WRAPPERID, window.parent.document).fadeOut("fast",function(){$('#'+WRAPPERID, window.parent.document).css('display', 'none');});
 }
}

function TB_MPPFrameHide(wrapperId)
{
    WRAPPERID=wrapperId;
  
     $('#MPPTB_overlay', window.parent.document).fadeOut("fast",function(){$('#MPPTB_overlay', window.parent.document).remove();});
    $('#'+WRAPPERID, window.parent.document).fadeOut("fast",function(){$('#'+WRAPPERID, window.parent.document).css('display', 'none');});
    parent.document.getElementById('ctl00_MainContent_Iframe1').src='';
}

