var prlcounter = 0;

var Heraklion=new Array(10);
Heraklion[0]="Select Location";
Heraklion[1]="Heraklion Airport";
Heraklion[2]="Heraklion Port";
Heraklion[3]="Heraklion City Centre";
Heraklion[4]="Agia Pelagia";
Heraklion[5]="Amoydara";
Heraklion[6]="Hersonisos";
Heraklion[7]="Malia";
Heraklion[8]="Stalis";

var Lassithi=new Array(7);
Lassithi[0]="Select Location";
Lassithi[1]="Agios Nikolaos Port";
Lassithi[2]="Agios Nikolaos";
Lassithi[3]="Ierapetra";
Lassithi[4]="Milatos";
Lassithi[5]="Sitia";
Lassithi[6]="Sissi";
Lassithi[7]="Vai";

var Rethymnon=new Array(3);
Rethymnon[0]="Select Location";
Rethymnon[1]="Rethymnon Port";
Rethymnon[2]="Rethymnon City Centre";
Rethymnon[3]="Bali";

var Chania=new Array(6);
Chania[0]="Select Location";
Chania[1]="Chania Airport";
Chania[2]="Chania Port";
Chania[3]="Chania City Centre";
Chania[4]="Georgioupolis";
Chania[5]="Plakias";
Chania[6]="Sfakia";

function initiatePrLocation(pprefecture, plocation, rprefecture, rlocation){
	prlcounter=0;
	document.getElementById(pprefecture).options[0].selected = "1";	
	document.getElementById(rprefecture).options[0].selected = "1";	
	document.getElementById(plocation).length = 0;
	document.getElementById(rlocation).length = 0;
}

function selectPrefecture(prefectureId, locationId){

var x;

var option = document.getElementById(prefectureId).selectedIndex;
var prefecture = document.getElementById(prefectureId).options[option].text;

var location = document.getElementById(locationId);

document.getElementById(locationId).length = 0;

if (prefecture == "Chania"){
	for (x in Chania){
		location.options[location.options.length] = new Option(Chania[x], x);
	}
}
else if (prefecture == "Rethymnon"){
	for(x in Rethymnon){
		location.options[location.options.length] = new Option(Rethymnon[x], x);
	}
}
else if (prefecture == "Heraklion"){
	for(x in Heraklion){
		location.options[location.options.length] = new Option(Heraklion[x], x);
	}
}
else if (prefecture == "Lassithi"){
	for(x in Lassithi){
		location.options[location.options.length] = new Option(Lassithi[x], x);
	}
}
else{
	document.getElementById(locationId).length = 0;
}

}

function selectPickupLocation(pprefecture, plocation, rprefecture, rlocation){
	if (prlcounter == 0){
		document.getElementById(rprefecture).options[document.getElementById(pprefecture).selectedIndex].selected = "1";
		selectPrefecture(pprefecture, rlocation);
		document.getElementById(rlocation).options[document.getElementById(plocation).selectedIndex].selected = "1";
		passValue(rlocation);
		resetLocationColor(rlocation);
	}
	prlcounter++;
}

function resetLocationColor(location){
	if (document.getElementById(location).selectedIndex != 0)
		document.getElementById(location).style.background = 'White';
}

function passValue(location){
	document.getElementById(location+"Value").value = document.getElementById(location).options[document.getElementById(location).selectedIndex].text;
}






