
Evonux.Custom = {}

var timer1;
var timer2;


/**
 * Show option popup
 */
Evonux.Custom.showOption = function (ref)
{
    var		width = 500;
    var		height = 400;
    var		top = (screen.height - height) / 2;
    var		left = (screen.width - width) / 2;
    var		popup;

    popup = window.open (U_ROOT + '/?module=webpage&action=view&template=none&ref=' + ref, '', "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, border=no, left=" + left + ", top=" + top + ", width=" + width + ", height=" + height);    
    popup.focus ();
}

/**
 * Fading slide
 */
Evonux.Custom.slide = function ()
{        
    clearInterval (timer1);
    var fx1 = new Fx.Morph ('bnr', { duration: 800, transition: Fx.Transitions.Pow.easeOut });
    var fx2 = new Fx.Morph ('bnr', { duration: 800, transition: Fx.Transitions.Pow.easeIn });

    Evonux.Page.get ("module=tools&action=refreshBanner", "", function () {
	var img = this.response.text;
	fx1.start({ 'opacity': 0.1, 'background-color': '#ffffff'}).chain(function() { $('bnr').src = img; fx2.start({ 'opacity': 1, 'background-color': 'transparent' }) });	   
    });
}

/**
 * Refresh home promos
 */
Evonux.Custom.refreshPromos = function ()
{        
    clearInterval (timer2);

    if ($('promos-tyres'))
    {
	Evonux.Page.get ("module=product&action=getTyresPromos", "", function () { $('promos-tyres').innerHTML = this.response.text; });
    }
    if ($('promos-wheels'))
    {
	Evonux.Page.get ("module=product&action=getWheelsPromos", "", function () { $('promos-wheels').innerHTML = this.response.text; });
    }
}

/** 
 * Open submenu
 */
Evonux.Custom.selectMenu = function (i)
{
    $$('sub').each (function (el)
	{
	    el.addClass ("off");
	    el.removeClass ("selected");
	});
    $('submenu-item-' + i).removeClass ("off");
    $('submenu-item-' + i).addClass ("selected");
}

/**
 * Mark submenu open
 */
Evonux.Custom.selectSubmenu = function (sel)
{
    $$('sublink').each (function (el)
	{
	    el.removeClass ("selected");
	});
    sel.addClass ('selected');
}
