
var submitcount = 0;
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
if(isNN) document.captureEvents(Event.KEYPRESS);

//autoTab(this,3,event,1);
function autoTab(input,len, e, selectit) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
		if (selectit==1) input.form[(getIndex(input)+1) % input.form.length].select();
	}

	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
		return found;
	}
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
		return index;
	}
return true;
}


function getObj(objID)
{
	if (document.getElementById) {return document.getElementById(objID);}
	else if (document.all) {return document.all[objID];}
	else if (document.layers) {return document.layers[objID];}
}

function toggleT(_w,_w2) {
	document.getElementById(_w).style.display='block';
	document.getElementById(_w).style.visibility='visible';
	document.getElementById(_w2).style.display='none';
	document.getElementById(_w2).style.visibility='hidden';
}

function SO(o)
{
	
	o.style.display = "inline";
	o.style.visibility = "visible";
	
}
function HO(o)
{
	
	o.style.display = "none";
	o.style.visibility = "hidden";
	
}

function ShowShip(the_cruise_ship_id)
{
	var f, sSpan, sTextSpan, e, evalue, newKlid;
	
	f=document.cruise_search;
	sSpan = getObj("shipSpan");
	sTextSpan = getObj("shipTextSpan");
	
	e=f.CRZCODE;
	evalue = e.value;
	if(evalue < 5)
	{
	f.klid.value="-1";
	
	HO(sSpan);
	HO(sTextSpan);
	
	}
	else
	{
	newKlid = evalue - 5;
	
	if(f.klid.value != newKlid)
	{
	f.klid.value = newKlid;
	FillShipSpan(newKlid);
	}
	
	var iKs = 0;
	for(iKs=0; iKs < f.the_the_cruise_ship_id.length; iKs++)
	{
	if(f.the_cruise_ship_id[iKs].value == the_cruise_ship_id)
	{
	f.the_cruise_ship_id.selectedIndex = iKs;
	break;
	}
	}
	SO(sSpan);
	SO(sTextSpan);
	
	}
}

function SelectShip(the_cruise_ship_id)
{
	var f, sSpan, sTextSpan, e, evalue, newKlid;
	
	f=document.cruise_search;
	sSpan = getObj("shipSpan");
	sTextSpan = getObj("shipTextSpan");
	
	e=f.CRZCODE;
	evalue = e.value;
	if(evalue < 5)
	{
	f.klid.value="-1";
	
	HO(sSpan);
	HO(sTextSpan);
	
	}
	else

	{
	newKlid = evalue;
	
	if(f.klid.value != newKlid)
	{
	f.klid.value = newKlid;
	FillShipSpan(newKlid, the_cruise_ship_id);
	}
	SO(sSpan);
	SO(sTextSpan);
	
	}
}


function FillShipSpan(klid, the_cruise_ship_id)
{
	var f, i, strspl, iOpts, opts;
	var array = new Array("CB,JR,Azamara Journey","CB,QS,Azamara Quest","CB,CN,Century","CB,CS,Constellation","CB,GL,Galaxy","CB,HZ,Horizon","CB,IN,Infinity","CB,MR,Mercury","CB,ML,Millennium","CB,SM,Summit","CB,XP,Xpedition","CB,ZN,Zenith","CO,Costa Melody,Adventure of the Seas","CO,AL,Costa Allegra","CO,AT,Costa Atlantica","CO,CL,Costa Classica","CO,CO,Costa Concordia","CO,EU,Costa Europa","CO,FO,Costa Fortuna","CO,MG,Costa Magica","CO,MA,Costa Marina","CO,MD,Costa Mediterranea","CO,RI,Costa Riviera","CO,RO,Costa Romantica","CO,SE,Costa Serena","CO,TR,Costa Tropicale","CO,VI,Costa Victoria","CS,3,Crystal Serenity","CS,2,Crystal Symphony","CU,QE,Queen Elizabeth 2","CU,QM,Queen Mary 2","CU,QV,Queen Victoria","CV,CQ,Carnival Conquest","CV,DE,Carnival Destiny","CV,FD,Carnival Freedom","CV,GL,Carnival Glory","CV,LE,Carnival Legend","CV,LI,Carnival Liberty","CV,MI,Carnival Miracle","CV,PR,Carnival Pride","CV,SP,Carnival Spirit","CV,SL,Carnival Splendor","CV,TI,Carnival Triumph","CV,VA,Carnival Valor","CV,VI,Carnival Victory","CV,CE,Celebration","CV,EC,Ecstasy","CV,EL,Elation","CV,FA,Fantasy","CV,FS,Fascination","CV,HO,Holiday","CV,IM,Imagination","CV,IS,Inspiration","CV,PA,Paradise","CV,SE,Sensation","DS,DM,Disney Magic","DS,DW,Disney Wonder","HA,AM,Amsterdam","HA,ED,Eurodam","HA,MA,Maasdam","HA,MP,Masterpiece","HA,NO,Noordam","HA,OS,Oosterdam","HA,PR,Prinsendam","HA,RT,Rotterdam","HA,RY,Ryndam","HA,SA,Statendam","HA,VE,Veendam","HA,VO,Volendam","HA,WE,Westerdam","HA,ZA,Zaandam","HA,ZU,Zuiderdam","MSC,AR,MSC Armonia","MSC,LI,MSC Lirica","MSC,ME,MSC Melody","MSC,MO,MSC Monterey","MSC,MU,MSC Musica","MSC,OP,MSC Opera","MSC,OR,MSC Orchestra","MSC,RH,MSC Rhapsody","MSC,SI,MSC Sinfonia","NC,12,Norwegian Crown","NC,03,Norwegian Dawn","NC,07,Norwegian Dream","NC,25,Norwegian Gem","NC,26,Norwegian Jade","NC,22,Norwegian Jewel","NC,19,Norwegian Majesty","NC,24,Norwegian Pearl","NC,06,Norwegian Sea","NC,21,Norwegian Spirit","NC,02,Norwegian Star","NC,09,Norwegian Sun","NC,04,Norwegian Wind","NC,83,Pride of Aloha","NC,15,Pride of America","NC,23,Pride of Hawaii","OC,IN,Insignia","OC,NA,Nautica","OC,RE,Regatta","PC,CB,Caribbean Princess","PC,CO,Coral Princess","PC,KP,Crown Princess","PC,DP,Dawn Princess","PC,DI,Diamond Princess","PC,EP,Emerald Princess","PC,NP,Golden Princess","PC,AP,Grand Princess","PC,IP,Island Princess","PC,PA,Pacific Princess","PC,GP,Regal Princess","PC,RP,Royal Princess","PC,SA,Sapphire Princess","PC,CP,Sea Princess","PC,TP,Star Princess","PC,SP,Sun Princess","PC,TA,Tahitian Princess","RC,AD,Adventure of the Seas","RC,BR,Brilliance of the Seas","RC,NE,Empress of the Seas","RC,EN,Enchantment of the Seas","RC,EX,Explorer of the Seas","RC,FR,Freedom of the Seas","RC,GR,Grandeur of the Seas","RC,ID,Independence of the Seas","RC,JW,Jewel Of The Seas","RC,LG,Legend of the Seas","RC,LB,Liberty of the Seas","RC,MJ,Majesty of the Seas","RC,MA,Mariner Of The Seas","RC,MN,Monarch of the Seas","RC,NV,Navigator Of The Seas","RC,RD,Radiance of the Seas","RC,RH,Rhapsody of the Seas","RC,SR,Serenade Of The Seas","RC,SS,Sovereign of the Seas","RC,SP,Splendour of the Seas","RC,VI,Vision of the Seas","RC,VY,Voyager of the Seas","RE,EXP,Explorer II","RE,PAU,Paul Gauguin","RE,MAR,Seven Seas Mariner","RE,NAV,Seven Seas Navigator","RE,VOY,Seven Seas Voyager","SEA,SEAGI,Seabourn Goddess I","SEA,SEAGII,Seabourn Goddess II","SEA,SEAL,Seabourn Legend","SEA,SEAP,Seabourn Pride","SEA,SEASP,Seabourn Spirit","SEA,SEASU,Seabourn Sun","SIL,SILC,Silver Cloud","SIL,SILS,Silver Shadow","SIL,SILWH,Silver Whisper","SIL,SILWI,Silver Wind","VIK,BUR,Viking Burgundy","VIK,CSK,Viking Century Sky","VIK,CST,Viking Century Star","VIK,CSU,Viking Century Sun","VIK,EUR,Viking Europe","VIK,KIR,Viking Kirov","VIK,LAV,Viking Lavrinenkov","VIK,NEP,Viking Neptune","VIK,PAK,Viking Pakhomov","VIK,PRI,Viking Pride","VIK,SCH,Viking Schumann","VIK,SEI,Viking Seine","VIK,SKY,Viking Sky","VIK,SPR,Viking Spirit","VIK,SUN,Viking Sun","VIK,SUR,Viking Surkov","WS,SO,Wind Song","WS,SP,Wind Spirit","WS,ST,Wind Star","WS,SU,Wind Surf","");
	f=document.cruise_search;
	opts = f.the_cruise_ship_id.options;
	iOpts = 1;
	opts.length = array.length;
	for(i=0;i<array.length-1;i++) //Do not do dummy val at end of array
	{
	strsplit = array[i].split(",");
	if(klid == strsplit[0])
	{	
	opts[iOpts].value = strsplit[1];
	opts[iOpts].text = strsplit[2];
	if(opts[iOpts.value] == the_cruise_ship_id)
	{
	f.the_cruise_ship_id.selectedIndex = iOpts;
	}
	iOpts++;
	}
	}
	f.the_cruise_ship_id.length = iOpts;
	f.the_cruise_ship_id.selectedIndex = 0;	
}

