function getstock(manualselect,prodID,prodQuant){
		if(manualselect == 1){
			var html = $.ajax({
				url: "ajax.asp?p=product&product=" + $("."+prodID).val(),
				async: false
			}).responseText;
			
			$("."+prodQuant).html(html)
		}
		else {
			var html = $.ajax({
				url: "ajax.asp?p=product&product=" + $("#product-type").val(),
				async: false
			}).responseText;
			
			$("#quantity").html(html)
		}
}


function sameDetails(){
	if (document.checkout.samedetails.checked != false){
		document.checkout.shippingfname.value = document.checkout.billingfname.value
		document.checkout.shippinglname.value = document.checkout.billinglname.value
		document.checkout.shippingaddress1.value = document.checkout.billingaddress1.value
		document.checkout.shippingaddress2.value = document.checkout.billingaddress2.value
		document.checkout.shippingcity.value = document.checkout.billingcity.value
		document.checkout.shippingpostcode.value = document.checkout.billingpostcode.value
		document.checkout.shippingcountry.value = document.checkout.billingcountry.value
		document.checkout.shippingtelephone.value = document.checkout.billingtelephone.value
		document.checkout.shippingemail.value = document.checkout.billingemail.value
	}
	else {
		document.checkout.shippingfname.value = ""
		document.checkout.shippinglname.value = ""
		document.checkout.shippingaddress1.value = ""
		document.checkout.shippingaddress2.value = ""
		document.checkout.shippingcity.value = ""
		document.checkout.shippingpostcode.value = ""
		document.checkout.shippingcountry.value = "UK"
		document.checkout.shippingtelephone.value = ""
		document.checkout.shippingemail.value = ""	
	}
}


function CreateBookmarkLink(title,url) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }



$(document).ready(function(){
						   
	//MENU ACCORDION
	$(".subcategorys").hide()
	
	$(".category-header.expandable").click(function(){
		if ( $(this).hasClass("expanded") ){
			$(this).next().slideUp("fast")
			$(this).removeClass("expanded")
		}
		else {
			$(".subcategorys").slideUp("fast")
			$(".expanded").removeClass("expanded")
			$(this).addClass("expanded")
			$(this).next().slideDown("fast")
		}
	})
	
	//RICKYS PAGE IMAGE GALLERY
	/*
	$("#rickysimages li").append("<div class='imageoverlay'></div>")
	$(".imageoverlay").css({
		"background-color" : "#000000",
		"opacity" : "0.3"
	})
	$("#rickysimages li").hover(function(){
		$(this).find(".imageoverlay").fadeOut("fast")
	},function(){
		$(this).find(".imageoverlay").fadeIn("fast")
	})
	*/
	//HOMEPAGE PRODUCT CAROUSEL
	
	var currentItem = 1;
	var numOfItems = $("#carousel").find("li").length;
	var itemWidth = $("#carousel").find("div").width();
	var timer;
	
	function movenext(){
		$("#carousel-info").slideDown("fast").remove()
		boxResize(-1);
		$("#carousel ul").animate({
			marginLeft: 0 - ((currentItem * (itemWidth+10)) )  //+50
		},1500,function(){
			currentItem++
			if(currentItem+2 == numOfItems){
				timer = setTimeout(function(){
					boxResize(-1);
					$(this).css("margin-left","-1000px");
					currentItem = 1;
					movenext();
				},2000)
			}
			else {
			timer = setTimeout(function(){ movenext() },2000);
			}
		})
		boxResize(1);
		showInfo();
	}
	
	function boxResize(direction){
		if(direction==1){
			$("#carousel").find("div:eq("+(currentItem+2)+")").animate({
				height:"160px",
				width:"140px",
				marginTop:"-35px"
			},800).addClass("active");
			$("#carousel").find("div:eq("+(currentItem+2)+") img").animate({
				height:"160px",
				width:"140px"
				//marginTop:"-15px"
			},800);
		}
		if(direction==-1){
			$(".active img").animate({
				height:"120px",
				width:"100px",
				marginTop:"5px"
			},800);
			$(".active").animate({
				height:"120px",
				width:"100px",
				marginTop:"5px"
			},800).removeClass("active");
			
		}
	}
	
	function showInfo(){
		$("#carousel").append("<div id='carousel-info'><div id='info-bg'></div></div>");
		$(".active").find(".prod-info").clone().appendTo($("#carousel-info"));
		$("#carousel-info").find(".prod-info").addClass("prod-info2");
		$("#carousel-info").hide();
		$("#carousel-info").slideDown("slow");
	}
	
	movenext();
	
	$("#search").focus(function(){
		if($(this).val() == "Search Here..." ){
			$(this).val("")
		}
	})

	$("#search").blur(function(){
		if($(this).val() == ""){
			$(this).val("Search Here...")
		}
	})
	
})

$(document).ready(function(){
    $('#slider4').mbSlider({ 
         autoplay: true,
         pauseOnHover: false,
         playDirection: 'right',
         continuous: true,
		 pagination: false,
		 slideDuration: 17000,
         mousewheelsupport: false,
         showControls : {
             next: false,
             prev: false,
             play: false,
             pause: false,
             first: false,
             last: false
         }
    })
})

