
function displayPopup(url, width, height) {
	var Win = window.open(url,"displayPopup",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=yes,menubar=no');
}

function searchFocus() {
	var fld = document.getElementById('querytext');
	if (fld.value=='Search') {
		fld.value='';
	}
}


function showHideTitleOther() {
	if( $("#title").val() == "Other" ) {
		$("#title_other_row").show();
	}else {
		$("#title_other_row").hide();
	}
}


function disableIstanbulAccomCheckBoxes() {
	if($("#istanbul_hotel_1").is(":checked") ) {
		$("#istanbul_hotel_2").attr("disabled", "disabled");
	}else {
		$("#istanbul_hotel_2").removeAttr('disabled');
	}

	if($("#istanbul_hotel_2").is(":checked") ) {
		$("#istanbul_hotel_1").attr("disabled", "disabled");
	}else {
		$("#istanbul_hotel_1").removeAttr('disabled');
	}
}

function arrivalTransCheckBoxes() {
	if($("#private_flight").is(":checked") ) {
		$("#own_tran_dal").attr("checked", false);
	}else {
		$("#own_tran_dal").attr("checked", true);
	}
	if($("#own_tran_dal").is(":checked") ) {
		$("#private_flight").attr("checked", false);
	}else {
		$("#private_flight").attr("checked", true);
	}
}



function disableAccomCheckBoxes(box) {

	if( $("#swiss_hotel_1, #swiss_hotel_2").length > 0 ) {
		if( $("#swiss_hotel_1, #swiss_hotel_2").is(":checked") ) {
			$("#gocek_hotel_1, #gocek_hotel_2, #gocek_hotel_3, #gocek_hotel_5").removeAttr('disabled');
		}else {
			$("#gocek_hotel_1, #gocek_hotel_2, #gocek_hotel_3, #gocek_hotel_5").attr("disabled", "disabled");
		}
	}else {

		if( box == "4" ) {
			if($("#gocek_hotel_4").is(":checked") ) {
				$("#gocek_hotel_1, #gocek_hotel_2, #gocek_hotel_3, #gocek_hotel_5").attr("disabled", "disabled");
			}else {
				$("#gocek_hotel_1, #gocek_hotel_2, #gocek_hotel_3, #gocek_hotel_5").removeAttr('disabled');
			}
		}else {
			if( $("#gocek_hotel_1, #gocek_hotel_2, #gocek_hotel_3, #gocek_hotel_5").is(":checked") ) {
				$("#gocek_hotel_4").attr("disabled", "disabled");
			}else {
				$("#gocek_hotel_4").removeAttr('disabled');
			}
		}
	}


}


$(document).ready(function(){

	$(function(){
		// Accordion
		$(".accordian").accordion({
			collapsible: false,
			header: 'h2',
			clearStyle: true,
			autoHeight: false
		});

		// Tabs
		$('#tabs').tabs();
		
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);
	});


	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jQueryBookmark").attr("rel") != ""){
			$("a.jQueryBookmark").attr("rel","sidebar");
		} 
	}

	$("a.jQueryBookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}
	
	});

	$(".functions li a").easyTooltip({
		xOffset: 0,
		yOffset: -20
	});

	// Reset Font Size
	$('.styleswitch').click(function(){
		
		var stylesheet = $('link[title= ' + $(this).attr("rel") + ']');
		
		if( $(stylesheet).is(":disabled") ) {
			$(stylesheet).removeAttr("disabled");

		}else {
			$(stylesheet).attr("disabled","disabled");
		}

		return false;
	});

	$(".login-link a.login").click(function(){
		
		if($("#login-box").is(":hidden")){
	
			$(this).addClass("selected");
			$("#login-spacer").show();
			$("#login-box").show();
		}else {

			$(this).removeClass("selected");
			$("#login-spacer").hide();
			$("#login-box").hide();
		}

		return false;
	});

	$("a.jQueryBookmark").click(function(e){
		e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
		var bookmarkUrl = this.href;
		var bookmarkTitle = this.title;
	 
		if (window.sidebar) { // For Mozilla Firefox Bookmark
			window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
		} else if( window.external || document.all) { // For IE Favorite
			window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
		} else if(window.opera) { // For Opera Browsers
			$("a.jQueryBookmark").attr("href",bookmarkUrl);
			$("a.jQueryBookmark").attr("title",bookmarkTitle);
			$("a.jQueryBookmark").attr("rel","sidebar");
		} else { // for other browsers which does not support
			 alert('Your browser does not support this bookmark action');
			 return false;
		}
	});

	$(".header-login a").click(function(){
		
		if($("#header-login-box").is(":hidden")){
	
			$(this).addClass("selected");
			$("#header-login-spacer").show();
			$("#header-login-box").show();
		}else {

			$(this).removeClass("selected");
			$("#header-login-spacer").hide();
			$("#header-login-box").hide();
		}

		return false;
	});

	
	$("#c_all").click(function(){
		if($(this).is(":checked")){
			$("input[id^='c_']").attr("checked","checked");
		}else {
			$("input[id^='c_']").removeAttr("checked");
		}
	});

	$("#meetings-form").submit(function(){
		 $.blockUI({ 
			message: '<div class="loading-meeting">Your submission is in progress, please wait...</div>',
			css: {
			}
		});
	});


	$.datepicker.setDefaults({ dateFormat: 'yy-mm-dd', defaultDate: new Date(2010,09, 1) });
	
	$("#ist_arr_date").datepicker();
	$("#dal_arr_date").datepicker();
	$("#gocek_dep_date").datepicker();
	$("#ist_dep_date").datepicker();



	showHideTitleOther();

	$("#title").change( function() {
		showHideTitleOther();
	});

	
/*
	disableIstanbulAccomCheckBoxes();
	$("#istanbul_hotel_1, #istanbul_hotel_2").click( function() {
		disableIstanbulAccomCheckBoxes();
	});
*/


	//arrivalTransCheckBoxes();
	$("#private_flight, #own_tran_dal").click( function() {

		if( $(this).attr("id") == "private_flight" ) {
			if($("#private_flight").is(":checked") ) {
				$("#own_tran_dal").attr("checked", false);
			}else {
				$("#own_tran_dal").attr("checked", true);
			}
		}else if( $(this).attr("id") == "own_tran_dal" ) {
			if($("#own_tran_dal").is(":checked") ) {
				$("#private_flight").attr("checked", false);
			}else {
				$("#private_flight").attr("checked", true);
			}
		}
//		arrivalTransCheckBoxes();
	});



	$("#gocek_hotel_4").click( function() {
		disableAccomCheckBoxes('4');
	});



	disableAccomCheckBoxes();

	$("#swiss_hotel_1, #swiss_hotel_2, #swiss_hotel_3").click( function() {
		disableAccomCheckBoxes();
	});



	$("#own_tran_gocek").click( function() {
		if( $(this).is(":checked") ) {
			$("#dep_gocek_flight_1, #dep_gocek_flight_2, #dep_gocek_flight_3, #dep_gocek_flight_4").attr("checked", false);
		}
	});

	$("#dep_gocek_flight_1, #dep_gocek_flight_2, #dep_gocek_flight_3, #dep_gocek_flight_4").click( function() {
		$("#own_tran_gocek").attr("checked", false );
	});

});
