var jQZoomOffsetW = 0; var jQZoomOffsetH = 0; var largeimageloaded = false; var prodPageZoom = "nozoom";

function _$(elm) { return document.getElementById(elm); }

function Zoom_Init(options) {
}

$(function(){
	clocks.init();
	addlViews.init();
});

var clocks = {
	init: function(){
		$.get(
				global.clock_Url,
				function(data){
					array = $.csv()(data, true);
					clocks.add_clocks(array);
				}	
		);
	},
	add_clocks: function(clock_data){
		var us_Cities = new  Array();
		var int_Cities1 = new  Array();
		var int_Cities2 = new  Array();
		$(clock_data).each(function(){
			if(this[0] == '' || this[0] == 'Country'){
				return true;
			}	else if(this[0] == "U.S."){
				us_Cities.push(this);
			}	else if(this[5] < 5 ) {
				int_Cities1.push(this);
			}	else {
				int_Cities2.push(this);
			}
		});
		
		this.set_Clock('#us_clock', '#us-location', 'us_Random', us_Cities);
		this.set_Clock('#int-clock-1', '#int-location-1', 'int_1_Random', int_Cities1);
		this.set_Clock('#int-clock-2', '#int-location-2', 'int_2_Random', int_Cities2);
	},
	set_Clock: function(clockElem, locElem, cookieName, Cities){
		var clockEl = $(clockElem);
		var loc = $(locElem);
		var Random = $.cookie(cookieName);
		var city ='';
		if(!Random){
			Random = rand(0, Cities.length-1);
			$.cookie(cookieName, Random, {expires:1});
		}
		
		city = Cities[Random];
		
		var state = '';
		if(city[1]){
			state = ', ' + city[1];
		}
		loc.html(city[2] + ' ' + state + ', ' + city[0]);
		clockEl.clock({
			"langSet": city[4],
			"timestamp": this.get_ClockOffset(city[3]),
			"format" : "12"
		});
	},
	get_ClockOffset: function(offset){
		var d = new Date();
		var localTime = d.getTime();
		var localOffset = d.getTimezoneOffset() * 60000;
		var utc = localTime + localOffset;
		return utc + (3600000*offset);
	}
};

function compairRandom(val1, val2){
	return val1 == val2;
}

function rand(from, to){
	return Math.floor(Math.random() * (to - from + 1) + from);
}

function JSSelector() {
	this.myself=null;
	this.selSkuIdx=null;
	this.colorBtns=null;
	this.sizeBtns=null;
	this.prodID="";
	this.selColor="";
	this.selColorLbl="";
	this.selSize="";
	this.selSizeLbl="";
	this.init = (function(prodID) {
		this.myself=this;
		this.prodID=prodID;
		this.colorBtns = $("#prColor_selector_"+prodID+" .prod-attsel-itm");
		this.sizeBtns = $("#prSize_selector_"+prodID+" .prod-attsel-itm");
		if(this.colorBtns.length>0) {
			this.selColor = $(this.colorBtns[0]).attr("attcolor"); 
			this.selColorLbl = $(this.colorBtns[0]).attr("attcolorlbl"); 
		}
		if(this.colorBtns.length==0&&this.sizeBtns.length>0) {
			this.selSize = $(this.sizeBtns[0]).attr("attsize"); 
			this.selSizeLbl = $(this.sizeBtns[0]).attr("attsizelbl"); 
		}
		this.assignEvent_onclick(this.colorBtns);
		this.assignEvent_onclick(this.sizeBtns);
	});
	this.assignEvent_onclick=(function(jqElmList){
		var self = this.myself;
		jqElmList.each(function(){
			var btn = $(this);
			var sColor = self.selColor;
			var sColorLbl = self.selColorLbl;
			var sSize = self.selSize;
			var sSizeLbl = self.selSize;
			var sAttr = "";
			if($(this).attr("attcolor")!=undefined) {
				sColor=$(this).attr("attcolor");
				sColorLbl=$(this).attr("attcolorlbl");
				sAttr="attcolor";
			}
			if($(this).attr("attsize")!=undefined) {
				sSize=$(this).attr("attsize");
				sSizeLbl=$(this).attr("attsizelbl");
				sAttr="attsize";
			}				
			btn.find("a").click(function(){
				if(sAttr=="attcolor"){
					self.selColor=sColor;
					self.selColorLbl=sColorLbl;
				}
				if(sAttr=="attsize"){
					self.selSize=sSize;
					self.selSizeLbl=sSizeLbl;
				}
				self.select_Sku();
			});
		});
	}); 
	this.select_Sku=(function(){
		var self = this.myself;
		if(self.skuArr==null) self.skuArr = eval("arrSku_"+self.prodID);
		self.style_nodes();	
		self.set_label();
		var selSKUObj = $("#hdnSelSkuID"+self.prodID)
		selSKUObj.val("");
		self.selSkuIdx=null;
		var sDefaultStatus="";
		if((self.colorBtns.length==0||self.selColor!="")&&(self.sizeBtns.length==0||self.selSize!="")){
			sDefaultStatus="INVDSC"; //At this point the user has selected all options necessary.  Therefore if we don't find a match in the array below, treat it like a discontinued sku;
			$.each(this.skuArr, function(i){
				if((self.colorBtns.length==0||this.color==self.selColor)&&(self.sizeBtns.length==0||this.size==self.selSize)) {
					if(this.status=="INVAVL") selSKUObj.val(this.skuID);
					self.selSkuIdx=i;
					return;
				}
			});
		}
		self.statusControl(sDefaultStatus);
	});
	this.set_label=(function() {
		var self = this.myself;
		$("#prColor_selector_"+self.prodID+" span.selectedColor").html(self.selColorLbl);
		$("#prSize_selector_"+self.prodID+" span.selectedSize").html(self.selSizeLbl);
	});
	this.statusControl=(function(sDefaultStatus) {
		var self = this.myself;
		var status = sDefaultStatus;
		var notifyMe = false;
		var skuID = "";
		if(self.selSkuIdx!=null){
			if(self.skuArr==null) self.skuArr = eval("arrSku_"+self.prodID);
			status = self.skuArr[self.selSkuIdx].status;
			notifyMe = self.skuArr[self.selSkuIdx].allowNotifyMe;
			skuID = self.skuArr[self.selSkuIdx].skuID;
		}
		var cartBox = $("#btnAddToCartBox_"+self.prodID);
		var cartBtn = $("#btnAddToCart_"+self.prodID);
		var cartDisBtn = $("#btnAddToCartDis_"+self.prodID);
		var wishBtn = $("#btnAddToWish_"+self.prodID);
		var wishDisBtn = $("#btnAddToWishDis_"+self.prodID);
		var tellBtn = $("#btnTellFriend_"+self.prodID);
		var tellDisBtn = $("#btnTellFriendDis_"+self.prodID);
		var qtyBox = $("#qty"+self.prodID);
		var qtyMsg = $("#prodQtyMsg_"+self.prodID);
		switch(status) {
			case "INVUVL": {
				if(cartBox.length>0) cartBox.removeClass("readyforcart");
				if(cartBtn.length>0) cartBtn.hide();
				if(cartDisBtn.length>0) cartDisBtn.show();
				if(wishBtn.length>0) wishBtn.show();
				if(wishDisBtn.length>0) wishDisBtn.hide();
				if(tellBtn.length>0) tellBtn.show();
				if(tellDisBtn.length>0) tellDisBtn.hide();
				if(qtyBox.length>0) qtyBox.css("background-color","#EEAAAA");
				if(qtyBox.length>0) qtyBox.prop("disabled", true);
				if(qtyMsg.length>0) qtyMsg.html("&nbsp;&nbsp;&nbsp;Out of stock.");
				if(notifyMe)NotifyMeControl(skuID,"block")
				break;
			} case "INVDSC": {
				if(cartBox.length>0) cartBox.removeClass("readyforcart");
				if(cartBtn.length>0) cartBtn.hide();
				if(cartDisBtn.length>0) cartDisBtn.show();
				if(wishBtn.length>0) wishBtn.hide();
				if(wishDisBtn.length>0) wishDisBtn.show();
				if(tellBtn.length>0) tellBtn.hide();
				if(tellDisBtn.length>0) tellDisBtn.show();
				if(qtyBox.length>0) qtyBox.css("background-color","#EEAAAA");
				if(qtyBox.length>0) qtyBox.prop("disabled", true);
				if(qtyMsg.length>0) qtyMsg.html("&nbsp;&nbsp;&nbsp;Not Available.");
				NotifyMeControl("","none");
				break;
			} case "INVAVL": {
				if(cartBox.length>0) cartBox.addClass("readyforcart");
				if(cartBtn.length>0) cartBtn.show();
				if(cartDisBtn.length>0) cartDisBtn.hide();
				if(wishBtn.length>0) wishBtn.show();
				if(wishDisBtn.length>0) wishDisBtn.hide();
				if(tellBtn.length>0) tellBtn.show();
				if(tellDisBtn.length>0) tellDisBtn.hide();
				if(qtyBox.length>0) qtyBox.css("background-color","#FFFCF3");
				if(qtyBox.length>0) qtyBox.prop("disabled", false);
				if(qtyMsg.length>0) qtyMsg.html("");
				NotifyMeControl("","none");
				break;
			} default: {
				if(cartBox.length>0) cartBox.removeClass("readyforcart");
				if(cartBtn.length>0) cartBtn.show();
				if(cartDisBtn.length>0) cartDisBtn.hide();
				if(wishBtn.length>0) wishBtn.show();
				if(wishDisBtn.length>0) wishDisBtn.hide();
				if(tellBtn.length>0) tellBtn.show();
				if(tellDisBtn.length>0) tellDisBtn.hide();
				if(qtyBox.length>0) qtyBox.css("background-color","#FFFCF3");
				if(qtyBox.length>0) qtyBox.prop("disabled", false);
				if(qtyMsg.length>0) qtyMsg.html("");
				NotifyMeControl("","none");
				break;
			}
		}
	});	
	this.style_nodes=(function() {
		var self = this.myself;
		self.colorBtns.each(function(){
			if($(this).attr("attcolor")==self.selColor){
				if(!$(this).hasClass("prod-attsel-itm-selected")) $(this).addClass("prod-attsel-itm-selected");
				addlViews.swap_group(self.selColor,self.prodID); 
			} else {
				$(this).removeClass("prod-attsel-itm-selected");
			}
		});
		self.sizeBtns.each(function(){
			if(self.colorBtns.length>0) {
				//set initial state of "discontinued"
				$(this).addClass("prod-attsel-itm-discontinued");
				$(this).removeClass("prod-attsel-itm-unavail");
			}
			if($(this).attr("attsize")==self.selSize){
				if(!$(this).hasClass("prod-attsel-itm-selected")) $(this).addClass("prod-attsel-itm-selected");
			} else {
				$(this).removeClass("prod-attsel-itm-selected");
			}
		});
		this.style_disabled_nodes();
	});
	this.style_disabled_nodes=(function() {
		var self = this.myself;
		if(self.skuArr==null) self.skuArr = eval("arrSku_"+self.prodID);
		if(self.colorBtns.length>0&&self.sizeBtns.length>0) {
			//handle freq disabled
			$.each(this.skuArr, function(){
				if(this.color==self.selColor) {
					if(this.status!="INVDSC") {
						self.sizeBtns.filter("[attsize='"+this.size+"']").removeClass("prod-attsel-itm-discontinued");
						if(this.status=="INVUVL") self.sizeBtns.filter("[attsize='"+this.size+"']").addClass("prod-attsel-itm-unavail");
					}
				}
			});
		}
	});
}



/************* On Product Page, Opens up Large Image **********/
	function ProductPopUp() {
		_$("product-detail-popup").style.display="block";
		_$("FadeOut").style.height=_$("Page").scrollHeight + "px";
		_$("FadeOut").style.display="block";
		IE6_IframeCtrl('OVER', _$("product-detail-popup"))		
		//var tmpVar = (($("doc2").scrollHeight)-750)/2;
		//$("product-detail-popup").style.top=tmpVar + "px";
	}
	
	function ErrorMsgPopUp() {
		_$("error-msg-popup").style.display="block";
		_$("FadeOut").style.height=_$("Page").scrollHeight + "px";
		_$("FadeOut").style.display="block";
		IE6_IframeCtrl('OVER', _$("error-msg-popup"))
	}
	
	function ProductSizePopUp() {
		_$("product-size-popup").style.display="block";
		_$("FadeOut").style.height=_$("Page").scrollHeight + "px";
		_$("FadeOut").style.display="block";
		//var tmpVar = (($("doc2").scrollHeight)-750)/2;
		//$("product-detail-popup").style.top=tmpVar + "px";
	}
	
	function closePopUpWindow() {
		if(_$("product-detail-popup")) _$("product-detail-popup").style.display="none";
		if(_$("product-size-popup")) _$("product-size-popup").style.display="none";
		if(_$("error-msg-popup")) _$("error-msg-popup").style.display="none";
		if(_$("FadeOut")) _$("FadeOut").style.display="none";
		if(window.parent._$("product-detail-popup")) window.parent._$("product-detail-popup").style.display="none";
		if(window.parent._$("product-size-popup")) window.parent._$("product-size-popup").style.display="none";
		if(window.parent._$("error-msg-popup")) window.parent._$("error-msg-popup").style.display="none";
		if(window.parent._$("FadeOut")) window.parent._$("FadeOut").style.display="none";
		//IE6_IframeCtrl('OUT', _$("product-detail-popup"))
	}
	
	
	var addlViews = {
		groups: null,
		init: function(){
			$(".prod-addl-views-img").click(function(){
				addlViews.showpop_up();
				addlViews.select_addlview($(this));
			});
			$(".hero-lightbox-ctrl").click(function(){
				addlViews.showpop_up();
			});
		},
		swap_group: function(selColor,prodID){
			if(this.groups==null) this.groups = $(".prod-addl-views-group");
			this.groups.each(function(){
				var grpThis = $(this);
				if(grpThis.attr("prodID")==prodID){
					if(grpThis.attr("attcolor")==selColor) {
						grpThis.show();
						var thumbs = grpThis.find(".prod-addl-views-img");
						if(thumbs.length>0) addlViews.select_addlview($(thumbs[0]));
					} else {
						grpThis.hide();
					}
				}
			});
		},
		select_addlview: function(thumb){
			var lrgSrc = thumb.attr("lrgImgSrc");
			var zoomSrc = thumb.attr("zoomImgSrc");
			$("#popupLink img").css("background", "transparent url("+lrgSrc+") no-repeat scroll 50% 50%");
			$('#popupLink').attr("href",zoomSrc);
			if($("#loupe_plugin-1").length>0) $("#loupe_plugin-1").remove();
			if($("#loupe_overlay-1").length>0) $("#loupe_overlay-1").remove();
			$('#popupLink').loupe_plugin({'shape':'square', 'default_size':200, 'glossy':false, 'drop_shadow':false, 'overlay_opacity':0.1}); 
		},
		showpop_up: function(){
			$("#FadeOut").show();
			$("#product-detail-popup").show();
		}
	};
	
	function AddlViewThumb_Ctrl(prodID, ctrlName, attXref, attValue)  {
		//Clean Up Viewable AV
		var arrAddlViewGroups = eval("arr"+ctrlName+"_AddlViewGroups");
		for(i=0; i<arrAddlViewGroups.length; i++) {
			var oDiv = document.getElementById(arrAddlViewGroups[i].AVGroupID);
			if(oDiv){
			oDiv.className = oDiv.className.replace(" groupselect","");
				oDiv.className = oDiv.className.replace("groupselect","");
			}
		}
		//Select first image in group
		var oColorAVGroupObj = document.getElementById("avColorGroup_"+ctrlName+"_"+prodID+"_"+attXref)
		var AVThumbArr = document.getElementsByName("ThAV_"+ctrlName+"_"+prodID+"_"+attXref)
		var FirstThumb="";
		if(AVThumbArr.length>0)FirstThumb=AVThumbArr[0].id;
		BorderStyle = "1px solid #FFFFFF";
		BorderSelStyle = "1px dotted #000000";
		var Thumbs = document.getElementsByName("ThAV_"+ctrlName+"_"+prodID+"_"+attXref);
		for(i=0; i<Thumbs.length; i++) {
			if(FirstThumb==Thumbs[i].id){
				Thumbs[i].parentNode.style.border=BorderSelStyle;
				Thumbs[i].className="selected";
			}else{
				Thumbs[i].parentNode.style.border=BorderStyle;
				Thumbs[i].className="";
			}
		}
		//Select the Color Additional Images Group
		if(oColorAVGroupObj)oColorAVGroupObj.className=oColorAVGroupObj.className+" groupselect";
	}	
	
/*************************IMG PReload*************************/

function preload_HiddenImgs() {
	var arrObj = arrImgPreLoad.split(',');
	var execString =""
	for(i=1;i<arrObj.length;i++){
		var img = new Image(); img.src=arrObj[i];
	}
}

/***********************  Swap Image *************************/

	function swatchSelCtrl_onclick(bIsPopUp,bIsSkuSelector,bProdLinkSelector,url,whichCtrlSet,prodID,ctrlName,attXrefVal,attVal,imgSrc,zoomSrc,zoomClass) {
		//swapImage('ThClr_'+ctrlName+'_'+prodID,attXrefVal,whichCtrlSet,attVal,ctrlName+prodID,imgSrc,zoomSrc,zoomClass);
		if(bIsPopUp) {
			SelectSku(prodID,'mainImg','Color',attXrefVal,attVal);
		}else{
			if(bIsSkuSelector) SelectSku(prodID,ctrlName,'Color',attXrefVal,attVal);
			if(bProdLinkSelector) setLink('lnkLstItm-'+prodID, url+'?cs='+attXrefVal);
		}
	}

	function swapImage(DivID,attXref,whichCtrlSet,attValue,img,src,lgimg,zoomClass){
		var el=_$(img);
		el.style.backgroundImage='url("'+src+'")';
		el.style.backgroundImage='url("'+src+'")';
		el.setAttribute('largeimg',lgimg);
		if(el.tagName.toUpperCase()=='IMG'&&el.parentNode.id!='popupLink'){
			var inputEl = $("input",$(el.parentNode));
			inputEl[0].value = lgimg;
			el.parentNode.className = zoomClass;
		}
		largeimageloaded = false;
		var Thumbs = document.getElementsByName(DivID);
		var BorderStyle = "";
		var BorderSelStyle = "";
		if(whichCtrlSet=="AddlView") {
			BorderStyle = "1px solid #FFFFFF";
			BorderSelStyle = "1px dotted #000000";
		}
		for(i=0; i<Thumbs.length; i++) {
			if((DivID+"_"+attXref)==Thumbs[i].id){
				Thumbs[i].parentNode.style.border=BorderSelStyle;
				Thumbs[i].className="selected";
			}else{
				Thumbs[i].parentNode.style.border=BorderStyle;
				Thumbs[i].className="";
			}
		}
	}

	function setLink(elementName, newHref){
		var oProdLinks = document.getElementsByName(elementName)
		if(oProdLinks.length>0){
			for(i=0;i<oProdLinks.length;i++){
				oProdLinks[i].onclick = function(){
						window.location.href = newHref;
				};
				oProdLinks[i].href = newHref;
			}
		}
	}

	function SelectSku(prodID, ctrlName, attName, attXref, attValue) {
		var arrSku = eval("arrSku_"+prodID);
		var SelSkuID = _$("hdnSelSkuID"+prodID);
		var SelSkuColor = _$("hdnSkuColor"+prodID);
		var SelSkuSize = _$("hdnSkuSize"+prodID);
		var ThumbsSize = document.getElementsByName("ThSize_"+ctrlName+"_"+prodID);
		//Clear SelSKUID
		SelSkuID.value="";
		switch(attName) {
			case "Color": {
				SelSkuColor.value = attXref;
				break;
			}
			case "Size":{
				SelSkuSize.value = attXref;
				break;
			}
		}
		//Now capture sku if both Color and Size have values
		if(!(SkuCapture(SelSkuID,SelSkuColor,SelSkuSize,arrSku,prodID))&&(!ThumbsSize.length>0||SelSkuSize.value!="")) {
				if(_$("btnAddToCart_"+prodID)){
					_$("btnAddToCart_"+prodID).style.display="none";
					_$("btnAddToCartDis_"+prodID).style.display="inline";
				}
				if(_$("btnAddToWish_"+prodID)){
					_$("btnAddToWish_"+prodID).style.display="none";
					_$("btnAddToWishDis_"+prodID).style.display="inline";
				}
				if(_$("btnTellFriend_"+prodID)){
					_$("btnTellFriend_"+prodID).style.display="none";
					_$("btnTellFriendDis_"+prodID).style.display="inline";
				}	
			_$("prodQtyMsg_"+prodID).innerHTML="&nbsp;&nbsp;&nbsp;Not Available.";
			_$("qty"+prodID).disabled=true;
			_$("qty"+prodID).style.backgroundColor="#EEAAAA";
			NotifyMeControl("","none")
		}
		SkuControl(arrSku, ThumbsSize, prodID, ctrlName, attName, attXref, attValue);
	}
	
	function SkuCapture(SelSkuID,SelSkuColor,SelSkuSize,arrSku,prodID) {
		//Now capture sku if both Color and Size have values
		var bSkuExists = false;
		for(i=0; i<arrSku.length; i++){
			if((SelSkuColor==null||arrSku[i].colorxref == SelSkuColor.value) && (SelSkuSize==null||arrSku[i].sizexref == SelSkuSize.value)){
				SelSkuID.value=arrSku[i].skuID;
				bSkuExists=true;
				StatusControl(arrSku[i],prodID);
				break;
			}
		}
		return bSkuExists;
	}	

	function StatusControl(arrSku, prodID) {
		if(_$("btnAddToCartBox_"+prodID)) $("#btnAddToCartBox_"+prodID).removeClass("readyforcart");
		switch(arrSku.status) {
			case "INVUVL": {
				if(_$("btnAddToCart_"+prodID)){
					_$("btnAddToCart_"+prodID).style.display="none";
					_$("btnAddToCartDis_"+prodID).style.display="inline";
				}
				if(_$("btnAddToWish_"+prodID)){
					_$("btnAddToWish_"+prodID).style.display="inline";
					_$("btnAddToWishDis_"+prodID).style.display="none";
				}
				if(_$("btnTellFriend_"+prodID)){
					_$("btnTellFriend_"+prodID).style.display="inline";
					_$("btnTellFriendDis_"+prodID).style.display="none";
				}				
				_$("prodQtyMsg_"+prodID).innerHTML="&nbsp;&nbsp;&nbsp;Out of stock.";
				_$("qty"+prodID).disabled=true;
				_$("qty"+prodID).style.backgroundColor="#EEAAAA";
				if(arrSku.allowNotifyMe)NotifyMeControl(arrSku.skuID,"block")
				break;
			} case "INVDSC": {
				if(_$("btnAddToCart_"+prodID)){
					_$("btnAddToCart_"+prodID).style.display="none";
					_$("btnAddToCartDis_"+prodID).style.display="inline";
				}
				if(_$("btnAddToWish_"+prodID)){
					_$("btnAddToWish_"+prodID).style.display="none";
					_$("btnAddToWishDis_"+prodID).style.display="inline";
				}
				if(_$("btnTellFriend_"+prodID)){
					_$("btnTellFriend_"+prodID).style.display="none";
					_$("btnTellFriendDis_"+prodID).style.display="inline";
				}				
				_$("prodQtyMsg_"+prodID).innerHTML="&nbsp;&nbsp;&nbsp;Not Available.";
				_$("qty"+prodID).disabled=true;
				_$("qty"+prodID).style.backgroundColor="#EEAAAA";
				NotifyMeControl("","none");
				break;
			} default: {
				if(arrSku.status=="INVAVL"){
					if(_$("btnAddToCartBox_"+prodID)) $("#btnAddToCartBox_"+prodID).addClass("readyforcart");
				}
				if(_$("btnAddToCart_"+prodID)){
					_$("btnAddToCart_"+prodID).style.display="inline";
					_$("btnAddToCartDis_"+prodID).style.display="none";
				}
				if(_$("btnAddToWish_"+prodID)){
					_$("btnAddToWish_"+prodID).style.display="inline";
					_$("btnAddToWishDis_"+prodID).style.display="none";
				}
				if(_$("btnTellFriend_"+prodID)){
					_$("btnTellFriend_"+prodID).style.display="inline";
					_$("btnTellFriendDis_"+prodID).style.display="none";
				}				
				_$("prodQtyMsg_"+prodID).innerHTML="";
				_$("qty"+prodID).disabled=false;
				_$("qty"+prodID).style.backgroundColor="#FFFCF3";
				if(arrSku.allowNotifyMe)NotifyMeControl("","none")
				break;
			}
		}
	}
	
	function NotifyMeControl(skuID, dispStyle) {
		if(_$("NotifyMe")){
			_$("formSkuID").value=skuID;
			_$("NotifyMe").style.display=dispStyle;
		}
	}
	
	function SkuControl(arrSku, ThumbsSize, prodID, ctrlName, attName, attXref, attValue) {
		var sLblVal = "";
		var oSizeObj=null;
		switch(attName) {
			case "Color": {
				if(ThumbsSize.length>0) {
					//Clean up Sizes... make all NotAvail by default
					for(i=0; i<ThumbsSize.length; i++) {
						oSizeObj = ThumbsSize[i];
						$(oSizeObj).removeClass();
						$(oSizeObj).addClass("notavail");
					}
					//Now change the class "status" for those that need it 
					for(i=0; i<arrSku.length; i++) {
						if(arrSku[i].colorxref == attXref) {
							oSizeObj = $("#ThSize_"+ctrlName+"_"+prodID+"_"+arrSku[i].sizexref);
							if(oSizeObj.length<=0) continue;
							switch(arrSku[i].status) {
								case "INVAVL": {
									oSizeObj.removeClass();
									break;
								}
								case "INVDSC": {
									oSizeObj.removeClass("notavail")
									oSizeObj.addClass("discontinued");
									break;
								}
								default: {
									break;
								}
							}
						}
					}
				}
				//Clean Up Selected Color
				var ThumbsColor = $(".prSwatch-img-"+prodID) //document.getElementsByName("ThClr_"+ctrlName+"_"+prodID);
				ThumbsColor.each(function(index) {
					var link =$(this).find("a");
					link.removeClass("selected");
					if($(this).hasClass("prSwatch-img-"+prodID+"-"+attXref)) link.addClass("selected");
				});
				//Select the Color
				//var oColorObj = $("#ThClr_"+ctrlName+"_"+prodID+"_"+attXref);
				sLblVal = attValue;
				//oColorObj.addClass("selected");
				//if(ctrlName!="outfitImg") 
				var addlViewsGroup = "prod-addl-views-group-"+attXref;
				addlViews.swap_group(addlViewsGroup,prodID);
				break;
			}
			case "Size": {
				//Clean Up Selected Size
				for(i=0; i<ThumbsSize.length; i++) {
					$(ThumbsSize[i]).removeClass("selected");
				}
				//Select the Size
				oSizeObj = $("#ThSize_"+ctrlName+"_"+prodID+"_"+attXref);
				sLblVal = oSizeObj.html();
				oSizeObj.addClass("selected");
				break;				
			}
		}
		//Update Labels
		if($("#sel"+attName+"_"+ctrlName+"_"+prodID).length>0) {
			$("#sel"+attName+"_"+ctrlName+"_"+prodID).html(sLblVal);
		}
	}
	
	
	function open_win(urlpath,heightwidth){
		window.open(urlpath,null,heightwidth);
		}
		
/************************************************************/

/*************** PowerReviews Tab Control *******************/

	function switch_pr_tab(showTab) {
		var oDTabPanel1 = document.getElementById("pr_tab_content_detail_1");
		var oDTabPanel2 = document.getElementById("pr_tab_content_detail_2");
		var oDTab = document.getElementById("imgPRTabDetails");
		var oRTabPanel = document.getElementById("pr_tab_content_review");
		var oRTab = document.getElementById("imgPRTabReviews");
		
		switch (showTab) {
			case "D": {
				oDTabPanel1.style.display = "block";
				oDTabPanel2.style.display = "block";
				oRTabPanel.style.display = "none";
				oDTab.style.backgroundImage = "url('/images/buttons/details_tab_on.gif')";
				oRTab.style.backgroundImage = "url('/images/buttons/reviews_tab_off.gif')";
				break;
			}
			case "R": {
				oDTabPanel1.style.display = "none";
				oDTabPanel2.style.display = "none";
				oRTabPanel.style.display = "block";
				oDTab.style.backgroundImage = "url('/images/buttons/details_tab_off.gif')";
				oRTab.style.backgroundImage = "url('/images/buttons/reviews_tab_on.gif')";
				break;
			}
		}
	}





/************************************************************/

/************ Update Sku Info on Prod Page ******************/
	function displaySkuInfo(selectBox, infoArray, PriceSpan) {
		if(selectBox.selectedIndex!=0) {
			var info = infoArray[selectBox.options[selectBox.selectedIndex].value];
			var strkAmt = "";
			if(PriceSpan=="DisplayPrice") StatusControl(info, info.prodID);
		}
	}
	
function TellaFriend() {
	if(_$("TellaFriend").style.display=='block') {
		_$("TellaFriend").style.display='none';
	} else {
		_$("TellaFriend").style.display='block';
	}
}
/************************************************************/

/****************** Payment Type Selector *******************/

function swap_PayMethods(selValue) {
	hide_PayMethods();
	document.getElementById("type"+selValue).style.display="block";
}

function hide_PayMethods(){
	if(document.getElementById("typePMTCCD"))document.getElementById("typePMTCCD").style.display="none";
	if(document.getElementById("typePMTPOR"))document.getElementById("typePMTPOR").style.display="none";
	if(document.getElementById("typePMTWUN"))document.getElementById("typePMTWUN").style.display="none";
	if(document.getElementById("typePMTBML"))document.getElementById("typePMTBML").style.display="none";
	if(document.getElementById("typePMTPPL"))document.getElementById("typePMTPPL").style.display="none";
	if(document.getElementById("typePMTGVX"))document.getElementById("typePMTGVX").style.display="none";
	if(document.getElementById("typePMTEGC"))document.getElementById("typePMTEGC").style.display="none";
	if(document.getElementById("typePMTMCR"))document.getElementById("typePMTMCR").style.display="none";
	if(document.getElementById("typePMTSGC"))document.getElementById("typePMTSGC").style.display="none";
	if(document.getElementById("typePMTCOD"))document.getElementById("typePMTCOD").style.display="none";
	if(document.getElementById("typePMTMOR"))document.getElementById("typePMTMOR").style.display="none";
	if(document.getElementById("typePMTPT"))document.getElementById("typePMTPT").style.display="none";
}		

/************************************************************/
function validate_required(field,alerttxt) {
	with (field) {
		if (value==null||value=="") {
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_skuforms(thisform,prodID) {
	var bValidated = false;
	var sMsg = "";
	switch (thisform.name){
		case 'productSkuForm': {
			sMsg='Error! Select a Color and Size';
			if(_$("hdnSelSkuID"+prodID)&&_$("hdnSelSkuID"+prodID).value!="") bValidated=true;
			if(bValidated==false&&_$("SKUSELECTION"+prodID)&&_$("SKUSELECTION"+prodID).options[_$("SKUSELECTION"+prodID).selectedIndex].value!="") bValidated=true;
			if(document.getElementById("qty"+prodID).value==""){
				if(bValidated) { sMsg=''; } else { sMsg+=' \n'; }
				sMsg+='Error! Insert a Quantity';
				bValidated==false;
			} 
			if(!bValidated) ErrorMsgPopUp(); //alert(sMsg);
			return bValidated; break;
		} case 'productBundleForm': {
			with (thisform) {
				for(i=0; i<elements.length; i++) {
					if (!validate_required(elements[i],"Error! Select a Size/Color")) {
						elements[i].focus();
						return false;	break;
					}
				}
			}
			return true; break;
		} default: {
			return true; break;
		}
	}
}

function displayProvinceDropDown(country_list,province_list,list) { 
	var country=""; 
	var pre_selected = list.value; country=country_list.value; 
	var provinces=null;
	for ( var i = 0; i < province_list.length; i++ ) { 
		if ( province_list[i].name==country ) { 
			provinces = province_list[i].provinces; break; 
		} 
	}
	list.innerHTML=""; 
	if (provinces==null || provinces.length == 0 ) { 
		list.style.visibility="hidden"; 
		_$("state_label").style.visibility="hidden"; 
	} else { 
		list.style.visibility="visible"; 
		_$("state_label").style.visibility="visible"; 
	}
	var o = document.createElement("option"); 
	o.innerHTML="Please Select A State/Province"; 
	list.appendChild(o);
	for ( var i = 0; i < provinces.length; i++ ) { 
		var province = provinces[i]; 
		var o = document.createElement("option"); 
		o.setAttribute("value", province.id); 
		o.innerHTML=province.name; 
		if ( province.id==pre_selected ) {
			o.setAttribute("selected", "selected"); 
		}
		list.appendChild(o); 
	} 
}

function CheckRightSku()
{
	if(document.getElementById('SKUSELECTION')){
		document.getElementById('formSkuID').value=document.getElementById('SKUSELECTION').value;
	}
}

function remove_BG(oObj){
	oObj.style.backgroundPosition='300px';
}

function IE6_IframeCtrl(sDir, oPopUp) {
	var oIfrmElm = document.getElementById("ifrmIE6Fix");
	//var oBGCopy = window.frames.ifrmIE6Fix.window.document.getElementById("IE6FixerImg");
	var oChild=null;
	if(oPopUp.id!='product-detail-popup'){
		if(oPopUp.childNodes!=null){
			for(i=0;i<oPopUp.childNodes.length;i++){
				if(oPopUp.childNodes[i].className=='sub-menu-box'){
					oChild = oPopUp.childNodes[i];
					break;
				}
			}
		}
	} else {
		oChild = oPopUp;
	}
	if(sDir == 'OVER') {
		//Show
		if(oChild!=null){
			oIfrmElm.style.left = oPopUp.offsetLeft + 'px';
			oIfrmElm.style.top = (oPopUp.offsetTop + oChild.offsetTop) + 'px';
			oIfrmElm.style.width = oChild.offsetWidth + 'px';
			//oBGCopy.style.width = oChild.offsetWidth + 'px';
			oIfrmElm.style.height = oChild.offsetHeight + 'px';
			//oBGCopy.style.height = oChild.offsetHeight + 'px';
			oIfrmElm.style.display = 'block';
		}
	} else {
		//Hide
		oIfrmElm.style.display = 'none';
	}
}

function showGiftWrap(ordItemID) {
	if(_$("cart-kitpart-elements-"+ordItemID).style.display == "block"){
		_$("cart-kitpart-elements-"+ordItemID).style.display = "none";
		_$("cart-kitpart-values-"+ordItemID).style.display = "block";
	} else {
		_$("cart-kitpart-elements-"+ordItemID).style.display = "block";
		_$("cart-kitpart-values-"+ordItemID).style.display = "none";
	}	
}

function showGiftMsg(elm,elmMsg,ordItemID,elmSel) {
	var bFireShowGiftCtrls = true;
	if(_$(elmMsg)) {
		var elmMsgTxt = elmMsg+"-value";
		if(_$(elm).checked==true||_$(elm).selectedIndex>0) {
			_$(elmMsg).style.display = "block";
		} else {
			if(_$("CartForm")) {
				if(elmSel=="true"){ 
					_$("CartForm").submit();
					return;
				} else {
					hideGiftCtrls(ordItemID);
					bFireShowGiftCtrls=false;
				}
			}
			_$(elmMsg).style.display = "none";
		}
		if(_$(elmMsgTxt)) _$(elmMsgTxt).style.display = "none";
		if(_$(elmSel+"-ctrl")) {
			_$(elmSel).style.display = "none";
			_$(elmSel+"-ctrl").style.display = "block";
		}
	}
	if(bFireShowGiftCtrls)showGiftCtrls(ordItemID);
}

function showGiftCtrls(ordItemID) {
	if(_$("cart-kitpart-ctrls-"+ordItemID)) _$("cart-kitpart-ctrls-"+ordItemID).style.display = "block";
}

function hideGiftCtrls(ordItemID) {
	if(_$("cart-kitpart-ctrls-"+ordItemID)) _$("cart-kitpart-ctrls-"+ordItemID).style.display = "none";
}


/***************** Image Carousel for 'Shop By Catalog' *****************/

/*jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider
	Copyright (c) 2009 Niall Doherty
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.*/

var sliderCount = 1;

$.fn.codaSlider = function(settings) {

	settings = $.extend({
		autoHeight: true,
		autoHeightEaseDuration: 1000,
		autoHeightEaseFunction: "easeInOutExpo",
		autoSlide: false,
		autoSlideInterval: 7000,
		autoSlideStopWhenClicked: true,
		crossLinking: true,
		dynamicArrows: true,
		dynamicArrowLeftText: "&#171; left",
		dynamicArrowRightText: "right &#187;",
		dynamicTabs: true,
		dynamicTabsAlign: "center",
		dynamicTabsPosition: "top",
		externalTriggerSelector: "a.xtrig",
		firstPanelToLoad: 1,
		panelTitleSelector: "h2.title",
		slideEaseDuration: 1000,
		slideEaseFunction: "easeInOutExpo"
	}, settings);
	
	return this.each(function(){
		
		// Uncomment the line below to test your preloader
		// alert("Testing preloader");
		
		var slider = $(this);
		
		// If we need arrows
		if (settings.dynamicArrows) {
			slider.parent().addClass("arrows");
			slider.before('<div class="catalog-nav-left" id="catalog-nav-left-' + sliderCount + '"><a href="#">' + settings.dynamicArrowLeftText + '</a></div>');
			slider.after('<div class="catalog-nav-right" id="catalog-nav-right-' + sliderCount + '"><a href="#">' + settings.dynamicArrowRightText + '</a></div>');
		};
		
		var panelWidth = slider.find(".panel").width();
		var panelCount = slider.find(".panel").size();
		var panelContainerWidth = panelWidth*panelCount;
		var navClicks = 0; // Used if autoSlideStopWhenClicked = true
		
		// Surround the collection of panel divs with a container div (wide enough for all panels to be lined up end-to-end)
		$('.panel', slider).wrapAll('<div class="panel-container"></div>');
		// Specify the width of the container div (wide enough for all panels to be lined up end-to-end)
		$(".panel-container", slider).css({ width: panelContainerWidth });
		
		// Specify the current panel.
		// If the loaded URL has a hash (cross-linking), we're going to use that hash to give the slider a specific starting position...
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			var currentPanel = parseInt(location.hash.slice(1));
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// If that's not the case, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) { 
			var currentPanel = settings.firstPanelToLoad;
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// Otherwise, we'll just set the current panel to 1...
		} else { 
			var currentPanel = 1;
		};
			
		// Left arrow click
		$("#catalog-nav-left-" + sliderCount + " a").click(function(){
			navClicks++;
			if (currentPanel == 1) {
				offset = - (panelWidth*(panelCount - 1));
				alterPanelHeight(panelCount - 1);
				currentPanel = panelCount;
				$('.catalog-nav').find('a.current').removeClass('current').parents('ul').find('li:last a').addClass('current');
			} else {
				currentPanel -= 1;
				alterPanelHeight(currentPanel - 1);
				offset = - (panelWidth*(currentPanel - 1));
				$('.catalog-nav').find('a.current').removeClass('current').parent().prev().find('a').addClass('current');
			};
			$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});
			
		// Right arrow click
		$('#catalog-nav-right-' + sliderCount + ' a').click(function(){
			navClicks++;
			if (currentPanel == panelCount) {
				offset = 0;
				currentPanel = 1;
				alterPanelHeight(0);
				$('.catalog-nav').find('a.current').removeClass('current').parents('ul').find('a:eq(0)').addClass('current');
			} else {
				offset = - (panelWidth*currentPanel);
				alterPanelHeight(currentPanel);
				currentPanel += 1;
				$('.catalog-nav').find('a.current').removeClass('current').parent().next().find('a').addClass('current');
			};
			$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});
		
		// If we need a dynamic menu
		if (settings.dynamicTabs) {
			var dynamicTabs = '<div class="catalog-nav" id="catalog-nav-' + sliderCount + '"><ul></ul></div>';
			switch (settings.dynamicTabsPosition) {
				case "bottom":
					slider.parent().append(dynamicTabs);
					break;
				default:
					slider.parent().prepend(dynamicTabs);
					break;
			};
			ul = $('#catalog-nav-' + sliderCount + ' ul');
			// Create the nav items
			$('.panel', slider).each(function(n) {
				ul.append('<li class="tab' + (n+1) + '"><a href="#' + (n+1) + '">' + $(this).find(settings.panelTitleSelector).text() + '</a></li>');												
			});
			navContainerWidth = slider.width() + slider.siblings('.catalog-nav-left').width() + slider.siblings('.catalog-nav-right').width();
			ul.parent().css({ width: navContainerWidth });
			
		};
			
		// If we need a tabbed nav
		$('#catalog-nav-' + sliderCount + ' a').each(function(z) {
			// What happens when a nav link is clicked
			$(this).bind("click", function() {
				navClicks++;
				$(this).addClass('current').parents('ul').find('a').not($(this)).removeClass('current');
				offset = - (panelWidth*z);
				alterPanelHeight(z);
				currentPanel = z + 1;
				$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
			});
		});
		
		// External triggers (anywhere on the page)
		$(settings.externalTriggerSelector).each(function() {
			// Make sure this only affects the targeted slider
			if (sliderCount == parseInt($(this).attr("rel").slice(12))) {
				$(this).bind("click", function() {
					navClicks++;
					targetPanel = parseInt($(this).attr("href").slice(1));
					offset = - (panelWidth*(targetPanel - 1));
					alterPanelHeight(targetPanel - 1);
					currentPanel = targetPanel;
					// Switch the current tab:
					slider.siblings('.catalog-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (targetPanel - 1) + ') a').addClass('current');
					// Slide
					$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
					if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
				});
			};
		});
			
		// Specify which tab is initially set to "current". Depends on if the loaded URL had a hash or not (cross-linking).
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			$("#catalog-nav-" + sliderCount + " a:eq(" + (location.hash.slice(1) - 1) + ")").addClass("current");
		// If there's no cross-linking, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) {
			$("#catalog-nav-" + sliderCount + " a:eq(" + (settings.firstPanelToLoad - 1) + ")").addClass("current");
		// Otherwise we must be loading Panel 1, so make the first tab the current one.
		} else {
			$("#catalog-nav-" + sliderCount + " a:eq(0)").addClass("current");
		};
		
		// Set the height of the first panel
		if (settings.autoHeight) {
			panelHeight = $('.panel:eq(' + (currentPanel - 1) + ')', slider).height();
			slider.css({ height: panelHeight });
		};
		
		// Trigger autoSlide
		if (settings.autoSlide) {
			slider.ready(function() {
				setTimeout(autoSlide,settings.autoSlideInterval);
			});
		};
		
		function alterPanelHeight(x) {
			if (settings.autoHeight) {
				panelHeight = $('.panel:eq(' + x + ')', slider).height()
				slider.animate({ height: panelHeight }, settings.autoHeightEaseDuration, settings.autoHeightEaseFunction);
			};
		};
		
		function autoSlide() {
			if (navClicks == 0 || !settings.autoSlideStopWhenClicked) {
				if (currentPanel == panelCount) {
					var offset = 0;
					currentPanel = 1;
				} else {
					var offset = - (panelWidth*currentPanel);
					currentPanel += 1;
				};
				alterPanelHeight(currentPanel - 1);
				// Switch the current tab:
				slider.siblings('.catalog-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (currentPanel - 1) + ') a').addClass('current');
				// Slide:
				$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				setTimeout(autoSlide,settings.autoSlideInterval);
			};
		};
		
		// Kill the preloader
		$('.panel', slider).show().end().find("p.loading").remove();
		slider.removeClass("preload");
		
		sliderCount++;
		
	});
};


/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d);},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b;},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b;},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b;},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b;},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b;},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b;},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b;},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b;},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b;},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b;},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b;},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b;},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b;},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b;},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b;}});

/************************************************************/
