
window.addEvent('domready', function() {
    var url = 'http://www.shopzine.fr';
    
    $('sbi').addEvent('focus', function() {
        $('sbi').setProperty('value', '');
    });
    
    $('sts').addEvent('click', function() {
        if ( $('sts').getProperty('class') == '_off' ) {
            $('sts').setProperty('src', url + '/images/search-shopzine-on.gif');
            $('sts').setProperty('class', '_on');
            
            $('stg').setProperty('src', url + '/images/search-google-off.gif');
            $('stg').setProperty('class', '_off');
            
            $('sitesearch').setProperty('value', 'http://www.shopzine.fr');
        }
    });
    
    $('stg').addEvent('click', function() {
        if ( $('stg').getProperty('class') == '_off' ) {
            $('sts').setProperty('src', url + '/images/search-shopzine-off.gif');
            $('sts').setProperty('class', '_off');
            
            $('stg').setProperty('src', url + '/images/search-google-on.gif');
            $('stg').setProperty('class', '_on');
            
            $('sitesearch').setProperty('value', '');
        }
    });
    
    $('t_offers').addEvent('click', function() {
        $('t_offers').removeClass('tab'); $('t_offers').addClass('tab-enabled');
        $('t_comments').removeClass('tab-enabled'); $('t_comments').addClass('tab');
        $('_comments').setStyle('display', 'none'); $('_offers').setStyle('display', 'block');
    });
    
    $('t_comments').addEvent('click', function() {
        $('t_offers').removeClass('tab-enabled'); $('t_offers').addClass('tab');
        $('t_comments').removeClass('tab'); $('t_comments').addClass('tab-enabled');
        $('_offers').setStyle('display', 'none'); $('_comments').setStyle('display', 'block');   
    });
    
    $('formComment').addEvent('submit', function(e) {
        new Event(e).stop();
        var buffer = $('comments').empty();
        $('sendComment').setProperty('value', 'Veuillez patienter ...');
        $('sendComment').setProperty('disabled', 'disabled');
        this.send({
            update: buffer,
            onComplete: function() {
                $('sendComment').removeProperty('disabled');
                $('sendComment').setProperty('value', 'Valider');
                
                $('nameComment').setProperty('value', '');
                $('emailComment').setProperty('value', '');
                $('textComment').setProperty('value', '');
                
                $('message').effect('opacity', {duration: 5000, transition: Fx.Transitions.Expo.easeIn}).start(0);
                (function(){$('message').setStyle('display', 'none')}).delay(5200);
            }                                                                                              
        });
     });
     
});

function addToFavorites(anchor)
{
    if (window.external) {
        window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
    }
}