function prdColorSwap(prdCode, whichOption, attrPrdCode, isComingSoon, txtComingSoon, updateProductPrice)
{
    var isMainProduct = false;
    if((attrPrdCode == mainPrd) || (whichOption != null) || (prdCode != null)) { isMainProduct = true; }
    if(isMainProduct)
    {
		var whichAttr = "attr_" + mainPrd;
		if((whichOption != null) && (document.getElementById(whichAttr) != null)) { document.getElementById(whichAttr).selectedIndex = whichOption; }
		if(prdCode == null) { prdCode = document.getElementById(whichAttr).value; }
        
		if((document.getElementById(whichAttr) == null) || (document.getElementById(whichAttr).selectedIndex != 0))
		{
			whichPrdImage = "prd_" + prdCode;
			mainImage = whichPrdImage;
			if(document.getElementById("product_image") != null)
			{
				document.getElementById("product_image").src = "/images/store/products/" + whichPrdImage + ".jpg";
			}
		}
		
		if(isComingSoon)
		{
			if(txtComingSoon != null)
			{
				document.getElementById('priceText').innerHTML = txtComingSoon;
			}
			else
			{
				document.getElementById('priceText').innerHTML = "Coming Soon";
			}
			whichPrdImage = "prd_" + prdCode;
			mainImage = whichPrdImage;
			if(document.getElementById("product_image") != null)
			{
				document.getElementById("product_image").src = "/images/store/products/" + whichPrdImage + ".jpg";
			}
			document.getElementById(whichAttr).selectedIndex = 0;
		}
		else if(updateProductPrice)
		{
			changePriceText(whichAttr);
		}
		else
		{
			if(document.getElementById('priceText'))
			{
				document.getElementById('priceText').innerHTML = mainPrdPrice;
			}
		}
		
		/* Add if monogramming
		
		if((attrPrdCode == 22000) && (checkPrdPattern(attrPrdCode)) && (document.getElementById("monogramCheck").checked))
		{
			alert('Monogramming cannot be added to patterns or stripes.  Please select a solid color if you wish to add monogramming.');	
			var whichAttr = "attr_&mvte:product:code;";
			document.getElementById("monogramCheck").checked = false;
			monogramCheck();
		}
		*/

    }
}


// ********** BEGIN UPDATED PRODUCT IMAGE SWAP - 2/12/2011 ********** //

function prdImageSwap(optionCode, whichOption, attrPrdCode, isComingSoon, txtComingSoon, updateProductPrice, updateCaptionText, newCaptionText)
{
    var isMainProduct = false;
    if((attrPrdCode == mainPrd) || (whichOption != null) || (optionCode != null)) { isMainProduct = true; }
    if(isMainProduct)
    {
		var whichAttr = "attr_" + mainPrd;
		if((whichOption != null) && (document.getElementById(whichAttr) != null)) { document.getElementById(whichAttr).selectedIndex = whichOption; }
		if(optionCode == null) { optionCode = document.getElementById(whichAttr).value; }
		
		if((document.getElementById(whichAttr) == null) || (document.getElementById(whichAttr).selectedIndex != 0))
		{
			whichPrdImage = "prd_" + optionCode;
			mainImage = whichPrdImage;
			if(document.getElementById("product_image") != null)
			{
				document.getElementById("product_image").src = "/images/store/products/" + mainPrd + "/" + whichPrdImage + ".jpg";
			}
			
			
		
			if((document.getElementById("prdCaption") != null) && (updateCaptionText == true) && (document.getElementById(whichAttr)))
			{
				menuText = document.getElementById(whichAttr).options[document.getElementById(whichAttr).selectedIndex].text
				if(menuText.indexOf(" - Add") > -1) { menuText = menuText.substring(0, menuText.indexOf(" - Add")); }
				if(menuText.indexOf(" - $") > -1) { menuText = menuText.substring(0, menuText.indexOf(" - $")); }
				document.getElementById("prdCaption").innerHTML = menuText;
			}
			else if((updateCaptionText == true) && (newCaptionText != null))
			{
				document.getElementById("prdCaption").innerHTML = newCaptionText;
			}
		}
		
		if(isComingSoon)
		{
			if(txtComingSoon != null)
			{
				document.getElementById('priceText').innerHTML = txtComingSoon;
			}
			else
			{
				document.getElementById('priceText').innerHTML = "Coming Soon";
			}
			whichPrdImage = "prd_" + optionCode;
			mainImage = whichPrdImage;
			
			if(document.getElementById("product_image") != null)
			{
				document.getElementById("product_image").src = "/images/store/products/" + mainPrd + "/" + whichPrdImage + ".jpg";
			}
			document.getElementById(whichAttr).selectedIndex = 0;
		}
		else if(updateProductPrice)
		{
			changePriceText(whichAttr);
		}
		else
		{
			if(document.getElementById('priceText'))
			{
				document.getElementById('priceText').innerHTML = mainPrdPrice;
			}
		}
		
		/* Add if monogramming
		
		if((attrPrdCode == 22000) && (checkPrdPattern(attrPrdCode)) && (document.getElementById("monogramCheck").checked))
		{
			alert('Monogramming cannot be added to patterns or stripes.  Please select a solid color if you wish to add monogramming.');	
			var whichAttr = "attr_&mvte:product:code;";
			document.getElementById("monogramCheck").checked = false;
			monogramCheck();
		}
		*/

    }
}

// ********** END UPDATED PRODUCT IMAGE SWAP ********** //


// ********** BEGIN PRODUCT IMAGE ENLARGE ********** //

var useNewScript = new Boolean(0);

function enlargeImage(whichImage, imgWidth, imgHeight)
{
	var dImgWidth = "375";
	var dImgHeight = "375";
	
	if(imgWidth != null) { dImgWidth = imgWidth; }
	if(imgHeight) { dImgHeight = imgHeight; }
	
	var imagePath = "/mm5/item_zoom.cgi?iid=";
	
	if(useNewScript == 1)
	{
		imagePath = imagePath + mainPrd + "/";
	}
	
    if(whichImage == null)
    {
		imagePath = imagePath + mainImage + "_exp.jpg";
    }
    else
    {
        imagePath = imagePath + whichImage + "_exp.jpg";
    }
	
	var prdImageEnlarged = window.open(imagePath, "prdImageEnlarged", "width=" + dImgWidth + ", height=" + dImgHeight + ", menubar=0, statusbar=0; scrollbars=0; scrolling=0");
	
	if(prdImageEnlarged) { prdImageEnlarged.focus(); }
}

function submitForm(whichForm,whichAttr)
{
    if(document.getElementById(whichAttr) != null)
    {
        if(document.getElementById(whichAttr).selectedIndex == 0)
        {
            alert('Please make a selection');
        }
        else
        {
            document.getElementById(whichForm).submit();
        }
        
    }
    else
    {
        document.getElementById(whichForm).submit();
    }
}

// ********** END PRODUCT IMAGE ENLARGE ********** //


//



// Product Tab Change //

var activeTab = "";
var tabHeader = "tabheader";

function switchTab(whichTab) {
	var newTab = "product_tab_" + whichTab;
	var newClass = "cls_" + whichTab;

	if (newTab != activeTab) {
		if (document.getElementById(newTab)) document.getElementById(newTab).style.visibility = "visible";
		if (document.getElementById(activeTab)) document.getElementById(activeTab).style.visibility = "hidden";
		document.getElementById(tabHeader).setAttribute("class", newClass);
		document.getElementById("product_tab_module").style.height = document.getElementById(newTab).offsetHeight + "px";
		activeTab = newTab;
	}
}

function setTabHeight() {
	if (document.getElementById("product_tab_module")) {
		if (activeTab == "") { activeTab = "product_tab_about"; }
		document.getElementById("product_tab_module").style.height = document.getElementById(activeTab).offsetHeight + "px";
	}
}

window.onload = setTabHeight;

//************************* CODE BELOW IS BEING DEPRECIATED.  IN USE FOR CERTAIN OLDER PRODUCTS *************************//
//***********************************************************************************************************************//
//***********************************************************************************************************************//
//***********************************************************************************************************************//

// Product Tab Change //

var tabs = new Array("tab_about", "tab_features", "tab_details", "tab_wheretobuy");
var tabsItems = new Array("SHI0209", "SHI0042", "SHI0207", "SHI0198", "SHI0196", "SHI0043", "SHI0044", "SHI0045", "SHI0046", "SHI0047", "305005", "305006", "306000", "306001", "306003", "306006", "276001", "276002", "276004", "276005");

function switchModule(whichTable) {

	document.getElementById(whichTable).style.visibility = "visible";
	for (i = 0; i < tabs.length; i++) {
		if (document.getElementById(tabs[i]) != null) {
			if (document.getElementById(tabs[i]) != document.getElementById(whichTable)) {
				document.getElementById(tabs[i]).style.visibility = "hidden";
			}
		}
	}
	document.getElementById("module").style.height = document.getElementById(whichTable).offsetHeight + "px";
	if (mainImage == "prd_TBBD") {
		alert(document.getElementById("module").style.height);
	}
}


function switchItemsModule(whichTable, whichAttr) {
	var thisTable = "";
	var isItemsTable = false;
	thisTable = whichTable;
	for (i = 0; i < tabsItems.length; i++) {
		if ((tabsItems[i] == thisTable) && (document.getElementById("tab_" + thisTable) != null)) {
			isItemsTable = true;
			document.getElementById("tab_" + thisTable).style.visibility = "visible";

			for (i = 0; i < tabsItems.length; i++) {
				if (document.getElementById("tab_" + tabsItems[i]) != null) {
					if (document.getElementById("tab_" + tabsItems[i]) != document.getElementById("tab_" + thisTable)) {
						document.getElementById("tab_" + tabsItems[i]).style.visibility = "hidden";
					}
				}
			}
			document.getElementById("module").style.height = document.getElementById("tab_" + thisTable).offsetHeight + "px";
		}
	}
	if (isItemsTable && whichAttr != null) {
		changePriceText(whichAttr);
	}
}

function changeOptions(whichAttr) {
	var optionText = "";

	if (document.getElementById(whichAttr)) {
		for (var i = 1; i < document.getElementById(whichAttr).children.length; i++) {
			optionText = document.getElementById(whichAttr).children[i].innerHTML;
			if (optionText.indexOf("Add ") != -1) {
				document.getElementById(whichAttr).children[i].innerHTML = optionText.substring(0, optionText.indexOf("Add ")) + optionText.substring(optionText.indexOf("Add ") + 4, optionText.length);
			}
		}
	}
}

function changePriceText(whichAttr) {
	if ((document.getElementById(whichAttr)) && (document.getElementById(whichAttr).selectedIndex != 0)) {
		var optionText = document.getElementById(whichAttr).children[document.getElementById(whichAttr).selectedIndex].innerHTML;
		document.getElementById('priceText').innerHTML = optionText.substring(optionText.indexOf("$"), optionText.length);
	}

}
