// JavaScript Document - 


////Anglers page controls click on top images - show large image below
$(document).ready(function() {
	$('ul.slidermenu img').click(function() {
		$(".anglersDetails").slideUp();
		var $img = $(this);	
		var anglerId = $img.attr('data-link');
		var imageName = $("#" + anglerId).attr('title');
		if ( imageName != 'un-defined') {
			
		
			var largeConsImage = '<img src="http://www.foxint.com/uploads/consultants/authors/' + imageName + '" alt="Fox Pro Angling Team" align="center" border="0" />';
			//alert (largeConsImage);
			$("#imageHolder" + anglerId ).html(largeConsImage);
			
		}
		
		//$($img).css({"filter":"alpha(opacity=100)", "opacity":"1.0", "-moz-opacity":"1.0", "border-color":"#F78F1E"});
		$("#" + anglerId).slideDown("slow");
		
	});
});


////control for anglers slider menu
$(document).ready(function(){
	
	var div = $("div.slidermenu"),
		ul = $("ul.slidermenu"),
		ulPadding = 15;
	
	var divWidth = div.width();
 
	div.css({overflow: "hidden"});
	
	var lastLi = ul.find("li:last-child");
	
	div.mousemove(function(e){
		
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
});


///show panel on image rollover
$(document).ready(function() {	
	$(".showPanel2").hover(
        function () {
			$(".showPanel2").css({"filter":"alpha(opacity=40)", "opacity":"0.4", "-moz-opacity":"0.4"});
			var panId = ( "panel" + $(this).attr('id') );
			var imageSrc = $(this).attr('src');
			var imageText = $("#" + panId).html();
			$(this).css({"filter":"alpha(opacity=100)", "opacity":"1.0", "-moz-opacity":"1.0"});
			
			imageSrc = imageSrc.replace("logos/", "logos/250/"); 
			
			$("#logoholder1").attr('src', imageSrc);
			$("#logotextholder").html(imageText);
		},function(){
		
			$(this).css({"filter":"alpha(opacity=40)", "opacity":"0.4", "-moz-opacity":"0.4"});
		
	});
});


//button dropshadow
$(document).ready(function() {	
	$("a.genButt,a.genButtNoWidth,input.button").hover(
         function () {
			$(this).dropShadow({left: 0, top: 0, blur: 2, color: "grey", opacity:0.4});
			$(this).css({"background-image":"URL(images/genbutt-back-grey.jpg"});
		},function(){
			$(this).removeShadow()
			$(this).css({"background-image":"URL(images/genbutt-back.jpg"});
		});
});

///access product bottom tab
$(document).ready(function() {
	$('a.foxBrands').click(function() {						   
		$('#tabcontent1').css({"display":"none"});
				$('#tabcontent2').fadeIn("slow");
				$('#tab2a a').css({"color":"#009900"});
				$('#tab2a').css({"background-image":"URL(images/footer-tab.jpg)"});
				$('#tab1a a').css({"color":"#666666"});
				$('#tab1a').css({"background-image":"URL(images/footer-tab-down.jpg)"});				   
		});
});


///display control for mini basket
$(document).ready(function(){
	$("#minibasket").mouseover(function(event){
		
		x=$("#siteNav2").offset();
		
		$("#minibasketholder").css( { "position": "absolute", "left": (x.left + 550) + "px", "top": (x.top + 50) + "px", "z-index":"5000" } ); 
  		$("#minibasketholder").slideDown("fast");
		
	});
});

///copy checkout card details to delivery
$(document).ready(function(){

	$("#copyAcross").click(function(event){
									
		var cardname = $("#cardname").val();
		$("#customername").val(cardname);
		var address = $("#address").val();
		$("#deliveryaddress").val(address);
		var town = $("#town").val();
		$("#deliverytown").val(town);
		var county = $("#county").val();
		$("#deliverycounty").val(county);
		var postcode = $("#postcode").val();
		$("#deliverypostcode").val(postcode);

	});
});

/////scroll to anchor in page
$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
});


/////general show/hide pass id to open
$(document).ready(function(){
	$('a.showButt').click(function() {					   
		var showId = $(this).attr('title');
		////alert("This iD:" + showId );
		$('#' + showId).slideDown("fast");


	});
});

/////general show/hide pass id to close
$(document).ready(function(){
	$('a.closeButt').click(function() {					   
		var showId = $(this).attr('title');
		////alert("This iD:" + showId );
		$('#' + showId).slideUp("fast");


	});
});

////multi image control
$(document).ready(function(){
$('#topImageHolder').cycle({ 
    fx:     'fade', 
    pause:   3
});

});

////Tab Multi image control
$(document).ready(function(){
$('#tabImagesScroll').cycle({ 
    fx:     'fade', 
    speed:   300, 
    timeout: 3000, 
    next:   '#tabImagesScroll', 
    pause:   1 
});

});

////multi image control
$(document).ready(function(){
$('#s3').cycle({ 
    fx:     'fade', 
    speed:   300, 
    timeout: 3000, 
    next:   '#s3', 
    pause:   1 
});

});


///home-anglers control
$(document).ready(function() {
    $('div.anglerHolder img').hoverpulse().each(function() {
    	var $img = $(this);
    	var link = $img.attr('data-link');
		var name = $img.attr('alt');
    	$img.attr('title','Goto: ' + name);
    	$img.click(function() {
    		document.location.href = link;
    		return false;
    	});
    });
});


///video control
$(document).ready(function(){
 $('#videoHolder').cycle({ 
    fx:     'scrollLeft', 
    speed:  'fast', 
    timeout: 3000, 
	pause: 1,
	pager:  '#videoNav',
	pagerAnchorBuilder: function(index, el) {
 		return '<a href="#">&bull;</a>';
 	},
	after: function() {
         $('#caption').html(this.title);
        }

 });
 
});


////sec-menu control
$(document).ready(function() {

	$(".navHolder").hide(); 

	$("li.menu").hover(
        function () {
		$(this).children(".navHolder").slideDown(100);
		$(this).children(".mainmenu").css({"background-image":"URL(images/sec-menu-bkgrd1.png)", "color":"#00FF66"});
        },function(){
		$(this).children(".navHolder").slideUp(100);
		$(this).children(".mainmenu").css({"background-image":"URL(images/sec-menu-bkgrd.jpg)", "color":"#FFFFFF"});
	});

});


///news menu control
$(document).ready(function() {
/////set backgrd default
$("#newstext1").css({"background-image":"URL(images/news_select-bkgrd.png)"});
$("#topimage1").css({"display":"block"});
		$(".newsText").mouseover(function() {
     		$(this).css({"background-image":"URL(images/news_select-bkgrd.png)"});
			var currentId = $(this).attr('id');
				if (currentId == "newstext1") {
					//$("#topimage1").css({"display":"block"});
					$("#topimage1").fadeIn("slow");
					$("#topimage2").css({"display":"none"});
					$("#newstext2").css({"background-image":"none"});
					$("#topimage3").css({"display":"none"});
					$("#newstext3").css({"background-image":"none"});
				} else if (currentId == "newstext2") {
					$("#topimage1").css({"display":"none"});
					$("#newstext1").css({"background-image":"none"});
					//$("#topimage2").css({"display":"block"});
					$("#topimage2").fadeIn("slow");
					$("#topimage3").css({"display":"none"});
					$("#newstext3").css({"background-image":"none"});
				} else if (currentId == "newstext3") {
					$("#topimage1").css({"display":"none"});
					$("#newstext1").css({"background-image":"none"});
					$("#topimage2").css({"display":"none"});
					$("#newstext2").css({"background-image":"none"});
					$("#topimage3").fadeIn("slow");
					//$("#topimage3").css({"display":"block"});
				} 
   		});        
    });

//langauge menu control position:absolute; left:0px; top:32px;
$(document).ready(function() {
	$('#currentlang').hover(function() {
		$('#chooselang').slideDown("fast");
	}, function() {
		 $('#chooselang').slideUp("fast");
	});
});

///access retailer bottom tab
$(document).ready(function() {
	$('a.findRetailer').click(function() {						   
		$('#tabcontent2').css({"display":"none"});
				$('#tabcontent1').fadeIn("slow");
				$('#tab1a a').css({"color":"#009900"});
				$('#tab1a').css({"background-image":"URL(images/footer-tab.jpg)"});
				$('#tab2a a').css({"color":"#666666"});
				$('#tab2a').css({"background-image":"URL(images/footer-tab-down.jpg)"});				   
		});
});

////botton tab control
$(document).ready(function() {
	$('#tabsHolder ul li').click(function() {
		var tabId = $(this).attr('id');
			if (tabId=='tab1a') {
				$('#tabcontent2').css({"display":"none"});
				$('#tabcontent1').fadeIn("slow");
				$('#tab1a a').css({"color":"#009900"});
				$('#tab1a').css({"background-image":"URL(images/footer-tab.jpg)"});
				$('#tab2a a').css({"color":"#ccc"});
				$('#tab2a').css({"background-image":"URL(images/footer-tab-down.jpg)"});
			} else if (tabId=='tab2a') {
				$('#tabcontent1').css({"display":"none"});
				$('#tabcontent2').fadeIn("slow");
				$('#tab1a a').css({"color":"#ccc"});
				$('#tab1a').css({"background-image":"URL(images/footer-tab-down.jpg)"});
				$('#tab2a a').css({"color":"#009900"});
				$('#tab2a').css({"background-image":"URL(images/footer-tab.jpg)"});
			} else if (tabId=='close') {
				$('#tabcontent1').slideUp();
				$('#tabcontent2').slideUp();
				$('#tab1a a, #tab1a a:visited, #tab1a a:active').css({"color":"#666666"});
				$('#tab2a a').css({"color":"#ccc"});
			}
		
		//alert(tabId);
		});
});

////Tips page shuffle
$(document).ready(function() {
  $('#s1').cycle({
    fx:     'shuffle',
    timeout: 0,
    next:   '#next1',
    prev:   '#prev1'
	}) 
	
	  $('#s2').cycle({
    fx:     'shuffle',
    timeout: 0,
    next:   '#next2',
    prev:   '#prev2'
	}) 	
	
	$('#s3').cycle({
    fx:     'shuffle',
    timeout: 0,
    next:   '#next3',
    prev:   '#prev3'
	})
	
});
