// JavaScript Document
function insertOffers(){
  var myHTML = '<IFRAME SRC="/sidebar.asp" width=160 marginHeight=0 marginWidth=0 height=2020 frameborder=0 scrolling=no style="padding:0px; margin:0px;"></IFRAME>';
	   
document.write(myHTML);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function clearText(){
	var tb = document.getElementById('freeTextSearch');
	tb.style.color="#000000";

	if (tb.value=="Destination Search..."){tb.value="";}
}

function submitRedirect(){
 var textField = document.getElementById('freeTextSearch'); 
 var monthField = document.getElementById('freeTextMonth');

 window.location = url;

}

function submitSearch(){
 var textField = document.getElementById('freeTextSearch'); 
 var monthField = document.getElementById('freeTextMonth');
 var monthBar = document.getElementById('');
 var url = "/cruise-search.aspx?freeText=" + textField.value + "&month=" + monthField.options.value;
 var searchStr = textField.value;
  
 eraseCookie('slider_search');

if (searchStr=="Destination Search..." || searchStr==""){
	alert('Please enter your destination search');}
		else
	{

    if (parseInt(searchStr.length) > 2) {

	setTimeout(function(){window.location=url},0);

	setTimeout(function(){loadingBar.style.visibility="visible"},1);
	monthField.style.visibility="hidden";
	textField.style.visibility="hidden";
	document.body.style.cursor='progress';
	}
	else
	{
	alert('Your destination search must be a minumum three letters');
	}

//	setTimeout( window.location = url, 1);
//	clearTimeout();
}

 
 
}
function mouseOnLink(){document.body.style.cursor = 'pointer';}
function mouseOffLink(){document.body.style.cursor = 'auto';}


function setDates(){
	var d = new Date();
	var ddl = document.getElementById('freeTextMonth');
	var inOpt = document.createElement('option');
	inOpt.text = "Any Month";
	inOpt.value = "";
	ddl.options.add(inOpt);
	
	for (i=0;i<=11;i=i+1){
		var nd = addMonth(d,i);
		var opt = document.createElement('option');
		opt.text = getMonthName(nd.getMonth()) + ' ' + nd.getFullYear();
		opt.value = (nd.getMonth() + 1) + '/' + nd.getFullYear();
		ddl.options.add(opt)
		//document.write('<option value="' + i + '">' + i + '</option>')
		}
	}

function getMonthName(m){
	switch(m){
		case 0:
			return 'January';
			break;
		case 1:
			return 'February';
			break;
		case 2:
			return 'March';
			break;
		case 3:
			return 'April';
			break;
		case 4:
			return 'May';
			break;
		case 5:
			return 'June';
			break;
		case 6:
			return 'July';
			break;
		case 7:
			return 'August';
			break;
		case 8:
			return 'September';
			break;
		case 9:
			return 'October';
			break;
		case 10:
			return 'November';
			break;
		case 11:
			return 'December';
			break;
		default:
			return 'January';
		}
	}

function addMonth(d,month){
t  = new Date (d);
  t.setMonth(d.getMonth()+ month) ;
  if (t.getDate() < d.getDate())
{
      t.setDate(0);
  }
  return t;
}
function drawSearch(){

document.write('<table cellpadding="0" cellspacing="0" width="580"><tr>');
document.write('<td class="newSearchMap"><a href="/cruise-destinations-world.aspx">Search Cruise Map</a></td>');
document.write('<td class="newSearchSpacer">&nbsp;</td>');
document.write('<td class="newSearchTextLeft"><img src="/images/searchBar/textarea-left.gif" style></td>');
document.write('<td class="newSearchTextCell"><input name="freeTextSearch" type="text" id="freeTextSearch" value="Destination Search..." onClick="clearText();" onFocus="clearText();"></td>');
document.write('<td class="newSearchTextRight"><img src="/images/searchBar/textarea-right.gif" style></td>');
document.write('<td class="newSearchMonthCell"><select id="freeTextMonth" style="font-size:10px;"></select></td>');
document.write('<td class="newCruiseSearch"><a onClick="javascript:submitSearch();" href="javascript:void(0);">Go!</a></td>');
document.write('</tr></table>');
document.write('<span id="loadingBar" class="loadingBar"><img src="/images/searchBar/loading-bar.gif" /></span>');


/*document.write('<table border="0" cellspacing="0" cellpadding="0" class="searchBar">');
document.write(' <tr>');
document.write('  <td id="world-cruise-destinations"><a href="/cruise-destinations-world.aspx">Cruise Map Search</a></td>');
document.write('  <td width="5"><img src="/images/searchBar/separator-bar.gif" width="5" height="24" hspace="3"></td>');
document.write('  <td valign="top" style="background-image:url(../images/searchBar/texbar-bg.gif); background-repeat:no-repeat;" width="207"><input name="freeTextSearch" type="text" id="freeTextSearch" value="Text Search..." onClick="clearText();" onFocus="clearText();"></td>');
document.write('  <td><img src="/images/spacer.gif" height="1" width="1" hspace="3"></td>');
document.write('  <td valign="top"><select id="freeTextMonth" style="font-size:10px;"></select></td>');
document.write('  <td><img src="/images/spacer.gif" height="1" width="1" hspace="3"></td>');
document.write('  <td id="submit-search"><a href="javascript:void(0);" onClick="javascript:submitSearch();">Search</a></td>');
document.write(' </tr>');
document.write('</table>');*/
	}
	
		function createXCookie(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 readXCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseXCookie(name) {
	createXCookie(name,"",-1);
}

function setPhoneNumbers() {
	var a = document.getElementById('lblUKPhone1');
	var b = document.getElementById('lblUKPhoneNav');
	var c = document.getElementById('lblIntPhone1');
	var d = document.getElementById('lblIntPhoneNav');
	var e = document.getElementById('lblUKPhoneFooter');
	var f = document.getElementById('lblIntPhoneFooter');
	if(a != null && b!= null){
		b.innerHTML = a.innerHTML;
		}
	if(c != null && d != null){
		d.innerHTML = c.innerHTML;
		}
	if(a != null && e != null){
		e.innerHTML = a.innerHTML;
		}
	if(c != null && f != null){
		f.innerHTML = c.innerHTML;
		}
	}
