﻿window.addEvent('domready',function(){
    if($defined($('ctl00_EmailSignup'))) {
        $('ctl00_EmailSignup').addEvents({
            'focus' : function(){
                if (this.value=="your email address")
                    this.value=""; 
            },
            'blur' : function() {
                if (this.value=="")
                    this.value="your email address"; 
            }
        });
    }

    $$('img.button','input.button').each(function(oEl){
        oEl.addEvents({
            'mouseover':function(){
                this.src=this.src.replace('.gif','_over.gif');
            },
            'mouseout':function(){
                this.src=this.src.replace('_over.gif','.gif');
            }
        });
    });
    
    if($defined($('ctl00_SearchText'))){
        $('ctl00_SearchText').addEvents({
            'focus':function(){
                if($('ctl00_SearchText').value=="Search our catalog"){
                    $('ctl00_SearchText').value='';
                }
            },
            'blur':function(){
                if($('ctl00_SearchText').value==""){
                    $('ctl00_SearchText').value='Search our catalog';
                }
            }
        });
    }

    $$('ul li.item a, #footer-index li.link').each(function(el) {  
	    var fx = new Fx.Morph(el,{ duration:200, link:'cancel' });
	    el.addEvents({
		    'mouseenter': function() { fx.start({ 'padding-left': 3 }); },
		    'mouseleave': function() { fx.start({ 'padding-left': 0 }); }
	    });
    }); 

    $$('div.success').each(function(el) {
        var fadeFunction = function() {
            $(el).fade('out').get('tween').chain(
                function() {
                    (el).morph({ height: 0 }).get('morph').chain(
                        function() { $(el).destroy(); }
                    );
                }
            );
        }
        fadeFunction.delay(4000);    
    });    
});