﻿
/////////////////////////////////////////////////////////////////////////////////
//Offerte
var timeEffect = 3000;
var timerOfferte;
var timerOfferte_2;
var timerOfferte_3;

function getOfferta() {
    try {
        if ($get("blindup") == null) {
            window.clearTimeout(timerOfferte);
            window.clearTimeout(timerOfferte_2);
            return;
        }

        Sidan.WebApplication.WebServiceOfferte.GetOfferta(SuccedCallbackOfferte);
        Effect.BlindDown('blindup', { duration: 2.0 });
    }
    catch (e) {
    }
}

function SuccedCallbackOfferte(result, arg) {
    try {
        if ($get("blindup") == null) {
            window.clearTimeout(timerOfferte);
            window.clearTimeout(timerOfferte_2);
            return;
        }

        $get("DivOffertaTitolo").innerHTML = result.Titolo;
        $get("DivOffertaDescrizione").innerHTML = result.Descrizione.length < 10 ? "<br/>Nessuna descrizione del prodotto disponibile" : result.Descrizione;
        $get("hProductID").value = result.ProductID;
        timerOfferte = window.setTimeout("Effect.BlindUp('blindup',{ duration: 2.0 });", (3000 + timeEffect));
        timerOfferte_2 = window.setTimeout("getOfferta();", (5500 + timeEffect));
    }
    catch (e) {
    }
}
//Offerte 
/////////////////////////////////////////////////////////////////////////////////

//cambio tra flash intro e pagina home
function LoadBody() {
    window.setTimeout("$get('PanelHomePage').style.display = 'inline';$get('PanelHomePage').style.visibility = 'visible';", 1000);
    window.setTimeout("new Effect.Opacity('PanelIntro', { from: 1, to: 0 });", 100);
    window.setTimeout("$get('PanelIntro').style.display = 'none';", 1000);
    window.setTimeout("$get('PanelIntro').style.visibility = 'hidden';", 1000);
    new Effect.Opacity('PanelHomePage', { from: 0, to: 1 });
    $get('PanelContent').style.display = 'none';
    getContent("Home");
}

/////////////////////////////////////////////////////////////////////////////////
//load dynamic usercontrols
var threadStartet = "";
var sectionNew = "";

function getContent(section) {
    
    if (threadStartet != "" || sectionNew == section && section != "Prodotti")
        return;

    Effect.ScrollTo('article_top');
    threadStartet = true;
    sectionNew = section;

    window.clearTimeout(timerOfferte);
    window.clearTimeout(timerOfferte_2);
    window.clearTimeout(timerOfferte_3);

    try {
        if ($get('map')) {
            new Effect.Opacity('map', { from: 1, to: 0 });
            window.setTimeout("$get('map').style.display = 'none';", 450);
        }
    }
    catch (e) {
    }
        //

    $get('PanelLoading').style.display = 'inline';
    new Effect.Opacity('PanelLoading', { from: 0, to: 1 });
    new Effect.Opacity('PanelBody', { from: 1, to: 0 });

    try {
        if ($get('PanelContent'))
            new Effect.Opacity('blindup', { from: 1, to: 0 });
    }
    catch (e) { 
    }
    
    window.setTimeout("DoPostBack();", 1000);

    var time = 2000;
    if (window.navigator.userAgent.indexOf("MSIE") == -1)
        time = 2200;
    window.setTimeout("LoadEffect();", time);

    if (section == "Home" || "Prodotti")
        timerOfferte_3 = window.setTimeout("getOfferta();", 3000);

    //return true; 
}

function DoPostBack() {
    $get('PanelContent').style.display = 'none';
    __doPostBack('ButtonFake', sectionNew);

    $get("HiddenFieldProductID").value = "";
    $get("HiddenFieldCategoryID").value = "";
}

function LoadEffect() {
    window.setTimeout("threadEnd();", 300);
    new Effect.Opacity('PanelBody', { from: 0, to: 1 });
    new Effect.Opacity('PanelLoading', { from: 1, to: 0 });
}

function threadEnd() {
    $get('PanelLoading').style.display = 'none';
    $get('PanelContent').style.display = 'inline';
    threadStartet = "";
}
//load dynamic usercontrols
/////////////////////////////////////////////////////////////////////////////////
//cambio lingua
function getLanguage(language) {
    __doPostBack('ButtonLang', language);
}
/////////////////////////////////////////////////////////////////////////////////
//display none,inline
var displayElement_currentObj = '';
function DisplayElement(obj) {
    try {
        if (displayElement_currentObj != '')
            if (displayElement_currentObj != obj)
            if ($get(displayElement_currentObj) != null)
            $get(displayElement_currentObj).style.display = 'none';
        if ($get(obj).style.display == 'inline')
            $get(obj).style.display = 'none';
        else if ($get(obj).style.display == 'none')
            $get(obj).style.display = 'inline';
        displayElement_currentObj = obj;
    }
    catch (e) {
    }
}
/////////////////////////////////////////////////////////////////////////////////
function CustomScroll() {
    //window.setTimeout("Effect.ScrollTo('product_" + productID + "');", 800);
    window.setTimeout("Effect.ScrollTo('article_top');", 200);
}




