var lastOpeneedDiv = "entree";

// This function is used to show the hidden div
function show(div)
{
	// Checking if the last opened div is not same as the present div
	if(lastOpeneedDiv != div)
	{
		// Displaying the div
		jQuery("#"+div).show();
		
		// Hiding the lastopeneddiv
		jQuery("#"+lastOpeneedDiv).hide();

		// Assigning the present div to lastopeneddiv
		lastOpeneedDiv = div;
	}
}

// Whenever the document is ready the actions has to be taken place here
$(document).ready(function()
{
	
	
	 // for pretty photo
	$("a[rel^='prettyPhoto']").prettyPhoto({    
			animationSpeed: 'normal', 		/* fast/slow/normal */
			padding: 40, 					/* padding for each side of the picture */
			opacity: 0.35, 					/* Value betwee 0 and 1 */
			showTitle: false, 				/* true/false */
			allowresize: false, 			/* true/false */
			counter_separator_label: ' of ', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_rounded' 			/* light_rounded / dark_rounded / light_square / dark_square */
		});
	
	/* For Left Side List in Offerte aanvraag*/
	var prevOpenedDiv='';
	$(".offerte_list li").click(function(){
		//remove the class from the default selected list
		if(prevOpenedDiv=='')
		{
			$(".select_list").removeClass("select_list");
		}
		else
		{
			$(prevOpenedDiv).removeClass("select_list");
		}
		//adding class to the present clicked list
	 	$(this).addClass("select_list");
		prevOpenedDiv=this;
	});
	/* End of Left Side List in Offerte aanvraag*/
	
	

	
	
	

	// Bind a function "setTotal" to the keyup event of each matched class element "entree_woonkamer".
	jQuery('.entree_woonkamer').keyup(function(event)
	{											   
		setTotal('ew_totaal_m3','entree_woonkamer');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "eetkamer".
	jQuery('.eetkamer').keyup(function(event)
	{											   
		setTotal('eet_totaal_m3','eetkamer');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "keuken".
	jQuery('.keuken').keyup(function(event)
	{											   
		setTotal('keuken_totaal_m3','keuken');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "schuur".
	jQuery('.schuur').keyup(function(event)
	{											   
		setTotal('sgt_totaal_m3','schuur');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "slaapkamer_1".
	jQuery('.slaapkamer_one').keyup(function(event)
	{											   
		setTotal('sk1_totaal_m3','slaapkamer_one');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "slaapkamer_2".
	jQuery('.slaapkamer_two').keyup(function(event)
	{											   
		setTotal('sk2_totaal_m3','slaapkamer_two');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "slaapkamer_3".
	jQuery('.slaapkamer_three').keyup(function(event)
	{											   
		setTotal('sk3_totaal_m3','slaapkamer_three');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "slaapkamer_4".
	jQuery('.slaapkamer_four').keyup(function(event)
	{											   
		setTotal('sk4_totaal_m3','slaapkamer_four');
	});

	// Bind a function "setTotal" to the keyup event of each matched class element "badkamer".
	jQuery('.badkamer').keyup(function(event)
	{											   
		setTotal('bad_totaal_m3','badkamer');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "studeerkamer".
	jQuery('.studeerkamer').keyup(function(event)
	{											   
		setTotal('study_totaal_m3','studeerkamer');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "zolder".
	jQuery('.zolder').keyup(function(event)
	{											   
		setTotal('zolder_totaal_m3','zolder');
	});
	
	// Bind a function "setTotal" to the keyup event of each matched class element "stukken".
	jQuery('.stukken').keyup(function(event)
	{											   
		setTotal('stukken_totaal_m3','stukken');
	});
	
});


// Calculating the subtotal and grand total when ever user enters some value in the text box
function setTotal(ref_total,cname)
{
	//alert(ref_total+" "+cname);
	// Assigning the sub_total, final_total as 0 for calculation purpose
	sub_total 	= 0;
	final_total = 0;
	null_value  = '';
	
	//gettting the form elements
	jQuery("."+cname).each(function (i)
	{
		// Checking if it is a numeric value
		if(!isNaN(jQuery(this).val()))
		{
			// Getting the name of the element
			ele_name = jQuery(this).attr("name");
			
			// Getting the calculated value by concatinating the name of the element with multiply suffix.
			ele_multiply_value = eval(ele_name+"_multiply");

			// Chacking if it is not null
			if(jQuery(this).val() != '')
			{
				// calculating the sub total from all the required fields
				sub_total = sub_total + (parseInt(jQuery(this).val()) * parseFloat(ele_multiply_value));
			}
		}
		else
		{
			// Assigning the value null if it is not a numeric
			jQuery(this).val(null_value);
		}
	});
	
	sub_total = Math.round(sub_total*100)/100;
	// Placing the subtotal in the subtotal field
	jQuery("#"+ref_total).val(sub_total);
	
	// Getting the all total values
	jQuery(".total_textbox").each(function(i)
    {
		// Checking if it is a numeric value
		if(!isNaN(jQuery(this).val()))
		{
			// Chacking if it is not null
			if(jQuery(this).val() != '')
			{
				// calculating the final total from all sub totals
				final_total = parseFloat(final_total) + parseFloat(jQuery(this).val());
			}
		}
		else
		{
			// Assigning the value null if it is not a numeric
			jQuery(this).val(null_value);
		}
    });
	
	// Assigning the final total in the grand_total field
	jQuery("#grand_total").val(final_total);
}


/******************************** Constants for Offerte aanvraag ****************************************/

	ew_3_zitsbank_multiply 			= 2.0;
	ew_2_zitsbank_multiply 			= 1.5;
	ew_fauteuil_multiply 			= 0.5;
	ew_salonkast_multiply  			= 3.0;
	ew_dressoir_multiply 			= 1.5;
	ew_tv_kast_multiply 			= 0.7;
	ew_tv_multiply  				= 0.3;
	ew_secretaire_multiply 			= 1.0;
	ew_kastje_side_table_multiply 	= 0.5;
	ew_stereomeubel_app_multiply  	= 0.3;
	ew_staande_klok_lamp_multiply 	= 0.3;
	ew_bijzettafels_multiply 		= 0.1;
	ew_salontafel_multiply  		= 0.5;
	ew_tapijt_multiply 				= 0.2;
	ew_planten_multiply 			= 0.2;
	ew_schilderijen_multiply  		= 0.2;
	ew_bureau_stoel_multiply 		= 1.5;
	ew_comp_monitor_printer_multiply= 0.3;
	ew_verhuisdozen_multiply  		= 0.1;
	ew_boeken_per_meter_multiply 	= 0.1;
	ew_diversen_p_m3_multiply 		= 1.0;

/******************************** End of Constants for Offerte aanvraag *********************************/

/******************************** Constants for Eetkamer ************************************************/

	eet_eettafel_multiply			= 1.0;
	eet_stoelen_multiply			= 0.2;
	eet_klein_meubilair_multiply	= 0.2;
	eet_kast_multiply				= 1.0;
	eet_kastje_multiply				= 0.5;
	eet_verhuisdozen_multiply		= 0.1;
	eet_boeken_per_meter_multiply	= 0.1;
	eet_diversen_p_m3_multiply		= 1.0;

/******************************** End of Constants for Eetkamer *****************************************/

/******************************** Constants for Keuken **************************************************/
	
	keuken_fornuis_multiply			= 0.4;
	keuken_vaatwasmachine_multiply	= 0.5;
	keuken_koelkast_multiply		= 0.5;
	keuken_koel_vriescomb_multiply	= 1.0;
	keuken_magnetron_multiply		= 0.2;
	keuken_kast_multiply			= 1.0;
	keuken_kastje_multiply			= 0.5;
	keuken_eethoek_multiply			= 1.5;
	keuken_verhuisdozen_p_multiply	= 0.1;
	keuken_diversen_p_m3_multiply	= 1.0;

/******************************** End of Constants for Keuken *******************************************/

/******************************** Constants for Schuur, garage, tuin ************************************/

	sgt_werkbank_multiply			= 1.0;
	sgt_kast_multiply				= 1.0;
	sgt_gereedschap_multiply		= 0.2;
	sgt_fiets_multiply				= 0.5;
	sgt_ladder_multiply				= 0.3;
	sgt_surfplank_multiply			= 1.0;
	sgt_kruiwagen_multiply			= 0.5;
	sgt_tuinameubl_multiply			= 1.5;
	sgt_planten_in_potten_multiply	= 0.2;
	sgt_hout_multiply				= 0.5;
	sgt_verhuisdozen_multiply		= 0.1;
	sgt_diversen_p_m3_multiply		= 1.0;
	
/******************************** End of Constants for Schuur, garage, tuin *****************************/

/******************************** Constants for Slaapkamer 1 ********************************************/

	sk1_1_persoonsbed_multiply		= 0.3;
	sk1_2_persoonsbed_multiply		= 0.7;
	sk1_ombouw_multiply				= 0.4;
	sk1_ladenkast_multiply			= 0.3;
	sk1_bedkast_stoel_multiply		= 0.2;
	sk1_linnenkast_2_drs_multiply	= 0.4;
	sk1_linnenkast_3_drs_multiply	= 0.8;
	sk1_kaptafel_multiply			= 0.5;
	sk1_tv_audio_multiply			= 0.3;
	sk1_verhuisdozen_multiply		= 0.1;
	sk1_boeken_per_meter_multiply	= 0.1;
	sk1_garderobedoos_multiply		= 0.5;
	sk1_diversen_p_m3_multiply		= 1.0;

/******************************** End of Constants for Slaapkamer 1 **************************************/

/******************************** Constants for Slaapkamer 2 ********************************************/

	sk2_1_persoonsbed_multiply		= 0.3;
	sk2_2_persoonsbed_multiply		= 0.7;
	sk2_ombouw_multiply				= 0.4;
	sk2_ladenkast_multiply			= 0.3;
	sk2_bedkast_stoel_multiply		= 0.2;
	sk2_linnenkast_2_drs_multiply	= 0.4;
	sk2_linnenkast_3_drs_multiply	= 0.8;
	sk2_kaptafel_multiply			= 0.5;
	sk2_tv_audio_multiply			= 0.3;
	sk2_bureau_stoel_multiply 		= 1.5;
	sk2_comp_monitor_printer_multiply= 0.3;
	sk2_verhuisdozen_multiply		= 0.1;
	sk2_boeken_per_meter_multiply	= 0.1;
	sk2_garderobedoos_multiply		= 0.5;
	sk2_diversen_p_m3_multiply		= 1.0;

/******************************** End of Constants for Slaapkamer 2 **************************************/

/******************************** Constants for Slaapkamer 3 ********************************************/

	sk3_1_persoonsbed_multiply		= 0.3;
	sk3_ombouw_multiply				= 0.4;
	sk3_ladenkast_multiply			= 0.3;
	sk3_bedkast_stoel_multiply		= 0.2;
	sk3_linnenkast_multiply			= 0.5;
	sk3_tv_audio_multiply			= 0.3;
	sk3_bureau_stoel_multiply 		= 1.5;
	sk3_comp_monitor_printer_multiply= 0.3;
	sk3_verhuisdozen_multiply		= 0.1;
	sk3_boeken_per_meter_multiply	= 0.1;
	sk3_garderobedoos_multiply		= 0.5;
	sk3_diversen_p_m3_multiply		= 1.0;

/******************************** End of Constants for Slaapkamer 3 **************************************/

/******************************** Constants for Slaapkamer 4 ********************************************/

	sk4_1_persoonsbed_multiply		= 0.3;
	sk4_ombouw_multiply				= 0.4;
	sk4_ladenkast_multiply			= 0.3;
	sk4_bedkast_stoel_multiply		= 0.2;
	sk4_linnenkast_multiply			= 0.5;
	sk4_tv_audio_multiply			= 0.3;
	sk4_bureau_stoel_multiply 		= 1.5;
	sk4_comp_monitor_printer_multiply= 0.3;
	sk4_verhuisdozen_multiply		= 0.1;
	sk4_boeken_per_meter_multiply	= 0.1;
	sk4_garderobedoos_multiply		= 0.5;
	sk4_diversen_p_m3_multiply		= 1.0;

/******************************** End of Constants for Slaapkamer 4 **************************************/

/******************************** Constants for Badkamer *************************************************/

	bad_wasmachine_multiply			= 0.5;
	bad_droogtrommel_multiply		= 0.5;
	bad_kast_multiply				= 0.5;
	bad_verhuisdozen_multiply		= 0.1;

/******************************** End of Constants for Badkamer ******************************************/

/******************************** Constants for Studeerkamer *********************************************/
	// pending from client
	study_bureau_stoel_multiply		= 1.5;
	study_comp_monitor_printer_multiply	= 0.3;
	study_boekenkast_multiply		= 0.5;
	study_verhuisdozen_multiply		= 0.1;
	study_boeken_per_meter_multiply	= 0.1;
	study_diversen_p_m3_multiply	= 1.0;

/******************************** End of Constants for Studeerkamer **************************************/

/******************************** Constants for Zolder ***************************************************/

	zolder_kast_multiply			= 0.5;
	zolder_tafel_multiply			= 0.5;
	zolder_verhuisdozen_multiply	= 0.1;
	zolder_boekendoos_multiply		= 0.1;
	zolder_diversen_p_m3_multiply	= 1.0;

/******************************** End of Constants for Zolder ********************************************/

/******************************** Constants for Bijzondere stukken ***************************************/

	stukken_piano_multiply			= 1.0;
	stukken_orgel_multiply			= 1.0;
	stukken_vleugel_multiply		= 2.0;
	stukken_brandw_kast_multiply	= 1.0;
	stukken_Kluis_less_50_multiply	= 0.5;
	stukken_Kluis_more_50_multiply	= 1.0;
	stukken_tuinbeelden_multiply	= 0.5;
	stukken_diversen_p_m3_multiply	= 1.0;

/******************************** End of Constants for Bijzondere stukken ********************************/





