﻿function tab_view(num) {
    switch (num) {
        case 2:
            var sn = 1;
            var tn = 3;

            break;
        case 3:
            var sn = 1;
            var tn = 2;

            break;
        case 1:
            var sn = 2;
            var tn = 3;

            break;

    }
    document.getElementById("tab" + num).style.display = "block";
    document.getElementById("tab" + sn).style.display = "none";
    document.getElementById("tab" + tn).style.display = "none";
    document.getElementById("t" + num).className = "active";
    document.getElementById("t" + sn).className = "";
    document.getElementById("t" + tn).className = "";
}
function verify_on(box1, box2) {
    document.getElementById(box1).style.display = "block";
    document.getElementById(box2).style.display = "none";
    return false;
}

var testing = { loading: 0 }

var ad = { show: false }



function thetext(type) {
    if (type == 'big') {

        document.getElementById("bigchar").innerHTML = '<a title="testo grande" style="background-position:0 -22px;" onclick=thetext("big") href=#>A</a>';
        document.getElementById("smallchar").innerHTML = '<a title="testo normale" style="background-position:0 0" onclick=thetext("small") href=#>A</a>';
        document.getElementById("doc").className = "dimension16";
        document.getElementById("caption").className = "dimension14";
        document.getElementById("captionbig").className = "dimension14";
    }
    else if (type == 'small') {

        document.getElementById("bigchar").innerHTML = '<a title="testo grande" style="background-position:0 0" onclick=thetext("big") href=#>A</a>';
        document.getElementById("smallchar").innerHTML = '<a title="testo normale" style="background-position:0 -18px" onclick=thetext("small") href=#>A</a>';
        document.getElementById("doc").className = "dimension12";
        document.getElementById("caption").className = "dimension11";
        document.getElementById("captionbig").className = "dimension11";
    }

}
function showStrip(num) {

    Effect.Appear("us" + num, { duration: 0.3, from: 0, to: 1 });

}
function hideStrip(num) {

    Effect.Fade("us" + num, { duration: 0.1, from: 1, to: 0 });

}
function showandhidden(what, id) {

    if (what == "open") {
        document.getElementById('open_approved_' + id).style.display = "none";
        document.getElementById('close_approved_' + id).style.display = "block";
        Effect.Appear("otherm_" + id, { duration: 0.3, from: 0, to: 1 });

    }
    else {
        document.getElementById('open_approved_' + id).style.display = "block";
        document.getElementById('close_approved_' + id).style.display = "none";
        Effect.Fade("otherm_" + id, { duration: 0.0, from: 1, to: 0 });

    }

}
function delDefaultValue(elem, id) {

    elemChange = document.getElementById(elem);
    if (elemChange.value == elemChange.defaultValue) {
        elemChange.value = '';
    }
    elemChange.style.color = '#333';


}

function checkEmptyValue(elem, id) {

    elemChange = document.getElementById(elem);
    if (elemChange.value == '') {
        elemChange.style.color = '#999';
        elemChange.value = elemChange.defaultValue;
    }
}

function comm_delDefaultValue(id) {
    if (id == undefined) {
        if (testing.loading == 1) {
            elemChange = document.getElementById("reply");
            if (elemChange.value == elemChange.defaultValue) {
                elemChange.value = '';
            }
            elemChange.style.color = '#333';
            elemChange.style.height = '80px';
            elemChange.style.width = '540px';
            document.getElementById("im").style.display = "block";

            document.getElementById("reply").focus()
        }
        else {

            document.getElementById("inscomments").style.display = "none";
            document.getElementById("comm_messagebig").style.display = "block";
            Effect.ScrollTo("all_comments");
        }
    }
    else {
        if (testing.loading == 1) {
            elemChange = document.getElementById("reply" + id);
            if (elemChange.value == elemChange.defaultValue) {
                elemChange.value = '';
            }
            elemChange.style.color = '#333';
            elemChange.style.height = '60px';
            elemChange.style.width = '425px';
            document.getElementById("im" + id).style.display = "block";
            document.getElementById("btn" + id).style.display = "block";
            document.getElementById("reply" + id).focus()
        }
        else {
            verify_on('only2_' + id, 'all_' + id)
            document.getElementById("rep_" + id).style.display = "none";
            document.getElementById("alert" + id).style.display = "block";
            Effect.ScrollTo("alert" + id);
        }
    }
}

function comm_checkEmptyValue(id) {
    if (id == undefined) {
        elemChange = document.getElementById("reply");
        if (elemChange.value == '') {
            elemChange.style.color = '#999';
            elemChange.value = elemChange.defaultValue;
            elemChange.style.height = '50px';
            elemChange.style.width = '595px';
            document.getElementById("im").style.display = "none";

        }
    }
    else {
        if (testing.loading == 1) {
            elemChange = document.getElementById("reply" + id);
            if (elemChange.value == '') {
                elemChange.style.color = '#999';
                elemChange.value = elemChange.defaultValue;
                elemChange.style.height = '20px';
                elemChange.style.width = '465px';
                document.getElementById("im" + id).style.display = "none";
                document.getElementById("btn" + id).style.display = "none";

            }
        }
    }

}

function sim_login(id) {
    testing.loading = 1;
    document.getElementById("login" + id).style.display = "none";
    document.getElementById("rep_" + id).style.display = "block";
    comm_delDefaultValue(id)

}

function ahah(url, target) {
    d = document.createElement("div");
    d.className = "popupDiv";
    d.style.width = "950px";
    d.style.height = "100px";
    d.style.position = 'absolute';
    d.style.zIndex = 1000;
    d.style.top = '100px';
    d.style.padding = '5px';
    d.style.backgroundColor = '#fff';
    d.style.backgroundImage = "url('http://livenetworkitalia.cloudapp.net/portals/images/loading.gif')";
    d.style.backgroundRepeat = 'no-repeat';
    d.innerHTML = "loading...";

    document.getElementById(target).appendChild(d);




    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (req != undefined) {
        req.onreadystatechange = function () { ahahDone(url, target); };
        req.open("GET", url, true);
        req.send("");
    }
}

function ahahDone(url, target) {
    if (req.readyState == 4) { // only if req is "loaded"
        if (req.status == 200) { // only if "OK"
            document.getElementById(target).innerHTML = req.responseText;
        } else {
            document.getElementById(target).innerHTML = "Errore:\n" + req.status + "\n" + req.statusText;
        }
    }
}



var conta = { text: 5 }
function increaseFontSize() {
    var p = document.getElementsByTagName('p');
    for (i = 0; i < p.length; i++) {
        if (p[i].style.fontSize) {
            var s = parseInt(p[i].style.fontSize.replace("px", ""));
        } else {
            var s = 13;
        }
        if (conta.text < 10) {
            s += 1;

        }
        p[i].style.fontSize = s + "px"

    }
    if (conta.text < 10) {
        conta.text += 1
    }

}
function decreaseFontSize() {
    var p = document.getElementsByTagName('p');
    for (i = 0; i < p.length; i++) {
        if (p[i].style.fontSize) {
            var s = parseInt(p[i].style.fontSize.replace("px", ""));
        } else {
            var s = 11;
        }
        if (conta.text > 3) {
            s -= 1;
        }
        p[i].style.fontSize = s + "px"

    }
    if (conta.text > 3) {
        conta.text -= 1
    }

}

function height(nome_div) {
    tt = document.getElementById(nome_div).offsetHeight;
    alert(tt)


}
function cinema_view(id) {
    var e = document.getElementById("cinema" + id);
    var f = document.getElementById("programmazione" + id);
    if ($(e).className == 'evidenza') {
        $(e).className = 'off_evidenza';
        f.style.visibility = 'hidden';
        f.style.display = 'none';


    }
    else {
        $(e).className = 'evidenza';
        f.style.visibility = 'visible';
        f.style.display = 'block';
    }

}



// Recupero la querystring della pagina
var qs = location.hash;


// Verifico che la pagina contenga una querystring
// ed in caso lancio la procedura di recupero dei dati,
// altrimenti avviso che non ci sono querystring definite
if (qs)
{
    // Definisco le variabili da recuperare in querystring
    var mediatype, mediaid, mediaval, mediaSec;

    // Recupero il valore delle tre variabili con semplici
    // ma ingegnosi controlli a catena sulle stringhe
    // dopo averle divise in array di stringa

    // Recupero il valore di mediatype
    mediatype = qs.split("#");
    mediatype = mediatype[1].split("&");
    mediatype = mediatype[0].substring(10);

    // Recupero il valore di mediaid
    mediaid = qs.split("&");
    mediaid = mediaid[1].substring(8);
	
	mediaval = qs.split("&");
	mediaval = mediaval[1].substring(9);
	
	mediaSec = qs.split("&");
	mediaSec = mediaSec[1].substring(9);




    // Controllo che le variabili siano state valorizzate
    mediatype == "" ? mediatype = "Non definito" : mediatype = mediatype;
    mediaid == "" ? mediaid = "Non definito" : mediaid = mediaid;
	mediaval == "" ? mediaval = "Non definito" : mediaval = mediaval;
	mediaSec == "" ? mediaSec = "Non definito" : mediaSec = mediaSec;

    // Stampo a video i valori
	
document.observe('dom:loaded', function() {
        
	
    if($('content-media')) {

	getMediaM(mediatype,mediaid,mediaval,mediaSec);
    }		

	
})
}





function getMedia(type, id, val) {
	window.location.hash = "mediatype=" + type +"&mediaid=" + id + "&mediaval=" + val;
    var divPlayer = document.getElementById("showmedia");
    divPlayer.style.display = 'block';
    var url = 'blank.html';
    if (type == 'video') {
		
        url = 'mediavideo.aspx?idMedia=' + id + '&val=' + val;
    }
    else {
         url = 'mediaimmagini.aspx?idMedia=' + id + '&val=' + val;
    }
    var th = 'content-media';
    $('content-media').hide();

    var unDiv = document.getElementById(th);
    if (unDiv.firstChild != null) {
        unDiv.removeChild(unDiv.firstChild);
    }
    unDiv.innerHTML = '';

    new Effect.Appear('loading', { duration: 0.1 });
    var myAjax = new Ajax.Updater(th, url,
			{
			    method: 'get',
			    insertion: Insertion.Top,
			    onSuccess: Success
			});
    return;
};

function getMediaM(type, id, typeSec, idSec) {
	window.location.hash = "mediatype=" + type +"&mediaid=" + id + "&mediaval=" + typeSec + "&mediaSec=" + idSec;
    var divPlayer = document.getElementById("showmedia");
    divPlayer.style.display = 'block';
    var url = 'blank.html';
    if (type == 'video') {
        url = 'mediavideo.aspx?idMedia=' + id;
    }
    else {
        url = 'mediaimmagini.aspx?idMedia=' + id + '&sec=' + typeSec + '&idsec=' + idSec;
    }
    var th = 'content-media';
	var unDiv = document.getElementById(th);

    unDiv.innerHTML = '';
    $('content-media').hide();



    document.getElementById("loading").style.display = "block";
    var myAjax = new Ajax.Updater(th, url,
			{
			    method: 'get',
			    insertion: Insertion.Top,
			    onSuccess: Success
			});
    return;
};


function showmedia(value) {
    var e = document.getElementById("showmedia");
    $(e).className = 'panel-hide';
    return false;
}


function Success() {
   document.getElementById("loading").style.display = "none";
	document.getElementById("content-media").style.display = "block";
};


/* main page video box (domestic & intl) 
===================================================================== */
var liveMpVpCurPage = 1;
var liveMpVpLock = false;
function liveMpVpBlur(lnk) {
    try {
        lnk.blur();
    } catch (e) { };
}
/*
* liveMpVpNext() and liveMpVpPrev()
* are called from previous and next buttons
*/
function liveMpVpNext(lnk) {
    liveMpVpBlur(lnk);
    if ((liveMpVpCurPage < 3) && (!liveMpVpLock)) {
        liveMpVpSlideLeft();
    }
}

function liveMpVpPrev(lnk) {
    liveMpVpBlur(lnk);
    if ((liveMpVpCurPage > 1) && (!liveMpVpLock)) {
        liveMpVpSlideRight();
    }
}

/*
* liveMpVpPage( intPage )
* called from clicking on gray dot icon
*/
function liveMpVpPage(intPage, lnk) {
    liveMpVpBlur(lnk);
    if ((liveMpVpCurPage != intPage) && (!liveMpVpLock)) {
        if (liveMpVpCurPage < intPage) {
            if ((intPage - liveMpVpCurPage) > 1) {
                liveMpVpSlideDoubleLeft();
            }
            else {
                liveMpVpSlideLeft();
            }
        }
        else {
            if ((liveMpVpCurPage - intPage) > 1) {
                liveMpVpSlideDoubleRight();
            }
            else {
                liveMpVpSlideRight();
            }
        }
    }
}

function liveLockMpVp(intDur) {
    var liveLockDur = intDur * 100;
    liveMpVpLock = true;
    setTimeout(function () { liveMpVpLock = false; }, liveLockDur);
}
function liveMpVpSlideLeft() {
    liveLockMpVp(3);
    new Effect.MoveBy('liveMpVidCtnt0', 0, -288, { duration: 0.3 });
    new Effect.MoveBy('liveMpVidCtnt1', 0, -288, { duration: 0.3 });
    new Effect.MoveBy('liveMpVidCtnt2', 0, -288, { duration: 0.3 });
    liveMpVpCurPage++;
    liveMpVpMoveDot();
    liveMpVpUpdateBtns();
}

function liveMpVpSlideDoubleLeft() {
    liveLockMpVp(6);
    new Effect.MoveBy('liveMpVidCtnt0', 0, -576, { duration: 0.6 });
    new Effect.MoveBy('liveMpVidCtnt1', 0, -576, { duration: 0.6 });
    new Effect.MoveBy('liveMpVidCtnt2', 0, -576, { duration: 0.6 });
    liveMpVpCurPage++;
    liveMpVpCurPage++;
    liveMpVpMoveDot();
    liveMpVpUpdateBtns();
}

function liveMpVpSlideRight() {
    liveLockMpVp(3);
    new Effect.MoveBy('liveMpVidCtnt0', 0, 288, { duration: 0.3 });
    new Effect.MoveBy('liveMpVidCtnt1', 0, 288, { duration: 0.3 });
    new Effect.MoveBy('liveMpVidCtnt2', 0, 288, { duration: 0.3 });
    liveMpVpCurPage--;
    liveMpVpMoveDot();
    liveMpVpUpdateBtns();
}

function liveMpVpSlideDoubleRight() {
    liveLockMpVp(6);
    new Effect.MoveBy('liveMpVidCtnt0', 0, 576, { duration: 0.6 });
    new Effect.MoveBy('liveMpVidCtnt1', 0, 576, { duration: 0.6 });
    new Effect.MoveBy('liveMpVidCtnt2', 0, 576, { duration: 0.6 });
    liveMpVpCurPage--;
    liveMpVpCurPage--;
    liveMpVpMoveDot();
    liveMpVpUpdateBtns();
}

function liveMpDotMouseOver(id) {
    $(id).src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_active_status.gif';
}

// image change functions
function liveMpVpMoveDot() {
    for (i = 1; i < 4; i++) {
        $('liveMpVidDot' + i).src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_status.gif';
        $('liveMpVidDot' + i).onmouseover = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_active_status.gif'; }
        $('liveMpVidDot' + i).onmouseout = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_status.gif'; }
    }
    $('liveMpVidDot' + liveMpVpCurPage).src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_active_status.gif';
    $('liveMpVidDot' + liveMpVpCurPage).onmouseover = function () { }
    $('liveMpVidDot' + liveMpVpCurPage).onmouseout = function () { }
}
function liveMpVpUpdateBtns() {
    if (liveMpVpCurPage > 1) {
        $('liveMpVidBtnL').style.cursor = 'pointer';
        $('liveMpVidBtnL').src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_red_btn.gif';
        $('liveMpVidBtnL').onmouseover = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_red_over_btn.gif'; }
        $('liveMpVidBtnL').onmouseout = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_red_btn.gif'; }
    }
    else {
        $('liveMpVidBtnL').style.cursor = 'default';
        $('liveMpVidBtnL').src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_gray_btn.gif';
        $('liveMpVidBtnL').onmouseover = function () { }
        $('liveMpVidBtnL').onmouseout = function () { }
    }

    if (liveMpVpCurPage < 3) {
        $('liveMpVidBtnR').style.cursor = 'pointer';
        $('liveMpVidBtnR').src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_red_btn.gif';
        $('liveMpVidBtnR').onmouseover = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_red_over_btn.gif'; }
        $('liveMpVidBtnR').onmouseout = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_red_btn.gif'; }
    }
    else {
        $('liveMpVidBtnR').style.cursor = 'default';
        $('liveMpVidBtnR').src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_gray_btn.gif';
        $('liveMpVidBtnR').onmouseover = function () { }
        $('liveMpVidBtnR').onmouseout = function () { }
    }
}
/* end main page video box
===================================================================== */


/* main page gallery box (domestic & intl) 
===================================================================== */
var liveMpGlCurPage = 1;
var liveMpGlLock = false;
function liveMpGlBlur(lnk) {
    try {
        lnk.blur();
    } catch (e) { };
}
/*
* liveMpGlNext() and liveMpGlPrev()
* are called from previous and next buttons
*/
function liveMpGlNext(lnk) {
    liveMpGlBlur(lnk);
    if ((liveMpGlCurPage < 3) && (!liveMpGlLock)) {
        liveMpGlSlideLeft();
    }
}

function liveMpGlPrev(lnk) {
    liveMpGlBlur(lnk);
    if ((liveMpGlCurPage > 1) && (!liveMpGlLock)) {
        liveMpGlSlideRight();
    }
}

/*
* liveMpGlPage( intPage )
* called from clicking on gray dot icon
*/
function liveMpGlPage(intPage, lnk) {
    liveMpGlBlur(lnk);
    if ((liveMpGlCurPage != intPage) && (!liveMpGlLock)) {
        if (liveMpGlCurPage < intPage) {
            if ((intPage - liveMpGlCurPage) > 1) {
                liveMpGlSlideDoubleLeft();
            }
            else {
                liveMpGlSlideLeft();
            }
        }
        else {
            if ((liveMpGlCurPage - intPage) > 1) {
                liveMpGlSlideDoubleRight();
            }
            else {
                liveMpGlSlideRight();
            }
        }
    }
}

function liveLockMpGl(intDur) {
    var liveLockDur = intDur * 100;
    liveMpGlLock = true;
    setTimeout(function () { liveMpGlLock = false; }, liveLockDur);
}
function liveMpGlSlideLeft() {
    liveLockMpGl(3);
    new Effect.MoveBy('liveMpGalCtnt0', 0, -288, { duration: 0.3 });
    new Effect.MoveBy('liveMpGalCtnt1', 0, -288, { duration: 0.3 });
    new Effect.MoveBy('liveMpGalCtnt2', 0, -288, { duration: 0.3 });
    liveMpGlCurPage++;
    liveMpGlMoveDot();
    liveMpGlUpdateBtns();
}

function liveMpGlSlideDoubleLeft() {
    liveLockMpGl(6);
    new Effect.MoveBy('liveMpGalCtnt0', 0, -576, { duration: 0.6 });
    new Effect.MoveBy('liveMpGalCtnt1', 0, -576, { duration: 0.6 });
    new Effect.MoveBy('liveMpGalCtnt2', 0, -576, { duration: 0.6 });
    liveMpGlCurPage++;
    liveMpGlCurPage++;
    liveMpGlMoveDot();
    liveMpGlUpdateBtns();
}

function liveMpGlSlideRight() {
    liveLockMpGl(3);
    new Effect.MoveBy('liveMpGalCtnt0', 0, 288, { duration: 0.3 });
    new Effect.MoveBy('liveMpGalCtnt1', 0, 288, { duration: 0.3 });
    new Effect.MoveBy('liveMpGalCtnt2', 0, 288, { duration: 0.3 });
    liveMpGlCurPage--;
    liveMpGlMoveDot();
    liveMpGlUpdateBtns();
}

function liveMpGlSlideDoubleRight() {
    liveLockMpGl(6);
    new Effect.MoveBy('liveMpGalCtnt0', 0, 576, { duration: 0.6 });
    new Effect.MoveBy('liveMpGalCtnt1', 0, 576, { duration: 0.6 });
    new Effect.MoveBy('liveMpGalCtnt2', 0, 576, { duration: 0.6 });
    liveMpGlCurPage--;
    liveMpGlCurPage--;
    liveMpGlMoveDot();
    liveMpGlUpdateBtns();
}

function liveMpGlDotMouseOver(id) {
    $(id).src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_active_status.gif';
}

// image change functions
function liveMpGlMoveDot() {
    for (i = 1; i < 4; i++) {
        $('liveMpGalDot' + i).src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_status.gif';
        $('liveMpGalDot' + i).onmouseover = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_active_status.gif'; }
        $('liveMpGalDot' + i).onmouseout = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_status.gif'; }
    }
    $('liveMpGalDot' + liveMpGlCurPage).src = 'http://livenetworkitalia.cloudapp.net/portals/images/gray_active_status.gif';
    $('liveMpGalDot' + liveMpGlCurPage).onmouseover = function () { }
    $('liveMpGalDot' + liveMpGlCurPage).onmouseout = function () { }
}
function liveMpGlUpdateBtns() {
    if (liveMpGlCurPage > 1) {
        $('liveMpGalBtnL').style.cursor = 'pointer';
        $('liveMpGalBtnL').src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_red_btn.gif';
        $('liveMpGalBtnL').onmouseover = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_red_over_btn.gif'; }
        $('liveMpGalBtnL').onmouseout = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_red_btn.gif'; }
    }
    else {
        $('liveMpGalBtnL').style.cursor = 'default';
        $('liveMpGalBtnL').src = 'http://livenetworkitalia.cloudapp.net/portals/images/left_gray_btn.gif';
        $('liveMpGalBtnL').onmouseover = function () { }
        $('liveMpGalBtnL').onmouseout = function () { }
    }

    if (liveMpGlCurPage < 3) {
        $('liveMpGalBtnR').style.cursor = 'pointer';
        $('liveMpGalBtnR').src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_red_btn.gif';
        $('liveMpGalBtnR').onmouseover = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_red_over_btn.gif'; }
        $('liveMpGalBtnR').onmouseout = function () { this.src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_red_btn.gif'; }
    }
    else {
        $('liveMpGalBtnR').style.cursor = 'default';
        $('liveMpGalBtnR').src = 'http://livenetworkitalia.cloudapp.net/portals/images/right_gray_btn.gif';
        $('liveMpGalBtnR').onmouseover = function () { }
        $('liveMpGalBtnR').onmouseout = function () { }
    }
}
/* end main page gallery box
===================================================================== */


