﻿var closebutton = "/App_Themes/Default/Images/close.png"; //Adress of image of the button
var invisibleImg = "/App_Themes/Default/Images/invisible.gif"; //Adress of invisible image
var iframe = false;

var raampje, xtra, ytra;
function sleepen(id) {
    try {
        if(event.button!=1) {
            return;	      
        }
        raampje = eval(id);temp1=raampje.style.posLeft;
        temp2=raampje.style.posTop;xpos=event.clientX;
        ypos=event.clientY;xtra = temp1-xpos;
        ytra = temp2-ypos;document.onmousemove=plaats;
    }
    catch(e){}
}
function plaats() {
    if(event.button==1) {
        raampje.style.pixelLeft=event.clientX+xtra;
        raampje.style.pixelTop=event.clientY+ytra;return false;
    }
}
function raam(id,inside,width,height,background,titlebg,titleopacity,x,y) {
    titlecolor = "black"; 						
    if(titlebg != "") {
	    titlecolor = titlebg;
    }
    opacitytitle = 100;
    if(titlebg != "") {
	    opacitytitle = titleopacity;
    }
    if(!width) {
        width = 500;            					
        height = 325;
    }
    if(inside.indexOf(".htm") != -1) {
        inside = "<iframe style='width: " + width + "px; height: " + (height-2) + "px; .height: " + (height-16) + "px' frameborder='0' name='raampje' src=\"" + inside + "\" scrolling='no' id='popupiframe'></iframe>";         
        iframe = true;
    }       
    var popup = document.getElementById(id);
    popup.style.pixelLeft = x;//document.body.scrollLeft + 100;		
    popup.style.pixelTop = y;//document.body.scrollTop + 100;
    if(!Browser()) {	    
	    popup.style.left = x + "px";
	    popup.style.top = y + "px";
	}
    popup.style.visibility = "visible";    
    /*
    output = "<table cellpadding='0' cellspacing='0' width='" + width + "' height='" + height + "' border='0'><tr valign='top'>";
    output += "<td onmousedown='sleepen(\"" + id + "\")' onmouseup='JavaScript:document.onmousemove=\"\" ' bgcolor='" + titlecolor + "' style='cursor:move; filter:alpha(opacity=" + opacitytitle + ");' style='border-top: 1px solid black' width='100%'>&nbsp;</td><td bgcolor='" + titlecolor + "' style='padding: 2px; border-top: 1px solid black; border-right: 1px solid black' align='right'>";
    output += "<a href='javascript:closeraam(\"" + id + "\")'><img alt='Close' src='" + closebutton + "' border='0' /></a></td></tr>";
    output += "<tr height='100%'><td width='100%' colspan='2' style='border: 1px solid black'><table ";   
    if(background) {
        output += "style='background-image:url(\" " + background + "\")'";
    }
    else {
        output += "bgcolor='" + background + "'";
    }
    output += " cellpadding='0' cellspacing='0' width='100%' height='100%'><tr><td height='100%' width='100%' bgcolor='" + background + "'>" + inside + "</td></tr></table></td></tr>";
    */
    output = "<div style='background: " + background + "'><img src='" + invisibleImg + "' width='" + width + "' height='" + height + "px' /></div>";
    output += "<div style='position: apsolute; z-index: 1; margin-top: -" + (height+14) + "px; .margin-top: -" + height + "px; width: " + width + "px; height: " + (height+13) + "px; .height: " + (height-1) + "px; border: 1px solid black'>";
    //output = "<div style='width: " + width + "px; height: " + height + "px; border: 1px solid black'>";
    output += "<div style='height: 14px; float: left; background: " + titlecolor + "; cursor: move' onmousedown='sleepen(\"" + id + "\")' onmouseup='JavaScript:document.onmousemove=\"\" '><img src='" + invisibleImg + "' width='" + (width-13) + "' height='100%' /></div>";
    output += "<div style='float: right; padding: 2px; background: " + titlecolor + "'><a href='javascript:closeraam(\"" + id + "\")'><img alt='Close' src='" + closebutton + "' border='0' /></a></div>";
    output += "<div style='clear: both'></div>";
    output += "<div style='border-top: 1px solid black; background: " + background + "'>";
    output += inside;
    output += "</div>";    
    output += "</div>";
    
    popup.innerHTML = output;
}
function closeraam(id) {
    var popup = document.getElementById(id);
    popup.style.visibility = "hidden";
    if(iframe) {
        document.getElementById("popupiframe").src = null;        
    }
}