// JavaScript Document
$(document).ready(function(){ 
        $("ul.sf-menu").supersubs({ 
            minWidth:    12,   // minimum width of sub-menus in em units 
            maxWidth:    27,   // maximum width of sub-menus in em units 
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
        }).superfish();  // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason. 
						 
		$("#sec_1").hover(
			 function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/home_ov.gif) center top no-repeat #009a34");
			  }, 
			  function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/home.gif) center top no-repeat #009a34");
			  }
		);
		$("#sec_2").hover(
			 function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/ales_ov.gif) center top no-repeat #009a34");
			  }, 
			  function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/ales.gif) center top no-repeat #009a34");
			  }
		);
		$("#sec_3").hover(
			 function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/merch_ov.gif) center top no-repeat #009a34");
			  }, 
			  function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/merch.gif) center top no-repeat #009a34");
			  }
		);
		$("#sec_4").hover(
			 function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/stuff2_ov.gif) center top no-repeat #009a34");
			  }, 
			  function () {
				$(this).css("background","url(http://www.battledownbrewery.com/images/menu/stuff2.gif) center top no-repeat #009a34");
			  }
		);
		$("#sec_5").hover(
			 function () {
				$(this).css("background","url(/images/menu/contacts_ov.gif) center top no-repeat #009a34");
			  }, 
			  function () {
				$(this).css("background","url(/images/menu/contacts.gif) center top no-repeat #009a34");
			  }
		);
		$("#sec_6").hover(
			 function () {
				$(this).css("background","url(/images/menu/links_ov.gif) center top no-repeat #009a34");
			  }, 
			  function () {
				$(this).css("background","url(/images/menu/links.gif) center top no-repeat #009a34");
			  }
		);
}); 

function toggleP(me,target) {
	$("#"+me).hide();	
	$("#"+target).fadeIn("slow");	
}
/*$(function() {
	$('.pics').cycle({
		timeout: 10000 ,	
		delay:  1000, 
		speed:  2000
		
	});
}); */
function select_options(id){
		
				
			$("#outofstock").hide();
			$("#instock").hide();
			$("#cartbutton").hide();
			$("#showprice").html("Fetching data...");
			$("#showprice").show();
			$("#option2").hide();
			var opt1 = $("colour").val();
			$.ajax({
				method: "get",url: "get_options.php",data: "id="+id,
				success: function(html){ //so, if data is retrieved, store it in html
					$("#showprice").hide();
					$("#option2").html(html); //show the html inside .content div
					$("#option2").show('fast');
					//$("#cartbutton").show();
				 }
			 }); //close $.ajax(
	
 } 
 
 
function check_stock(id){
		
			$("#outofstock").hide();
			$("#instock").hide();
			$("#cartbutton").hide();
			$("#showprice").html("Fetching data...");
			$("#showprice").show();
			var opt1 = ($("#colour").val());	
			var opt2 = ($("#size").val());	
			$.ajax({
				method: "get",url: "check_stock.php",data: "id="+id+"&opt1="+opt1+"&opt2="+opt2,
				success: function(html){ //so, if data is retrieved, store it in html
					//$("#instockans").html(html);
					if(html.substring(0,1) == '1'){
						$("#showprice").hide();
						$("#showprice").html("Total Price = &pound;"+html.substr(2,html.length)); //show the html inside .content div
						$("#showprice").show("slow");
						//$("#instock").show("slow");
						$("#cartbutton").show("slow");
					} else {
						$("#showprice").hide();
						$("#stockans").html(html);
						//$("#outofstock").show("slow");
					}
				 }
			 }); //close $.ajax(
	
 } 