function popup(url,name,windowWidth,windowHeight){
    myleft=(screen.width)?(screen.width-windowWidth)/2:100;
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;
	properties = "width="+windowWidth+",height="+windowHeight+",scrollbars=yes, top="+mytop+",left="+myleft;
    window.open(url,name,properties)
}

$(document).ready(function(){
	//$('#courses').jForms({listSize:20, imagePath:'/elements/css/images/red/'});
	//$.NiceJForms.build({
	//	imagesPath:"/elements/css/images/red/"
	//})


/*
     var cat = $('#course_location');
     var el = $('#start_date');
	 var item = $('#item_id').val();
	 
     cat.selectChain({
          target: el,
          url: 'index.php',
          data: { item_id: item , ajax: true }
     }).trigger('change');

    */ 
     $("#donatetable").hide();
     
    $("#donateoption").click(function () {
		$("#donatetable").toggle();
    });
    
    

	      var selectid = $('#deliveryoption option:selected').attr("value");
          var amountship = $("#pricewithshipping").val();          
          var amount = $("#pricewithout").val();
          
          var total = $("#totalEx").val(); 
          var totalship = $("#totalExship").val();
          
          var gst = $("#gst").val(); 
          var gstship = $("#gstShip").val();
               
          if (selectid=='2') {
          	 $("#grandtotal").html("<strong>$"+ (amountship/100).toFixed(2) +"</strong>");     
          	 $("#subtotal").html("$"+ (totalship/100).toFixed(2));       	
          	 $("#totalGST").html("$"+ (gstship/100).toFixed(2));     
          } else if (selectid=='1') {
          	 $("#grandtotal").html("<strong>$"+ (amount/100).toFixed(2) +"</strong>");          	
          	 $("#subtotal").html("$"+ (total/100).toFixed(2)); 
          	 $("#totalGST").html("$"+ (gst/100).toFixed(2));         
          }
	$("#deliveryoption").change(function () {

       
	      var selectid = $('#deliveryoption option:selected').attr("value");
          var amountship = $("#pricewithshipping").val();          
          var amount = $("#pricewithout").val();
          
          var total = $("#totalEx").val(); 
          var totalship = $("#totalExship").val();
          
          var gst = $("#gst").val(); 
          var gstship = $("#gstShip").val();
               
          if (selectid=='2') {
          	 $("#grandtotal").html("<strong>$"+ (amountship/100).toFixed(2) +"</strong>");     
          	 $("#subtotal").html("$"+ (totalship/100).toFixed(2));       	
          	 $("#totalGST").html("$"+ (gstship/100).toFixed(2));     
          } else if (selectid=='1') {
          	 $("#grandtotal").html("<strong>$"+ (amount/100).toFixed(2) +"</strong>");          	
          	 $("#subtotal").html("$"+ (total/100).toFixed(2)); 
          	 $("#totalGST").html("$"+ (gst/100).toFixed(2));         
          }

        });

   
        
		$("#servicelocation").change(function () {
               var selectid = $("#servicelocation option:selected").val();
               var centredetails = $("#centredetails"+selectid).html();
	   			   
               if (selectid=='' || selectid==0) {
			   $("#containercentre").hide();          	
          		}else {
			   $("#containercentre").show();          	
			   $("#containercentre").html("<strong>"+ centredetails +"</strong>");          	
			   }

        });  
        

});






