﻿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 tab_view_multimedia(num) {
    switch (num) {
        case 2:
            var sn = 1;
           

            break;
     
        case 1:
            var sn = 2;
          
            break;

    }
    document.getElementById("tab" + num).style.display = "block";
    document.getElementById("tab" + sn).style.display = "none";
    document.getElementById("t" + num).className = "active";
    document.getElementById("t" + sn).className = "";
}
function handleEnter(obj, event) {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13) {
        document.getElementById(obj).click();
        return false;
    }
    else {
        return true;
    }
}
function verify_on(box1, box2) {
    if (document.getElementById(box1) != null) {
        if (document.getElementById(box1).style.display == "none")
       { document.getElementById(box1).style.display = "block"; }
       else { document.getElementById(box1).style.display = "none"; }
    }
    if (document.getElementById(box2) != null) {
        if (document.getElementById(box2).style.display == "none")
        { document.getElementById(box2).style.display = "block"; }
        else { document.getElementById(box2).style.display = "none"; }
    }
    return false;
}
//function verify_on(box1) {
//    if (document.getElementById(box1) != null) {
//        if (document.getElementById(box1).style.display == "none")
//        { document.getElementById(box1).style.display = "block"; }
//        else { document.getElementById(box1).style.display = "none"; }
//        
//    }
//   
//    return false;
//}
var testing = { loading: 0 }

var thisid = { id: -1}

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("comments_page");
        }
    }


    else if (id == 'h') {
        if (testing.loading == 1) {
            elemChange = document.getElementById("reply_h");
            if (elemChange != null) {
                if (elemChange.value == elemChange.defaultValue) {
                    elemChange.value = '';
                }
                elemChange.style.color = '#333';
                elemChange.style.height = '80px';
                elemChange.style.width = '540px';
                document.getElementById("im_h").style.display = "block";

                document.getElementById("reply_h").focus();
            }
        }
        else {

            document.getElementById("inscomments_h").style.display = "none";
            document.getElementById("comm_messagebig_h").style.display = "block";
            Effect.ScrollTo("comments_h");
        }
    }

    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 (id == 'h') {
        elemChange = document.getElementById("reply_h");
        if (elemChange.value == '') {
            elemChange.style.color = '#999';
            elemChange.value = elemChange.defaultValue;
            elemChange.style.height = '50px';
            elemChange.style.width = '595px';
            document.getElementById("im_h").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 sim_loginH() {
    testing.loading = 1;
    //    document.getElementById("comm_loginbig_h").style.display = "none";
    //    document.getElementById("inscomments_h").style.display = "block";
    comm_delDefaultValue('h');
}
function ismaxlength(obj) {
    var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
    if (obj.getAttribute && obj.value.length > mlength)
        obj.value = obj.value.substring(0, mlength)
}
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://www.edix.it/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
    }

}

var dropliciousShowingUpDuration = 0;
var dropliciousHidingDuration = 0.1;
var dropliciousHideDelay = 0.5;

function dropliciousShowingUpEffect(element) {
    if (!element.visible()) {
        new Effect.Appear(element, {
            duration: dropliciousShowingUpDuration,
            queue: {
                position: 'end',
                scope: element.identify(),
                limit: 2
            }
        });
    }
}

function dropliciousHidingEffect(element) {
    new Effect.Fade(element, {
        duration: dropliciousHidingDuration,
        queue: {
            position: 'end',
            scope: element.identify(),
            limit: 2
        }
    });
}

function setDelayedHide(element) {
    element.addClassName('waitingtohide')
    if (!element.hasClassName('hidding')) {
        if (!element.hasClassName('hiddingtimerset')) {
            element.addClassName('hiddingtimerset');
            setTimeout(function () { delayedHide(element); }, dropliciousHideDelay * 1000);
        }
    }
}
function delayedHide(dropElement) {
    dropElement.removeClassName('hiddingtimerset');
    if (dropElement.hasClassName('waitingtohide')) {
        dropliciousHidingEffect(dropElement);
        dropElement.addClassName('hidding');
        setTimeout(
                                               function () {
                                                   dropElement.removeClassName('waitingtohide');
                                                   dropElement.removeClassName('hidding');
                                                   dropElement.removeClassName('active');
                                               }, dropliciousHidingDuration * 1000);
    }
}

function linkMouseOut(id) {
    var dropElement = id.element().next();
    if (dropElement && dropElement.hasClassName('active')) {
        setDelayedHide(dropElement);
    }
}
function linkMouseOver(id) {

    var dropElement = id.element().next();
    if (dropElement) {
        if (!dropElement.hasClassName('hidding')) {
            dropElement.removeClassName('waitingtohide');
        }
        if (!dropElement.hasClassName('active')) {
            dropElement.addClassName('active');
            dropliciousShowingUpEffect(dropElement);
        }
    }
}
function submenuMouseOut(event) {
    var dropElement = event.findElement("ul");
    if (dropElement && dropElement.hasClassName('active')) {
        setDelayedHide(dropElement);
    }
}

function submenuMouseOver(event) {
    var dropElement = event.findElement("ul");
    if (dropElement && !dropElement.hasClassName('hidding')) {
        dropElement.removeClassName('waitingtohide');
    }
}

document.observe('dom:loaded', function () {
    $$('a.drops').each(function (name) {
        name.observe('click', linkMouseOver.bindAsEventListener(this));
        name.observe('mouseout', linkMouseOut.bindAsEventListener(this));
    });

    $$('ul.scriptaculously').each(function (name) {
        name.observe('mouseover', submenuMouseOver.bindAsEventListener(this));
        name.observe('mouseout', submenuMouseOut.bindAsEventListener(this));
    });
})
/* 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://www.edix.it/portals/images/gray_active_status.gif';
}

// image change functions
function liveMpVpMoveDot() {
	for(i=1;i<4;i++) {
		$('liveMpVidDot'+i).src = 'http://www.edix.it/portals/images/gray_status.gif';
		$('liveMpVidDot'+i).onmouseover = function() {this.src = 'http://www.edix.it/portals/images/gray_active_status.gif';}
		$('liveMpVidDot'+i).onmouseout = function() {this.src = 'http://www.edix.it/portals/images/gray_status.gif';}
	}
	$('liveMpVidDot'+liveMpVpCurPage).src = 'http://www.edix.it/portals/images/gray_active_status.gif';
	$('liveMpVidDot'+liveMpVpCurPage).onmouseover = function() {}
	$('liveMpVidDot'+liveMpVpCurPage).onmouseout = function() {}
}
function showdivimg() {
    document.getElementById("img_insert").style.display = "block";
    document.getElementById("video_insert").style.display = "none";
}
function showdivvideo() {
    document.getElementById("video_insert").style.display = "block";
    document.getElementById("img_insert").style.display = "none";
}


function liveMpVpUpdateBtns() {
	if(liveMpVpCurPage > 1) {
		$('liveMpVidBtnL').style.cursor ='pointer';
		$('liveMpVidBtnL').src = 'http://www.edix.it/portals/images/left_red_btn.gif';
		$('liveMpVidBtnL').onmouseover = function() { this.src = 'http://www.edix.it/portals/images/left_red_over_btn.gif'; }
		$('liveMpVidBtnL').onmouseout = function() { this.src = 'http://www.edix.it/portals/images/left_red_btn.gif'; }
	}
	else {
		$('liveMpVidBtnL').style.cursor ='default';
		$('liveMpVidBtnL').src = 'http://www.edix.it/portals/images/left_gray_btn.gif';
		$('liveMpVidBtnL').onmouseover = function() {}
		$('liveMpVidBtnL').onmouseout = function() {}
	}

	if(liveMpVpCurPage < 3) {
		$('liveMpVidBtnR').style.cursor ='pointer';
		$('liveMpVidBtnR').src = 'http://www.edix.it/portals/images/right_red_btn.gif';
		$('liveMpVidBtnR').onmouseover = function() {this.src = 'http://www.edix.it/portals/images/right_red_over_btn.gif';}
		$('liveMpVidBtnR').onmouseout = function() {this.src = 'http://www.edix.it/portals/images/right_red_btn.gif';}
	}
	else {
		$('liveMpVidBtnR').style.cursor ='default';
		$('liveMpVidBtnR').src = 'http://www.edix.it/portals/images/right_gray_btn.gif';
		$('liveMpVidBtnR').onmouseover = function() {}
		$('liveMpVidBtnR').onmouseout = function() {}
	}
}
/* end main page video box
===================================================================== */



