function closeclock() {
	state = 0;
	setTimeout(shutoff,700);
}

function shutoff() {
	if (state == 0) {
		document.getElementById("worldclock").style.display = "none";
	}
}

function actstate() {
	state = 1;
}

function openclock() {
	document.getElementById("worldclock").style.display = "block";
}

function lmjquote() {
	if (document.getElementById("sv_from").value == "fdoor") {
		document.getElementById("origin_d").style.display = "";
		document.getElementById("origin_d").style.height = "157";
	}
	else if (document.getElementById("sv_from").value == "fport") {
		document.getElementById("origin_p").style.display = "";
		document.getElementById("origin_p").style.height = "89";
	}
	
	if (document.getElementById("sv_to").value == "tdoor") {
		document.getElementById("destination_d").style.display = "";
		document.getElementById("destination_d").style.height = "157";
	}
	else if (document.getElementById("sv_to").value == "tport") {
		document.getElementById("destination_p").style.display = "";
		document.getElementById("destination_p").style.height = "89";
	}
}

//Quote Packages ------->>>>>

pkt = 1;

function updatetotalpackages() {
	document.getElementById('packagetotal').value = pkt;
}

function request_add() {
	
	for (i=1; i<=pkt; i++) {
		if ((document.getElementById(i+'_ready').value != 'ready') && (document.getElementById(i+'_ready').value != 'removed')) {
			alert ('Please save your current packages, before adding a new one.');
			return false;
		}
	}
	
	add_package();
}

//End Quote Packages ---<<<<<

function lmjfind(dest) {
	if (dest == "from") {
		if (document.getElementById("sv_from").value == "fdoor") {
			lmjdisp("origin_d");
		}
		else if (document.getElementById("sv_from").value == "fport") {
			lmjdisp("origin_p");
		}
		else {
			lmjkill('from');
		}
	}
	else if (dest == "to") {
		if (document.getElementById("sv_to").value == "tdoor") {
			lmjdisp("destination_d");
		}
		else if (document.getElementById("sv_to").value == "tport") {
			lmjdisp("destination_p");
		}
		else {
			lmjkill('to');
		}
	}
}

function lmjdisp(x) {
	//Origin
	if (x == "origin_d") {
		togglevar(x, "d", 4, "origin_p");
	}
	else if (x == "origin_p") {
		togglevar(x, "p", 4, "origin_d");
	}
	
	//Destination
	if (x == "destination_d") {
		togglevar(x, "d", 4, "destination_p");
	}
	else if (x == "destination_p") {
		togglevar(x, "p", 4, "destination_d");
	}
}

function invalidate() {
	document.getElementById("sv_from").disabled = false;
	document.getElementById("sv_to").disabled = false;
}

function devalidate() {
	document.getElementById("sv_from").disabled = true;
	document.getElementById("sv_to").disabled = true;
}

function togglevar(myele, mytype, myinc, mykill) {
orpc = 0;
if (mytype == "d") {
	orpd = 89; 
	mymax = 157;
}
else {
	orpd = 157; 
	mymax = 89;
}
		
		devalidate();
		
		//Grow
		var showor_p = function(){
			orpc += myinc;
			if (orpc >= mymax) {
				orpc = mymax;
				invalidate();
			}
			if (orpc < mymax) {
				document.getElementById(myele).style.height = orpc;
				setTimeout(showor_p,1);
			}
		}
		
		
		//Shrink
		var killor_p = function(){
			orpd -= myinc+6;
			if (orpd < 1) {
				orpd = 1;
				document.getElementById(mykill).style.display = "none";
				document.getElementById(myele).style.height = orpc;
				document.getElementById(myele).style.display = "";
				setTimeout(showor_p,1)
			}
			if (orpd > 1) {
				document.getElementById(mykill).style.height = orpd;
				setTimeout(killor_p,1);
			}
		}
				
		setTimeout(killor_p,1)
}

function lmjkill(dest) {
	if (dest == 'from') {
		document.getElementById("origin_p").style.display = "none";
		document.getElementById("origin_d").style.display = "none";
	}
	else if (dest == 'to') {
		document.getElementById("destination_p").style.display = "none";
		document.getElementById("destination_d").style.display = "none";
	}
	else {
		alert("Error on LMJK");
	}
}

	var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield){
	var today=new Date()
	var dayfield=document.getElementById(dayfield)
	var monthfield=document.getElementById(monthfield)
	var yearfield=document.getElementById(yearfield)
	for (var i=0; i<32; i++)
	dayfield.options[i]=new Option(i+0, i+0)
	dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
	for (var m=0; m<12; m++)
	monthfield.options[m]=new Option(monthtext[m], monthtext[m])
	monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
	var thisyear=today.getFullYear()
	for (var y=0; y<20; y++){
	yearfield.options[y]=new Option(thisyear, thisyear)
	thisyear+=1
}

yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}