//----------------------------------------------------------------------------------------------------
//
//     Rel. 2009.03.01
//     
//     copyright 1996-2008 by EELImedia sas
//
//----------------------------------------------------------------------------------------------------

	var NlPreview;
	var NlEdit;
	var xpAlias;
	var tabId;
	var mid;

	function lOver(ctl){
		if(ctl.className!="leftLinkSelected"){
			ctl.className="leftLinkHover";
		}
	}
	function lOut(ctl){
		if(ctl.className!="leftLinkSelected"){
			ctl.className="leftLink"
		}	
	}
	
	function mOver(ctl){
		if(ctl.className!="rigaSelected"){
			ctl.className="rigaHover";
		}
	}
	function mOutA(ctl){
		if(ctl.className!="rigaSelected"){
			ctl.className="rigaNotHover"
		}	
	}
	function mOut(ctl){
		if(ctl.className!="rigaSelected"){
			ctl.className="riga"
		}	
	}

	
//*********************************************************
//                UI Functions
//*********************************************************

// immagine ingrandita
function imgBig(imgName, slideShow) {
    var xx;
    if (slideShow != undefined)
        var xx = window.open("/" + xpAlias + "/imgBIG.aspx?pid=" + xpAlias + "&CMS_SHOW=1&ID=" + escape(imgName), "imgw", "height=540,width=680,menubar=yes,scrollbars=no,toolbar=no,status=no,location=no,resizable=yes");
    else
        var xx = window.open("/" + xpAlias + "/imgBIG.aspx?pid=" + xpAlias + "&ID=" + escape(imgName), "imgw", "height=540,width=680,menubar=yes,scrollbars=no,toolbar=no,status=no,location=no,resizable=no");

    xx.focus();
}

function legalInfo() {
	var xx;
	var xx = window.open("/" + xpAlias + "/legalInfo.aspx?pid=" + xpAlias , "LegalInfo", "height=500,width=500,menubar=no,scrollbars=no,toolbar=no,status=no,location=no,resizable=no");
	if (xx != undefined) {
		xx.focus()
	}
}
function footer(oWindow,str){
	oWindow.document.getElementById("VistaFooterText").innerHTML=str
}
function goNull(){
	//return false;
}
	
function CMS_initLayout(){
    //var ctl=document.getElementById("TopTable");
    alert(document.body.offsetHeight);
}	



//----------------------------------------------------------------------------------------------------
//
//     Administration UI helpers
//     
//----------------------------------------------------------------------------------------------------
function goLoginUrl(returnUrl) {
    var wHeight = getWindowHeight();
    var vCenter = getCurrentVerticalCenter();
    var hCenter = getCurrentHorizontalCenter();
    var shadowDiv = document.createElement("div");
    shadowDiv.className = "loginBg";
    shadowDiv.setAttribute("id", "shadowDiv");
    shadowDiv.style.top = getCurrentTop() + "px";
    document.body.appendChild(shadowDiv);
    var i = document.createElement("iframe");
    i.id = "iLogin";
    i.style.width = "700px";
    i.style.height = "280px";
    i.style.top = (vCenter - 140) + "px";
    i.style.left = (hCenter - 350) + "px";
    i.className = "loginFrame";
    i.frameBorder = "0";
    i.src = "/Login/Login.aspx?pid=" + xpAlias + "&returnUrl=" + escape(returnUrl);
    document.body.appendChild(i);
}
function goLogin() {
    destroyLogin();
    var wHeight = getWindowHeight();
    var vCenter = getCurrentVerticalCenter();
    var hCenter = getCurrentHorizontalCenter();
    var shadowDiv = document.createElement("div");
    shadowDiv.className="loginBg";
    shadowDiv.setAttribute("id", "shadowDiv");
    shadowDiv.style.top = getCurrentTop() + "px";
    document.body.appendChild(shadowDiv);
    var i = document.createElement("iframe");
    i.id = "iLogin";
    i.style.width = "700px";
    i.style.height = "280px";
    i.style.top = (vCenter - 140) + "px";
    i.style.left = (hCenter - 350) + "px";
    i.className = "loginFrame";
    i.frameBorder = "0";
    i.src = "/Login/Login.aspx?pid=" + xpAlias;
    document.body.appendChild(i);    
}
function destroyLogin() {
    var ifr = $get("iLogin")
    if (ifr != undefined) {
        document.body.removeChild(ifr)
    }
    var iSh = $get("shadowDiv")
    if (iSh != undefined) {
        document.body.removeChild(iSh)
    }
}

function createUtilityFrame(sUrl, _top, _left, _height, _width, bShow) {
    var ifr = document.getElementById("iUty")
    if (ifr != undefined) {
        document.body.removeChild(ifr)
    }

    //imposta defaults
    if (_top == undefined) { _top = "10" }
    if (_left == undefined) { _left = "10" }
    if (_height == undefined) { _height = "100" }
    if (_width == undefined) { _width = "100" }

    var i = document.createElement("IFRAME");
    i.id = "iUty";
    i.style.width = _width + "px";
    i.style.height = _height + "px";
    i.style.top = _top + "px";
    i.style.left = _left + "px";
    i.style.position = "absolute";
    i.style.zIndex = "10000";
    i.className = "utilityFrame";
    i.frameBorder = "0";
    if (bShow == undefined) {
        i.style.visibility = "hidden";
        i.style.display = "none";
    }
    i.src = sUrl;
    document.body.appendChild(i);
}

function wclose(oDoc) {

    if (oDoc == undefined) { oDoc = document }
    var ifr = oDoc.getElementById("iUty")
    if (ifr != undefined) {
        oDoc.body.removeChild(ifr)
    }
}

function getAbsLeft(oNode) {
    var oCurrentNode = oNode;
    var iLeft = 0;
    while (oCurrentNode.tagName != "BODY") {
        iLeft += oCurrentNode.offsetLeft;
        oCurrentNode = oCurrentNode.offsetParent;
        if (oCurrentNode == undefined) { return iLeft; }
    }
    return iLeft;
}
function maximizeBody() {
    var wWidth = getWindowWidth();
    var wHeight = getWindowHeight();
    document.body.style.height = wHeight + "px";
}
function getWindowWidth() {
    if (document.compatMode && document.compatMode != "BackCompat") {
        return parseInt(document.documentElement.clientWidth);
    }
    else {
        return parseInt(document.body.clientWidth);
    }
}
function getWindowHeight() {
    
    if (document.compatMode && document.compatMode != "BackCompat") {
        return parseInt(document.documentElement.clientHeight);
    }
    else {
        return parseInt(document.body.clientHeight);
    }
}
function getBodyHeight() {
    return parseInt(document.body.parentNode.clientHeight);
}
function getCurrentTop() {
    if (parseInt(document.body.scrollHeight) > getWindowHeight()) {
        return (parseInt(document.body.scrollHeight) - getWindowHeight());
    }
    else {
        return 0;
    }
}
function getCurrentVerticalCenter() {
    if(getCurrentTop()>0)
        return parseInt((getCurrentTop()+getWindowHeight()) - (getWindowHeight() / 2));
    else
        return parseInt((getWindowHeight() / 2));
}
function getCurrentHorizontalCenter() {
    return parseInt(getWindowWidth() / 2);
}
function setCookie(sName, sValue) {
    var expiration_date = new Date();
    expiration_date.setYear(expiration_date.getYear() + 1);
    expiration_date = expiration_date.toGMTString();
    var cookie_string = escape(sName) + "=" + escape(sValue) + "; expires=" + expiration_date;
    document.cookie = cookie_string;
}
function clearCookie(sName) {
    var expiration_date = new Date();
    expiration_date.setYear(expiration_date.getYear() - 1);
    expiration_date = expiration_date.toGMTString();
    var cookie_string = escape(sName) + "=; expires=" + expiration_date;
    document.cookie = cookie_string;
}

// editing descrizioni SlideSHow
function editSlideShow(strPath, album) {
	var xx = window.open("/DesktopModules/_GalleryEdit.aspx?pid=" + xpAlias + "&ID=" + strPath + "&A=" + album, "imgw", "height=350,width=550,menubar=no,scrollbars=no,toolbar=no,status=no,location=no,resizable=no");
	xx.focus();
}

