//START Homepage slide show
var currentTab = 0;
var rotateSpeed = 5000;
var numTabs;
var autoRotate;

function openTab(clickedTab) {
	var thisTab = jQuery("div.contentBox #contentItems li a").index(clickedTab);

	if(thisTab != currentTab){
		jQuery("div.contentBox #contentItems li a").removeClass("selected");
		jQuery("div.contentBox #contentItems li a:eq("+thisTab+")").addClass("selected");
		jQuery("div.contentBox .content").css("z-index", "8").fadeOut(1000);
		jQuery("div.contentBox .content:eq("+thisTab+")").css("z-index", "9").fadeIn(1000);
		currentTab = thisTab;
	}
}

function rotateTabs() {
	var nextTab = (currentTab == (numTabs - 1)) ? 0 : currentTab + 1;
	openTab(jQuery("div.contentBox #contentItems li a:eq("+nextTab+")"));
}
//END Homepage slide show

$.noConflict();

jQuery(document).ready(function($) {

	// Main navigation menu
	$('div.subNav ul:not(.subNavMenu) li').hover(
		function() {
			$('ul', this).stop(true, true).show('300');
		},
		function() {
			$('ul', this).stop(true, true).hide('fast');
		}
	);

	// START Homepage slide show
	numTabs = $("div.contentBox #contentItems li a").length;

	$("div.contentBox #contentItems li a").click(
		function() {
			openTab($(this));
			return false;
		}
	);

	$("div.contentBox").mouseover(
		function(){
			clearInterval(autoRotate)}
		)
	.mouseout(
		function(){
			autoRotate = setInterval("rotateTabs()", rotateSpeed)
		}
	);

	$("div.contentBox #contentItems li a:eq("+currentTab+")").click();

	$("div.contentBox").mouseout();
	// END Homepage slide show
	
	
 });

jQuery.fn.showHideContent = function(charToShow) {
	
	if(jQuery(this).html().length > charToShow){
	
		var text = jQuery(this).html().replace(/<p>/g,"").replace(/<\/p>/g,"<br><br>");
		var hiddenPageText = text.substring(charToShow,jQuery(this).html().length);
	
		if(hiddenPageText.length < 30){
			return;
		}
		var visPageText = text.substring(0,charToShow);
		jQuery(this).css("cursor", "pointer").html(visPageText+"<span id='moreTag' class='moreTextLnk'>&nbsp;&nbsp;&nbsp;more...</span><span id='hiddenTag' style='display:none;'>"+hiddenPageText+"</span>");
		
		jQuery(this).click(
		  function(){
		   var innerText = jQuery(this).find('#hiddenTag');
		   var moreText = jQuery(this).find('#moreTag');
		   if(innerText.css('display')=='none'){
			   moreText.hide();
			   innerText.show();
			} else {
				innerText.hide();
				moreText.show('slow');
			   
			}
		  }
		 );
	 
	}
}

//Opens popup window showing some html content
//This window uses product QuickView styles 
function openPopUpInfo(htmlContent,wwidth,wheight,wresize,wshow,whide,wtop,wleft,wmodal) {
	var win = new Window({className:'pqv',width:wwidth,height:wheight,zIndex:10000,resizable:wresize,showEffect:wshow,hideEffect:whide,wiredDrag:true,minimizable:false,maximizable:false,effectOptions:{duration: 0.2},destroyOnClose: true}); 
	win.setHTMLContent('<div style="text-align:left;">'+htmlContent+'</div>');
	win.showCenter(wmodal,wtop,wleft);	
}
