//handle Product Overview Features / Use/Care Tabs
var currentTab = "";
var originalHero = "";

function ShowTab(TabName,me) {
	HideAllTabs();
	ClearSelected();
	setTimeout('Effect.Appear("'+TabName+'")',500)
	me.parentNode.addClassName("TabLink");
	me.parentNode.addClassName("Selected");

	if (TabName == "ItemPhotoGallery") {
		HideColorPicker();
	}

	if (currentTab == "ItemPhotoGallery") {
		ShowColorPicker();
		SwitchProductHero(originalHero);
		Effect.Fade('ReturnToProduct');
	}

	currentTab = TabName;
}

function HideAllTabs() {
	$('FeatureBenefit').getElementsBySelector(".Tab").each(function(tab){Effect.Fade(tab,{duration:0.25})});
	//$('FeatureBenefit').getElementsByClassName("Tab").each(function(tab){Effect.Fade(tab,{duration:0.25})});
}

function ClearSelected() {
	$('FeatureBenefit').getElementsBySelector(".TabLink").each(function(tablink){tablink.className="TabLink"});
	//$('FeatureBenefit').getElementsByClassName("TabLink").each(function(tablink){tablink.className="TabLink"});
}
/* end PRODUCT OVERVIEW TABS */

function DeselectColors() {
	if ($('ColorPicker')) {
		$('ColorPicker').getElementsBySelector(".Color").each(function(color){color.className="Color"});
		//$('ColorPicker').getElementsByClassName("Color").each(function(color){color.className="Color"});
	}
}

function ShowColorPicker() {
	if ($('ColorPicker')) {
		Effect.Appear('ColorPicker');
	}
}


function HideColorPicker() {
	if ($('ColorPicker')) {
		Effect.Fade('ColorPicker');
	}
}

function SwitchProductHero(imgpath,link,showReturn) {
	if (originalHero == "") {
		originalHero = $('ProductHero').src;
	}

	DeselectColors();
	Effect.Fade('ReturnToProduct',{duration:.25});
	Effect.Fade('ProductHero',{duration:.25});
	setTimeout('imageSwitch("' + imgpath + '")', 250);
	setTimeout('Effect.Appear("ProductHero")',750)

	if (showReturn) {
		setTimeout('ShowReturn()',800);
	}

	if (typeof(link) == "object") {
		link.addClassName("Selected");
	}
}

function ShowReturn() {

	if ( $('ProductHero').src != originalHero ) {
		showReturn = true;
	} else {
		showReturn = false;
	}

	if (showReturn) {
		setTimeout('Effect.Appear("ReturnToProduct")',250);
	}
}

function ReturnToProduct() {
	ShowTab('ItemFeatures',$('ItemFeaturesLink'));
}

function imageSwitch(imgpath) {
	$('ProductHero').src = imgpath;
}


function EmailFriendPopup(ProductID) {
	var popUp = window.open("/shop/emailfriend.asp?id="+ProductID, 'emailfriend', 'width=620, height=450,scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
	popUp.focus();
}

function DoBoink() {
	Effect.Appear('FeatureHighlight',{duration:.25});
	setTimeout('Effect.Pulsate("FeatureHighlight",{duration: 2})',500);
	setTimeout('Effect.Fade("FeatureHighlight",{duration:.5})',2250);
}

function ResizeIFrameToContent(iframe) {
	if (iframe.contentDocument && iframe.contentDocument.body.offsetHeight) //ns6 syntax
		iframe.height = iframe.contentDocument.body.offsetHeight+30;
	else if (iframe.Document && iframe.Document.body.scrollHeight) //ie5+ syntax
		iframe.height = iframe.Document.body.scrollHeight+30;

}