
	window.addEvent("domready",function(){

		// MAKE NEWSLETTER FORM WORK

		$('newsletter-form-field').addEvent("focus",function(){
			this.setStyle("color","#000000");
			if (this.get("value") == 'Enter Email Address...') this.value = '';
		});

		$('newsletter-form-field').addEvent("blur",function(){
			if (this.get("value") == '') {
				this.setStyle("color","#c1c1c1");
				this.value = 'Enter Email Address...';
			}
		});

		$('newsletter-form-button').addEvent("click",function(event){
			event.stop();
			$('newsletter-form').submit();
		});

		$$('.qty-add').addEvent("click",changeQty);
		$$('.qty-sub').addEvent("click",changeQty);

		$$('a.popup-link').addEvent("click",function(event){
			event.stop();
			link = event.target;
			while (link.tagName != 'A' && link.tagName != 'HTML') {
				link = $(link).getParent();
			}
			link.blur();
			window.open(link.href,'largeimage','width=640,height=400,left=250,top=100,screenX=250,screenY=150,scrollbars=yes,resizable=no,menubar=no,status=no,directories=no,location=no');
		});
	});

	function changeQty(event) {

		event.stop();
		event.target.blur();
		tableCell = event.target;
		while (tableCell.tagName != 'TD') { tableCell = tableCell.getParent(); }

		qtybox = tableCell.getElements('.qty-box')[0];

		if (event.target.hasClass("qty-add")) {
			qtybox.value = (qtybox.value * 1) + 1;
		} else if (event.target.hasClass("qty-sub")) {
			if (qtybox.value > 0) {
				qtybox.value = (qtybox.value * 1) - 1;
			}
		}

	}

        function runSlideShow(imagearray,show,showpos) {

                // If no position then set one.
                if (!show) var show = 0;
                if (!showpos) var showpos = Array();
                if (!showpos[show]) showpos[show] = 0;

                nextPic = showpos[show] + 1; if (nextPic >= imagearray[show].length) nextPic = 0;

                fadelength = 2000;
                steps = 100;

                // Set Background Image to Match Foreground
                document.getElementById('slideshow'+show+'back').src = document.getElementById('slideshow'+show+'front').src;

                // Set Foreground Opacity to Transparent
                setTimeout('setOpacity("slideshow'+show+'front",0)',50);

                // Set Foreground to the next Picture
                setTimeout('document.getElementById(\'slideshow'+show+'front\').src = \''+imagearray[show][nextPic].src+'\'',100);

                // Loop through changing the Opacity
                for(i = 0; i <= steps; i++) {
                        opacity = i/steps * 100;
                        setTimeout('setOpacity("slideshow'+show+'front",'+opacity+')',((i*(fadelength/steps))+150));
                }

                showpos[show] = nextPic;
                show = show + 1; if (show >= imagearray.length) show = 0;

                setTimeout( function () { runSlideShow(imagearray,show,showpos) } ,3000);

        }

        function setOpacity(id,value) {
                document.getElementById(id).style.opacity = (value / 100);
                document.getElementById(id).style.MozOpacity = (value / 100);
                document.getElementById(id).style.KhtmlOpacity = (value / 100);
                document.getElementById(id).style.filter = "alpha(opacity=" + value + ")";
        }




