//Javascript Include for Home Page

var gbIsIE;
var gDoc;
var gFrm;

if (parseInt(navigator.appVersion) <= 4) {
	if (navigator.appName == "Netscape") {
		isNav = true
		//alert("Is Netscape");
		location.href = "gwmapNETSCAPE.htm"
	} else {
		isNav = false
		//alert("Is Not Netscape");
	}
}

function body_onLoad()
{		
	if (document.all != null)
	{
		gbIsIE = true;
		gDoc = document.all;
	}
	else
	{
		gbIsIE = false;
		gDoc = document;
	}
	if (gDoc.form1 != null)
		gFrm = gDoc.form1;
}
function verify(x){
 if (x.Route1.selectedIndex == 0){
 		alert("You must enter an outward Journey");
 		document.form1.Route1.focus ()
 		return false;
 }

 if (x.NoPax.selectedIndex == 0){
  	alert("You must specify the number of passengers");
  	document.form1.NoPax.focus ()
  	return false;
 }
	return true;
}

function make_return(x){
	if (x.Route2.disabled == false) 
	{
	arr = x.Route1.value.split(" - ");
	x.Route2.value = arr[1]+" - "+arr[0];
	}
}
function delRoute(id){
	id.selectedIndex = 0;
	return;
}

function find_route(pobjselect,pstrvalue) {
var i

	for(i = 0 ; i < pobjselect.options.length ; i++)
		if (pobjselect.options[i].value == pstrvalue)
			pobjselect.selectedIndex = i;
}

function selRoute_onChange(pthis, pintCode, pselCode){
	var intRouteid;

	if (pintCode == 0) {
		intRouteid = pthis;	
	}
	
	if (pintCode == 1) 
	{
		switch (pselCode)
			{
			case 1:
				intRouteid = document.form1.Route1.value;
				break;
			case 2:
				intRouteid = document.form1.Route2.value;
				break;
			case 3:
				intRouteid = document.form1.Route3.value;
				break;
			case 4:
				intRouteid = document.form1.Route4.value;
				break;
			}

	}
}

function DoReset()
{
document.form1.reset(); 
document.form1.NoPax.selectedIndex=0;
document.form1.Route2.disabled = false;
}

function ZoomOut()
{
	//window.ifrMAP.location="../map/mainAFRY.html#bottom";
	frames['ifrMAP'].location.href="../map/mainAFRY.html#bottom";
	//alert("Status:"+window.status);
	//document.form1.Route1.focus(); 
	//DoReset();
	return;
}

function ZoomOutNew()
{
	frames['ifrMAP'].location.href="../map/mainAFRYNew.html#bottom";
	return;
}

function Save_FullRoute() {
	document.form1.hidRoute1.value = get_value(document.form1.Route1);
	document.form1.hidRoute2.value = get_value(document.form1.Route2);
	document.form1.hidRoute3.value = get_value(document.form1.Route3);
	document.form1.hidRoute4.value = get_value(document.form1.Route4);
	document.form1.hidNoPax.value = get_text(document.form1.NoPax);
	document.form1.submit ();
	return true;  
}

function get_text(pobjelem) {

	if (pobjelem == null) {
		return "";
	}
	if (pobjelem.selectedIndex == 0) {
		return ""
	}
	return pobjelem.options[pobjelem.selectedIndex].text;
}

//Rotate banner graphic on home page
/*function Banner_Rotate() {
  var j,d="",l="",m="",p="",q="",z="",list= new Array()
  list[list.length]='<a href=ferrycrossingdeals/ferryoffers.htm><img border=0 src=map/bannerimages/carmousebanner.gif></a>';
  list[list.length]='<a href=ferrycrossingdeals/cheap-ferry.asp?hID=ByDuration&selD=Early><img border=0 src=map/bannerimages/specialoffersbannerEARL1.gif></a>';
  list[list.length]='<a href=ferrycrossingdeals/seafrance.htm><img border=0 src=map/bannerimages/specialoffersbannerSEAF1.gif></a>';
  list[list.length]='<a href=ferrycrossingdeals/redfunnel.htm><img border=0 src=map/bannerimages/specialoffersbannerREDF4.gif></a>';
  list[list.length]='<a href=ferrycrossingdeals/stenaline.htm><img border=0 src=map/bannerimages/specialoffersbannerSTEN6.gif></a>';
  list[list.length]='<a href=ferrycrossingdeals/stenaline.htm><img border=0 src=map/bannerimages/specialoffersbannerSTEN7.gif></a>';
  j=parseInt(Math.random()*list.length);
  j=(isNaN(j))?0:j;
    document.write(list[j]);
}*/

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 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.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Save_Currency()
{
	//Currency
	switch (get_value(gDoc.hidReferComp))
	{
		case "EURO":
			document.form1.hidCurrency.value = "EUR";
			break;
		default:
			switch (get_text(gDoc.hidReferComp))
			{
				case "EUR (Euros)":
					document.form1.hidCurrency.value = "EUR";
					break;
				default:
					document.form1.hidCurrency.value = "GBP";
					break;
			}
	}
}

function doDropdowns(pintID,pstrType) {
	switch (pstrType)
	{
		default:   //HTM or ASP homepage
			switch (pintID)
			{
				case "1": //Single
					document.form1.Route2.selectedIndex = 0;
					document.form1.Route2.disabled = true;
					break;
				case "2": //Return
				    document.form1.Route2.selectedIndex = 1;
				    document.form1.Route2.disabled = false;
					break;
				case "4": //Multiple
					location.href = 'gwmap.asp?R=Y'; 
					break;
				default: //Default to Return
					document.form1.Route2.disabled = false;
			}
	}	
}

