//Tabbed Featured Items

function changeTabbedItem(b){
if(b == "1")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-61819287486445/ey-tabbedLinksBG.jpg) no-repeat scroll center top");
}
else if(b == "2")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-61819287486445/ey-tabbedLinksBG.jpg) no-repeat scroll center -44px");
}
else if(b == "3")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-61819287486445/ey-tabbedLinksBG.jpg) no-repeat scroll center -88px");
}
else if(b == "4")
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-61819287486445/ey-tabbedLinksBG.jpg) no-repeat scroll center -132px");
}
else
{
$(".tabbedLinks").css("background", "url(http://lib.store.yahoo.net/lib/yhst-61819287486445/ey-tabbedLinksBG.jpg) no-repeat scroll center -176px");
}

$(".tabbedA").removeClass('selectedTab');
$("#TabbedA" + b).addClass('selectedTab');
$(".tabbedItemsTable").css("display", "none");
$("#TabbedItemsTable" + b).css("display", "block");

}

//Instruction Tabs

function changeInsTab(b){

$(".guideTabs").css("display", "none");
$("#GuideTab" + b).css("display", "block");
if(b=="2" || b=="3")
{
$(".translateImage").css("display", "none");
}
else
{
$(".translateImage").css("display", "block");
}

}


//Rotate Testimonials

function writeTestimonial()
{
var refreshId = setInterval(function()
{
$(".testimonials").hide();
$(".testimonials").html("");
randomnumber=Math.floor(Math.random()*out.length);
$(".testimonials").append(out[randomnumber]);
$(".testimonials").fadeIn("slow");
}, 10000);

}


//Rotate

function startRotate()
{
intervalId=setInterval('slideshow()', 6000);
}

var num = 0;

function slideshow() {
num++;
if (num == howMany)
{
num = 0;
}
$(".image_thumb ul li:eq("+num+") a").trigger("click");
}

$(document).ready(function(){
howMany = $(".image_thumb li").length;

startRotate();
});

//Multiple Suckertree Menu Vertical 

var menuclass=["suckertree1"] //Enter class(es) of SuckerTree UL menus, separated by commas

function buildsubmenus(){
for (var i=0; i<menuclass.length; i++)
	{
	for(var rang=0,rangUl=document.getElementsByTagName('ul');rang<rangUl.length;rang++){
	if(rangUl[rang].className==menuclass[i])
	{
		var ultags=rangUl[rang].getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
		if (ultags[t].parentNode.parentNode.className==menuclass[i]) //if this is a first level submenu
			ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
		else //else if this is a sub level submenu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.display="block"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none"
    }
    }
		for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
		ultags[t].style.visibility="visible"
		ultags[t].style.display="none"
		}}}
	}
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)


function checkQty()
{
var availableText=$(".available").text();
var splitMe=availableText.split(" ");
var result=parseInt(splitMe[0]);

if ($("input[name=vwquantity]").length)
{
if (document.orderForm.vwquantity.value > result)
{
alert("We're sorry.  There are only "+result+" of this item available.  Please re-enter a valid quantity.");
$("input.theqty").val(result);
return false;
}
else
{
document.orderForm.submit();
}
}
else
{
if (document.orderForm.vwquantity0.value > result)
{
alert("We're sorry.  There are only "+result+" of this item available.  Please re-enter a valid quantity.");
$("input.theqty").val(result);
return false;
}
else
{
document.orderForm.submit();
}
}
}
