function frontFlash (){
var flashvars = {};
		
	var params = {};	
	params.scale = "noscale";
	params.salign = "t";
	params.wmode = "transparent";
	
	var attributes = {};
	
	swfobject.embedSWF("../flash/newpreloader.swf", "flashReplace", "100%", "100%", "10.0.0","../expressInstall.swf", flashvars, params, attributes);
}

var addthis_config = {
   ui_click: true
}

function replaceImageAndZoom(imgName, zoomName, fSize, imgFile) {
		document.getElementById(zoomName).href = "/itemimages/" + imgFile;
		replaceImage(imgName, fSize, imgFile);
	}
 
function setTab(link, content) {
    var tabContainer = $(link).up().up();
    var tab = $(link).up();

    tabContainer.getElementsBySelector('li').each(function(element) {
        if (element.hasClassName('current')) element.removeClassName('current');
        if (element == tab) element.addClassName('current');
    } .bind(this));

    $('ProductTabContent').childElements().each(function(element) {
        if (element.hasClassName('Description')) element.hide().removeClassName('Description');
        if (element.identify() == content) {
            element.appear({ duration: 0.3 });
        }
        else {
            if (element.visible()) element.fade({ duration: 0.3 });
        }
    } .bind(this));
}

function toggleProductTab(divID, parentID) {
	
	if ($('ProductTabStory')) {
		if ($('ProductTabStory').hasClassName('ProductBottomSelected')) { 
			$('ProductTabStory').removeClassName('ProductBottomSelected'); 
			$('ProductTabStoryLeft').removeClassName('ProductLeftTabSelected').addClassName('ProductLeftTab'); 
			$('ProductTabStoryText').removeClassName('ProductTabTextAreaSelected').addClassName('ProductTabTextArea'); 
			$('ProductTabStoryRight').removeClassName('ProductRightTabSelected').addClassName('ProductRightTab'); 
		}
	}
	if ($('ProductTabDetails')) {
		if ($('ProductTabDetails').hasClassName('ProductBottomSelected')) { 
			$('ProductTabDetails').removeClassName('ProductBottomSelected'); 
			$('ProductTabDetailsLeft').removeClassName('ProductLeftTabSelected').addClassName('ProductLeftTab'); 
			$('ProductTabDetailsText').removeClassName('ProductTabTextAreaSelected').addClassName('ProductTabTextArea'); 
			$('ProductTabDetailsRight').removeClassName('ProductRightTabSelected').addClassName('ProductRightTab');
		}
	}
	if ($('ProductTabCare')) {
		if ($('ProductTabCare').hasClassName('ProductBottomSelected')) { 
			$('ProductTabCare').removeClassName('ProductBottomSelected'); 
			$('ProductTabCareLeft').removeClassName('ProductLeftTabSelected').addClassName('ProductLeftTab'); 
			$('ProductTabCareText').removeClassName('ProductTabTextAreaSelected').addClassName('ProductTabTextArea'); 
			$('ProductTabCareRight').removeClassName('ProductRightTabSelected').addClassName('ProductRightTab');
		}
	}
	if ($('ProductTabReviews')) {
		if ($('ProductTabReviews').hasClassName('ProductBottomSelected')) { 
			$('ProductTabReviews').removeClassName('ProductBottomSelected'); 
			$('ProductTabReviewsLeft').removeClassName('ProductLeftTabSelected').addClassName('ProductLeftTab'); 
			$('ProductTabReviewsText').removeClassName('ProductTabTextAreaSelected').addClassName('ProductTabTextArea'); 
			$('ProductTabReviewsRight').removeClassName('ProductRightTabSelected').addClassName('ProductRightTab');
		}
	}
		
    if ($(divID).hasClassName('Description')) {
        $(divID).hide().removeClassName('Description');
    }

    var divs = $(parentID).getElementsBySelector('div');

    $(divs).each(function(e) {
        if ($(e).visible() && $(e).identify() != divID) {
            $(e).fade({ duration: 0.1 });
        }

        if (!$(e).visible() && $(e).identify() == divID) {
            $(e).appear({ duration: 0.1 });
        }
    });
    
    var selTab = divID.replace('Product', 'ProductTab');
    $(selTab).addClassName('ProductBottomSelected');
    $(selTab + 'Left').addClassName('ProductLeftTabSelected').removeClassName('ProductLeftTab'); 
		$(selTab + 'Text').addClassName('ProductTabTextAreaSelected').removeClassName('ProductTabTextArea'); 
		$(selTab + 'Right').addClassName('ProductRightTabSelected').removeClassName('ProductRightTab');  
}

function updateSwatch(id) {
	if ($('swatch_' + id)) {
		$$('#ProductSwatchList li').invoke('removeClassName', 'ProductSwatchSelected');
		$('swatch_' + id).addClassName('ProductSwatchSelected');
		
		if ($('swatchimage_' + id)) {
			$('ProductSwatchSectionTopBoxRight').innerHTML = $('swatchimage_' + id).alt;
			$('ProductImageBig').alt = $('swatchimage_' + id).alt;
			$('ProductImageBig').src = $('swatchimage_' + id).src.replace(/19/g,'49');
			
			updateSizes($('swatchimage_' + id).alt);
		}
		
		if ($('option_' + id)) { replaceImageAndZoom('imgMain', 'imgZoom', 256, $('option_' + id).value.split('|')[4]); }
		if ($('thumbs_' + id)) {
			$$('#ProductSmallThumbnails .thumbnails').invoke('hide');
			$('thumbs_' + id).show(); 
		}
		if ($('ProductReadStoryMain')) { 
			if ($('option_' + id) && $('option_' + id).value.split('|')[6] == "show") {
				$('ProductReadStoryMain').show();
				$('ProductReadStoryMain').href = "/templates/product_colorstory.asp?option_id=" + id; 
			}
			else {
				$('ProductReadStoryMain').hide();
			}
		}
		if ($('ProductReadStorySide')) { 
			if ($('option_' + id) && $('option_' + id).value.split('|')[6] == "show") {
				$('ProductReadStorySide').show();
				$('ProductReadStorySide').href = "/templates/product_colorstory.asp?option_id=" + id; 
			}
			else {
				$('ProductReadStorySide').hide();
			}			
		}	
		
		if ($('ProductReadStorySide2')) { 
					if ($('option_' + id) && $('option_' + id).value.split('|')[6] == "show") {
						$('ProductReadStorySide2').href = "/templates/product_colorstory.asp?option_id=" + id; 
					}
					else {
						$('ProductReadStorySide2').href = "javascript:void(0)";
					}			
		}	
	}
}

function updateSizes(clr) {
	//clear selection, hide all, and set everything out of stock
	$$('#ProductSizeArea li').invoke('removeClassName', 'ProductSizeSelected').invoke('addClassName', 'ProductSizeNotInStock').invoke('hide');
	$$('#ProductSizeArea li a div').invoke('removeClassName', 'ProductSelected').invoke('removeClassName', 'ProductDown').invoke('addClassName', 'ProductNotStocked');
	
	var aOptions = $('ProductSwatchSectionTopBox').getElementsBySelector('input[@type="hidden"]');
	var hasSelect = false;
	for (var i = 0, len = aOptions.length; i < len; ++i) {
		var aOption = aOptions[i].value.split('|')[1].split(';');
		if (aOption[1].split('=')[1] == clr) {
			$('currentColor').value = clr;
    	var iQty = aOptions[i].value.split('|')[3];
    	var size = aOption[0].split('=')[1];    	
    	if ($('ProductSize' + size)) { 
    		$('ProductSize' + size).show();
    		if (parseInt(iQty) > 0) {
    			$('ProductSize' + size).removeClassName('ProductSizeNotInStock');     	
    			if ($('ProductSizeText' + size)) { $('ProductSizeText' + size).removeClassName('ProductNotStocked'); }
    			if (!hasSelect) { selectSize(size); hasSelect = true; }    	 
    		}
    	}
    }    
	}
	//if nothing is in stock, disable add to cart
	if (!hasSelect)	{		
		$('ProductBuyAreaLink').hide();
	}
	else {
		$('ProductBuyAreaLink').show();
	}
}

function selectSize(size) {
	if ($('ProductSize' + size)) {
		if ($('ProductSize' + size).hasClassName('ProductSizeNotInStock')) { return; }
		$$('#ProductSizeArea li').invoke('removeClassName', 'ProductSizeSelected');
		$$('#ProductSizeArea li a div').invoke('removeClassName', 'ProductSelected').invoke('addClassName','ProductDown');
		$('ProductSize' + size).addClassName('ProductSizeSelected');
		if ($('ProductSizeText' + size)) { $('ProductSizeText' + size).removeClassName('ProductDown').addClassName('ProductSelected'); }		
		
		var optText = "Size=" + size + ";Color=" + $('currentColor').value;
		var aOptions = $('ProductSwatchSectionTopBox').getElementsBySelector('input[@type="hidden"]');
		for (var i = 0, len = aOptions.length; i < len; ++i) {
			var aOption = aOptions[i].value.split('|');
			if (optText == aOption[1]) {
				$('options').value = aOption[0] + ";" + aOption[5];
				break;
			}
    }    
	}
}

function AddToCart(productID,qty,opts) {
	
		//if (qty > parseInt($('baseQty').value)) {
		//	alert('Low stock alert, only ' + $('baseQty').value + ' available for purchase.');
		//	return false;
		//}
	
		showProduct('Shopping Basket',qty,productID,opts);			

		var itemsinbag=0;
		
		//check out header.asp wrap span tag around it pull the innerhtml out of it and add the quantity to the number.....
		//get innerhtml of  document.getElementById('spnCartCount').innerHTML
		itemsinbag=document.getElementById('spnCartCount').innerHTML;
		itemsinbag=itemsinbag.replace('(','');
		itemsinbag=itemsinbag.replace(')','');
		var totalItems = parseInt(qty) + parseInt(itemsinbag);
		
		//add to bag....
		document.getElementById('spnCartCount').innerHTML = '' + totalItems.toString() + '';
				
		return(false);
	}
	
function showProduct(title,qty,productID,opts) {
		var page = "/ajax_addedtocart.asp?prod=" + productID.toString() + "&quantity=" + qty.toString();
		if (opts != '') { page +=  "&options=" + opts.replace("'","''"); }
		
		showLightWindow(page, title, 460, 500);	 	
	}

function showLightWindow(iUrl,iTitle,iWidth,iHeight){
		if (iTitle.length > 40)	{
			iTitle = iTitle.substring(0,40);
		}
		//  Create the lightwindow
		myLightWindow.activateWindow({
			href: iUrl,
			type: 'page',
			title: iTitle,
			width: iWidth,
			height: iHeight
		});
	}	

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

$(function () {
    var tabContainers = $('div.tabs > div');
    
    $('div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
});


var Cat_Name;
var Cat_ID;
var lbColorSelected=false;
var docSubmitted;
var colorSelected;
//document.frmSort.action = '<%=rootLink%><%=removeIllegalCharacters(subCatName)%>/<%=removeillegalCharacters(subCatName)%>.asp';
function submitME(docSubmitted,lbColorSelected,Cat_Name,subCatName,Cat_ID,colorSelected,rootlink) {
	if (lbColorSelected) {
		colorSelected = Cat_ID;
		docSubmitted.action = rootlink + subCatName + '/' + subCatName + '/'  + Cat_Name + '-' + Cat_ID + '-CL.aspx';
	}
	docSubmitted.submit();
}

function showMore() {
       var element = "moreToShow";
       if ($(element) && $(element).up().next('div')) {
		var menu = $(element)  //.up().next('div');
		if (menu.hasClassName('Description')) menu.hide().removeClassName('Description');
		if (!menu._moving) menu._moving = false;

		if (!menu._moving) {
			if (!menu.visible()) {
				menu._moving = true;
				Effect.BlindDown(menu, { delay: 0.2, duration: 0.3, transition: Effect.Transitions.sinoidal, afterFinish: function() { menu._moving = false; } .bind(this) });
				$("ClassificationReadMoreButton").innerHTML = " - READ LESS";
			}
			else {
				menu._moving = true;
				Effect.BlindUp(menu, { delay: 0.2, duration: 0.3, transition: Effect.Transitions.sinoidal, afterFinish: function() { menu._moving = false; } .bind(this) });
				$("ClassificationReadMoreButton").innerHTML = " + READ MORE";
			}
		}
	}
}


