jQuery(document).ready(function(){
	// function to show and hide product information :

 	jQuery(function() {
		jQuery('.pouttercontainer').hover(function(){			
				jQuery(this).find('.poverinfo').css({"display":"block","marginTop": "-6px", "marginLeft":"5px"});
			}, function(){
				jQuery(this).find('.poverinfo').css({"display":"none","marginTop": "-11px", "marginLeft":"10px"});
		});
	});
	
	// function to show and hide the drop cart :
	jQuery(function() {
 		jQuery("#dccartbutton").click(function () { 
				jQuery("#dropcart").animate({"width":"toggle", "height":"toggle"}, {queue:false,duration:500,easing:"easeOutQuint"}); 
		});
	});
	
	// function to show and hide team buy matrix :
	jQuery(function() {
 		jQuery("#teammatrix").click(function () { 
				jQuery("#teambuycontainer").animate({"height":"toggle"}, {queue:false,duration:600}); 
				jQuery('#item11').focus();				
		});
	});

	
	// function to show and hide the drop cart :
	jQuery(function() {
		jQuery('.productcolorswatch').hover(function(){
				jQuery(this).find('.bigswatch').animate({"marginTop": "-144px","height":"195px"}, {queue:false,duration:500,easing:"easeInCirc"}).fadeIn();
		}, function(){
				jQuery(this).find('.bigswatch').fadeOut('fast', function() {jQuery(this).css({"marginTop": "52px", "height":"0px"});});
		});
	});
	
	// function to change add to cart button to adding to cart :
	
	jQuery(function() {
 		jQuery("#thesubmitbutton").click(function () { 
			showDropCartLoad();
			toggleDropCart();
			jQuery("#thesubmitbutton").css({"display":"none"}); 
			jQuery(".adding").css({"display":"inline"}); 
			
			doSingleItemSubmit();	
		});
	});
	

	jQuery('#dropsizelist').change(function() {
  		var _setValue = '';
  		_setValue = jQuery(this).val();
  		jQuery('#hiddensize').val(_setValue);
	});
	
	jQuery('#dropcolorlist').change(function() {
  		var _setValue = '';
  		_setValue = jQuery(this).val();
  		jQuery('#hiddencolor').val(_setValue);
	});
	
	jQuery('#visqty').change(function() {
  		var _setValue = '';
  		_setValue = jQuery(this).val();
  		jQuery('#hiddenquantity').val(_setValue);
	});

	// function to activate team buy :
	jQuery(function() {
 		jQuery(".addalltocart").click(function () { 
 				var _itemsTotal = 0;
 				var _index = 0;
 		
				jQuery(".addalltocart").css({"display":"none"}); 
				jQuery(".addingteam").css({"display":"inline"}); 
				
				jQuery("#tbmatrix").find('input').each(function(i) {
					jQuery(this).attr("disabled", true);
				});	
				
				jQuery("#tbmatrix").find('input').each(function(i) {
					if (jQuery(this).val()!=0) {
						_itemsTotal = _itemsTotal + 1;
					}
				});	
				
				if (_itemsTotal>0){
					
					toggleteambuycontainer();
					showDropCartLoad();
					toggleDropCart();
				
					jQuery("#tbmatrix").find('input').each(function(i) {

						if (jQuery(this).val()!=0) {
							_index = _index + 1;
							
							var _qty = jQuery(this).val();
							var _size = jQuery(this).attr('xsize');
							var _color = jQuery(this).attr('name');
							
							jQuery('#hiddensize').val(_size);
							jQuery('#hiddencolor').val(_color);
							jQuery('#hiddenquantity').val(_qty);

							doTeamBuySubmit(_index,_itemsTotal);
						}
					});	
				} else {				
					finishedTeamSubmit();
				}
		});
	});
	

	
	// team matrix
	jQuery(function() {		
		jQuery('#tbmatrix input').each(function() {
		    var default_value = this.value;
		    jQuery(this).focus(function() {
		        if(this.value == default_value) {
		            this.value = '';
		        }
		    });
		    jQuery(this).blur(function() {
		        if(this.value == '') {
		            this.value = default_value;
		        }
		 		doAdd();
		    });
		});
	});


});


closeMailingList = function() {
	jQuery("#outterfootersignup").animate({"height":"0px"}, {queue:false,duration:600}).fadeOut();
}


serializeObj = function(obj) {
	var str = "";
	jQuery.each(obj, function(i,n) {
		str += i+'='+n+'&';
	});
	return str.replace(/\&$/, '');
}

fc_BuildFoxyCart = function() {
	xSessionString = fc_json.session_id;
	document.cookie ='fcsid=' + xSessionString +'; path=/';
	my_funtion();
}



getMySessionIdFromCookie = function() {
	var _SessionId = "";
	_foxycartsession = "exp_foxycart_session_id";
	var nameEQ = _foxycartsession + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) _SessionId = c.substring(nameEQ.length,c.length);
	}
	if (_SessionId != "") {
		return _SessionId;
	} else {
		return "";
	}
}

getMySessionStringFromCookie = function() {
	var _SessionId = "";
	_foxycartsession = "exp_foxycart_session_id";
	var nameEQ = _foxycartsession + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) _SessionId = c.substring(nameEQ.length,c.length);
	}
	if (_SessionId != "") {
		return "&fcsid=" + _SessionId;
	} else {
		return "";
	}
}


setDefaultFoxeeFormValues = function() {	
	jQuery('#hiddensize').val(jQuery('#dropsizelist').val());
	jQuery('#hiddencolor').val(jQuery('#dropcolorlist').val());
	jQuery('#hiddenquantity').val(jQuery('#visqty').val());	    		
}

finishedTeamSubmit = function() {

updateTeamBuyCartItemDiscounts();


	jQuery("#tbmatrix").find('input').each(function(i) {
		jQuery(this).attr("disabled", false);
		jQuery(this).val(0);
	});
	setDefaultFoxeeFormValues();
	jQuery(".addalltocart").css({"display":"inline"}); 
	jQuery(".addingteam").css({"display":"none"}); 
	
	
}

toggleteambuycontainer = function() {
	jQuery("#teambuycontainer").animate({"height":"toggle"}, {queue:false,duration:600});
}

toggleDropCart = function() {
	jQuery("#dropcart").animate({"width":"toggle", "height":"toggle"}, {queue:false,duration:500,easing:"easeOutQuint"}); 
}

showDropCartLoad = function() {
	jQuery("#dropcartloading").css({"display":"inline"});
	jQuery("#dropcartloadingtext").text('Adding Items To Your Cart');
}

showDropCartLoadDone = function() {
	jQuery("#dropcartloading").css({"display":"None"});
	jQuery("#dropcartloadingtext").text('Items Have Been Added To Your Cart');
}

dropCartClearTextAlerts = function() {
	jQuery("#dropcartloadingtext").text('');
}


showSingleItemTextAlert = function() {
	jQuery("#singletextalert").fadeIn(); 
	setTimeout("hideingleItemTextAlert()", 2000);
}

hideingleItemTextAlert = function() {
	jQuery("#singletextalert").fadeOut(); 
}

sortByCID = function(a,b){
		if(a.options.cid == b.options.cid){
			if(a.options.cid == b.options.cid){
				return 0;
			}
				return (a.options.cid < b.options.cid) ? -1 : 1;
			}
		return (a.options.cid < b.options.cid) ? -1 : 1;
}


checkForDiscounts = function(data) {
	var _productMatch = false;
	var _itemMatch = false;
	var _sizeMatch = false;
	var _colorMatch = false;
	var _productId = jQuery('input[name=code]').val();
	var _productSize = jQuery('input[name=sizes]').val();
	var _productColor = jQuery('input[name=colors]').val();
	var _productCount = parseInt(jQuery('input[name=quantity]').val());
	var _discounts = jQuery("#discounts").text().split("|");
	var _isdiscount = false;

	// check if product is in cart ::
	for (i=0;i<fc_json.products.length;i++) {    
		if (_productId==fc_json.products[i].code) {
			_productMatch = true;
			_productCount = _productCount + parseInt(fc_json.products[i].quantity);
			if (_productSize==fc_json.products[i].options.sizes) {
				_sizeMatch = true;
			} else {_sizeMatch = false;}
			if (_productColor==fc_json.products[i].options.colors) {
				_colorMatch = true;
			} else {_colorMatch = false;}
		}
		
		if (_sizeMatch && _colorMatch) {
			_itemMatch = true;
			_updatefoxyid = fc_json.products[i].id;
			_updatefoxyqty = parseInt(fc_json.products[i].quantity);
			_jsonproductplace = i;
			_updateCID = fc_json.products[i].options.cid;
		}
     }

	//alert(_productCount)
     
     // product NOT in cart ::
     if (_productMatch==false) {
     	for (d=0;d<_discounts.length;d++) { 
			if (_productCount >= parseInt(_discounts[d].split("-")[0])) {
				_isdiscount = true;
				_discountprice = _discounts[d].split("-")[1];
			}
		}

		if (_isdiscount) {
			return data = data.replace('price='+jQuery('input[name=price]').val(), 'price='+_discountprice);
		} else {
			return data;
		}
     }
     
     if (_itemMatch) {
     	for (d=0;d<_discounts.length;d++) { 
			if (_productCount >= parseInt(_discounts[d].split("-")[0])) {
				_isdiscount = true;
				_discountprice = _discounts[d].split("-")[1];
			}
		}
     	
		if (_isdiscount) {
				// remove item from cart
				removeItem(_updatefoxyid);
				// set discount price
				itemupdated = {
			     	"x:sku": _productId,
			     	"code": _productId,
			     	"weight": jQuery('input[name=weight]').val(),
			     	"name": jQuery('input[name=name]').val(),
			     	"price": _discountprice,
			     	"category": jQuery('input[name=category]').val(),
			     	"sizes": _productSize,
			     	"colors": _productColor,
			     	"quantity": _updatefoxyqty+parseInt(jQuery('input[name=quantity]').val()),
			     	"sku": jQuery('input[name=sku]').val(),
			     	"cid": _updateCID
			     	};

				// do item update
				doNewItemUpdate(jQuery.param(itemupdated));	
				return false;
		} else {
			_cid = jQuery('input[name=cid]').val();
			data = data.replace('cid='+_cid, 'cid='+_updateCID);
	
			return data;
		}
		
     } else {
     
     	for (d=0;d<_discounts.length;d++) { 
			if (_productCount >= parseInt(_discounts[d].split("-")[0])) {
				_isdiscount = true;
				_discountprice = _discounts[d].split("-")[1];
			}
		}
		
     	if (_isdiscount) {
			return data = data.replace('price='+jQuery('input[name=price]').val(), 'price='+_discountprice);
		} else {
			return data;
		}
		
     }

}


updateCartItemDiscounts = function(data) {
	var _productMatch = false;
	var _productId = jQuery('input[name=code]').val();
	var _productCount = parseInt(jQuery('input[name=quantity]').val());
	var _discounts = jQuery("#discounts").text().split("|");
	var _isdiscount = false;
	
	var _productSize = jQuery('input[name=sizes]').val();
	var _productColor = jQuery('input[name=colors]').val();
	_sizeMatch = false;
	_colorMatch = false;
	_foxycartid = 0;
	// check if product is in cart ::
     for (i=0;i<fc_json.products.length;i++) {    
		if (_productId==fc_json.products[i].code) {
			_productMatch = true;
			_productCount = _productCount + parseInt(fc_json.products[i].quantity);
			if (_productSize==fc_json.products[i].options.sizes) {
				_sizeMatch = true;
			} else {_sizeMatch = false;}
			if (_productColor==fc_json.products[i].options.colors) {
				_colorMatch = true;
			} else {_colorMatch = false;}
		}
		if (_sizeMatch && _colorMatch) {
			_itemMatch = true;
			_foxycartid = fc_json.products[i].id;
		}
     }

     if (_productMatch) {
     	for (d=0;d<_discounts.length;d++) { 
			if (_productCount >= parseInt(_discounts[d].split("-")[0])) {
				_isdiscount = true;
				_discountprice = _discounts[d].split("-")[1];
			}
		}
		
		if (_isdiscount)
			for (x=0;x<fc_json.products.length;x++) {    
				if (_productId==fc_json.products[x].code) {
				
					if (fc_json.products[x].id != _foxycartid) {
						
						// remove item from cart
						removeItem(fc_json.products[x].id);
						
						// set discount price
						itemupdated = {
					     	"x:sku": fc_json.products[x].code,
					     	"code": fc_json.products[x].code,
					     	"weight": fc_json.products[x].weight,
					     	"name": fc_json.products[x].name,
					     	"price": _discountprice,
					     	"category": fc_json.products[x].category,
					     	"sizes": fc_json.products[x].options.sizes,
					     	"colors": fc_json.products[x].options.colors,
					     	"quantity": fc_json.products[x].quantity,
					     	"sku": fc_json.products[x].options.sku,
					     	"cid": fc_json.products[x].options.cid
					     	};
	
						// do item update
						doItemUpdate(jQuery.param(itemupdated));	
						
					}
				}
			}

	}
} // end : updateCartItemDiscounts


updateTeamBuyCartItemDiscounts = function() {
	var _productMatch = false;
	var _productId = jQuery('input[name=code]').val();
	var _productCount = parseInt(jQuery('input[name=quantity]').val());
	var _discounts = jQuery("#discounts").text().split("|");
	var _isdiscount = false;
	
	var _productSize = jQuery('input[name=sizes]').val();
	var _productColor = jQuery('input[name=colors]').val();
	_sizeMatch = false;
	_colorMatch = false;
	_foxycartid = 0;
	// check if product is in cart ::
     for (i=0;i<fc_json.products.length;i++) {    
		if (_productId==fc_json.products[i].code) {
			_productMatch = true;
			_productCount = _productCount + parseInt(fc_json.products[i].quantity);
			if (_productSize==fc_json.products[i].options.sizes) {
				_sizeMatch = true;
			} else {_sizeMatch = false;}
			if (_productColor==fc_json.products[i].options.colors) {
				_colorMatch = true;
			} else {_colorMatch = false;}
		}
		if (_sizeMatch && _colorMatch) {
			_itemMatch = true;
			_foxycartid = fc_json.products[i].id;
		}
     }

     if (_productMatch) {
     	for (d=0;d<_discounts.length;d++) { 
			if (_productCount >= parseInt(_discounts[d].split("-")[0])) {
				_isdiscount = true;
				_discountprice = _discounts[d].split("-")[1];
			}
		}
		
		if (_isdiscount)
			for (x=0;x<fc_json.products.length;x++) {    
				if (_productId==fc_json.products[x].code) {
				
					//if (fc_json.products[x].id != _foxycartid) {
						
						// remove item from cart
						removeItem(fc_json.products[x].id);
						
						// set discount price
						itemupdated = {
					     	"x:sku": fc_json.products[x].code,
					     	"code": fc_json.products[x].code,
					     	"weight": fc_json.products[x].weight,
					     	"name": fc_json.products[x].name,
					     	"price": _discountprice,
					     	"category": fc_json.products[x].category,
					     	"sizes": fc_json.products[x].options.sizes,
					     	"colors": fc_json.products[x].options.colors,
					     	"quantity": fc_json.products[x].quantity,
					     	"sku": fc_json.products[x].options.sku,
					     	"cid": fc_json.products[x].options.cid
					     	};
	
						// do item update
						doTeamBuyItemUpdate(jQuery.param(itemupdated));	
						
					}
				//}
			}

	}
} // end : updateCartItemDiscounts

doTeamBuyItemUpdate = function(xItem) {    
	var _item = xItem;
	_item = _item.replace(/.*?\?/, '')+
				'&fc_session_id='+fc_json.session_id+
				'&func=order_form_cache'+
				'&ACT='+fe_AjaxACT;
	jQuery.ajax({
		url: fe_url,
		type: 'POST',
		data: _item,
		dataType: 'jsonp',
		success: newTeamBuyItemUpdateReturn
	});
	return false;
}
newTeamBuyItemUpdateReturn = function(json) {
	var MyFoxyData = (typeof json == 'object') ? serializeObj(json) : json;
	var url = "https://" + FoxyDomain + "/cart.php?" + MyFoxyData + fc_AddSession();
	jQuery.getScript(url+'&output=json&callback=fc_FoxyJSON');
	return false;
}

doNewItemUpdate = function(xItem) {    
	var _item = xItem;
	_item = _item.replace(/.*?\?/, '')+
				'&fc_session_id='+fc_json.session_id+
				'&func=order_form_cache'+
				'&ACT='+fe_AjaxACT;
	jQuery.ajax({
		url: fe_url,
		type: 'POST',
		data: _item,
		dataType: 'jsonp',
		success: newItemUpdateReturn
	});
	return false;
}
newItemUpdateReturn = function(json) {
	var MyFoxyData = (typeof json == 'object') ? serializeObj(json) : json;
	var url = "https://" + FoxyDomain + "/cart.php?" + MyFoxyData + fc_AddSession();
	jQuery.getScript(url+'&output=json&callback=my_BuildSingleItemCart'); //fc_FoxyJSON
	return false;
}


doItemUpdate = function(xItem) {    
	var _item = xItem;
	_item = _item.replace(/.*?\?/, '')+
				'&fc_session_id='+fc_json.session_id+
				'&func=order_form_cache'+
				'&ACT='+fe_AjaxACT;
	jQuery.ajax({
		url: fe_url,
		type: 'POST',
		data: _item,
		dataType: 'jsonp',
		success: itemUpdateReturn
	});
	return false;
}

itemUpdateReturn = function(json) {
	var MyFoxyData = (typeof json == 'object') ? serializeObj(json) : json;
	var url = "https://" + FoxyDomain + "/cart.php?" + MyFoxyData + fc_AddSession();
	jQuery.getScript(url+'&output=json&callback='); //fc_FoxyJSON
	return false;
}

updateItemQuantity = function(itemID,qty) {
	var updatestring = 'output=json&cart=update&1:quantity='+qty+'&1:id='+itemID;
	var updateurl = "https://" + FoxyDomain + "/cart.php?" + updatestring + fc_AddSession();	
	jQuery.getScript(updateurl+'&output=json&callback=updateItemQuantityReturn'); //fc_FoxyJSON
	return false;
}

updateItemQuantityReturn = function() {
	my_BuildSingleItemCart();
}


removeItem = function(itemID) {
	removestring = 'output=json&cart=update&1:quantity=0&1:id='+itemID;
	var removeurl = "https://" + FoxyDomain + "/cart.php?" + removestring + fc_AddSession();
	jQuery.getJSON(removeurl+'&output=json&callback=removeItemSuccess'); //fc_FoxyJSON
	return false;
}

removeItemSuccess = function() {
	var MyFoxyData = (typeof json == 'object') ? serializeObj(json) : json;
	var url = "https://" + FoxyDomain + "/cart.php?" + MyFoxyData + fc_AddSession();
	jQuery.getScript(url+'&output=json&callback='); //fc_FoxyJSON
	return false;
}

getNextCartItemNum = function() {
	_cartItemsTotal = fc_json.products.length;
	if (fc_json.products.length > 0) {
		_currentCartCount = parseInt(fc_json.products[_cartItemsTotal-1].options.cid);
	} else {
		_currentCartCount = 0;
	}
	
	return _currentCartCount+1;

}


doSingleItemSubmit = function() {    
	xID = jQuery('input[name=x:sku]').val();
	//_cid = getNextCartItemNum();
	//jQuery('input[name=cid]').val(_cid);

    var data = jQuery("form#foxycart_"+xID).serialize();
    
    //updateCartItemDiscounts(data);
    
	//xdata = checkForDiscounts(data);

	//if (xdata!=false) {
		data = data.replace(/.*?\?/, '')+
					'&fc_session_id='+fc_json.session_id+
					'&func=order_form_cache'+
					'&ACT='+fe_AjaxACT;
		jQuery.ajax({
			url: fe_url,
			type: 'POST',
			data: data,
			dataType: 'jsonp',
			success: my_BuildSingleItemCart
		});	
	//}
	return false;
}

my_BuildSingleItemCart = function(json) {

	var MyFoxyData = (typeof json == 'object') ? serializeObj(json) : json;
	
	var url = "https://" + FoxyDomain + "/cart.php?" + MyFoxyData + fc_AddSession();
		
	jQuery.getScript(url+'&output=json&callback=mySingleReturnFunction'); //fc_FoxyJSON

	return false;
}

mySingleReturnFunction = function() {

	var url = "https://" + FoxyDomain + "/cart.php?output=json&callback=fc_FoxyJSON"+fc_AddSession();
	jQuery.getScript(url);
	
	showSingleItemTextAlert();
	showDropCartLoadDone();
	setTimeout("toggleDropCart()", 4000);
	setTimeout("dropCartClearTextAlerts();", 4500);
}

doTeamBuySubmit = function(xItem,xTotal) {    
	xID = jQuery('input[name=x:sku]').val();
	
	//_nextid = getNextCartItemNum();
	//_cid = parseInt(_nextid)+parseInt(xItem);
	
	//jQuery('input[name=cid]').val(_cid);
	
    var data = jQuery("form#foxycart_"+xID).serialize();


	data = data.replace(/.*?\?/, '')+
				'&fc_session_id='+fc_json.session_id+
				'&func=order_form_cache'+
				'&ACT='+fe_AjaxACT;
	
	jQuery.ajax({
		url: fe_url,
		type: 'POST',
		data: data,
		dataType: 'jsonp',
		success: function(d) {my_BuildCart(d,xItem,xTotal);}
		 
	});

	return false;
}

my_BuildCart = function(json,xItem,xTotal) {
	var MyFoxyData = (typeof json == 'object') ? serializeObj(json) : json;
	var url = "https://" + FoxyDomain + "/cart.php?" + MyFoxyData + fc_AddSession();
	
	if (xItem==xTotal) {
		jQuery.getScript(url+'&output=json&callback=myReturnFunction'); //fc_FoxyJSON
	} else {
		jQuery.getScript(url+'&output=json&callback=fc_FoxyJSON');
	}

	return false;
}


myReturnFunction = function() {
	
		var url = "https://" + FoxyDomain + "/cart.php?output=json&callback=fc_FoxyJSON"+fc_AddSession();
		jQuery.getScript(url);
	
		finishedTeamSubmit();
		showDropCartLoadDone();
		setTimeout("toggleDropCart()", 4000);
		setTimeout("dropCartClearTextAlerts();", 4500);
}


doAdd = function() {
		var _numItems = 0;		
		var _foxeePrice = jQuery("#xprice").text();
		var _cleanPrice = _foxeePrice.replace(/^[ $]/g,'');

		jQuery("#tbmatrix").find('input').each(function(i) {
			_numItems = parseInt(_numItems) + parseInt(jQuery(this).val());
		});
		_priceTotal = _numItems * _cleanPrice;
		_finalPrice = _priceTotal.toFixed(2);
		jQuery("#totalteamitems").html(_numItems);
		jQuery("#totalteamprice").html(_finalPrice);
}


// function to create cells for matrix
function createTeamMatrix(xTotalRows) {
	var _matrixwidth = 718;
	var _numberofsizes = xTotalRows;
	_cellwidth = Math.floor(_matrixwidth/_numberofsizes)-1;
	_fullcell = _cellwidth + 1;
	_totalfullcells = parseInt(_fullcell*_numberofsizes);
	_remainder = parseInt(_matrixwidth - _totalfullcells);
	if (_remainder > 0) {
		_endcellwidth = (_cellwidth + _remainder + 1);
		
	} else {
		_endcellwidth = (_cellwidth + 1);
	}
	jQuery(".tbm_size_title, .tbm_size").css({"width": _cellwidth+"px"});
	jQuery(".tbm_size_title:last").css({"border-right":"0","width": _endcellwidth +"px"});
	jQuery(".tbmcell"+_numberofsizes).css({"border-right":"0","width": _endcellwidth +"px"});
	
	jQuery("#tbmatrix").find('input').each(function(i) {
		jQuery(this).numeric();
	});	
}




function startSlider(xCount) {
	var   _container = (450 * xCount);
	jQuery("#ppslider").css("width", _container);
}

function slideNext() {
	_tempCount = index + 1;
	if (_tempCount == _totalPages) {
		jQuery("#nextbutton").unbind("click", slideNext);
	}
	jQuery('#ppslider').animate({"marginLeft" : (index * -450) + "px"},1500 ,'easeOutElastic', function(){changePageNumber(index, _totalPages);});
	index = index + 1;
	return false;
}

function slidePrevious() {
	_tempCount = index - 1;
	if (_tempCount == 1) {
		jQuery("#previousbutton").unbind("click", slidePrevious);
	} 
	_currentMargin = parseInt(jQuery('#ppslider').css("marginLeft"));
	jQuery('#ppslider').animate({"marginLeft" : ( _currentMargin +450) + "px"},1500 ,'easeOutElastic', function(){changePageNumber(index, _totalPages);}); 
	index = index - 1;
	return false;
}

function changePageNumber(xPage) {
	jQuery('#currentpage').html(xPage);
	toggleNavButtons(xPage,_totalPages);
}

function toggleNavButtons(xPage,xPageCount) {
	if (xPage == xPageCount) { jQuery('#nextbutton').fadeOut("slow") } else { jQuery('#nextbutton').fadeIn("slow"); jQuery("#nextbutton").bind("click", slideNext); }
	if (xPage == 1) { jQuery('#previousbutton').fadeOut("slow") } else { jQuery('#previousbutton').fadeIn("slow"); jQuery("#previousbutton").bind("click", slidePrevious); }
}

function resetAddToCartButton() {
	jQuery("#thesubmitbutton").css({"display":"inline"}); 
	jQuery(".adding").css({"display":"none"}); 

}






/*
 		$("#tbmatrix").keyup(function () { 
				_numItems = 0;
				$(this).find('input').each(function(i) {
					_numItems = parseInt(_numItems) + parseInt($(this).val());
				});
				_priceTotal = _numItems * 49.95;
				_finalPrice = _priceTotal.toFixed(2);
				$("#totalteamitems").html(_numItems);
				$("#totalteamprice").html(_finalPrice);
		});		
		
		
		$("#tbmatrix input").focus(function (e) { 
			var _currentID = $(this).attr('id');
			if (_currentID!=0) {
      			$("#"+_currentID).val();
     		}
		});	
		
		$("#tbmatrix input").keyup(function (e) { 
			var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
			if (key==8) {
				var _currentID = $(this).attr('id');
      			$("#"+_currentID).val(0);
     		}
		});	
		
		$("#tbmatrix input").blur(function (e) { 
			var _currentID = $(this).attr('id');
			var _currentValue = $(this).val();			
			if (_currentValue.length > 1 && _currentValue.charAt(0) == 0) {
				var _cleanvalue = _currentValue.replace(/^[ 0]/g,'');
			} else {
				var _cleanvalue = _currentValue;
			}     		
     		$("#"+_currentID).val(_cleanvalue);
		});	
		*/

















