$(document).ready(function() {
    try {
        
    	//if (document.all && version < 7 && version >= 5.5) correctPNG();
    	MM_preloadImages(
    		'images/topnav_beans_on.png',
    		'images/topnav_tea_on.png',
    		'images/topnav_gift_on.png',
    		'images/topnav_things_on.png',
    		'images/topnav_store_on.png'
    	);
    	//-----------------------
    	$('.addToCart').click(function(){
    		formID = $(this).attr('href');
    		$(formID).submit();
    		return false;
    	});
    	
    	$('#addToCartGiftCard').submit(function(){
    		$('#coffee_card_description').val(
    			'$'+$('#coffee_card_amount').val()
    		);
    	});
    	
        $('.thumbnail a').lightBox();
        
        //--------------------
        $('#giftbox_small').mouseover(
    		function() {
    			$('#rollover_giftbox_small').fadeIn('fast');
    		}
    	);
    	
    	$('#giftbox_medium').mouseover(
    		function() {
    			$('#rollover_giftbox_medium').fadeIn('fast');
    		}
    	);
    	
    	$('#giftbox_large').mouseover(
    		function() {
    			$('#rollover_giftbox_large').fadeIn('fast');
    		}
    	);
    	
    	$('#javathings_mugs').mouseover(
    		function() {
    			$('#rollover_javathings_mugs').fadeIn('fast');
    		}
    	);
    	//---------------
    	$('#javathings_travelmugs').mouseover(
    		function() {
    			$('#rollover_javathings_travelmugs').fadeIn('fast');
    		}
    	);
    	
    	//teas
    	$('#tea_black').mouseover(
    		function() {
    			$('#rollover_tea_black').fadeIn('fast');
    		}
    	);
    	$('#tea_decaf').mouseover(
    		function() {
    			$('#rollover_tea_decaf').fadeIn('fast');
    		}
    	);
    	$('#tea_boxed').mouseover(
    		function() {
    			$('#rollover_tea_boxed').fadeIn('fast');
    		}
    	);
    	$('#tea_acc').mouseover(
    		function() {
    			$('#rollover_tea_acc').fadeIn('fast');
    		}
    	);
    	
    	//coffees
    	$('#coffee_accessories').mouseover(
    		function() {
    			$('#rollover_coffee_accessories').fadeIn('fast');
    		}
    	);
    	
    	$('.header_rollover').mouseout(
    		function() {
    			$('.header_rollover').fadeOut('fast');
    		}
    	);
        
    } catch(err) {
        alert(err);
    }
});
function fnRoll(imgName,strSrc) {
	if (document.images&&!(document.all&&version<7)) document[imgName].src = strSrc;
}
function PNGswap(myID) {
	strOver =	"_on";
	strOff =	"_off";
	oSpan = 	document.all[myID];
	currentAlphaImg = oSpan.filters(0).src;
	oSpan.filters(0).src = (currentAlphaImg.indexOf(strOver) != -1) ? currentAlphaImg.replace(strOver,strOff) : currentAlphaImg.replace(strOff,strOver);
}
function MM_preloadImages() { //v3.0
	var d=document;
	if (d.images) {
		if (!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for (i=0; i<a.length; i++) if (a[i].indexOf("#")!=0) {
			d.MM_p[j]=new Image;
			d.MM_p[j++].src=a[i];
		}
	}
}
function correctPNG() {
	for (var i=0;i<document.images.length;i++) {
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			var imgID = (img.id) ? "id='" + img.id + "' " : "";
			var imgClass = (img.className) ? "class='" + img.className + "' " : "";
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			var imgStyle = "display:inline-block;" + img.style.cssText;
			if (img.align == "left") imgStyle = "float:left;" + imgStyle;
			if (img.align == "right") imgStyle = "float:right;" + imgStyle;
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
			var strNewHTML = "<span " + imgID + imgClass + imgTitle + ' style="width:' + img.width + "px;height:" + img.height + "px;" + imgStyle + ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale');\"";
			if (img.id) strNewHTML += " onmouseover=\"PNGswap('" + img.id + "')\" onmouseout=\"PNGswap('" + img.id +"')\"";
			strNewHTML += "></span>";
			img.outerHTML = strNewHTML;
			i = i-1;
		}
	}
}
arVersion =	navigator.appVersion.split("MSIE");
version =	parseFloat(arVersion[1]);
