


/***************************************
*	Global Site Wide JQuery Functions
**/


function basketPopup() {
	
	if($("#flashBasket").length>0) {
		if(window.location.href.match("added=1")!==null){
			$("#basketMessage").show();
		}
	}
}

$.fn.search = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};



$(function() {
	//ie6 top nav menu
	/*if ($.browser.version<7 && $.browser.msie) {
		$("#nav li").each( function() {
			$(this).bind("mouseover", function() {
				$(this).addClass("sfHover");							   
			}).bind("mouseout", function() {
				$(this).removeClass("sfHover");							   
			});
		});
	}*/


	$("#siteSearch, #emailInput").search();
	$("#basketMessage .continue a,.close").bind("click", function() { 
		$("#basketPopup").fadeOut("slow");
		$("#basketMessage").fadeOut("slow");
	});
	//search form brand/cat jumper
	$("#sBrands,#sCategory").bind("change", function() {
		window.location = '/'+this.value;									 
	});
	
	if($('#preview').length>0) {
		$('.large a').lightBox();
	}
	
});

function incBasket(elm, basket) {

	if($(elm)) {

		//$(elm).val(parseInt($(elm).val())+1);
		document.getElementById(elm).value = parseInt(document.getElementById(elm).value)+1	
		if(basket==true) {
			submitDoc('cart');
		}
	}
}
function decBasket(elm, basket, limit) {

	if($(elm)) {
		if(parseInt(parseInt(document.getElementById(elm).value))>limit) {
			//$(elm).val(parseInt($(elm).val())-1);
			document.getElementById(elm).value = parseInt(document.getElementById(elm).value)-1	
		}
		if(basket==true) {
			submitDoc('cart');
		}
	}
}


// prod detail/cart tabs
$(function() {
	
	/*$(".also a").click(function() {
		showTab1();
	});
	
	$(".related a").click(function() {
		showTab2();
	});

	if($("#tab div").length>1) {
		//if we have customers also bought products ... 
		showTab1();
	} else if ($("#tab2 div").length>1) {
		//else if we have related products ...
		showTab2();
	}*/
	
});

function showTab1() {
	$(".also").addClass("active");
	$(".related").removeClass("active");
	$("#tab2").hide();
	$("#tab").show();
}

function showTab2() {
	$(".related").addClass("active");
	$(".also").removeClass("active");
	$("#tab").hide();
	$("#tab2").show();
}

function changeLb(elm,imgSrc,thumbNo) {
	$('#'+elm).attr("href", imgSrc);
}



