$(function() {
		   
	//$('input[type="text"]').addClass("text");			   
	//$('input[type="radio"]').addClass("radio");
	//$('input[type="checkbox"]').addClass("checkbox");
	//$('input[type="image"]').addClass("image");
	
	$('.listing li:nth-child(7n)').addClass("last");
	
	
	 // inside labels for inputs
	 $("input, textarea").labelify();
	
	 // home page slider
	 $('#slider1').anythingSlider({
	  buildArrows : false,
	  delay : 4000,
	  navigationFormatter : function(index, panel){
		  // Format navigation labels with text
		  return ['Product Range', 'Downloads', 'Need to know', 'Help'][index - 1];
	  }
	 });
	 
	 // Product detail options slide panel
	 $('#opts .panel .colours li:first-child').addClass("first");
	 $('#opts .panel .colours li:nth-child(9n)').addClass("last");
	 $('#opts .panel .accs li:nth-child(4n)').addClass("last");
	 
	 // ie fix, as not rendering transparent png correctly during opacity animation
	 //$('.plus-overlay').css('filter', 'alpha(opacity=50)');
	 
	 $("#opts a").hover(function() {
		$(this).next(".panel").animate({opacity: "show", left: "-309"}, "slow");
		//$(this).find('.plus-overlay').animate({opacity: "show"}, "slow");					
	 }, function() {
		$(this).next(".panel").animate({opacity: "hide", left: "-319"}, "fast");
		//$(this).find('.plus-overlay').animate({opacity: "hide"}, "fast");
		//$(this).find('.plus-overlay').hide();
	 });

	 jQuery.each(jQuery.browser, function(i) {
	 if($.browser.msie){	 
		 $("#opts a").hover(function() {
			$(this).find('.plus-overlay').show();	
						
		 }, function() {
			$(this).find('.plus-overlay').hide();
		 });
	 }else{
		 $("#opts a").hover(function() {
			$(this).find('.plus-overlay').animate({opacity: "show"}, "slow");	
						
		 }, function() {
			$(this).find('.plus-overlay').animate({opacity: "hide"}, "fast");
		 });
	 }
     });
		



});

function pageLoad() {
	
$("input, textarea").labelify();

}



// DOM READY
$(function() {


	// Basket modal
	$modal = $("#mdlPopup");
	modalH = $modal.outerHeight();
	modalW = $modal.outerWidth();
	windowH = $(window).height();
	windowW = $(window).width();
	$modal.before("<div id=\"overlay\"><!--[if lte IE 6]><iframe></iframe><![endif]--></div>");
	$overlay = $("#overlay").css({ height: $(document).height(), opacity: "0.6" });

	// Info modal
	$infomodal = $("#infomdlPopup");
	infomodalH = $infomodal.outerHeight();
	infomodalW = $infomodal.outerWidth();
	windowH = $(window).height();
	windowW = $(window).width();
	$infomodal.before("<div id=\"overlay\"><!--[if lte IE 6]><iframe></iframe><![endif]--></div>");
	//alert($modal);


	$.models = function() {


		$modal = $("#mdlPopup");
		modalH = $modal.outerHeight();
		modalW = $modal.outerWidth();
		windowH = $(window).height();
		windowW = $(window).width();
		$modal.before("<div id=\"overlay\"><!--[if lte IE 6]><iframe></iframe><![endif]--></div>");
		$overlay = $("#overlay").css({ height: $(document).height(), opacity: "0.6" });

		// Info modal
		$infomodal = $("#infomdlPopup");
		infomodalH = $infomodal.outerHeight();
		infomodalW = $infomodal.outerWidth();
		windowH = $(window).height();
		windowW = $(window).width();
		$infomodal.before("<div id=\"overlay\"><!--[if lte IE 6]><iframe></iframe><![endif]--></div>");
		//alert($modal);

	};

});

// Basket modal
basketModal = function(text) {
	modalH = $modal.outerHeight();
	modalW = $modal.outerWidth();
	windowH = $(window).height();
	windowW = $(window).width();
	if (text) $modal.find("p").html(text);
	var left = (windowW / 2) - (modalW / 2);
	var top = ((windowH / 2) + $(window).scrollTop()) - (modalH / 2) - 22;
	$overlay.fadeIn(500);
	$("#overlay iframe").css({ top: top, left: left, width: $modal.outerWidth(), height: $modal.outerHeight() })

	$modal
	.css({ top: top, left: left })
	.fadeIn(500)
	.find("img[class='modal-close'], img[class='continue']")
	.click(function(e) {
		e.preventDefault();
		$modal.hide();
		$overlay.fadeOut(750);
	});
}

$(window).resize(function() {
	modalH = $modal.outerHeight();
	modalW = $modal.outerWidth();
	windowH = $(window).height();
	windowW = $(window).width();
	var left = (windowW / 2) - (modalW / 2);
	var top = ((windowH / 2) + $(window).scrollTop()) - (modalH / 2) - 22;
	if ($modal.is(":visible")) {
		$modal.animate({ top: top, left: left }, 500);
	}
});

// Info modal
infoModal = function(text) {
	infomodalH = $infomodal.outerHeight();
	infomodalW = $infomodal.outerWidth();
	windowH = $(window).height();
	windowW = $(window).width();
	if (text) $infomodal.find("p").html(text);
	var left = (windowW / 2) - (modalW / 2);
	var top = ((windowH / 2) + $(window).scrollTop()) - (infomodalH / 2) - 22;
	$overlay.fadeIn(500);
	$("#overlay iframe").css({ top: top, left: left, width: $infomodal.outerWidth(), height: $infomodal.outerHeight() })

	$infomodal
	.css({ top: top, left: left })
	.fadeIn(500)
	.find("img[class='modal-close'], img[class='continue']")
	.click(function(e) {
		e.preventDefault();
		$infomodal.hide();
		$overlay.fadeOut(750);
	});
}
$(window).resize(function() {
	infomodalH = $infomodal.outerHeight();
	infomodalW = $infomodal.outerWidth();
	windowH = $(window).height();
	windowW = $(window).width();
	var left = (windowW / 2) - (infomodalW / 2);
	var top = ((windowH / 2) + $(window).scrollTop()) - (infomodalH / 2) - 22;
	if ($infomodal.is(":visible")) {
		$infomodal.animate({ top: top, left: left }, 500);
	}
});
	

