$(document).ready(function() {
	/* hovering scripts */
	$(".PAL4Div td").hover(
		function(){
			$(this).css("backgroundColor","#e3e3e3");
		},
		function(){
			$(this).css("backgroundColor","");
		}
	)
	$(".PAL3Div").hover(
		function(){
			$(this).css("backgroundColor","#e3e3e3");
			var myID = $(this).attr("id");
			var myL4id = "#L4" + myID.substring(2,myID.length);
			var myIL3id = "#IL3" + myID.substring(2,myID.length);
			$(myL4id).css("backgroundColor","#e3e3e3");
			$(myIL3id).css("backgroundColor","#e3e3e3");
		},
		function(){
			$(this).css("backgroundColor","");
			var myID = $(this).attr("id");
			var myL4id = "#L4" + myID.substring(2,myID.length);
			var myIL3id = "#IL3" + myID.substring(2,myID.length);
			$(myL4id).css("backgroundColor","");
			$(myIL3id).css("backgroundColor","");
		}
	)
	$(".InnerL3Div").hover(
		function(){
			$(this).css("backgroundColor","#e3e3e3");
			var myID = $(this).attr("id");
			var myL4id = "#L4" + myID.substring(3,myID.length);
			var myL3id = "#L3" + myID.substring(3,myID.length);
			$(myL4id).css("backgroundColor","#e3e3e3");
			$(myL3id).css("backgroundColor","#e3e3e3");
		},
		function(){
			$(this).css("backgroundColor","");
			var myID = $(this).attr("id");
			var myL4id = "#L4" + myID.substring(3,myID.length);
			var myL3id = "#L3" + myID.substring(3,myID.length);
			$(myL4id).css("backgroundColor","");
			$(myL3id).css("backgroundColor","");
		}
	)
	/* checkbox scripts */
	$(".PAL3Div input").click(
		function() {
			if ($(this).attr("checked")==true) {
				var myID = "#L4" + $(this).attr("value");
				$(myID).find("input").attr("checked",true);
				var l4dispStatus = $(myID).css("display");
				if (l4dispStatus=="none") {
					$("#IL3" + $(this).attr("value")).find("img").attr("src","http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/BLK_ARRDOWN.GIF");
					$(myID).css("display","block");
				}
			} else {
				var myID = "#L4" + $(this).attr("value");
				$(myID).find("input").each(
					function(index,domEle)  {
						if (domEle.name == "point_id")
							domEle.checked = false;
					}
				)
			}
		}
	)
	$(".PAL4Div input").click(
		function() {
			if ($(this).attr("checked")==false) {
				if ($(this).attr("parent")!=undefined) {
					var l3idStr = "#L3" + $(this).attr("parent") + " input";
					$(l3idStr).attr("checked",false);
				}
			} else {
				if ($(this).attr("parent")!=undefined) {
					var l3idStr = "#L3" + $(this).attr("parent") + " input";
					var l4idStr = "#L4" + $(this).attr("parent");
					var allChecked = false;
					$(l4idStr).find("input").each(
						function (index, domEle) {
							if (domEle.checked) {
								allChecked = true;
							} else {
								allChecked = false;
								return false;
							}
						}
					);
					if (allChecked)
						$(l3idStr).attr("checked",true);
				}

			}
		}
	)
	$(".InnerL3Div").click(
		function() {
			var divIdStr = $(this).attr("id")
			var l4divStr = "#L4" + divIdStr.substring(3,divIdStr.length);	
			var l4dispStatus = $(l4divStr).css("display");
			if (l4dispStatus=="none") {
				$(this).find("img").attr("src","http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/BLK_ARRDOWN.GIF");
				$(l4divStr).css("display","block");
			} else if (l4dispStatus=="block") {
				$(this).find("img").attr("src","http://akamai.globalsources.com.edgesuite.net/f/593/3445/5d/static.globalsources.com/gsol/en/clean/images/BLKARR_RIGHT.GIF");
				$(l4divStr).css("display","none");
			}
		}
	)
});
function toggleL1() {
	var catlistBox = document.getElementById('L1Categories');
	var catlistText = document.getElementById('L1ToggleText');
	var resultBox = document.getElementById('paResultBox');
	if (catlistBox.style.display == "block") {
		catlistBox.style.display = "none";
		catlistText.innerHTML = "View";
		if (resultBox!=null)
			resultBox.style.height = "290px";
	} else {
		catlistBox.style.display = "block";
		catlistText.innerHTML = "Hide";
		if (resultBox!=null)
			resultBox.style.height = "190px";
	}
}
function submitInlineSearch() {

}