function deapartureChange(destObj) {
	selDepValue = destObj.options[destObj.selectedIndex].value;
	selDepContent = destObj.options[destObj.selectedIndex].innerHTML;
	
	var anchorObjectArray = document.getElementsByTagName('a');
	for (var i=0; i<anchorObjectArray.length; i++) {
		if (anchorObjectArray[i].name == "dep_city") {
			anchorObjectArray[i].innerHTML = selDepContent;
			anchorObjectArray[i].parentNode.in_origination_key.value = selDepValue;
		}
	}
	
	closeBubble();
}

function changeDep(lnkObj) {
	var pos = getPos(lnkObj);
	var wdth = lnkObj.offsetWidth;
	document.getElementById('select_departure').style.left = (pos.x + wdth - 3) + "px";
	document.getElementById('select_departure').style.top  = (pos.y - 23) + "px";
	document.getElementById('select_departure').style.display = "block";
}

function searchTravelocityLastminute(week, obj) {
	var actForm = obj.parentNode;
	actForm.in_start_date.value = week;
	actForm.in_end_date.value = week;
	actForm.submit();
}

function getPos(e) {
    var left = 0, top = 0;
	
	while (e.offsetParent) {
		left += e.offsetLeft - e.scrollLeft;
		top  += e.offsetTop  - e.scrollTop;
		e = e.offsetParent;
	}
	left += e.offsetLeft - e.scrollLeft;
	top  += e.offsetTop;
	
	return {x:left, y:top};
}

function preventEventToPropagate(ev) {
	if (document.all) {
		ev.returnValue = false;
		ev.cancelBubble = true;
	}
	else {
		ev.preventDefault();
		ev.stopPropagation();
	}
}

function closeBubble() {
	document.getElementById('select_departure').style.display = "none";
}