						
	$(document).ready(Initialize);
	
	
	function Initialize() 
	{		
		new Accordion('section_container',option);					        
		$("#section_container img").bind('click',LoadBigImage);
		$("#btn_estimate").bind('click',CalculatePrice);
		$("#btn_add_info").bind('click',ShowAddInfo);
		$(".section_title:first-child").click();
		
		MakeCheckboxRadioOperation();		
		
	}
	
	function LoadBigImage(evnt)
	{
		$("#big_image").css('display','block');
		$("#big_image").css('left',$(evnt.target).attr('offsetLeft')+50);
		$("#big_image").css('top',$(evnt.target).attr('offsetTop'));
		$("#big_image").css('display','block');
		$("#big_image img").attr('src',evnt.target.src);		
	}
	
	function MakeCheckboxRadioOperation()
	{
	    for(i=1;i<discount.length;i++)
	    {
	       RadioGroup($("[type='checkbox'][name^="+i+"_]"));
	    }
	}
	
	
	function RadioGroup(elements)
	{	    
	    elements.attr('checked','');
	    elements.bind('click',function(evnt){
	                                
	                                var st = evnt.target.checked;
	                                elements.attr('checked','');
	                                evnt.target.checked = st;
	    
	                            });
	}
	
	
	
	function HideBigImage()
	{
		$("#big_image").css('display','none');				
	}
	
	function CalculatePrice(evnt)
	{
		var total_price = 0.00;
		$("#section_container input[type='checkbox']:checked").each(function()
																		{
																			total_price += parseInt(this.value);
																		}																	
																	)
		var total_discount = 0.00;
		total_discount = (total_price==0)?0:(total_price/100)*discount[$("#section_container input[type='checkbox']:checked").length];

		total_discount = (total_discount=='NaN')?0.00:total_discount;
		var total_cost = total_price-total_discount;
		$("#txt_price").attr('value','$'+total_price); 
		$("#txt_discount").attr('value','$'+total_discount); 
		$("#txt_cost").attr('value','$'+total_cost);
		$("#txt_amount").attr('value','$'+total_cost);
	}
	
	function ShowAddInfo(evnt)
	{		
	    odertext = "You have ordered:";
	    
	    section_titles = $(".section_title");
	    	    
	    $("[type='checkbox']:checked").each(function(){	                                          
	                                            section_index = parseInt($(this).attr('name').split("_",1));                                          
	                                            odertext += section_titles.eq(section_index-1).text();	                                            
	                                            odertext += ", level"+$(this).attr('name').split("_")[1] + "; ";
	                                            $("#order_text").text(odertext);
	                                        });
	    
	    
		$("#info").css('display','block');
	}
	
	function validate()
	{
		var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

		if($("#txt_name").attr('value')=="Your Name"||$("#txt_name").attr('value')=="")
		{
			alert("Invalid Name");
			$("#txt_name").focus();
			return false;
		}
		if($("#txt_email").attr('value')=="Your Email"||$("#txt_email").attr('value')==""||!pattern.test($("#txt_email").attr('value')))
		{
			alert("Invalid Email");
			$("#txt_email").focus();
			return false;
		}		
	}
