
	var sumPrice_pl = 0;//除原有价钱外，?中后的价钱?
	var sumHours_pl = 0;//小时总数
	var plpromotion = 0;

	
	function show_cpf()
	{		
		plpromotion = 1;		
	}
	function hide_cpf()
	{
		plpromotion = 0;		
	}
	
function show_hide_cpf()
	{		
		if(plpromotion == 1){			
			document.getElementById("choosepldivf").style.display = 'block';
		}
		else{
			document.getElementById("choosepldivf").style.display = 'none';
		}
	}
	
	
function add(obj){
	var objdays = document.getElementById('daysf');
	var objhours = document.getElementById('hoursf');	
	var hours = parseInt(objhours.value) + parseInt(objdays.value*24);
	var days;

	var v = obj.value.split('|||');
	var price = v[0];
	var seriesTime = v[3];
	P = document.getElementById('price1f');
	if(obj.checked){
		sumPrice_pl += parseFloat(price);
		sumHours_pl += parseInt(seriesTime);
		P.value = Math.round((parseFloat(P.value)+parseFloat(price))*100)/100;
		
		days = parseInt((parseInt(hours)+parseInt(seriesTime))/24);
		
		hours = parseInt((parseInt(hours)+parseInt(seriesTime))%24);
		objdays.value  = days;
		objhours.value = hours;
		
	}else{
		sumPrice_pl -= parseFloat(price);
		sumHours_pl -= parseInt(seriesTime);
		P.value = Math.round((parseFloat(P.value)-parseFloat(price))*100)/100;
		
		days = parseInt((parseInt(hours)-parseInt(seriesTime))/24);
		hours = parseInt((parseInt(hours)-parseInt(seriesTime))%24);
		objdays.value  = days;
		objhours.value = hours;
		
	}
}

function checkReset(){
	
		var priceStr = document.getElementById('price1f');
		var checkArray = document.getElementsByName("list[]");
		var objdays = document.getElementById('daysf');
		var objhours = document.getElementById('hoursf');	
		var hours = parseInt(objhours.value) + parseInt(objdays.value*24);
		//alert(checkArray.length);
		for(var i =0 ; i < checkArray.length; i++){			
				checkArray[i].checked = false;
			var v = checkArray[i].value.split('|||');
			var price = v[0];
			var seriesTime = v[3];
			if(sumPrice_pl<0){
				sumPrice_pl = 0;
			}
			if(sumHours_pl < 0){
				sumHours_pl = 0;
			}
		}
		priceStr.value = document.getElementById('prf').value;
		hours -= sumHours_pl;
		objdays.value = parseInt(parseInt(hours)/24);
		objhours.value = parseInt(parseInt(hours)%24);
		
		sumPrice_pl = 0;
		sumHours_pl = 0;
	}
function checkResetf(){
	
		var priceStr = document.getElementById('price1f');
		var checkArray = document.getElementsByName("list[]");
		var objdays = document.getElementById('daysf');
		var objhours = document.getElementById('hoursf');	
		var hours = parseInt(objhours.value) + parseInt(objdays.value*24);
		//alert(checkArray.length);
		for(var i =0 ; i < checkArray.length; i++){			
				checkArray[i].checked = false;
			var v = checkArray[i].value.split('|||');
			var price = v[0];
			var seriesTime = v[3];
			if(sumPrice_pl<0){
				sumPrice_pl = 0;
			}
			if(sumHours_pl < 0){
				sumHours_pl = 0;
			}
		}
		priceStr.value = document.getElementById('prf').value;
		hours -= sumHours_pl;
		objdays.value = parseInt(parseInt(hours)/24);
		objhours.value = parseInt(parseInt(hours)%24);
		
		sumPrice_pl = 0;
		sumHours_pl = 0;
	}

				
(function ($) {
    $(document).ready(function () {

			var gameTypeId = $('#gameTypeIdf').val();	
					url = "configs/ajax/equipment.ajax.php";
					$.post(url,{"gameTypeId":gameTypeId},function(data){
							if(data){
								$('#choosepldivf').html("<div class='tt'>Optional Add-on Services</div><div class='tt1'>"+data+"</div>");							
							}else{
								$('#choosepldivf').html("");
							}
							
					});
				
				setInterval('show_hide_cpf()',500);
				
			$('#gameTypeIdf').change(function(){
					var gameTypeId = $('#gameTypeIdf').val();
					url = "configs/ajax/equipment.ajax.php";
					$.post(url,{"gameTypeId":gameTypeId},function(data){
							if(data){
								$('#choosepldivf').html("<div class='tt'>Optional Add-on Services</div><div class='tt1'>"+data+"</div>");							
							}else{
								$('#choosepldivf').html("");
							}					
							});
					});
			});
			
		
})(jQuery);

