﻿/// <reference path="jquery-1.2.6-vsdoc.js" />
$(document).ready(function() {
	$('#loading').hide();

	//category image click event
	$(".division img").click(function() {
		$(".division img").animate({ opacity: '0.25' }); //set opacity to all
		$("." + this.id).show(); //show only the related block
		$("#" + this.id).animate({ opacity: '1' }); //set the selected category image opactiy to 1
		$('#loading').show();
		location.href = "#loading";
		$('#tourlist').html("");
		//a cid with random data for IE only. It forces IE refresh the TourList.aspx
		$.get("../TourList.aspx", { division: getDivision(), subdivision: $(this).attr("id"), cid: Math.random() },
      function(data) {
      	//twice replace actions for replace name and ID. To replace the __Viewstate variable to avoid the conflict to the Main(container) page's viewstate. This for hacking IE too
      	data = data.replace("__VIEWSTATE", "nothing");
      	data = data.replace("__VIEWSTATE", "nothing");
      	$('#tourlist').html(data);
      	$('#loading').hide();
      }
    );
	});

});

function getDivision() {
	var url = location.href.split("/");
	var page = url[url.length - 2];
	var division;
	switch (page.toLowerCase()) {
		case "us_canada":
			division = "North America";
			break;
		case "europe":
			division = "Europe";
			break;
		case "asia":
			division = "Asia";
			break;
		case "packagetour":
			division = "PackageTours";
			break;
	}
	return division;
}

