 
var selectIsOpen = false;
 
//change size of <select> "id" to "width" pixels wide
function selectHover(id, width)
{
	width = width + "px";
	document.getElementById(id).style.width = width;
	selectIsOpen = false;
}
  
//change size of <select> "id" to "width" pixels wide if mouse has not been clicked (i.e. <select> has not been opened)
function selectOut(id, width)
{
	width = width + "px";
	if (!selectIsOpen)
	{
	  document.getElementById(id).style.width = width;
	}
	selectIsOpen = false;
}
  
//change size of <select> "id" to "width" pixels wide if mouse has been clicked (i.e. <select> has been opened) 
function selectClick(id, width)
{
	width = width + "px";
	if (!selectIsOpen)
	{ 
	  //this click will open the <select>
	  selectIsOpen = true;
	}
	else
	{
	  document.getElementById(id).style.width = width;
	  selectIsOpen = false;
	}
}

//show or hide selected item (id)
function toggle(id)
{
  if (document.getElementById(id).style.display == "none")
  {
    document.getElementById(id).style.display = "block";
	chevimg=new Image();
	chevimg.src='images/button_chevron_up.gif';
	document.getElementById('chev').src='images/button_chevron_up.gif';
	//document.getElementById("chev").setAttribute('src', 'images/button_chevron_up.gif');
  }
  else
  {
    document.getElementById(id).style.display = "none";
	chevimg=new Image();
	chevimg.src='images/button_chevron_down.gif';
	document.getElementById('chev').src=chevimg.src;
//	document.getElementById("chev").setAttribute('src', 'images/button_chevron_down.gif');

  }
}

//open Cruise Seasons table
function seasonsOpen()
{
  document.getElementById("seasonspopup").style.display = "block";
}

//close Cruise Seasons table
function seasonsClose()
{
  document.getElementById("seasonspopup").style.display = "none";
}

//move Cruise Seasons table left
function seasonsLeft()
{
  var currentLocation = parseInt(document.getElementById("seasonscontainer").style.left);
  
  currentLocation += 378;
  if (currentLocation > 0)
  {
    currentLocation = -1134;
  }    
  
  document.getElementById("seasonscontainer").style.left = currentLocation + "px";
}

//move Cruise Seasons table right
function seasonsRight()
{
  var currentLocation = parseInt(document.getElementById("seasonscontainer").style.left);
 
  currentLocation += -378;
  if (currentLocation < -1134)
  {
    currentLocation = 0;
  }  
  
  document.getElementById("seasonscontainer").style.left = currentLocation + "px";
}




//move Ship Info Seasons table left
function shipinfoseasonsLeft()
{
  var currentLocation = parseInt(document.getElementById("shipinfoseasonscontainer").style.left);
  
  currentLocation += 72;
  if (currentLocation > 0)
  {
    currentLocation = -286;
  }    
  
  document.getElementById("shipinfoseasonscontainer").style.left = currentLocation + "px";
}


//move Ship Info Seasons table right
function shipinfoseasonsRight()
{
  var currentLocation = parseInt(document.getElementById("shipinfoseasonscontainer").style.left);
 
  currentLocation += -72;
  if (currentLocation < -286)
  {
    currentLocation = 0;
  }  
  
  document.getElementById("shipinfoseasonscontainer").style.left = currentLocation + "px";
}







//select Fly Cruise
function selectFlyCruise()
{
  document.getElementById("portcontainer").style.display = "none";
  document.getElementById("airportcontainer").style.display = "block";
}

//select Standard Cruise
function selectStandardCruise()
{
  document.getElementById("portcontainer").style.display = "block";
  document.getElementById("airportcontainer").style.display = "none";
}

//select Cruise Only
function selectCruiseOnly()
{
  document.getElementById("portcontainer").style.display = "none";
  document.getElementById("airportcontainer").style.display = "none";  
}


//zoom in to map
function zoom(id, on)
{ 
  if (on == 'on')
  {
	//show mouseOver element
	document.getElementById(id).style.display = "block";
  }
  else
  {
    //mouseOut is OK
	document.getElementById(id).style.display = "none";
  }
}
  
//highlight area of map
function showMapItem(id)
{
  document.getElementById(id).style.backgroundImage = "url(./images/map/" + id + ".gif)";
 }
  
//hide highlighted map area
function hideMapItem(id)
{
  document.getElementById(id).style.backgroundImage = "none";
}

//tooltip 
var tooltip = false;
document.onmousemove=moveToolTip;

function showToolTip(copy)
{
  document.getElementById("tooltip").innerHTML=copy;
  document.getElementById("tooltip").style.display="block";
  tooltip = true;
}

function hideToolTip()
{
  document.getElementById("tooltip").style.display="none";
  document.getElementById("tooltip").innerHTML="";
  tooltip = false;
}

function moveToolTip(e)
{
  if (tooltip)
  { 
    //get mouse co-ordinates
	var posx = 0;
	var posy = 0;
	
	if (!e) var e = window.event;
	
	if (e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	//posx and posy contain the mouse position relative to the document
 
    //add offsets
    posx += 20;
	posy += 20;
  
    //set co-ordinates
    document.getElementById("tooltip").style.left=posx +"px";
	document.getElementById("tooltip").style.top=posy + "px";
  }
}

//show selected item (id)
function showDetail(id)
{
  document.getElementById(id).style.display = "block";
}

//hide selected item (id)
function hideDetail(id)
{
  document.getElementById(id).style.display = "none";
}

function showEgyptMapItem(id)
{
  document.getElementById(id).style.backgroundImage = "url(./images/egyptian/" + id + ".gif)";
 }

function addToWish (Itinerary_Name,TC_Price,sailDate,Cruise_ID) {
	var ts = Math.round(new Date().getTime() / 1000);
	var url = 'Itinerary_Name='+Itinerary_Name+'&TC_Price='+TC_Price+'&sailDate='+sailDate+'&Cruise_ID='+Cruise_ID+'&ts='+ts+'';

	var xmlhttp;
	var response;
	
	if (window.XMLHttpRequest){
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}
	else{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			getRes = xmlhttp.responseText;
			document.getElementById('wishlist').innerHTML = getRes;
			//if(getRes == 'OK')
			//{	
				//window.location.reload(true);
				//alert('Added to wish list');
			//} 
			//else 
			//{
				//alert(getRes);
			//}
		}
	}
	xmlhttp.open("GET","addToWishList.php?"+url,true);
	xmlhttp.send(null);
	return;
}	

function delWishList (cookieVal) {
	var ts = Math.round(new Date().getTime() / 1000);
	var url = 'cookieVal='+cookieVal+'&ts='+ts+'';

	var xmlhttp;
	var response;
	
	if (window.XMLHttpRequest){
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}
	else{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			getRes = xmlhttp.responseText;
			document.getElementById('wishlist').innerHTML = getRes;
		}
	}
	xmlhttp.open("GET","delWishList.php?"+url,true);
	xmlhttp.send(null);
	return;
}


function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	

}

