//==========================popup div====================================
var boxWidth = 0;
var boxHeight = 0;
function PopupBox() {
    var obj = this;
    this.show = function(isCenter, left, top, content, width, height, CSSName) {
        boxWidth = width;
        boxHeight = height;
        if ($("#backgroundPopup").length == 0) {
            $("form").eq(0).append("<div id='backgroundPopup' style='z-index:100;filter:alpha(opacity=30);opacity:0.3;background-color:#000;position:absolute;left:0;top:0;display:none'></div>");
            $("#backgroundPopup").css({ "height": jQuery(document).height() + "px", "width": "100%" });
            $("form").eq(0).append("<div id='popupContent' style='z-index:101;position:absolute;'></div");
        }
        $("#popupContent").html(content).css({ "width": width, "height": height });
        if (CSSName == ""){
            $("#popupContent").css({ "background-color": "#555" });
			$("#popupContent").css({ "color": "#fff" });
        }else
            $("#popupContent").attr("class", CSSName);
        if (!$("#backgroundPopup").is(":visible")) {
            //==========================================================
            if (isCenter == true) {
                $("#popupContent").css({
                    "position": "absolute",
                    "top": ($(document).scrollTop() + (window.screen.availHeight - height) / 2 - 56) + "px",
                    "left": ((document.body.scrollWidth - width) / 2) + "px"
                });
            } else {
                $("#popupContent").css({
                    "position": "absolute",
                    "top": top,
                    "left": left
                });
            }
            //==========================================================
            $("#backgroundPopup").show();
            $("#popupContent").show();
            // process IE6's background height
            if (isCenter) {
              //  if (window.addEventListener) { // firefox , w3c
              //      window.addEventListener("scroll", setPopupBoxTop, false);                    
              //  } else {   // ie
               //     window.attachEvent("onscroll", setPopupBoxTop);                    
              //  }
            }
        }
        $("#popupContent").click(function() { obj.hide(); });
    }
    this.hide = function() {
        //disables popup only if it is enabled
        if ($("#backgroundPopup").length > 0) {
            if ($("#popupContent").is(":visible")) {
                $("#popupContent").removeClass();
                $("#backgroundPopup").hide();
                $("#popupContent").html("").hide();
                if (window.addEventListener) { // firefox , w3c
                    window.removeEventListener("scroll", setPopupBoxTop, false);                    
                } else {   // ie
                    window.detachEvent("onscroll", setPopupBoxTop);                    
                }                    
                
            }
        }
    }
}
function setPopupBoxTop() {
    $("#popupContent").css({
        "position": "absolute",
        "top": ($(document).scrollTop() + (window.screen.availHeight - boxHeight) / 2 - 50) + "px",
        "left": ((document.body.scrollWidth - boxWidth) / 2) + "px"
    });
}
//=====================================================================

function popupTextWindow(path) {
    var p = new PopupBox();
    var content = "<div><span style='float:right;margin-right:5px;cursor:pointer;' onclick='var p = new PopupBox(); p.hide();'>close</span></div><iframe id='iPop' src='' width=\"100%\" height=\"420px\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
    p.show(true, 0, 0, content, 700, 450, "");
    document.getElementById('iPop').src=path;
}

function popupWindow(path,w,h) {
    var p = new PopupBox();
    var content = "<div><span style='float:right;margin-right:5px;cursor:pointer;' onclick='var p = new PopupBox(); p.hide();'>close</span></div><iframe id='iPop' src='' width=\"100%\" height=\"" + (h - 20) +"px\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
    p.show(true, 0, 0, content, w, h, "");
    document.getElementById('iPop').src=path;
}

function popupVideoWindow(path) {
    
	
    var sPath = $("#dnn_dnnLOGO_imgLogo").attr("src");
    if ($("#dnn_dnnLOGO_imgLogo").length > 0)
        sPath = sPath.substring(0, sPath.lastIndexOf("/")) + "/video/" + path;
    //alert(sPath);
    var p = new PopupBox();
    // var content = "<div><span style='float:right;width:20px;cursor:pointer;' onclick='var p = new PopupBox(); p.hide();'>X</span></div><iframe id='iPop' src='" + sPath + "' width=\"100%\" height=\"360px\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
    var content = "<div><span style='float:right;margin-right:5px;cursor:pointer;' onclick='var p = new PopupBox(); p.hide();'>close</span></div><iframe id='iPop' src='' width=\"100%\" height=\"360px\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
    p.show(true, 0, 0, content, 640, 375, "");
    document.getElementById('iPop').src=sPath;
}

function popupVideoWindow6(path) {
    
	
    var sPath = $("#dnn_dnnLOGO_imgLogo").attr("src");
    if ($("#dnn_dnnLOGO_imgLogo").length > 0)
        sPath = sPath.substring(0, sPath.lastIndexOf("/")) + "/video/" + path;
    //alert(sPath);
    var p = new PopupBox();
    // var content = "<div><span style='float:right;width:20px;cursor:pointer;' onclick='var p = new PopupBox(); p.hide();'>X</span></div><iframe id='iPop' src='" + sPath + "' width=\"100%\" height=\"428px\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
    var content = "<div style=\"background:#555555;\"><span style='float:right;cursor:pointer;margin-right:5px;' onclick='var p = new PopupBox(); p.hide();'>close</span></div><iframe id='iPop' src='' width=\"100%\" height=\"420px\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
    p.show(true, 0, 0, content, 652, 420, "");
    document.getElementById('iPop').src=sPath;
}


/// New Popup
var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
	// var sPath = $("#dnn_dnnLOGO_imgLogo").attr("src");
 //   if ($("#dnn_dnnLOGO_imgLogo").length > 0)
 //       sPath = sPath.substring(0, sPath.lastIndexOf("/")) + "/video/" + url;

//url = sPath;
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

//var img1 = new Image();
//img1.src = "";
//var img2 = new Image();
//img2.src = "";
//var img3 = new Image();
//img3.src = "";
//var img4 = new Image();
//img4.src = "";
//var img5 = new Image();
//img5.src = "";
//var img6 = new Image();
//img6.src = "";
//var img7 = new Image();
//img7.src = "";
//var img8 = new Image();
//img8.src = "";

