
//var fullAdd = new String(window.location.href);
//var qKey = new String(fullAdd.substring(fullAdd.length - 4,fullAdd.length));
//if(qKey=="raks"){
//showSearchButton();
//}

//PAN Commented below for VP 27-Aug-2010
//showSearchButton();

//PAN display search button
function showSearchButton() {
	var searchHTML;
	searchHTML = '<table border=0 cellpadding=0 cellspacing=0><tr><td><a href=\'javascript:promptPass(true)\'><img src=../themes/flycrc/images/searchButton.gif border=0></a></td></tr></table>';

	if (document.getElementById) {
		//create the Search Button and overlay existing one
		//var sbBody = document.getElementsByTagName("body")[0];
		var sOrigSButton = document.getElementById("uiSearchLoader__ctl0_uxDpPassengerAllocationMatrix_Anker");
		var sbNode = document.createElement('div');
		sbNode.innerHTML = searchHTML;
		sbNode.style.position='absolute';
		sbNode.style.zIndex = 2;
		//sbNode.style.topmargin='60px';
		//sbNode.style.left='20px';
		sbNode.style.visible = true;
		sbNode.id='divSearchBut';
		var parentDiv = sOrigSButton.parentNode;
		parentDiv.insertBefore(sbNode,sOrigSButton);
		//hide existing search button
		var iSearch =  document.getElementById("uiSearchLoader__ctl0_uxSearch");
		iSearch.style.display='none';
	}
	else if (document.all) {
		//deal with IE only implmentation - if required.
	}
	else if (document.layers) {
		//deal with netscape
	}else{
		//browser can't handle
	}

}


//PAN prompts user to enter pasword
function promptPass() {
	grayOut(true);
	showPassBox();
}


//PAN prompts user to enter pasword
function cancelLogin() {
	grayOut(false);
	var sPassB = document.getElementById("divPassBox");
	sPassB.style.display='none';
}



//PAN displays password box
function showPassBox() {
	var passHTML;
	passHTML = '<div style=\"border:1px solid #F00\"><table border=0 width=\"250px\" bgcolor=yellow><tr><td colspan=3>In order to give you the lowest fares CRC negotiate special deals with the airlines. Part of the deals means we can only advertise these fares to our members, not the general public. To access the lowest fares to the Caribbean use the password we have sent you. If you have not yet received your password please click <a href=\"#\" onClick=\"window.open(\'http://www.flycrc.com/popup_newsletter.asp\', \'popup\', \'width=350,height=500\'); return false">here</a> to get one, or phone us on 0207 344 0101.</td></tr><tr><td>Enter Password</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td width=80px><input type=password maxlength=20 id=passIT size=10 /></td><td width=80px><a href=\"javascript:valPass();\">Get Fares</a></td><td width=90px align=center><a href=\"javascript:cancelLogin();\">Cancel</a></td></tr></table>';

	if(document.getElementsByTagName) {
		//check if exists already
		if (document.getElementById("divPassBox") != null){
			document.getElementById("divPassBox").style.display='block';		
		}else{
			//create the Search Button and overlay existing one
			var sbBody = document.getElementsByTagName("body")[0];
			var sbNode = document.createElement('div');
			sbNode.innerHTML = passHTML;
			sbNode.style.position='absolute';
			sbNode.style.top='240px';
			sbNode.style.left='400px';
			sbNode.visible = true;
			sbNode.style.zIndex = 52;
			sbNode.id='divPassBox';
			sbBody.appendChild(sbNode);
		}
	}
	else if (document.all) {
		//deal with IE only implmentation - if required.
	}
	else if (document.layers) {
		//deal with netscape
	}else{
		//browser can't handle
	}
}


//PAN prompts user to enter pasword
function valPass() {
	if(document.getElementById) {
		var sPassW = document.getElementById("passIT");
		var sPassB = document.getElementById("divPassBox");
		var sPass = new String(sPassW.value);
		//alert(sPass.toUpperCase());
		if(sPass.toUpperCase() == "REUNION" || sPass.toUpperCase() == "FLYCRC"){
			var iSearch =  document.getElementById("uiSearchLoader__ctl0_uxSearch");
			var browser = new String(navigator.appName);
			//on IE supports click event
			if (browser.indexOf('Microsoft') >= 0 ){
				iSearch.click();
			} else {
				__doPostBack('uiSearchLoader:_ctl0:uxSearch', '');
			}
			sPassB.style.display='none';
		} else {
			alert('Password Incorrect');
		}
	}

}


//grays out items with zIndex less than 50
function grayOut(vis, options) {
	// Pass true to gray out screen, false to ungray
	// options are optional.  This is a JSON object with the following (optional) properties
	// opacity:0-100
	// Lower number = less grayout higher = more of a blackout
	// zindex: #
	// HTML elements with a higher zindex appear on top of the gray out
	// bgcolor: (#xxxxxx)
	// Standard RGB Hex color code
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	// in any order.  Pass only the properties you need to set.
	var options = options || {};
	var zindex = options.zindex || 50;
	var opacity = options.opacity || 70;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || '#000000';
	var dark=document.getElementById('darkenScreenObject');
	if (!dark) {
		// The dark layer doesn't exist, it's never been created.  So we'll
		// create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');
		// Create the layer.
		tnode.style.position='absolute';
		// Position absolutely
		tnode.style.top='0px';
		// In the top
		tnode.style.left='0px';
		// Left corner of the page
		tnode.style.overflow='hidden';
		// Try to avoid making scroll bars
		tnode.style.display='none';
		// Start out Hidden
		tnode.id='darkenScreenObject';
		// Name it so we can find it later
		tbody.appendChild(tnode);
		// Add it to the web page
		dark=document.getElementById('darkenScreenObject');
		// Get the object.
	}
	if (vis) {
		// Calculate the page width and height
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';    }
		else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';    }
		else {
			var pageWidth='100%';
			var pageHeight='100%';
		}       //set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;
		dark.style.MozOpacity=opaque;
		dark.style.filter='alpha(opacity='+opacity+')';
		dark.style.zIndex=zindex;
		dark.style.backgroundColor=bgcolor;
		dark.style.width= (screen.width - 20) + 'px'; 
		dark.style.height= (screen.height - 20) + 'px'; 
		dark.style.display='block';
	} else {
		dark.style.display='none';
	}
}



