var limit_to_country_count = 10;
var max_no_of_age_of_children = 17;
var max_no_of_room = 3;
var max_no_of_adult = 3;
var max_no_of_children = 3;
var start_index = 0;
var no_of_faq_cat = 8;
var max_question_no = 10;
var language = "en";
var alert_message = "";
var main_url = SiteAdi;

function get_url_parameters(){
	var url_parts = window.location.href.split("#");
	if(url_parts[0]){
		var url_parts = url_parts[0].split("?");
		var url_parts = url_parts[1];
		if(url_parts){
			var url_parts = url_parts.split("&");
			var url_parameters = new Array();
			for(var i=0;i<(url_parts.length);i++){
				var temp = url_parts[i].split("=");
				url_parameters[temp[0]] = temp[1];
			}
			return url_parameters;
		}
	}
	return false;
}

function toggle_new(target)
{
	toggleDiv(target);
}

function toggleDiv(divid){
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
    }else{
      document.getElementById(divid).style.display = 'none';
    }
  }

function get_city_by_state(dest_type) {

	$("#state_status_classic").html("<img src='"+main_url+"images/ui-anim_basic_16x16.gif'>");
	var country = document.getElementById('country').value;
	var state = document.getElementById('state').value;
	$.ajax({url:
		main_url+'AjaxComponents/CalledByJS.php',
			
				type : 'POST',
				data : 'fn=getcitiesbystate&country=' + country + '&state='
						+ state + '&dest_type=' + dest_type,
				success : function(req) {
					$("#cities").html(req);
					$("#state_status_classic").html("");
				}
			});
}


function initDatePicker(){
    calculate_check_out();
}

function calculate_check_out(){
    var  day = document.getElementById('day').value;
    var  month = document.getElementById('month').value;
    var  year = document.getElementById('year').value;
    var  nights = document.getElementById('nights').value;
    //
    // if(day=='day' || month=='month' || year=='year' ){
    // showDialog('Error','You have entered an invalid check in
	// date.','error',2);
    // }
    // else{
    //

    if(month=="2"){
        document.getElementById('day').remove(30);
        document.getElementById('day').remove(29);
        if(year%4!=0){
        document.getElementById('day').remove(28);
        }
        // document.getElementById('day').selectedIndex = 0;
    }
    else if(month=="1" || month=="3"  || month=="5"  ||month=="7"  ||month=="8"  || month=="10"  ||month=="12" ){

        if(document.getElementById('day').length == 28){
        	addOption(document.getElementById('day'), 29, 29);
            addOption(document.getElementById('day'), 30, 30);
            addOption(document.getElementById('day'), 31, 31);
        }
        else if(document.getElementById('day').length == 29){
            addOption(document.getElementById('day'), 30, 30);
            addOption(document.getElementById('day'), 31, 31);
        }else if(document.getElementById('day').length == 30){
            addOption(document.getElementById('day'), 31, 31);
        }

    }
    else{
        if(document.getElementById('day').length == 28){
            addOption(document.getElementById('day'), 29, 29);
            addOption(document.getElementById('day'), 30, 30);
        }
        else if(document.getElementById('day').length == 29){
            addOption(document.getElementById('day'), 30, 30);
        }
        else if(document.getElementById('day').length == 31){
            document.getElementById('day').remove(30);
        }

    }
    
    if(year%4==0 && month=="2" && document.getElementById('day').length == 28){
    	addOption(document.getElementById('day'), 29, 29);
    }
    
    var  day = document.getElementById('day').value;
    var  month = document.getElementById('month').value;
    var  year = document.getElementById('year').value;
    var  nights = document.getElementById('nights').value;

    var check_in_day = new Date (year,month-1,day);
    // alert(check_in_day);
    var today = new Date();
    // alert(check_in_day);
    // if(check_in_day < today){
    // // showDialog('Error','You have entered a past check in
	// date.','error',2);
    // }else{
    var stay_time = oneDay *nights;
    var check_out_day = new Date (check_in_day.getTime() + stay_time) ;
    // alert("check " + check_out_day);
    var check_out_label_str =   format_string_label(check_out_day);
    // var check_out_string = check_out_day.getDay() + " - "+
	// check_out_day.getMonth()+ " - " + check_out_day.getYear();
    var check_in_label_str =  format_string_label(check_in_day);
    document.getElementById('check_out_date').innerHTML=check_out_label_str ;
    document.getElementById('check_out').value = check_out_label_str;
    document.getElementById('check_in').value = check_in_label_str;
    document.getElementById('check_out_formatted').value = format_string_input(check_out_day);
    document.getElementById('check_in_formatted').value = format_string_input(check_in_day);
// }
// }

}

function show_all_rooms(i) {

	var div_room_deatils = document
			.getElementById('room_deatils_of_hotel_' + i);
	$.ajax({url:main_url+"AjaxComponents/ResultantRooms.php", 
		type : 'POST',
		data : 'hotel_index=' + i,
		success : function(req) {
			div_room_deatils.innerHTML = req;
			document.getElementById('span_click_here_for_more_rooms_'+i).style.display = 'none';
		}
	});
}

function no_of_children() {

	var children_no = document.getElementById('child1').value;
	var response = "";

	for ( var j = 1; j <= children_no; j++) {
		response += "<select id='child_age_1_" + j + "' name='child_age_1_" + j + "' class='slogan'>";
		for ( var i = 1; i <= max_no_of_age_of_children; i++) {
			response += "<option value='" + i + "'>";
			response += i;
			response += "</option>";
		}
		response += "</select>";
	}
	document.getElementById('word_age').style.display = '';
	document.getElementById('div_children_age').innerHTML = response;

}

function display_children_age_cys(no) {

	var children_no = document.getElementById('child' + no).value;
	var response = "";

	for ( var j = 1; j <= children_no; j++) {
		response += "<select id='child_age_" + no + "_" + j
				+ "' name='child_age_" + no + "_" + j + "' class='slogan'>";
		for ( var i = 1; i <= max_no_of_age_of_children; i++) {
			response += "<option value='" + i + "' >";
			response += i;
			response += "</option>";
		}
		response += "</select>";
	}
	document.getElementById('word_age').style.display = '';
	$('#children_age_' + no).html(response);

}

function no_of_rooms_cys() {

	var room_no = document.getElementById('room_no').value;
	var response = "";
	response += '<table id="room_table">';
	for ( var j = 1; j <= room_no; j++) {
		response += '<tr><td height="27" align="left" valign="middle" class="slogan">Room' + j + ':</td>';
		response += '<td height="27" align="left" valign="middle" class="slogan">'
				+ '<select name="adult'
				+ j
				+ '" id="adult'
				+ j
				+ '" class="slogan" >';
		for ( var i = 1; i <= max_no_of_adult; i++) {
			response += "<option value='" + i + "'>";
			response += i;
			response += "</option>";
		}
		response += ' </select></td> '
				+ ' <td width="61" height="37" align="center" class="slogan"> '
				+ ' <select name=\"child' + j + '\" id=\"child' + j
				+ '\"  class="slogan" onchange="display_children_age_cys(\'' + j
				+ '\')">';
		for ( var i = 0; i <= max_no_of_children; i++) {
			response += "<option value='" + i + "'>";
			response += i;
			response += "</option>";
		}
		response += ' </select></td> ';
		response += ' <td colspan="2" id="children_age_' + j + '" width="71" height="37" align="right" class="slogan"></td> ';
		response += '</tr>';
	}
	response += '</table>';
	$('#room_row').html(response);
}

function no_of_children_cys() {

	var children_no = document.getElementById('child1').value;
	var response = "";

	for ( var j = 1; j <= children_no; j++) {
		response += "<select id='child_age_1_" + j + "' name='child_age_1_" + j + "' class='slogan'>";
		for ( var i = 1; i <= max_no_of_age_of_children; i++) {
			response += "<option value='" + i + "'>";
			response += i;
			response += "</option>";
		}
		response += "</select>";
	}
	document.getElementById('word_age').style.display = '';
	document.getElementById('div_children_age').innerHTML = response;

}

function get_country_all_by_continent_with_limit(continent){
    var result = "";
    var i = 0;
    if(continent=="Europe"){
        for ( i=0;i<country_of_Europe.length && i<limit_to_country_count;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Europe[i]+'\')" >'+country_of_Europe[i]+'</span>, ';
        }
        if(country_of_Europe.length<=limit_to_country_count)
            result = result.substr(0, result.length-2);
        else
        result += ' <span  class="dest_on_mouseover_hand"  onclick="get_country_by_continent_no_limit(\''+continent+'\')" >Others...</span> ';
    }

    if(continent=="Asia"){
        for ( i=0;i<country_of_Asia.length && i<limit_to_country_count;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Asia[i]+'\')" >'+country_of_Asia[i]+'</span>, ';
        }
        if(country_of_Asia.length<=limit_to_country_count)
            result = result.substr(0, result.length-2);
        else
        result += ' <span  class="dest_on_mouseover_hand"  onclick="get_country_by_continent_no_limit(\''+continent+'\')" >Others...</span> ';
    }

    if(continent=="Australia"){
        for ( i=0;i<country_of_Australia.length && i<limit_to_country_count;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Australia[i]+'\')" >'+country_of_Australia[i]+'</span>, ';
        }
        if(country_of_Australia.length<=limit_to_country_count)
            result = result.substr(0, result.length-2);
        else
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_country_by_continent_no_limit(\''+continent+'\')" >Others...</span> ';
    }

    if(continent=="North America"){
        for ( i=0;i<country_of_North_America.length && i<limit_to_country_count;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_North_America[i]+'\')" >'+country_of_North_America[i]+'</span>, ';
        }
        if(country_of_North_America.length<=limit_to_country_count)
            result = result.substr(0, result.length-2);
        else
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_country_by_continent_no_limit(\''+continent+'\')" >Others...</span> ';
    }

    if(continent=="Africa"){
        for ( i=0;i<country_of_Africa.length && i<limit_to_country_count;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Africa[i]+'\')" >'+country_of_Africa[i]+'</span>, ';
        }
        if(country_of_Africa.length<=limit_to_country_count)
            result = result.substr(0, result.length-2);
        else
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_country_by_continent_no_limit(\''+continent+'\')" >Others...</span> ';
    }

    if(continent=="South America"){
        for ( i=0;i<country_of_South_America.length && i<limit_to_country_count;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_South_America[i]+'\')" >'+country_of_South_America[i]+'</span>, ';
        }
        if(country_of_South_America.length<=limit_to_country_count)
            result = result.substr(0, result.length-2);
        else
        result += ' <span  class="dest_on_mouseover_hand"  onclick="get_country_by_continent_no_limit(\''+continent+'\')" >Others...</span> ';
    }

    document.getElementById('countries_by_continents').innerHTML = result;

    var cont = "<span  class=\"dest_on_mouseover_hand\" href=\"javascript:;\" onclick=\"get_country_all_by_continent_with_limit('"+continent+"')\" >" + continent + "</span>" + " &#187; ";
    document.getElementById('world_map_part_continent').innerHTML = cont;
    document.getElementById('hidden_continent').value = cont;
    document.getElementById('continent').value = continent;

}

function get_country_by_continent_no_limit(continent){
	var result = "";
    var i = 0;
    if(continent=="Europe"){
        for ( i=0;i<(country_of_Europe).length;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Europe[i]+'\')" >'+country_of_Europe[i]+'</span>, ';
        }
        result = result.substr(0, result.length-2);
    }

    if(continent=="Asia"){
        for ( i=0;i<country_of_Asia.length;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Asia[i]+'\')" >'+country_of_Asia[i]+'</span>, ';
        }
        result = result.substr(0, result.length-2);
    }

     if(continent=="Australia"){
        for ( i=0;i<country_of_Australia.length;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Australia[i]+'\')" >'+country_of_Australia[i]+'</span>, ';
        }
        result = result.substr(0, result.length-2);
    }

    if(continent=="North America"){
        for ( i=0;i<country_of_North_America.length;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_North_America[i]+'\')" >'+country_of_North_America[i]+'</span>, ';
        }
        result = result.substr(0, result.length-2);
    }

    if(continent=="Africa"){
        for ( i=0;i<country_of_Africa.length;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_Africa[i]+'\')" >'+country_of_Africa[i]+'</span>, ';
        }
        result = result.substr(0, result.length-2);
    }

    if(continent=="South America"){
        for ( i=0;i<country_of_South_America.length;i++ ) {
            result += ' <span  class="dest_on_mouseover_hand"  onclick="get_city_by_country_with_comma(\''+country_of_South_America[i]+'\')" >'+country_of_South_America[i]+'</span>, ';
        }
        result = result.substr(0, result.length-2);
    }

    document.getElementById('countries_by_continents').innerHTML = result;

	var cont = "<span  class=\"dest_on_mouseover_hand\" onclick=\"get_country_all_by_continent_with_limit('"+continent+"')\" >" + continent + "</span>" + " &#187; ";
	document.getElementById('world_map_part_continent').innerHTML = cont;
	document.getElementById('hidden_continent').value = cont;
	document.getElementById('continent').value = continent;
}
var country_of_Asia = ["United Arab Emirates","Saudi Arabia","Philippines","China","Japan","Thailand","India","Sri Lanka","Singapore","Korea, Republic Of","Malaysia","Cambodia","Indonesia","Taiwan","Vietnam","Armenia","Bahrain","Israel","Jordan","Kuwait","Lebanon","Oman","Qatar","Syrian Arab Republic"];
var country_of_Europe = ["United Kingdom","Italy","Spain","France","Greece","Switzerland","Germany","Malta","Finland","Turkey","Macedonia (Fyrom)","Moldova, Republic Of","Netherlands","Latvia","Andorra","Slovakia","Slovenia","Sweden","Russian Federation","Romania","Portugal","Poland","Norway","Luxembourg","Lithuania","Albania","Austria","Bosnia And Herzegovina","Belgium","Bulgaria"];
var country_of_Australia = ["Australia","Fiji","New Zealand"];
var country_of_North_America = ["Canada","Usa","Belize","Colombia","Costa Rica","Ecuador","Guatemala","Honduras","Mexico","Nicaragua","Panama","El Salvador"];
var country_of_Africa = ["Angola","Egypt","Kenya","Morocco","Seychelles","Senegal","Tunisia","Tanzania, United Republic Of","South Africa","Zambia"];
var country_of_South_America = ["Argentina","Bolivia","Brazil","Chile","Peru","Paraguay","Uruguay","Venezuela","Antigua And Barbuda","Anguilla","Netherlands Antilles","Aruba","Barbados","Bermuda","Bahamas","Dominican Republic","Grenada","Guadeloupe","Jamaica","Saint Kitts And Nevis","Cayman Islands","Saint Lucia","Martinique","Puerto Rico","Turks And Caicos Islands","Trinidad And Tobago","Saint Vincent And The Grenadines","British Virgin Islands","U.S. Virgin Islands"];

/*
 * not used only for future need var country_of_Asia_Far_East =
 * ["Philippines","China","Japan","Thailand","India","Sri
 * Lanka","Singapore","Korea, Republic
 * Of","Malaysia","Cambodia","Indonesia","Taiwan","Vietnam"]; var
 * country_of_South_America_Caribbean =
 * ["Argentina","Bolivia","Brazil","Chile","Peru","Paraguay","Uruguay","Venezuela"];
 * var country_of_Caribbean = ["Antigua And Barbuda","Anguilla","Netherlands
 * Antilles","Aruba","Barbados","Bermuda","Bahamas","Dominican
 * Republic","Grenada","Guadeloupe","Jamaica","Saint Kitts And Nevis","Cayman
 * Islands","Saint Lucia","Martinique","Puerto Rico","Turks And Caicos
 * Islands","Trinidad And Tobago","Saint Vincent And The Grenadines","British
 * Virgin Islands","U.S. Virgin Islands"]; var
 * country_of_Central_America_Latin_America = ["Belize","Colombia","Costa
 * Rica","Ecuador","Guatemala","Honduras","Mexico","Nicaragua","Panama","El
 * Salvador"]; var country_of_Middle_East = ["United Arab
 * Emirates","Armenia","Bahrain","Israel","Jordan","Kuwait","Lebanon","Oman","Qatar","Saudi
 * Arabia","Syrian Arab Republic"]; var country_of_Pacific = ["Fiji","New
 * Zealand"];
 */


function changeLanguage(lang) {

	var url_par = window.location.href.split("#");
	if(url_par[0].indexOf("lang=en")!=-1){
		url_par[0] = url_par[0].replace("lang=en", "lang="+lang);
	}
	else if(url_par[0].indexOf("lang=tr")!=-1){
		url_par[0] = url_par[0].replace("lang=tr", "lang="+lang);
	}
	else if(url_par[0].indexOf("lang=fr")!=-1){
		url_par[0] = url_par[0].replace("lang=fr", "lang="+lang);
	}
	else if(url_par[0].indexOf("lang=it")!=-1){
		url_par[0] = url_par[0].replace("lang=it", "lang="+lang);
	}
	else if(url_par[0].indexOf("lang=es")!=-1){
		url_par[0] = url_par[0].replace("lang=es", "lang="+lang);
	}
	else if(url_par[0].indexOf("lang=de")!=-1){
		url_par[0] = url_par[0].replace("lang=de", "lang="+lang);
	}
	else{
		if(url_par[0].indexOf("?")==-1)
			url_par[0] = url_par[0] + "?";
		url_par[0] = url_par[0] + "&lang=" + lang;
	}
	window.location = url_par[0];
	// document.lang_form.submit();
}

function changeCurrency(currency) {

	var url_par = window.location.href.split("#");
	if(url_par[0].indexOf("currency=USD")!=-1){
		url_par[0] = url_par[0].replace("currency=USD", "currency="+currency);
	}
	else if(url_par[0].indexOf("currency=EUR")!=-1){
		url_par[0] = url_par[0].replace("currency=EUR", "currency="+currency);
	}
	else if(url_par[0].indexOf("currency=AUD")!=-1){
		url_par[0] = url_par[0].replace("currency=AUD", "currency="+currency);
	}
	else if(url_par[0].indexOf("currency=TRY")!=-1){
		url_par[0] = url_par[0].replace("currency=TRY", "currency="+currency);
	}
	else if(url_par[0].indexOf("currency=GBP")!=-1){
		url_par[0] = url_par[0].replace("currency=GBP", "currency="+currency);
	}
	else if(url_par[0].indexOf("currency=JPY")!=-1){
		url_par[0] = url_par[0].replace("currency=JPY", "currency="+currency);
	}
	else if(url_par[0].indexOf("currency=RUB")!=-1){
		url_par[0] = url_par[0].replace("currency=RUB", "currency="+currency);
	}
	else{
		if(url_par[0].indexOf("?")==-1)
			url_par[0] = url_par[0] + "?";
		url_par[0] = url_par[0] + "&currency=" + currency;
	}
	window.location = url_par[0];
	// var url_par = window.location.href.split("#");
	// var url_par = url_par[0].split("?");
	// window.location = url_par[0] + "?currency=" + currency;
	// window.location = window.location.href + "?currency=" + currency;
	// document.currency_form.submit();
}

function set_hash(new_hash) {
	window.location.hash = new_hash;
}

function get_hash() {
	return current_hash;
}

var current_hash = window.location.hash;

function check_hash() {
	if (window.location.hash != current_hash) {
		current_hash = window.location.hash;
		page_change(current_hash.substr(1,current_hash.length));
	}
}

function page_change(new_hash) {

	var url_parts = window.location.href.split("/");
	var url_parts = url_parts[url_parts.length - 1];
	var url_parts = url_parts.split("#");
	var url_parts = url_parts[0].split("?");
	var current_page = url_parts[0];
	var hash_array = new_hash.split("|");

	/*
	 * if (current_page == "booking.php") { var hash_1 = hash_array[0]; if
	 * (hash_1 == "Booking_Form") { $.ajax({url: "booking/booking_form.php",
	 * success : function(req) { $("#booking").html(req); window.scrollTo(0,
	 * 20); set_hash("Booking_Form"); } }); } else if (hash_1 == "Payment") {
	 * check_booking_form_necessities(); set_hash("Booking_Form"); } else if
	 * (hash_1 == "Confirmation") { check_payment_necessities(); } else
	 * if(hash_1==""){ history.go(-1); } }
	 */
	if (current_page == "search_results.php") {
		start_index = hash_array[0];
		per_page_count = hash_array[1];
		if(start_index!=""){
			populate_resultant_hotels(start_index, per_page_count);
		}
		else {
			history.go(-1);
		}
	}
	else if (current_page == "customer_support.php") {
		var active_tab = hash_array[0];
		if(active_tab=="Contact_Us"){
			populate_customer_support('contact_us');
		}
		else if(active_tab=="FAQ"){
			populate_customer_support('faq');
		}
		else if(active_tab=="Terms_And_Conditions"){
			populate_customer_support('terms_conditions');
		}
		else if(active_tab=="Privacy_Policy"){
			populate_customer_support('privacy_policy');
		}
		else if(active_tab=="About_Us"){
			populate_customer_support('about_us');
		}
		else {
			populate_customer_support('faq');
		}
	}
	else if (current_page == "profile.php") {
		var active_tab = hash_array[0];
		var active_page = hash_array[1];

		if (active_tab == "My_Bookings") {
			if (!active_page)
				populate_my_account_tab('upcoming_booking');
			if (active_page == "Upcoming_Bookings") {
				manage_my_booking_links('upcoming_booking');
			} else if (active_page == "Past_Bookings") {
				manage_my_booking_links('past_booking');
			}
		} else if (active_tab == "Account_Information") {
			if (!active_page)
				populate_my_account_tab('my_account');
			if (active_page == "Edit_Profile") {
				manage_profile_links('my_account');
			} else if (active_page == "Change_My_E-mail_Address") {
				manage_profile_links('change_email');
			} else if (active_page == "Change_My_Password") {
				manage_profile_links('change_password');
			}
		} else if (active_tab == "Customer_Service") {
			if (!active_page)
				populate_my_account_tab('customer_service');
			if (active_page == "Contact_Us") {
				manage_customer_service_links('customer_service');
			} else if (active_page == "FAQ") {
				slidedown('td_faq_cats');
				manage_customer_service_links('faq');
			}
		}
	}
}


// global variables //
var TIMER = 5;
var SPEED = 10;
var WRAPPER = 'content';

// calculate the current window width //
function pageWidth() {
  return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

// calculate the current window height //
function pageHeight() {
  return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() {
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() {
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}

// build/show the dialog box, populate the data and call the fadeDialog function
// //
function showDialog(title,message,type,autohide) {
  if(!type) {
    type = 'error';
  }
  var dialog;
  var dialogheader;
  var dialogclose;
  var dialogtitle;
  var dialogcontent;
  var dialogmask;
  if(!document.getElementById('dialog')) {
    dialog = document.createElement('div');
    dialog.id = 'dialog';
    dialogheader = document.createElement('div');
    dialogheader.id = 'dialog-header';
    dialogtitle = document.createElement('div');
    dialogtitle.id = 'dialog-title';
    dialogclose = document.createElement('div');
    dialogclose.id = 'dialog-close'
    dialogcontent = document.createElement('div');
    dialogcontent.id = 'dialog-content';
    dialogmask = document.createElement('div');
    dialogmask.id = 'dialog-mask';
    document.body.appendChild(dialogmask);
    document.body.appendChild(dialog);
    dialog.appendChild(dialogheader);
    dialogheader.appendChild(dialogtitle);
    dialogheader.appendChild(dialogclose);
    dialog.appendChild(dialogcontent);;
    dialogclose.setAttribute('onclick','hideDialog()');
    dialogclose.onclick = hideDialog;
  } else {
    dialog = document.getElementById('dialog');
    dialogheader = document.getElementById('dialog-header');
    dialogtitle = document.getElementById('dialog-title');
    dialogclose = document.getElementById('dialog-close');
    dialogcontent = document.getElementById('dialog-content');
    dialogmask = document.getElementById('dialog-mask');
    dialogmask.style.visibility = "visible";
    dialog.style.visibility = "visible";
  }
  dialog.style.opacity = .00;
  dialog.style.filter = 'alpha(opacity=0)';
  dialog.alpha = 0;
  var width = pageWidth();
  var height = pageHeight();
  var left = leftPosition();
  var top = topPosition();
  var dialogwidth = dialog.offsetWidth;
  var dialogheight = dialog.offsetHeight;
  var topposition = top + (height / 3) - (dialogheight / 2);
  var leftposition = left + (width / 2) - (dialogwidth / 2);
  dialog.style.top = topposition + "px";
  dialog.style.left = leftposition + "px";
  dialogheader.className = type + "header";
  dialogtitle.innerHTML = title;
  dialogcontent.className = type;
  dialogcontent.innerHTML = message;
  var content = document.getElementById(WRAPPER);
  dialogmask.style.height = content.offsetHeight + 'px';
  dialog.timer = setInterval("fadeDialog(1)", TIMER);
  if(autohide) {
    dialogclose.style.visibility = "hidden";
    window.setTimeout("hideDialog()", (autohide * 1000));
  } else {
    dialogclose.style.visibility = "visible";
  }
}

// hide the dialog box //
function hideDialog() {
  var dialog = document.getElementById('dialog');
  clearInterval(dialog.timer);
  dialog.timer = setInterval("fadeDialog(0)", TIMER);
}

// fade-in the dialog box //
function fadeDialog(flag) {
  if(flag == null) {
    flag = 1;
  }
  var dialog = document.getElementById('dialog');
  var value;
  if(flag == 1) {
    value = dialog.alpha + SPEED;
  } else {
    value = dialog.alpha - SPEED;
  }
  dialog.alpha = value;
  dialog.style.opacity = (value / 100);
  dialog.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(dialog.timer);
    dialog.timer = null;
  } else if(value <= 1) {
    dialog.style.visibility = "hidden";
    document.getElementById('dialog-mask').style.visibility = "hidden";
    clearInterval(dialog.timer);
  }
}


function show_classic_search(lang) {
	$.ajax({
		  url: main_url+'AjaxComponents/ClassicSearchBox.php',
		  success: function(data) {
		    $('#search').html(data);
		    initDatePicker();
		  }
		});
}
function show_quick_search(lang) {
	$.ajax({
		  url: main_url+'AjaxComponents/QuickSearchBox.php',
		  success: function(data) {
		    $('#search').html(data);
		    initDatePicker();
		  }
		});
}

function showResponse(req){
    document.getElementById('search').innerHTML= req.responseText;
    initDatePicker();
}

function subscribe_email() {
      var email = document.getElementById('email').value;
	$.ajax({
		   type: "POST",
		   url: "AjaxComponents/SubscribeEmail.php",
		   data:  'email='+ email,
		   success: function(req){
		         document.getElementById('email_subscribed').style.display = 'block';
                               document.getElementById('email_subscribed').innerHTML= req;
		   }
		 });

}

function open_register_dialog() {
	$('#dialog-form-register').dialog({
        autoOpen: false,
        height: 'auto',
        width: 'auto',
        resizable : false,
        modal: true
    });
	
	$.post(main_url+"account/register.php",
	        function(data) {
	            $("#dialog-form-register").html(data);
	            $('#dialog-form-register').dialog('open');
	        }
	    );
}

function open_login_dialog() {

	$('#dialog-form-login').dialog({
        autoOpen: false,
        height: 'auto',
        width: 'auto',
        resizable : false,
        modal: true
    });
	$.post(main_url+"account/login.php",
	        function(data) {
	            $("#dialog-form-login").html(data);
	            $('#dialog-form-login').dialog('open');
	        }
	    );
}

function register(){
	var first_name_to_register = document.getElementById('first_name_to_register').value;
	var last_name_to_register = document.getElementById('last_name_to_register').value;
	var email_to_register = document.getElementById('email_to_register').value;
	var email_confirm_to_register = document.getElementById('email_confirm_to_register').value;
	var password_to_register = document.getElementById('password_to_register').value;
	var password_confirm_to_register = document.getElementById('password_confirm_to_register').value;
	var country_to_register = document.getElementById('country_to_register').value;
	var daytime_phone_to_register = document.getElementById('daytime_phone_to_register').value;
	var mobile_phone_to_register = document.getElementById('mobile_phone_to_register').value;
	var address_to_register = document.getElementById('address_to_register').value;
	var city_to_register = document.getElementById('city_to_register').value;
	var nationality_to_register = document.getElementById('nationality_to_register').value;
	var state_to_register = document.getElementById('state_to_register').value;
	var post_zip_code_to_register = document.getElementById('post_zip_code_to_register').value;

	if(first_name_to_register=="") {
		alert(word_check_name[lang]);
		document.getElementById('first_name_to_register').focus();
		return false;
	}
	if(last_name_to_register=="") {
		alert(word_check_surname[lang]);
		document.getElementById('last_name_to_register').focus();
		return false;
	}
	if(email_to_register=="") {
		alert(word_check_email[lang]);
		document.getElementById('email_to_register').focus();
		return false;
	}
	if(!check_email(email_to_register)){
		alert(word_check_email_is_valid[lang]);
		document.getElementById('email_to_register').focus();
		return false;
	}
	if(password_to_register=="") {
		alert(word_check_password[lang]);
		document.getElementById('password_to_register').focus();
		return false;
	}
	if(email_to_register!=email_confirm_to_register){
		alert(word_check_email_consistency[lang]);
		document.getElementById('email_confirm_to_register').focus();
		return false;
	}
	if(password_to_register!=password_confirm_to_register){
		alert(word_check_password_consistency[lang]);
		document.getElementById('password_confirm_to_register').focus();
		return false;
	}
	if(daytime_phone_to_register=="" && mobile_phone_to_register==""){
		alert(word_check_phone[lang]);
		if(daytime_phone_to_register=="")
			document.getElementById('daytime_phone_to_register').focus();
		if(mobile_phone_to_register=="")
			document.getElementById('mobile_phone_to_register').focus();
		return false;
	}
	if(address_to_register=="") {
		alert(word_check_address[lang]);
		document.getElementById('address_to_register').focus();
		return false;
	}
	if(city_to_register=="") {
		alert(word_check_city[lang]);
		document.getElementById('city_to_register').focus();
		return false;
	}
	if(country_to_register=="") {
		alert(word_check_country[lang]);
		document.getElementById('country_to_register').focus();
		return false;
	}
	if(nationality_to_register=="") {
		alert(word_check_nationality[lang]);
		document.getElementById('nationality_to_register').focus();
		return false;
	}
	
	document.getElementById('register_status').innerHTML =  "<img src='"+main_url+"/images/ui-anim_basic_16x16.gif'>";
	$.ajax({url:
		main_url+'AjaxComponents/CalledByJS.php',
			
				type : 'POST',
				data : 'fn=register&first_name_to_register=' + first_name_to_register + '&last_name_to_register=' + last_name_to_register
				+ '&email_to_register=' + email_to_register + '&email_confirm_to_register=' + email_confirm_to_register
				 + '&password_to_register=' + password_to_register + '&password_confirm_to_register=' + password_confirm_to_register
				  + '&country_to_register=' + country_to_register+ '&nationality_to_register=' + nationality_to_register+ '&city_to_register=' + city_to_register
				  + '&address_to_register=' + address_to_register+ '&daytime_phone_to_register=' + daytime_phone_to_register+ '&mobile_phone_to_register=' + mobile_phone_to_register
				  + '&post_zip_code_to_register=' + post_zip_code_to_register + '&state_to_register=' + state_to_register,
				success : function(req) {
					if(req=="1" || req==1){
						open_registration_approval_dialog(email_to_register);
					}
					else{
						document.getElementById('register_status').innerHTML =  "";
						alert(req);
					}
				}
			});
}

function send_new_password(){
	var email_forgot_password = document.getElementById('email_forgot_password').value;
	if(email_forgot_password==""){
		alert(word_check_email[lang]);
		document.getElementById('email_forgot_password').focus();
		return false;
	}
	if(!check_email(email_forgot_password)){
		alert(word_check_email_is_valid[lang]);
		document.getElementById('email_forgot_password').focus();
		return false;
	}
	document.getElementById('forgot_password_status').innerHTML =  "<img src='"+main_url+"/images/ui-anim_basic_16x16.gif'>";
	$.ajax({
		   type: "POST",
		   url: main_url+'AjaxComponents/CalledByJS.php',
		   data: 'fn=forgot_password&email=' + email_forgot_password,
		   success: function(req){
			 document.getElementById('forgot_password_status').innerHTML = req;
		   }
		 });
}

function open_forgot_password_dialog() {

	$('#dialog-forgot-password').dialog({
        autoOpen: false,
        height: 'auto',
        width: 'auto',
        resizable : false,
        modal: true
    });
	
	$.post(main_url+"account/forgot_password.php",
	        function(data) {
	            $("#dialog-forgot-password").html(data);
	            $('#dialog-forgot-password').dialog('open');
	        }
	    );
}

function login(){
	var email = document.getElementById('email_to_login').value;
	var password = document.getElementById('password_to_login').value;
	
	if(email==""){
		alert(word_check_email[lang]);
		document.getElementById('email_to_login').focus();
		return false;
	}
	if(!check_email(email)){
		alert(word_check_email_is_valid[lang]);
		document.getElementById('email_to_login').focus();
		return false;
	}
	if(password==""){
		alert(word_check_password[lang]);
		document.getElementById('password_to_login').focus();
		return false;
	}
	
	document.getElementById('login_status').innerHTML =  "<img src='"+main_url+"/images/ui-anim_basic_16x16.gif'>";
	$.ajax({
		   type: "POST",
		   url: main_url+'AjaxComponents/CalledByJS.php',
		   data: 'fn=login&email=' + email + '&password='
			+ password,
		   success: function(req){
				if(req=="1" || req==1){
					document.getElementById('form_login').submit();
				}
				else{
					document.getElementById('login_status').innerHTML =  "";
					alert(word_check_mail_password[lang]);
				}
		   }
		 });
}

function logout(){
	$.ajax({
		   type: "POST",
		   url: main_url+'AjaxComponents/CalledByJS.php',
		   data: 'fn=logout',
		   success: function(req){
			   document.logout_form.submit();
		   }
		 });
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){
			return (false);
		}	
	} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}

function check_input_change_your_search(){

	var destination_id = document.getElementById("destination_id").value;


  
         var  day = document.getElementById('day').value;
        var  month = document.getElementById('month').value;
        var  year = document.getElementById('year').value;

        if(day=='day' || month=='month' || year=='year' ){
            showDialog('Error',word_invalid_date[lang],'error',2);
            return false;
        }
        var check_in_day = new Date (year,month-1,day);
        var today = new Date();
        if(check_in_day < today){
         showDialog('Error',word_past_date[lang],'error',2);
         return false;
        }
      // alert(document.getElementById("destination").value.length);
  if(document.getElementById("destination").value.length<3){
	  showDialog('Warning',word_specify_location[lang],'warning',2);
	  return false;
  }else if(destination_id.length<10 &&document.getElementById("destination").value.length>15){
	  showDialog('Warning',word_specify_location[lang],'warning',2);
	  return false;
  }
document.getElementById('search').submit();
  // document.getElementById("loader_dest").innerHTML=
	// document.getElementById("destination").value;
show_loader();
window.scrollTo(0, 0);
}

function get_city_by_country(dest_type) {

	$("#country_status_classic").html("<img src='http://www.bookingbest.com/images/ui-anim_basic_16x16.gif'>");
	var country = $("#country").val();
	$.ajax({url:main_url+'AjaxComponents/CalledByJS.php', 
		type : 'POST',
		data : 'fn=getcities&country=' + country + '&dest_type=' + dest_type,
		success : function(req){
			$("#dest_classic").html(req);
			$("#country_status_classic").html("");
		}
	});
}

function showSiteSearchResult(req) {
	document.getElementById('siteSearchResults').innerHTML = req;
}

function go_to_site_search_page_of(no) {
    var pageno=no-1;
   // alert(pageno);
    var type='number';
      $.ajax({url:main_url+"AjaxComponents/SiteSearchResults.php", 
			type : 'POST',
			data : 'pagingtype=' + type +'&pagenumber='+pageno,
			success : showSiteSearchResult
	});

}
function get_prev_page_of_site_search_results() {

    var type='prev';
    $.ajax({url:main_url+"AjaxComponents/SiteSearchResults.php", 
			type : 'POST',
			data : 'pagingtype=' + type,
			success : showSiteSearchResult
	});

}

function get_next_page_of_site_search_results() {
    var type='next';
    $.ajax({url:main_url+"AjaxComponents/SiteSearchResults.php", 
			type : 'POST',
			data : 'pagingtype=' + type,
			success : showSiteSearchResult
	});

}

function close_cancel_approval_dialog(){
	$("#profile_reload_status").html("<img src='http://www.bookingbest.com/images/ui-anim_basic_16x16.gif'>");
	window.location = 'profile.php';
}

function close_registration_approval_dialog(){
	$("#registration_approval_status").html("<img src='http://www.bookingbest.com/images/ui-anim_basic_16x16.gif'>");
	window.location = 'profile.php';
}

function get_location_by_city() {

	$("#city_status_classic").html("<img src='http://www.bookingbest.com/images/ui-anim_basic_16x16.gif'>");
	var city = $("#city").val();
	var state = "";
	var country = $("#country").val();
	if (!document.getElementById('state') || $("#state").val()==""){
		$('#destination').val( city + ", " + country);
	}
	else{
		state = $("#state").val();
		$('#destination').val(city + ", " + state + ", " + country);
	}
	$.ajax({url:'AjaxComponents/CalledByJS.php', 
		type : 'POST',
		data : 'fn=getlocations&city=' + city + '&country=' + country
				+ '&state' + state,
		success : fn2
	});
}

function fn2(req) {
	$("#locations").html(req);
	$("#city_status_classic").html("");
}

function get_country_by_continent(continent) {
	$.ajax({url:'AjaxComponents/CalledByJS.php', 
		type : 'POST',
		data : 'fn=getcountries&continent=' + continent,
		success : fn3
	});

	var cont = "<a class=\"dest_on_mouseover_hand\"  onclick=\"get_country_by_continent('"
			+ continent + "')\" >" + continent + "</span>" + " &#187; ";
	document.getElementById('world_map_part_continent').innerHTML = cont;
	document.getElementById('hidden_continent').value = cont;
	document.getElementById('continent').value = continent;
}

function fn3(req) {
	document.getElementById('countries_by_continents').innerHTML = req;
}

function fn4(req) {
	document.getElementById('countries_by_continents').innerHTML = req;
}

function send_to_search_result_page_from_index(requester_page) {
	var destination_id = $("#destination_id").val();	
	if(requester_page=="ClassicSearchBox"){
		if($("#country").val()==""){
           showDialog('Error',word_check_country[lang],'error',2);
			$('#country').focus();
			return false;
		}
		if($("#city").val()==""){
          showDialog('Error',word_check_city2[lang],'error',2);
			$('#city').focus();
			return false;
		}

        var  day = $('#day').val();
        var  month = $('#month').val();
        var  year = $('#year').val();

        if(day=='day' || month=='month' || year=='year' ){
            showDialog('Error',word_invalid_date[lang],'error',2);
            return false;
        }
        var check_in_day = new Date (year,month-1,day);
        var today = new Date();
        if(check_in_day < today){
         showDialog('Error',word_past_date[lang],'error',2);
         return false;
        }
	}
        else if(requester_page=="QuickSearchBox"){
             var  day = $('#day').val();
            var  month = $('#month').val();
            var  year = $('#year').val();

            if(day=='day' || month=='month' || year=='year' ){
                showDialog('Error',word_invalid_date[lang],'error',2);
                return false;
            }
            var check_in_day = new Date (year,month-1,day);
            var today = new Date();
            if(check_in_day < today){
             showDialog('Error',word_past_date[lang],'error',2);
             return false;
            }
          // alert($("#destination").val().length);
	  if($("#destination").val().length<3){
		  showDialog('Warning',word_specify_location[lang],'warning',2);
		  return false;
	  }else if(destination_id.length<10 &&$("#destination").val().length>15){
		  showDialog('Warning',word_specify_location[lang],'warning',2);
		  return false;
	  }
        }
	else{
	  if(destination_id.length<10){
		  showDialog('Warning',word_specify_location[lang],'warning',2);
		  return false;
	  }
           var  day = $('#day').val();
            var  month = $('#month').val();
            var  year = $('#year').val();

            if(day=='day' || month=='month' || year=='year' ){
                showDialog('Error',word_invalid_date[lang],'error',2);
                return false;
            }
            var check_in_day = new Date (year,month-1,day);
            var today = new Date();
            if(check_in_day < today){
             showDialog('Error',word_past_date[lang],'error',2);
             return false;
            }
	}
       
        $('#search').submit();
      // $("#loader_dest").innerHTML= $("#destination").val();
	show_loader();
	window.scrollTo(0, 0);
}

// MSDropDown - jquery.dd.js
// author: Marghoob Suleman - Search me on google
// Date: 12th Aug, 2009
// Version: 2.3 {date: 18 June 2010}
// Revision: 27
// web: www.giftlelo.com | www.marghoobsuleman.com
/*
 * //msDropDown is free jQuery Plugin: you can redistribute it and/or modify
 * //it under the terms of the either the MIT License or the Gnu General Public
 * License (GPL) Version 2
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(6($){4 1E="";4 2T=6(p,q){4 r=p;4 s=1b;4 q=$.2U({1j:3F,2a:7,2V:23,1F:11,1V:3G,2W:\'1W\',1G:14,2t:\'\',1k:\'\'},q);1b.1N=2b 2X();4 t="";4 u={};u.2u=11;u.2c=14;u.2d=1n;4 v=14;4 w={2v:\'3H\',1O:\'3I\',1H:\'3J\',1I:\'3K\',1f:\'3L\',2w:\'3M\',2x:\'3N\',3O:\'3P\',2e:\'3Q\',2Y:\'3R\'};4 x={1W:q.2W,2y:\'2y\',2z:\'2z\',2A:\'2A\',1p:\'1p\',1i:.30,2B:\'2B\'};4 y={2Z:"2f,2C,2D,1P,2g,2h,1q,1w,2i,1J,3S,1X,2E",3T:"1x,1r,1i,3U"};1b.1K=2b 2X();4 z=$(r).12("1a");4 A=$(r).12("1k");q.1k+=(A==18)?"":A;4 B=$(r).31();v=($(r).12("1x")>0||$(r).12("1r")==11)?11:14;5(v){q.2a=$(r).12("1x")};4 C={};4 D=6(a){15 z+w[a]};4 E=6(a){4 b=a;4 c=$(b).12("1k");15 c};4 F=6(a){4 b=$("#"+z+" 2j:9");5(b.1c>1){1s(4 i=0;i<b.1c;i++){5(a==b[i].1g){15 11}}}1d 5(b.1c==1){5(b[0].1g==a){15 11}};15 14};4 G=6(a,b,c,d){4 e="";4 f=(d=="2F")?D("2x"):D("2w");4 g=(d=="2F")?f+"2G"+(b)+"2G"+(c):f+"2G"+(b);4 h="";4 i="";5(q.1G!=14){i=\' \'+q.1G+\' \'+a.32}1d{h=$(a).12("1Q");h=(h.1c==0)?"":\'<33 34="\'+h+\'" 35="36" /> \'};4 j=$(a).1y();4 k=$(a).3V();4 l=($(a).12("1i")==11)?"1i":"2k";C[g]={1z:h+j,1Y:k,1y:j,1g:a.1g,1a:g};4 m=E(a);5(F(a.1g)==11){e+=\'<a 3a="3b:3c(0);" 1o="9 \'+l+i+\'"\'}1d{e+=\'<a  3a="3b:3c(0);" 1o="\'+l+i+\'"\'};5(m!==14&&m!==18){e+=" 1k=\'"+m+"\'"};e+=\' 1a="\'+g+\'">\';e+=h+\'<1t 1o="\'+x.1p+\'">\'+j+\'</1t></a>\';15 e};4 H=6(){4 f=B;5(f.1c==0)15"";4 g="";4 h=D("2w");4 i=D("2x");f.2H(6(c){4 d=f[c];5(d.3W=="3X"){g+="<1u 1o=\'3Y\'>";g+="<1t 1k=\'3d-3Z:41;3d-1k:42; 43:44;\'>"+$(d).12("45")+"</1t>";4 e=$(d).31();e.2H(6(a){4 b=e[a];g+=G(b,c,a,"2F")});g+="</1u>"}1d{g+=G(d,c,"","")}});15 g};4 I=6(){4 a=D("1O");4 b=D("1f");4 c=q.1k;1R="";1R+=\'<1u 1a="\'+b+\'" 1o="\'+x.2A+\'"\';5(!v){1R+=(c!="")?\' 1k="\'+c+\'"\':\'\'}1d{1R+=(c!="")?\' 1k="46-2l:47 48 #49;1S:2I;1A:2J;\'+c+\'"\':\'\'}1R+=\'>\';15 1R};4 J=6(){4 a=D("1H");4 b=D("2e");4 c=D("1I");4 d=D("2Y");4 e="";4 f="";5(8.10(z).1B.1c>0){e=$("#"+z+" 2j:9").1y();f=$("#"+z+" 2j:9").12("1Q")};f=(f.1c==0||f==18||q.1F==14||q.1G!=14)?"":\'<33 34="\'+f+\'" 35="36" /> \';4 g=\'<1u 1a="\'+a+\'" 1o="\'+x.2y+\'"\';g+=\'>\';g+=\'<1t 1a="\'+b+\'" 1o="\'+x.2z+\'"></1t><1t 1o="\'+x.1p+\'" 1a="\'+c+\'">\'+f+\'<1t 1o="\'+x.1p+\'">\'+e+\'</1t></1t></1u>\';15 g};4 K=6(){4 c=D("1f");$("#"+c+" a.2k").1e("1P",6(a){a.1Z();N(1b);5(!v){$("#"+c).1L("1w");P(14);4 b=(q.1F==14)?$(1b).1y():$(1b).1z();T(b);s.20()};X()})};4 L=6(){4 d=14;4 e=D("1O");4 f=D("1H");4 g=D("1I");4 h=D("1f");4 i=D("2e");4 j=$("#"+z).2K();j=j+2;4 k=q.1k;5($("#"+e).1c>0){$("#"+e).2m();d=11};4 l=\'<1u 1a="\'+e+\'" 1o="\'+x.1W+\'"\';l+=(k!="")?\' 1k="\'+k+\'"\':\'\';l+=\'>\';l+=J();l+=I();l+=H();l+="</1u>";l+="</1u>";5(d==11){4 m=D("2v");$("#"+m).2L(l)}1d{$("#"+z).2L(l)};5(v){4 f=D("1H");$("#"+f).2n()};$("#"+e).19("2K",j+"21");$("#"+h).19("2K",(j-2)+"21");5(B.1c>q.2a){4 n=22($("#"+h+" a:3e").19("24-3f"))+22($("#"+h+" a:3e").19("24-2l"));4 o=((q.2V)*q.2a)-n;$("#"+h).19("1j",o+"21")}1d 5(v){4 o=$("#"+z).1j();$("#"+h).19("1j",o+"21")};5(d==14){S();O(z)};5($("#"+z).12("1i")==11){$("#"+e).19("2o",x.1i)};R();$("#"+f).1e("1w",6(a){2M(1)});$("#"+f).1e("1J",6(a){2M(0)});K();$("#"+h+" a.1i").19("2o",x.1i);5(v){$("#"+h).1e("1w",6(c){5(!u.2c){u.2c=11;$(8).1e("1X",6(a){4 b=a.3g;u.2d=b;5(b==39||b==40){a.1Z();a.2p();U();X()};5(b==37||b==38){a.1Z();a.2p();V();X()}})}})};$("#"+h).1e("1J",6(a){P(14);$(8).1L("1X");u.2c=14;u.2d=1n});$("#"+f).1e("1P",6(b){P(14);5($("#"+h+":3h").1c==1){$("#"+h).1L("1w")}1d{$("#"+h).1e("1w",6(a){P(11)});s.3i()}});$("#"+f).1e("1J",6(a){P(14)});5(q.1F&&q.1G!=14){W()}};4 M=6(a){1s(4 i 2q C){5(C[i].1g==a){15 C[i]}};15-1};4 N=6(a){4 b=D("1f");5(!v){$("#"+b+" a.9").1M("9")};4 c=$("#"+b+" a.9").12("1a");5(c!=18){4 d=(u.1T==18||u.1T==1n)?C[c].1g:u.1T};5(a&&!v){$(a).1D("9")};5(v){4 e=u.2d;5($("#"+z).12("1r")==11){5(e==17){u.1T=C[$(a).12("1a")].1g;$(a).4a("9")}1d 5(e==16){$("#"+b+" a.9").1M("9");$(a).1D("9");4 f=$(a).12("1a");4 g=C[f].1g;1s(4 i=3j.4b(d,g);i<=3j.4c(d,g);i++){$("#"+M(i).1a).1D("9")}}1d{$("#"+b+" a.9").1M("9");$(a).1D("9");u.1T=C[$(a).12("1a")].1g}}1d{$("#"+b+" a.9").1M("9");$(a).1D("9");u.1T=C[$(a).12("1a")].1g}}};4 O=6(a){4 b=a;8.10(b).4d=6(e){$("#"+b).1U(q)}};4 P=6(a){u.2u=a};4 Q=6(){15 u.2u};4 R=6(){4 b=D("1O");4 c=y.2Z.4e(",");1s(4 d=0;d<c.1c;d++){4 e=c[d];4 f=Y(e);5(f==11){3k(e){1m"2f":$("#"+b).1e("4f",6(a){8.10(z).2f()});1h;1m"1P":$("#"+b).1e("1P",6(a){$("#"+z).1C("1P")});1h;1m"2g":$("#"+b).1e("2g",6(a){$("#"+z).1C("2g")});1h;1m"2h":$("#"+b).1e("2h",6(a){$("#"+z).1C("2h")});1h;1m"1q":$("#"+b).1e("1q",6(a){$("#"+z).1C("1q")});1h;1m"1w":$("#"+b).1e("1w",6(a){$("#"+z).1C("1w")});1h;1m"2i":$("#"+b).1e("2i",6(a){$("#"+z).1C("2i")});1h;1m"1J":$("#"+b).1e("1J",6(a){$("#"+z).1C("1J")});1h}}}};4 S=6(){4 a=D("2v");$("#"+z).2L("<1u 1o=\'"+x.2B+"\' 1k=\'1j:4g;4h:4i;1A:3l;\' 1a=\'"+a+"\'></1u>");$("#"+z).4j($("#"+a))};4 T=6(a){4 b=D("1I");$("#"+b).1z(a)};4 U=6(){4 a=D("1I");4 b=D("1f");4 c=$("#"+b+" a.2k");1s(4 d=0;d<c.1c;d++){4 e=c[d];4 f=$(e).12("1a");5($(e).3m("9")&&d<c.1c-1){$("#"+b+" a.9").1M("9");$(c[d+1]).1D("9");4 g=$("#"+b+" a.9").12("1a");5(!v){4 h=(q.1F==14)?C[g].1y:C[g].1z;T(h)};5(22(($("#"+g).1A().2l+$("#"+g).1j()))>=22($("#"+b).1j())){$("#"+b).2r(($("#"+b).2r())+$("#"+g).1j()+$("#"+g).1j())};1h}}};4 V=6(){4 a=D("1I");4 b=D("1f");4 c=$("#"+b+" a.2k");1s(4 d=0;d<c.1c;d++){4 e=c[d];4 f=$(e).12("1a");5($(e).3m("9")&&d!=0){$("#"+b+" a.9").1M("9");$(c[d-1]).1D("9");4 g=$("#"+b+" a.9").12("1a");5(!v){4 h=(q.1F==14)?C[g].1y:C[g].1z;T(h)};5(22(($("#"+g).1A().2l+$("#"+g).1j()))<=0){$("#"+b).2r(($("#"+b).2r()-$("#"+b).1j())-$("#"+g).1j())};1h}}};4 W=6(){5(q.1G!=14){4 a=D("1I");4 b=8.10(z).1B[8.10(z).1l].32;5(b.1c>0){4 c=D("1f");4 d=$("#"+c+" a."+b).12("1a");4 e=$("#"+d).19("25-4k");4 f=$("#"+d).19("25-1A");4 g=$("#"+d).19("24-3n");5(e!=18){$("#"+a).26("."+x.1p).12(\'1k\',"25:"+e)};5(f!=18){$("#"+a).26("."+x.1p).19(\'25-1A\',f)};5(g!=18){$("#"+a).26("."+x.1p).19(\'24-3n\',g)};$("#"+a).26("."+x.1p).19(\'25-3o\',\'4l-3o\');$("#"+a).26("."+x.1p).19(\'24-3f\',\'4m\')}}};4 X=6(){4 a=D("1f");4 b=$("#"+a+" a.9");5(b.1c==1){4 c=$("#"+a+" a.9").1y();4 d=$("#"+a+" a.9").12("1a");5(d!=18){4 e=C[d].1Y;8.10(z).1l=C[d].1g};5(q.1F&&q.1G!=14)W()}1d 5(b.1c>1){4 f=$("#"+z+" > 2j:9").4n("9");1s(4 i=0;i<b.1c;i++){4 d=$(b[i]).12("1a");4 g=C[d].1g;8.10(z).1B[g].9="9"}};4 h=8.10(z).1l;s.1N["1l"]=h};4 Y=6(a){5($("#"+z).12("4o"+a)!=18){15 11};4 b=$("#"+z).2N("4p");5(b&&b[a]){15 11};15 14};4 Z=6(){4 b=D("1f");5(Y(\'2D\')==11){4 c=C[$("#"+b+" a.9").12("1a")].1y;5(t!=c){$("#"+z).1C("2D")}};5(Y(\'1q\')==11){$("#"+z).1C("1q")};5(Y(\'2C\')==11){$(8).1e("1q",6(a){$("#"+z).2f();$("#"+z)[0].2C();X();$(8).1L("1q")})}};4 2M=6(a){4 b=D("2e");5(a==1)$("#"+b).19({3p:\'0 4q%\'});1d $("#"+b).19({3p:\'0 0\'})};4 3q=6(){1s(4 i 2q 8.10(z)){5(4r(8.10(z)[i])!=\'6\'&&8.10(z)[i]!==18&&8.10(z)[i]!==1n){s.1v(i,8.10(z)[i],11)}}};4 3r=6(a,b){5(M(b)!=-1){8.10(z)[a]=b;4 c=D("1f");$("#"+c+" a.9").1M("9");$("#"+M(b).1a).1D("9");4 d=M(8.10(z).1l).1z;T(d)}};4 3s=6(i,a){5(a==\'d\'){1s(4 b 2q C){5(C[b].1g==i){4s C[b];1h}}};4 c=0;1s(4 b 2q C){C[b].1g=c;c++}};1b.3i=6(){5((s.28("1i",11)==11)||(s.28("1B",11).1c==0))15;4 c=D("1f");5(1E!=""&&c!=1E){$("#"+1E).3t("2O");$("#"+1E).19({1V:\'0\'})};5($("#"+c).19("1S")=="3u"){$(8).1e("1X",6(a){4 b=a.3g;5(b==39||b==40){a.1Z();a.2p();U()};5(b==37||b==38){a.1Z();a.2p();V()};5(b==27||b==13){s.20();X()};5($("#"+z).12("3v")!=18){8.10(z).3v()}});$(8).1e("2E",6(a){5($("#"+z).12("3w")!=18){8.10(z).3w()}});$(8).1e("1q",6(a){5(Q()==14){s.20()}});$("#"+c).19({1V:q.1V});$("#"+c).4t("2O",6(){5(s.1K["3x"]!=1n){2s(s.1K["3x"])(s)}});5(c!=1E){1E=c}}};1b.20=6(){4 b=D("1f");$(8).1L("1X");$(8).1L("2E");$(8).1L("1q");$("#"+b).3t("2O",6(a){Z();$("#"+b).19({1V:\'0\'});5(s.1K["3y"]!=1n){2s(s.1K["3y"])(s)}})};1b.1l=6(i){s.1v("1l",i)};1b.1v=6(a,b,c){5(a==18||b==18)3z{3A:"1v 4u 4v?"};s.1N[a]=b;5(c!=11){3k(a){1m"1l":3r(a,b);1h;1m"1i":s.1i(b,11);1h;1m"1r":8.10(z)[a]=b;v=($(r).12("1x")>0||$(r).12("1r")==11)?11:14;5(v){4 d=$("#"+z).1j();4 f=D("1f");$("#"+f).19("1j",d+"21");4 g=D("1H");$("#"+g).2n();4 f=D("1f");$("#"+f).19({1S:\'2I\',1A:\'2J\'});K()}1h;1m"1x":8.10(z)[a]=b;5(b==0){8.10(z).1r=14};v=($(r).12("1x")>0||$(r).12("1r")==11)?11:14;5(b==0){4 g=D("1H");$("#"+g).3B();4 f=D("1f");$("#"+f).19({1S:\'3u\',1A:\'3l\'});4 h="";5(8.10(z).1l>=0){4 i=M(8.10(z).1l);h=i.1z;N($("#"+i.1a))};T(h)}1d{4 g=D("1H");$("#"+g).2n();4 f=D("1f");$("#"+f).19({1S:\'2I\',1A:\'2J\'})};1h;4w:4x{8.10(z)[a]=b}4y(e){};1h}}};1b.28=6(a,b){5(a==18&&b==18){15 s.1N};5(a!=18&&b==18){15(s.1N[a]!=18)?s.1N[a]:1n};5(a!=18&&b!=18){15 8.10(z)[a]}};1b.3h=6(a){4 b=D("1O");5(a==11){$("#"+b).3B()}1d 5(a==14){$("#"+b).2n()}1d{15 $("#"+b).19("1S")}};1b.4z=6(a,b){4 c=a;4 d=c.1y;4 e=(c.1Y==18||c.1Y==1n)?d:c.1Y;4 f=(c.1Q==18||c.1Q==1n)?\'\':c.1Q;4 i=(b==18||b==1n)?8.10(z).1B.1c:b;8.10(z).1B[i]=2b 4A(d,e);5(f!=\'\')8.10(z).1B[i].1Q=f;4 g=M(i);5(g!=-1){4 h=G(8.10(z).1B[i],i,"","");$("#"+g.1a).1z(h)}1d{4 h=G(8.10(z).1B[i],i,"","");4 j=D("1f");$("#"+j).4B(h);K()}};1b.2m=6(i){8.10(z).2m(i);5((M(i))!=-1){$("#"+M(i).1a).2m();3s(i,\'d\')};5(8.10(z).1c==0){T("")}1d{4 a=M(8.10(z).1l).1z;T(a)};s.1v("1l",8.10(z).1l)};1b.1i=6(a,b){8.10(z).1i=a;4 c=D("1O");5(a==11){$("#"+c).19("2o",x.1i);s.20()}1d 5(a==14){$("#"+c).19("2o",1)};5(b!=11){s.1v("1i",a)}};1b.2P=6(){15(8.10(z).2P==18)?1n:8.10(z).2P};1b.2Q=6(){5(29.1c==1){15 8.10(z).2Q(29[0])}1d 5(29.1c==2){15 8.10(z).2Q(29[0],29[1])}1d{3z{3A:"4C 1g 4D 4E!"}}};1b.3C=6(a){15 8.10(z).3C(a)};1b.1r=6(a){5(a==18){15 s.28("1r")}1d{s.1v("1r",a)}};1b.1x=6(a){5(a==18){15 s.28("1x")}1d{s.1v("1x",a)}};1b.4F=6(a,b){s.1K[a]=b};1b.4G=6(a){2s(s.1K[a])(s)};4 3D=6(){s.1v("2R",$.1U.2R);s.1v("2S",$.1U.2S)};4 3E=6(){L();3q();3D();5(q.2t!=\'\'){2s(q.2t)(s)}};3E()};$.1U={2R:2.3,2S:"4H 4I",4J:6(a,b){15 $(a).1U(b).2N("1W")}};$.4K.2U({1U:6(b){15 1b.2H(6(){4 a=2b 2T(1b,b);$(1b).2N(\'1W\',a)})}})})(4L);',62,296,'||||var|if|function||document|selected|||||||||||||||||||||||||||||||||||||||||||||||||||||getElementById|true|attr||false|return|||undefined|css|id|this|length|else|bind|postChildID|index|break|disabled|height|style|selectedIndex|case|null|class|ddTitleText|mouseup|multiple|for|span|div|set|mouseover|size|text|html|position|options|trigger|addClass|bg|showIcon|useSprite|postTitleID|postTitleTextID|mouseout|onActions|unbind|removeClass|ddProp|postID|click|title|sDiv|display|oldIndex|msDropDown|zIndex|dd|keydown|value|preventDefault|close|px|parseInt||padding|background|find||get|arguments|visibleRows|new|keyboardAction|currentKey|postArrowID|focus|dblclick|mousedown|mousemove|option|enabled|top|remove|hide|opacity|stopPropagation|in|scrollTop|eval|onInit|insideWindow|postElementHolder|postAID|postOPTAID|ddTitle|arrow|ddChild|ddOutOfVision|blur|change|keyup|opt|_|each|block|relative|width|after|bi|data|fast|form|item|version|author|bh|extend|rowHeight|mainCSS|Object|postInputhidden|actions||children|className|img|src|align|absmiddle||||href|javascript|void|font|first|bottom|keyCode|visible|open|Math|switch|absolute|hasClass|left|repeat|backgroundPosition|bj|bk|bl|slideUp|none|onkeydown|onkeyup|onOpen|onClose|throw|message|show|namedItem|bm|bn|120|9999|_msddHolder|_msdd|_title|_titletext|_child|_msa|_msopta|postInputID|_msinput|_arrow|_inp|keypress|prop|tabindex|val|nodeName|OPTGROUP|opta|weight||bold|italic|clear|both|label|border|1px|solid|c3c3c3|toggleClass|min|max|refresh|split|mouseenter|0px|overflow|hidden|appendTo|image|no|2px|removeAttr|on|events|100|typeof|delete|slideDown|to|what|default|try|catch|add|Option|append|An|is|required|addMyEvent|fireEvent|Marghoob|Suleman|create|fn|jQuery'.split('|'),0,{}))
