/*move the background position of the menu item for current section -custom*/
$(document).ready(function(){
	$("#menu").find("a").each(function(i){
	 	if ($(this).attr("rel") == $("body").attr("class")){
	 		$(this).addClass("active");
			$(this).parent("li").addClass("active");
		 };
	});
});
/*same again for sub menu - custom*/
$(document).ready(function(){
	$("#sub-menu ul").find("a").each(function(i){
	 	if ($(this).attr("rel") == $("h1").attr("id")){
	 		$(this).addClass("sub-active");
		 };
	});
});
/*suckerfish dropdown menu -relies on jquery.superfish.js - (has been customised) and also relies on bgiframe.js */
$(document).ready(function(){
	$("#menu")
	.superfish({
		animation : { opacity:"show",height:"show"}
	})
	.find("li[ul]")
		.mouseover(function(){
			$("ul", this).bgiframe();
		})
		.focus(function(){
			$("ul", this).bgiframe();
		});
});
/*open external links - custom- nice accessible html :-) */
$(document).ready(function() {
	$("a[@rel='external']").click(function() {
		return !window.open($(this).attr("href"));
		});
})
/* remove ugly dotted outline from Firefox - custom*/
$(document).ready(function() {
    $('a').click(function() {
		this.blur();
	});
});
/* custom WIP - tabs for top tips section - once the last object is identified and removed this script is good to go*/
$(document).ready(function(){
	$(".tab-links").find("ul").each(function(i){
		if ($(this).attr("id") != "section-1"){
	 		$(this).css("display","none");
		}
	});
});

$(document).ready(function(){
var tabcurrent = null;
var tablast = null;				   
	$(".tab-links").find("a").each(function(i){
		$(this).click(function() {
			  if (tabcurrent != null) {
    				tablast = tabcurrent;
    				$(tablast).css({zIndex : "0"}).fadeOut("slow");	
  			}
			$(this).next().fadeIn("slow");return false;
  			tabcurrent = $(this).next("ul").attr("id");	
		});
	});
});
/*show & hide on product pages - custom*/
$(document).ready(function(){
	$(".prod-def").find("dt").each(function(i){
			$(this).css("cursor","pointer");
			$(this).next("").css("display","none");
	 		$(this).click(function(){
				$(this).next("dd").slideToggle("fast");					   
			});
	});
});
/*-relies on jquery.innerfade.js */
$(document).ready( function(){ 
			$('#product-shots').innerfade({ 
				speed: "slow", 
				timeout: 4000, 
				type: 'sequence', 
				containerheight: '150px' 
				});
	} );

/* conflicts occuring - may be simpler to do a css :hover statement */
/*$().ready(function(){			   
	$('#tooltip1').ToolTip({
				   className: 'tooltip1',
				   position: 'top',
				   delay: 200
	});
});
$().ready(function(){			   
	$('#tooltip2').ToolTip({
				   className: 'tooltip2',
				   position: 'top',
				   delay: 200
	});
});*/



var newwindow;
function poptastic(url, sWidth, sHeight)
{
	if (sWidth==null){
		sWidth=500;
		sHeight=500;
	}
	
	newwindow=window.open(url,'name','height='+sHeight+',width='+sWidth+',resizable=no,scrollbars=no,toolbar=no,status=yes');
	if (window.focus) {newwindow.focus()}
}

function expandIt(whichEl){
    whichEl.style.display = (whichEl.style.display == "none" ) ? "" : "none";
}

function showhide(whichEl, whichImg){
	show = new Image();
	hide = new Image();
	show.src = "../objects/img/icon_show.gif";
	hide.src = "../objects/img/icon_hide.gif";
	if (whichEl.style.display=='none'){
		whichEl.style.display='';
		whichImg.src=hide.src
	} else {
		whichEl.style.display='none'
		whichImg.src=show.src
	}	
}

function doBookmark(sURL){
var url = 'http://www.localkingsmill.co.uk/'
var title  = 'Local Kingsmill'
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}