// JavaScript Document

/*jQuery(document).ready(function(){
	var vehiOnload = $("#vehiOnload").val();
	if ( vehiOnload == '' ) {
		$("#cpDetails").html("");
	} else {
		getCpDetails(vehiOnload);
	}
});*/

// updated by Hoi 20090902
var vehiOnload = $("#vehiOnload").val();
if ( vehiOnload == '' ) {
	$("#cpDetails").html("");
} else {
	getCarVeh(null, vehiOnload);
}

// updated by Hoi 20090903
function getCpDetails(vehicle) {
	var cpId = $("#cpId").val();
	$("#cpDetails").html("Loading...");
	$(".liC").attr("style","background:url(images/easy_locator_detail/locator_btn_off.gif) no-repeat top left;");
	$("#li_" + vehicle).attr("style","background:url(images/easy_locator_detail/locator_btn_on.gif) no-repeat top left;");
	
	$(".liC a").attr("style","color:#AAAAAA;");
	$("#li_a_" + vehicle).attr("style","color:#000000;");
	
	jQuery.ajax({
	   type: "POST",
	   url: "cp_details.php",
	   data: "cpId=" + cpId + "&funNum=1&vehicle=" + vehicle,
	   success: function(html){
			$("#cpDetails").html(html);
			
			if ( $("#cpDetails").height() < 340 ) {
				$("#cpDetails").height("340px");
			}
			else {
				$("#cpDetails").height($("#cpDetails").height());
			}
			$(".liC").attr("style","background:url(images/easy_locator_detail/locator_btn_off.gif) no-repeat top left;");
			$("#li_" + vehicle).attr("style","background:url(images/easy_locator_detail/locator_btn_on.gif) no-repeat top left;");
	   }
	}); 
}

// ȡ܇��
// updated by Hoi 20090903
function getCarVeh(direct,pos) {
	var cpId = $("#cpId").val();
	
	$.ajax({
	   type: "POST",
	   url: "cp_details.php",
	   data: "cpId=" + cpId + "&funNum=4&direct=" + direct + "&pos=" + pos,
	   success: function(html){
			if ( html == 'no' ) {
				return false;	
			}
			$("#vehUl").html(html);
			getCpDetails(pos);
	   }
	}); 
}
