jQuery.noConflict();

jQuery(document).ready(function() {
	
	jQuery("#specdestint").attr("disabled", "disabled");
	destinationChange();
	
	// Travelling month
	jQuery("#travmon_all").bind("click", function() {
		jQuery(".travmon_check").attr("checked", "checked");
	});
	
	jQuery(".travmon_check").bind("click", function() {
		jQuery("#travmon_all").removeAttr("checked");
	});
	
	// Booking month
	jQuery("#bookmon_all").bind("click", function() {
		jQuery(".bookmon_check").attr("checked", "checked");
	});
	
	jQuery(".bookmon_check").bind("click", function() {
		jQuery("#bookmon_all").removeAttr("checked");
	});
	
	// Destination interest click
	jQuery("#destint").bind("change", destinationChange);
	
});

function destinationChange() {
	
	if (jQuery("#destint").val() == null) {
		jQuery("#specdestint").attr("disabled", "disabled");
	}
	else {
		jQuery("#specdestint").removeAttr("disabled");
		var destCodes = new String(jQuery("#destint").val());
		var splittedDestCodes = destCodes.split(",");
		
		var specificDestInt = jQuery("#specdestint").children("option");
		for (var i = 0; i < specificDestInt.length; i++) {
			
			var value = jQuery(specificDestInt[i]).val();
			var splittedValue = value.split('-');
			var disable = "yes";
			
			if (jQuery.inArray("ALL", splittedDestCodes) > -1) {
					disable = "no";
			}
			
			if (splittedValue.length == 2) {
				if (jQuery.inArray(splittedValue[0], splittedDestCodes) > -1) {
					disable = "no";
				}
			}
			
			if (disable == "yes") {
				jQuery(specificDestInt[i]).attr("disabled", "1");
				jQuery(specificDestInt[i]).removeAttr("selected");
			}
			else {
				jQuery(specificDestInt[i]).removeAttr("disabled");
			}
		}
	}
}

