﻿var globarCookieDomain = "ganges.com";
function _chkForm(){
	var txt = document.getElementById("q");
	var txtValue = txt.value ;
	if (txtValue == "")
	{
		return false;
	}else{
		return true;
	}
}

function qfocus(){
	var q = document.getElementById("q");
	if (q.value == "Search News"){
		q.value = "";
	}
}

function qblur(){
	var q = document.getElementById("q");
	if (q.value == ""){
		q.value = "Search News";
	}
}

var dealsLoad = false;
function dealsChange(v){
	if (dealsLoad == true){
		return false;
	}
	dealsLoad = true;
	$("listDiv").update('<img src="/travel/img/index/loading.gif" alt="Loading" />');
	new Ajax.Request('/travel/deals/load_deals.html',{
		parameters:{
			category:v
		},
		onSuccess:function(res){
			$("deals").update(res.responseText);
			dealsLoad = false;
		}
	}) ;
}

function loadDeals(){
	$("deals").update('<img src="/travel/img/index/loading.gif" alt="Loading" />');
	new Ajax.Request('/travel/deals/load_deals.html',{
		parameters:{
			category:""
		},
		onSuccess:function(res){
			$("deals").update(res.responseText);
		}
	}) ;
}

function fullOpen(_u,_name){
	var myWin = window.open(_u,_name,"toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0,width=" + screen.availWidth + ",height=" + screen.availWidth + "");
	myWin.focus();
}

// Change Package Type
function changePackage(values) {
	var tmpClass = String($("reserved").classNames());
	if (values == null) values = tmpClass;

	$("reserved").className = values;
	$("reserved").getInputs("radio", "singlemenu").each(function(s){
		if (s.value == values) {
			s.checked = true;
			s.up(4).select("li").invoke("removeClassName", "select");
			s.up(1).addClassName('select');
		}
	});

	switch (values) {
		case "air":
			if (["air", "air_hotel", "air_car", "air_hotel_car"].include(tmpClass) == true) {
				$("blockHotels").hide();
				$("blockCars").hide();
				$("blockCars").down(1).checked = false;
				if ($("tobox").value) _processDeal($("tobox").value);
			} else {
				document.location.href = "/travel/";
			}
			break;
		case "air_car":
			if (["air", "air_hotel", "air_car", "air_hotel_car"].include(tmpClass) == true) {
				$("blockHotels").hide();
				$("blockCars").show();
				$("blockCars").down(1).checked = true;
				if ($("tobox").value) _processDeal($("tobox").value);
			} else {
				document.location.href = "/travel/?package=air_car";
			}
			break;
		case "air_hotel":
			if (["air", "air_hotel", "air_car", "air_hotel_car"].include(tmpClass) == true) {
				$("blockHotels").show();
				$("blockCars").hide();
				$("blockCars").down(1).checked = false;
				if ($("tobox").value) _processDeal($("tobox").value);
			} else {
				document.location.href = "/travel/?package=air_hotel";
			}
			break;
		case "air_hotel_car":
			if (["air", "air_hotel", "air_car", "air_hotel_car"].include(tmpClass) == true) {
				$("blockHotels").show();
				$("blockCars").show();
				$("blockCars").down(1).checked = true;
				if ($("tobox").value) _processDeal($("tobox").value);
			} else {
				document.location.href = "/travel/?package=air_hotel_car";
			}
			break;
		case "hotel_car":
			if (["hotel", "hotel_car"].include(tmpClass) == true) {
				$("blockCars").show();
				$("blockCars").down(1).checked = true;
				if ($("frombox").value) _processDeal($("frombox").value);
			} else {
				document.location.href = "/travel/hotels/?package=hotel_car";
			}
			break;
		case "hotel":
			if (["hotel", "hotel_car"].include(tmpClass) == true) {
				$("blockCars").hide();
				$("blockCars").down(1).checked = false;
				if ($("frombox").value) _processDeal($("frombox").value);
			} else {
				document.location.href = "/travel/hotels/";
			}
			break;
		case "car":
			if (["car"].include(tmpClass) != true) {
				document.location.href = "/travel/cars/";
			}
			break;
		case "cruise":
			if (["cruise"].include(tmpClass) != true) {
				document.location.href = "/travel/cruises/";
			}
			break;		
	}

	reserveButton(chkForm());
}