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');
			}
		}
	}
}

