/**
  *  BASYS JS scripts.
  *  (c) 2010 Sycon pcHelp GmbH // ml
  **/ 

Position.getSize = function() {
    var width, height;
    var D = document;
    height = Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
    width = Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
    if ( Prototype.Browser.IE )
        return { w: width-4, h:height-4 };
    else 
        return { w: width, h:height };
}

function openThis(filename, width, height) {
    width  = width  || 800;
    height = height || 600;
    
    MsgBoxDisplay(width+8,height+48);
    
    $("modalBoxContent").innerHTML = '<img style="border:0;" id="prodImg" src="images/blank.gif" alt="" />';
    $("modalBox").style.visibility="visible";
    
    var img = new Image();
    img.src = filename;
    
    $('prodImg').style.margin = 0;
    $('prodImg').src = img.src;
    $('prodImg').height = height;
    $('prodImg').width = width;
}

function modalboxHide() {
    if ($("modalwindow").style.visibility != 'hidden') {
        $("modalwindow").setStyle({visibility: "hidden", width: "1px", height: "1px" });
        $("modalBox").style.visibility="hidden";
        $("modalBoxContent").innerHTML = "";
    }
}

function centerWindow(element) {
    if($(element) != null) {
        $(element).style.top = 
            Math.round(document.viewport.getScrollOffsets().top + 
            ((document.viewport.getHeight() - $(element).getHeight()))/2)+"px";
        $(element).style.left = 
            Math.round(document.viewport.getScrollOffsets().left + 
            ((document.viewport.getWidth() - $(element).getWidth()))/2)+"px";
    }
}
function MsgBoxDisplay(boxW,boxH) {
    var psize = Position.getSize();

    if (Object.isElement($("modalwindow")) != true) {
        var Overlay = new Element("div",{id: "modalwindow" });
        document.body.appendChild(Overlay);
        
        var modalBox = new Element("div",{id: "modalBox" });
        modalBox.innerHTML = '<div style="height:44px;background:transparent url(images/modal_head.gif) repeat-x;" ></div><div id="modalBoxContent" style="border:4px solid #ff0000;border-top:0;background-color:#ffffff"><img style="border:0" id="prodImg" src="images/blank.gif" alt="" /><\/div>';
        $(document.body).insert(modalBox);
        modalBox.setStyle({position:"absolute", backgroundColor: "#ffffff", zIndex: 1000, width: "448px" });

        var modalBoxC = new Element("div",{id: "modalBoxC",title:"[ESC]-Taste zum Schliessen" });
        $("modalBox").insert(modalBoxC);
        modalBoxC.setStyle({position:"absolute", cursor:"pointer",backgroundImage:"url(images/close.gif)", backgroundColor: "transparent", top:"4px",right:"4px", zIndex: 1001, width:"17px", height:"17px" });

        
        Overlay.setStyle({backgroundImage: "url(images/gray.gif)", position: "absolute", top: "0", left: "0", zIndex: 999, width: psize['w']+"px", height: psize['h']+"px" });
        Overlay.setStyle({opacity: 0.5 });
        Overlay.onclick = function(){ modalboxHide() }; 
        modalBoxC.onclick = function(){ modalboxHide() }; 
        Event.observe(document, "keypress", function(event){ if(event.keyCode == 27) modalboxHide(); });
        
        Overlay.show();
    } else {
        $("modalwindow").setStyle({visibility: "visible", backgroundImage: "url(images/gray.gif)", position: "absolute", top: 4, left: 4, zIndex: 999, width: psize['w']+"px", height: psize['h']+"px" });
    }
    $("modalBox").setStyle({visibility:"visible",width:boxW+"px",height:boxH+"px"});
    centerWindow($("modalBox"));
}
function showMenuImage(that, image, url, target) {
    
    $('ThumbDetail').setStyle({cursor:"pointer",top: (that.parentNode.offsetTop - 7) +"px",left: (that.parentNode.offsetLeft+3)+"px", display:"block", backgroundImage:"url(pix_basycon/thumbs-menu/"+image+")"});
    $('ThumbDetail').stopObserving();
    if (target != null) {
        $('ThumbDetail').observe('click',function(){
            window.open(url, target);
        });        
    } else {
        $('ThumbDetail').observe('click',function(){
            window.location.href = url;
        });        
    }
    
}
function hideMenuImage() {
    if ($('ThumbDetail').style.display == "block") $('ThumbDetail').style.display = "none";
}

