  $(function() {
    //Fancy Box gallery
	$("p#thumbs a").fancybox();
	//Accordion
	$("#accordion").accordion({ header: "div.title1", active: false,  alwaysOpen: false });
	//AJAX form submit
	var newsletteroptions = { target:        '#newsletter'}; 
	$('#newsletterfrm').ajaxForm(newsletteroptions); 
	var newsletteroptions1 = { target:        '#newsletter_unsubscribe'}; 
	$('#unsubscribenewsletterfrm').ajaxForm(newsletteroptions1); 
  });

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function submitFrm(frm){
	   $('form#'+frm).submit();
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function clearInput(id,value){
	   if($('input#'+id).val()==value){$('input#'+id).val('');}
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function hideDiv(id){	  $("div#"+id).hide();}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function showDiv(id){	  $("div#"+id).show();	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function switchLanguage(langid){
	  //ajax script to set new session language
	  $.get("language_switcher.php", {id:langid});
	  //reload page
	  location.reload(); 
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function change2PassType(id, divid){
	   if($('input#'+id).attr('type')=='text'){
	      $('div#'+divid).html('<input type="password" name="'+id+'" id="'+id+'" value=""/>');
		  $('input#'+id).focus();
	   }
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   function add2cart(options){
	 $("#cart").html("<img src='imgs/loading.gif'/>");
     $.get('add2cart.jx.php', {id:options.id},function(data){ 
       $("#cart").html(data);
     });
   }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   function removefromcart(options){
	 $("#cart_details").html("<img src='imgs/loading.gif'/>");
     $.get('removefromcart.jx.php', {id:options.id},function(data){ 
       $("#cart_details").html(data);
	   refresh_cart();
     });
   }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   function refresh_cart(){
	if($("#cart")){
		$("#cart").html("<img src='imgs/loading.gif'/>");
		$.get('refresh_cart.jx.php', function(data){ 
			$("#cart").html(data);
		});
     	}
   }
   
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function updateCart(itemId){
		var qty = $("#qty"+itemId).val();
		$.get('refresh_cart.jx.php', {id:itemId, qty: qty},function(data){ 
			$("#total").html(data);
			refresh_cart();			
			updateSubtotal(itemId);
		});
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	function updateSubtotal(itemId){
		$.get("refresh_subtotal.jx.php", {id:itemId}, function(data){
			$("#subtotal"+itemId).html(data);
		});
	}
