var activeexpander;
var globaldynhtml;
var toggleShow = false;
var multilinetext = false;

hs.graphicsDir = '../highslide/graphics/';
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.showCredits = false; 
//hs.align = 'center';
//hs.dimmingOpacity = 0.75;

// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	slideshowGroup: 'flickerimages',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: true,
	overlayOptions: {
		opacity: .75,
		position: 'top center',
		hideOnMouseOut: true
	}
});

hs.skin.contentWrapper =
	'<div class="highslide-header">'+
	'</div>'+
	'<div class="highslide-body"></div>'+
	'<div class="highslide-footer"><div>'+
		'<table width="100%"><tr><td align="left"><a href="#" title="{hs.lang.closeTitle}" onclick="return hs.close(this)"><span>{hs.lang.closeText}</span></a></td>'+
		'<td align="right"><span class="highslide-resize" title="{hs.lang.resizeTitle}"><span></span></span></td></tr></table>'+
	'</div></div>';

hs.Expander.prototype.onBeforeClose = function() {
	multilinetext = false;
	document.body.focus();
}

hs.Expander.prototype.onAfterExpand = function() {
	var thisexpander = hs.getExpander();
	
	//alert(thisexpander.a.id);
	
	switch(thisexpander.a.id){
		case 'loginlink':
			document.getElementById("userName").focus();	
		break;
	}
}

hs.transitions = ['expand', 'crossfade'];

hs.moveText = '<img src="highslide/graphics/move.gif" border="0" />';
hs.closeText = '<img src="highslide/graphics/close.gif" border="0" />';

hs.onActivate = function() {
   var theForm = document.getElementById("form1");
   if (theForm) theForm.appendChild(hs.container);
}

hs.onDimmerClick = function() {
  return false;
}

//hs.Expander.prototype.onMouseOver = function () {
//  this.focus();
//  activeexpander=this;
//}

hs.Expander.prototype.onDrag = function (sender, e) {
	var line = "";   
	   //for (var x in e) line += x +": "+ e[x] +", ";
	   //alert(e.type);
	if(sender.thumb.title=='panocontent'){
		if(e.type=='resize'){
			resizepano();
		}
	}
}

hs.onKeyDown = function (sender, e) {
	var thisexpander = hs.getExpander();
	var expanderid=thisexpander.a.id;
	//alert(expanderid);
	switch (expanderid){
		case 'explorelink':
			return false;
		break;
		
		case 'mystufflink':
			return false;
		break;
		
		case 'dynhtmllink':
			return false;
		break;
		
		case 'cpcontrolslink':
			return false;
		break;
		
		case 'cpcontentlink':
			return false;
		break;
		
		case 'resultshtmllink':
			return false;
		break;
		
		case 'cpresultshtmllink':
			return false;
		break;
		
		case 'mediacontentlink':
			return false;
		break;
		
		case 'wizardlink':
			return false;
		break;
		
		case 'addresssearchlink':
			return false;
		break;
	}
		
}
		
		
function highslidecontrol(panel, hswidth, hsheight){
	
	if(!hswidth){
		hswidth = '500';
	}
	
	if(!hsheight){
		hsheight = '250';
	}
	
	switch (panel){
		
		case 'dynhtml':
			var imagetag=document.getElementById('dynhtmllink');
			imagetag.onclick = function() {hs.htmlExpand(imagetag, { contentId:'dynhtmlpanel', align: 'center', width: hswidth, height: hsheight, dimmingOpacity: 0.75 } )};
			imagetag.onclick();
		break;
		
		case 'dynhtmloff':
			var imagetag=document.getElementById('dynhtmllink');
			var activepanel = hs.getExpander();
			activepanel.close();
		break;
		
		case 'addresssearch':
			var imagetag=document.getElementById('addresssearchlink');
			imagetag.onclick = function() {hs.htmlExpand(imagetag, { contentId:'addresssearch', align: 'center', dimmingOpacity: 0.75 } )};
			imagetag.onclick();
		break;
		
		case 'addresssearchoff':
			var imagetag=document.getElementById('addresssearch');
			hs.close(imagetag);
		break;
		
		case 'changeloc':
			var imagetag=document.getElementById('changeloclink');
			imagetag.href='wizards/changeloc.html';
			imagetag.onclick = function() {return hs.htmlExpand(imagetag, { objectType: 'ajax', preserveContent: false, anchor: 'left'  } )};														
			imagetag.onclick();
		break;
		
		case 'changelocoff':
			var imagetag=document.getElementById('changeloclink');
			hs.close(imagetag);
		break;
		
		case 'mediacontent':
			hswidth = '750';
			hsheight = '400';
			var imagetag=document.getElementById('mediacontentlink');
			hs.htmlExpand(imagetag, { contentId: 'webmediacontent', minWidth: 400, align: 'center', width: hswidth, height: hsheight } );
		break;
		
		case 'mediacontentoff':
			var imagetag=document.getElementById('webmediacontent');
			hs.close(imagetag);
		break;
		
		case 'pano':
			var imagetag=document.getElementById('panolink');
			hs.htmlExpand(imagetag, { contentId: 'panopanel', align: 'center' } );
		break;
		
		case 'panooff':
			try{
				svp.remove();
			}catch(err){
				//No Action
			}
			var imagetag=document.getElementById('panopanel');
			hs.close(imagetag);
		break;
		
		case 'directions':
			var imagetag=document.getElementById('directionslink');
			hs.htmlExpand(imagetag, { contentId: 'directionspanel', targetX: 'directionslink 100px' } );
		break;
		
		case 'directionsoff':
			var imagetag=document.getElementById('directionspanel');
			hs.close(imagetag);
		break;
		
		case 'login':
			document.getElementById("logginerror").innerHTML='';
			var imagetag=document.getElementById('loginlink');
			hs.htmlExpand(imagetag, { contentId: 'loginpanel', align: 'center', dimmingOpacity: 0.75, width: 600, height: 340 } );
		break;
		
		case 'loginoff':
			var imagetag=document.getElementById('loginpanel');
			hs.close(imagetag);
		break;
		
	
		case 'explore':
			if(mod_searchstring){
				var imagetag=document.getElementById('explorepanel');
				hs.htmlExpand(imagetag, { contentId: 'exploreresults', targetX: 'map -10px', targetY: 'map 75px' } );
			}else{
				midnavsearchdisplay('on');
			}
		break;
		
		case 'exploreoff':
			var imagetag=document.getElementById('exploreresults');
			hs.close(imagetag);
		break;
		
		case 'resultshtml':
			var imagetag = document.getElementById('resultsanchor');
			if(userplatform != 'iphone'){
				hs.htmlExpand(imagetag, { contentId: 'resultshtmlpanel', targetX: 'map 20px', targetY: 'map 165px', width: 275, height: 350 } );
			}else{
				hs.htmlExpand(imagetag, { contentId: 'resultshtmlpanel', targetX: 'map 20px', targetY: 'map 165px', width: 275, allowSizeReduction: false } );
			}
			highslidecontrol('cpresultshtmloff');
		break;
		
		case 'cthereresultshtml':
			var imagetag = document.getElementById('resultsanchor');
			if(userplatform != 'iphone'){
				hs.htmlExpand(imagetag, { contentId: 'resultshtmlpanel', align: 'center', width: 350, height: 400 } );
			}else{
				hs.htmlExpand(imagetag, { contentId: 'resultshtmlpanel', align: 'center', width: 350, allowSizeReduction: false } );
			}
			highslidecontrol('cpresultshtmloff');
		break;
		
		case 'resultshtmlwizard':
			hswidth = '350';
			hsheight = '300';
			var imagetag=document.getElementById('resultshtmllink');
			imagetag.onclick = function() {hs.htmlExpand(imagetag, { contentId:'resultshtmlpanel', align: 'center', width: hswidth, height: hsheight, dimmingOpacity: 0.75 } )};
			imagetag.onclick();
		break;
		
		case 'resultshtmloff':
			document.getElementById("resultshtmlpanel").style.height = '350px';
			var imagetag=document.getElementById('resultshtmlpanel');
			hs.close(imagetag);
		break;
		
		case 'mystuff':
			var imagetag=document.getElementById('mystufflink');
			hs.htmlExpand(imagetag, { contentId: 'myresults', targetX: 'mystufflink -250px', targetY: 'mystufflink 35px' } );
		break;
		
		case 'mystuffoff':
			var imagetag=document.getElementById('myresults');
			hs.close(imagetag);
		break;
		
		case 'gueststuff':
			var imagetag=document.getElementById('mapdirectories');
			hs.htmlExpand(imagetag, { contentId: 'guestpassport', width: 285, height: 400, targetX: 'mapdirectories 75px', targetY: 'mapdirectories 75px' } );
		break; 
		
		case 'gueststuffoff':
			var imagetag=document.getElementById('mapdirectories');
			hs.close(imagetag);
		break;
		
		case 'cpresultshtml':
			var imagetag = document.getElementById('cpresultshtmllink');
			hs.htmlExpand(imagetag, { contentId: 'cpresultshtmlpanel', targetX: 'mapdirectories 100px', targetY: 'mapdirectories 150px' });
			try{
				if(tb_active == false){
					highslidecontrol('resultshtmloff');
				}
			}catch(err){
				highslidecontrol('resultshtmloff');
			}
		break;
		
		case 'cpresultshtmloff':
			var imagetag=document.getElementById('cpresultshtmlpanel');
			hs.close(imagetag);
		break;
		
		case 'sendtome':
			var imagetag=document.getElementById('sendtomelink');
			hs.htmlExpand(imagetag, { contentId: 'sendtomepanel', align: 'center', width: 600, height: 300, minWidth: 550, minheight: 300, dimmingOpacity: 0.75 } );
		break;
		
		case 'sendtomeoff':
			var imagetag=document.getElementById('sendtomepanel');
			hs.close(imagetag);
		break;
		
		case 'wizardoff':
			var imagetag=document.getElementById('wizardlink');
			hs.close(imagetag);
		break;
	
	
	}
	
}


function closeactiveexpander(){
	var thisexpander = hs.getExpander();
	thisexpander.close();
}

function highslideajax(extpage, pagesection, hsanchor, htitle, hswidth, hsheight, dimmeron){
	
	//alert(extpage+' , '+pagesection+' , '+htitle+' , '+hswidth+' , '+hsheight+' , '+dimmeron)
	
	if(!hswidth){
		hswidth = '550';
	}
	
	if(!hsheight){
		hsheight = '450';
	}
	
	var ajaxlink = extpage
	
	if(pagesection){
		ajaxlink += '#'+pagesection;
	}
	
	var hsheaderhtml = '<table><tr><td width="100%"><div class="cpfontheading" id="ajaxtitle">'+htitle+'</div></td><td align="right"><img src="highslide/graphics/close.gif" onclick="closeactiveexpander()" alt="Close Panel" onmouseover="this.style.cursor=\'pointer\'" border="0" /></td></tr></table>';
	
	if(!hsanchor){
		var imagetag = document.getElementById('wizardlink');
	}else{
		var imagetag = document.getElementById(hsanchor);
	}
	
	
	imagetag.href = ajaxlink;
	
	if(dimmeron == true){
		imagetag.onclick = function() {return hs.htmlExpand(imagetag, {  objectType: 'ajax', preserveContent: false, headingText: hsheaderhtml, align: 'center', width: hswidth, height: hsheight, dimmingOpacity: 0.75 } )};
	}else{
		imagetag.onclick = function() {return hs.htmlExpand(imagetag, {  objectType: 'ajax', preserveContent: false, headingText: hsheaderhtml, align: 'center', width: hswidth, height: hsheight } )};
	}
	
	imagetag.onclick();
	
}


function closeextajax(){
	
	var imagetag=document.getElementById('wizardlink');
	hs.close(imagetag);
	
}


function closeextajax_l2(){
	
	var imagetag=document.getElementById('wizardlink_l2');
	hs.close(imagetag);
	
}


function passportmenu(htitle){
	
	var ajaxlink = 'wizards/addtopassport.html#destmenu';
	var imagetag = document.getElementById('passportmenulink');
	var hsheaderhtml = '<table width="100%"><tr><td><div id="ajaxtitle">'+htitle+'</div></td><td align="right"><img src="highslide/graphics/close.gif" onclick="closeactiveexpander()" alt="Close Panel" onmouseover="this.style.cursor=\'pointer\'" border="0" /></td></tr></table>';
	
	imagetag.href = ajaxlink;
	
	imagetag.onclick = function() {return hs.htmlExpand(imagetag, {  objectType: 'ajax', headingText: hsheaderhtml, preserveContent: false, targetX: 'passportmenulink -300px', targetY: 'passportmenulink 125px', width: 270, height: 365 } )};
	
	imagetag.onclick();
	
}

function closepassportmenu(){
	
	var imagetag=document.getElementById('passportmenulink');
	hs.close(imagetag);
	
}

function opentb_controlpanel(){
	
	var ajaxlink = 'wizards/tripbuilder.html#tb_controlpanel';
	var imagetag = document.getElementById('tbanchor');
	var htitle = 'Trip Builder Control Panel';
	var hsheaderhtml = '<table width="100%"><tr><td><div id="ajaxtitle">'+htitle+'</div></td><td align="right"><img src="highslide/graphics/close.gif" onclick="closeactiveexpander()" alt="Close Panel" onmouseover="this.style.cursor=\'pointer\'" border="0" /></td></tr></table>';
	
	imagetag.href = ajaxlink;
	
	imagetag.onclick = function() {return hs.htmlExpand(imagetag, {  objectType: 'ajax', headingText: hsheaderhtml, preserveContent: false, targetX: 'tbanchor -710px', targetY: 'tbanchor 10px', width: 550, height: 80 } )};
	
	imagetag.onclick();
	
}

function closetbcp(){
	
	var imagetag=document.getElementById('tbanchor');
	hs.close(imagetag);
	
}

function closeaddtopp(){
	
	var imagetag=document.getElementById('addtopp');
	hs.close(imagetag);
	
}



function closehscontrols(){
	var imagetag=document.getElementById('cpcontrolslink');
	hs.close(imagetag);
}



function opencontrol(control){
	
	refreshtourid='';
	var contentform;
	var imagetag = document.getElementById('cpcontrolslink');
	var hswidth = 550;
	var hsheight = 300;
	var htitle = '';
	
		switch (control){
			
			case 'savedest':
				//alert('opening mystuff');
				hswidth = 600;
				hsheight = 550;
				htitle = '<span class="cpfontheading"><i>Organize Your Destination -</i></span>'
						+'<span class="cpfont_red16bold">'+activedest[0].name+'</span>';
						
				var activetourid = document.getElementById('HiddenTourID').value;
				//alert(activetourid);
				if(activetourid != ''){
					var argstring = '?tourid='+activetourid;
					if(savedestinationid != ''){
						argstring += '&destid='+savedestinationid;
					}
					contentform='controls/MyStuff_v4.aspx'+argstring;
				}else{
					try{
						//alert(savedestinationid);
						if(savedestinationid != ''){
							//alert(savedestinationid);
							var argstring = '?destid='+savedestinationid;
							contentform='controls/MyStuff_v4.aspx'+argstring;
						}else{
							contentform='controls/MyStuff.aspx';
						}
					}catch(err){
						contentform='controls/MyStuff.aspx';	
					}
				}
				//alert(contentform);
			break;
			
			case 'describedest':
				hswidth = 850;
				hsheight = 650;
				htitle = '<span class="cpfontheading"><i>Create a Rich Media Destination Description of</i></span>'+
						+'<span class="cpfont_red16bold">'+activedest[0].name+'</span>';
				if(savedestinationid != ''){
					//alert(savedestinationid);
					var argstring = '?destid='+savedestinationid+'&pageidentity=description';
					contentform='Content_Forms/frmInfo.aspx'+argstring;
				}else{
					alert('No Destination ID found');
					return false;
				}
			break;
			
			case 'associatedest':
				contentform='controls/associatedest.aspx';
			break;
			
			case 'lostpassword':
				contentform='controls/lostpassword.aspx';
				highslidecontrol('loginoff');
			break;
			
			case 'editmystuff':
				
				contentform='controls/ManagePassport.aspx';
				
				htitle = '<img src="/globalgraphics/general/passport_icon.gif" width="21" height="30" /><span class="cpfontheading18"><i>  Manage Your Cplanet Passport</i></span>'
							+'  -  <a href="controls/ManagePassport.aspx" target="_blank">   Open in new window</a>';
							
				hswidth = 825;
				hsheight = 650;
			break;
			
			case 'uploadavatar':
				contentform='Content_Forms/avatar.aspx';
				hswidth = 350;
				hsheight = 220;
			break;
			
			case 'whatiscp':
				contentform='wizards/whatiscplanet/1info_main.html';
				hswidth = 650;
				hsheight = 450;
			break;
			
			case 'search':
				htitle = '<span class="cpfontheading"><i>Advanced Cplanet Search</i></span>';
				contentform='controls/usersearch.aspx';
				hswidth = 450;
				hsheight = 250;
			break;
			
			case 'buildatrip':
				htitle = '<span class="cpfontheading"><i>Cplanet Trip Builder</i></span>';
				contentform='wizards/buildatrip/buildtrip_createtrip.aspx';
				hswidth = 650;
				hsheight = 450;
			break;
			
			case 'createstorefront':
				contentform='wizards/createstorefront/comingsoon.html';
				hswidth = 650;
				hsheight = 450;
			break;
			
			
		}
		
		var hsheaderhtml = '<table><tr><td width="100%">'+htitle+'</td><td align="right"><img src="highslide/graphics/close.gif" onclick="closeactiveexpander()" alt="Close Panel" onmouseover="this.style.cursor=\'pointer\'" border="0" /></td></tr></table>';
		
		imagetag.href=contentform;
		imagetag.onclick = function() {return hs.htmlExpand(imagetag, { objectType: 'iframe', headingText: hsheaderhtml, preserveContent: false, align: 'center', width: hswidth, height: hsheight, objectHeight: hsheight, dimmingOpacity: 0.75 } )};
		//imagetag.onclick = function() {return hs.htmlExpand(imagetag, { objectType: 'iframe', preserveContent: false, align: 'center', width: hswidth, height: hsheight, objectHeight: hsheight } )};
		imagetag.onclick();

}


function closecontentforms(){
	
	var imagetag=document.getElementById('cpcontentlink');
	hs.close(imagetag);
	
}

function enterdestdescription(){
	
	var contentform = 'controls/frmInfo.aspx?pageidentity=description';
	var imagetag = document.getElementById('cpcontrolslink');	
	imagetag.href=contentform;
	imagetag.onclick = function() {return hs.htmlExpand(imagetag, { objectType: 'iframe', preserveContent: false, align: 'center', width: 800, height: 700, dimmingOpacity: 0.75 } )};
	imagetag.onclick();
	
}

function framewebsite(siteurl){

	var linkhtml;
	var hswidth = windowwidth - 100;
	var linkanchor = document.getElementById('dynweblink');
	
	linkhtml = '<a href="'+siteurl+'" target="_blank"><img src="globalgraphics/general/newwindow.gif" border="0" onmouseover="this.style.cursor=\'pointer\'" /></a>';
	
	linkanchor.href=siteurl;
	linkanchor.onclick = function() {hs.htmlExpand(linkanchor, { objectType: 'iframe', contentId:'iframecontent', preserveContent: false, align: 'center', height: 650, minWidth: 900, objectHeight: 600 } )};
	linkanchor.onclick();
	document.getElementById("framecaption").innerHTML = linkhtml;
	
}

function closeiframe(){
	document.getElementById('framecaption').innerHTML = 'blank';
	var imagetag=document.getElementById('dynweblink');
	hs.close(imagetag);
}


//****NOTE:  HIGHSLIDE EXT PAGE FUNCTION REQUIRES THE HIGHSLIDE FUNCTIONALITY JAVASCRIPTS INCLUDED IN THE PAGE
//****NOTE:  THE ANCHOR LINK 'extpagelink' MUST RESIDE ON THE PAGE
function highslide_extpage(page, hswidth, hsheight, blackout){

	var imagetag = document.getElementById('extpagelink');
			
	if(!hswidth){
		hswidth = '700';
	}
	
	if(!hsheight){
		hsheight = '600';
	}
	
	if(page!=''){
		imagetag.href=page;
		if(blackout==false){
			imagetag.onclick = function() {return hs.htmlExpand(imagetag, { objectType: 'iframe', preserveContent: false, objectLoadTime: 'after', align: 'center', width: hswidth, height: hsheight} )};
		}else{
			imagetag.onclick = function() {return hs.htmlExpand(imagetag, { objectType: 'iframe', preserveContent: false, objectLoadTime: 'after', align: 'center', width: hswidth, height: hsheight, dimmingOpacity: 0.75 } )};
		}
																
		imagetag.onclick();
	}
}



function displayMessage(message, htitle, hswidth, hsheight) {
	
	if(!message){
		message = globaldynhtml;	
	}
	
	if(!htitle){
		htitle = '';
	}
	
	var hsheaderhtml = '<table width="100%"><tr><td>'+htitle+'</td><td align="right"><img src="highslide/graphics/close.gif" onclick="closeactiveexpander()" alt="Close Panel" onmouseover="this.style.cursor=\'pointer\'" border="0" /></td></tr></table>';
	
	if(!hswidth){
		hs.htmlExpand(document.getElementById('dynhtmllink'), { maincontentText: message, headingText: hsheaderhtml, preserveContent: false });
	}else{
		hs.htmlExpand(document.getElementById('dynhtmllink'), { maincontentText: message, headingText: hsheaderhtml, preserveContent: false, width: hswidth, height: hsheight });
	}
		
}

function dynmaichtml(newcontent) {
	var imagetag=document.getElementById('dynhtmllink');
	imagetag.onclick = function() {hs.htmlExpand(imagetag, { align: 'center', dimmingOpacity: 0.75 } )};
	imagetag.onclick();
      //var slot = document.getElementById("dynhtmlcontent");
      //var newNode = document.createTextNode(" ...and more, ");
      //slot.appendChild(newNode);
      //slot.innerHTML=newcontent;
	var exp2 = hs.getExpander(imagetag);
	exp2.body.innerHTML = newcontent;
	exp2.reflow();
   }

