var http = createRequestObject();
var lastUrl = '';
var current_url = '';
var field = '';
var interval = '';
var loading=0;
var update = '001';
var loadingText = "<img src='images/loading.gif' align=absmiddle hspace=5><font color=red>Loading ...</font>";

function createRequestObject() {
	var xmlhttp;
	try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e) 
	{
		try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
		catch(f) { xmlhttp=null; }
	}
	if(!xmlhttp&&typeof XMLHttpRequest!="undefined") 
	{
		xmlhttp=new XMLHttpRequest();
	}
	return  xmlhttp;
}

function reload_Option( ID, divName )
{
	field = divName;
	if( field == 'dsCity' )
		document.getElementById('dsHotel').innerHTML = '<SELECT name=hotel style="width:156px;"><OPTION value=0 selected>All</OPTION></SELECT>';
	try{
		document.getElementById(field).innerHTML = loadingText;
		http.open('POST', 'actions.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = ConfirmCode_handleResponse;
		http.send('url='+ divName +','+ ID);
	}
	catch(e){}
	finally{}
}

function reload_Cruise( ID )
{
	field = 'CruiseID';
	try{
		document.getElementById(field).innerHTML = loadingText;
		http.open('POST', 'actions.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = ConfirmCode_handleResponse;
		http.send('url=Cruises,'+ ID);
	}
	catch(e){}
	finally{}
}

function request_Help()
{
	field = document.getElementById('Terms_of_Payment');
	self.scrollTo(0, 0);
	try{
		if (loading == 0) 
		{
			loading = 1;
			show_bOOm();
		}
		document.getElementById('main').style.display = "none";
		http.open('POST', 'actions.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
		http.onreadystatechange = handleResponse;
		http.send('url=Terms_and_Conditions');
	}
	catch(e){}
	finally{}
}
function request_Help_Back()
{
	document.getElementById('main').style.display = "";
	document.getElementById('Terms_of_Payment').innerHTML = "";
	document.getElementById('Terms_of_Payment').style.display = "none";
}

function reload_ConfirmCode() {
	field = 'Confirmation_Code';
	try{
		document.getElementById(field).innerHTML = loadingText;
		http.open('POST', 'actions.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = ConfirmCode_handleResponse;
		http.send('url='+ field);
	}
	catch(e){}
	finally{}
}

function handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			hide_bOOm();
			loading = 0;
			field.innerHTML = http.responseText;
			field.style.display = "";
		}
  	}
	catch(e){}
	finally{}
}

function ConfirmCode_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200))
			document.getElementById(field).innerHTML = http.responseText;
  	}
	catch(e){}
	finally{}
}

// bOOm Loading
//configure below variable for menu width, position on page
var offsetleft= 0;
var offsettop = 0;

var ns4 = document.layers ? 1 : 0;
var ie4 = document.all ? 1 : 0;
var ns6 = document.getElementById && !document.all ? 1 : 0;

function makeStatic() 
{
	if (ie4) bOOm_Loading.style.pixelTop = document.body.scrollTop + offsettop;
	else if (ns6) document.getElementById("bOOm_Loading").style.top = window.pageYOffset + offsettop;
	else if (ns4) eval(document.bOOm_Loading.top = eval(window.pageYOffset + offsettop));
	setTimeout("makeStatic()", 0);
}

function menu_3()
{
	if (ns6||ie4||ns4)
		makeStatic();
}

// bOOm Loading
function show_bOOm()
{
	document.getElementById('bOOm_Loading').style.display = 'inline';
	menu_3();
}

function hide_bOOm()
{
	document.getElementById('bOOm_Loading').style.display = 'none';
	window.clearTimeout(menu_3);
}

function getVar(url, cnt)
{
	url = url + '#';
	url = url.split('#');
//	if (!url[1]) window.location.href = '#Home';
	url = url[1];
	url = url + ',';
	url = url.split(',');
	if (url[0] == 'Home') window.location.href = './';
	if (cnt != -1) {
		url = url[cnt];
		if (!url) return '';
	}
	return url;
}

function loadPage() {
	act = getVar(window.location.href, 0);
	if (act) {
		current_url = window.location.href;
		current_url = current_url+'#';
		current_url = current_url.split('#');
		current_url = current_url[1];
		if (current_url) sendRequest(current_url, act);
	}
}

function urlCheck()
{
	url = window.location.href;
	if (url != '' && url != lastUrl)
	{
		loadPage();
		lastUrl = url;
	}
}

function startLoad() 
{
	interval = setInterval('urlCheck()',100);
}

/*------------------------------------------------------*/

function showSection(Name,Name2,Name3) {
	var byList		= window.document.getElementById('list');
	var tdByList	= window.document.getElementById('tdByList');
	var aByList		= window.document.getElementById('aByList');
	byList.style.display='none';
	tdByList.className='notSelectedIndex';
	aByList.className='notSelectedIndex';
	
	var byPrice		= window.document.getElementById('rate');
	var tdByPrice	= window.document.getElementById('tdByPrice');
	var aByPrice	= window.document.getElementById('aByPrice');
	byPrice.style.display='none';
	tdByPrice.className='notSelectedIndex';
	aByPrice.className='notSelectedIndex';
	
	var elem = document.getElementById(Name);
	elem.style.display='';
	var ielem = document.getElementById(Name3);
	ielem.className='selectedIndex';
	
	document.getElementById('findby').value = Name;
	return false;
}

function jemail(user, domain, suffix){
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '" class=copyright>' + user + '@' + domain + '.' + suffix + '</a>');
}
function jemail1(title, user, domain, suffix){
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '" class=copyright><img src="http://mail.opi.yahoo.com/online?u=' + user + '&amp;m=g&amp;t=0" alt="Send an Instant Message" border="0" height="12" width="12" align=absmiddle> ' + title + '</a>');
}

function openSmallWindow(url,vtop,vleft,vwidth,vheight)
{
	if(vtop == null)
	if(vleft == null)
	if(vwidth == null) {vwidth=550; }
	if(vheight == null) {vheight=300; }
	var win_param;
	win_param = "top="+vtop+",left="+vleft+",width="+vwidth+",height="+vheight+"channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0,screenX=0,top=0,left=0,screenY=0";
	msgWindow = open(url, "smallWindow", win_param);
	msgWindow.focus();
	msgWindow.opener = self;
	return false;
}

function viewImage(strLocation, strCaption, vwidth,vheight){
	if( vwidth  == null )	{ vwidth  = 100; }
	if( vheight == null )	{ vheight = 100; }
	window.open("pictures.php?image=" + strLocation + "&title=" + strCaption, "imgView", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width="+ vwidth +",height="+ vheight +",resizable=yes,top=50,left=100");
}

function doWeatherCheck(cityCode){							
	if (cityCode=='') 
		return;	
	width  = 270;
	height = 175;
	var left = ((window.screen.width - width) / 2);
	var top = ((window.screen.height - height) / 2);
	msgWindow = open("weather.php?Local=" + cityCode, "Weather", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width="+ width +",height="+ height +",resizable=yes,left="+ left +",top="+ top);
	msgWindow.focus();
}