// Document Ready Functions
$(document).ready(function() {


	$('#holiday_shipping_link').click(function() {
		if ($('#holidayPop').is(':visible')) {
			$('#holidayPop').fadeOut('fast');
		} else {
			$('#holidayPop').fadeIn('fast');
		}
	});
	
	$('#holiday_shipping_close_button').click(function() {
		$('#holidayPop').fadeOut('fast');
	});
	
	
});



function openLargePop2(image){
	NewWin = window.open(image,"LargeImage","resizable=yes,scrollbars=auto,status=no,width=600,height=700");
	if (window.focus) {NewWin.focus();}
}
function openLargePop3(image){
	NewWin3 = window.open(image,"LargeImage3","resizable=yes,scrollbars=yes,status=no,width=780,height=700");
	if (window.focus) {NewWin3.focus();}
}
function openPopupWindow(url,window_name,width,height) {
	var newPopupWindow = window.open(url, window_name, "resizable=yes,scrollbars=yes,status=yes,width=" + width + ",height=" + height);
	if (window.focus) {newPopupWindow.focus();}
}

function showAttrOpts(bttn, id){
	document.getElementById(bttn).style.display = 'none';
	document.getElementById(id).style.display = 'block';
}
function getProdOpt(pratt) {
	var opt;
	for (var i=0; i<pratt.length; i++)
	{
		if (pratt[i].checked == true)
		{
			opt = pratt[i].value;
			break;
		}
	}
	return opt;
}
function scAddToCartWithAttr(pratt,url,strfnbr,prrfnbr,suffix,wl){
	var opt = document.getElementById('pratt'+prrfnbr).value;
	var qty = document.getElementById('qty'+prrfnbr).value;
	if (qty == null) { qty = 1; }
	var re = new RegExp("\\d", "g");
	if (!qty.match(re)) { qty = 1; }
	scAddToCart(url,strfnbr,prrfnbr,suffix,opt,qty,'','',wl);

}

//Chrome/Safari 1px background alignment fix
$(window).resize(function() {
	chrome1pxFix();
});
$(document).ready(function(){
	chrome1pxFix();
});

function chrome1pxFix() {
	if ($.browser.webkit == true) {
		if (document.documentElement.clientWidth % 2 == 1) 	{ $('html').css({'margin-left': '-1px'}); }
		else 												{ $('html').css({'margin-left': '0px'}); }
	}
}
function stripWhiteSpace(id) {
	document.getElementById(id).value = document.getElementById(id).value.replace(/^\s+|\s+$/g,"");
}

$.extend({
	getUrlVars: function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++) {
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	},
	getUrlVar: function(name){
		return $.getUrlVars()[name];
	}
});
