﻿ 
var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var fileupImage = "/images/popup/up.gif";
var filedownImage = "/images/popup/down.gif";		
var fileCloseImage = "/images/popup/close.gif";
var bordercolor = "#999999";
var HighDiv = Class.create();
HighDiv.prototype = {
	div : 'boxdigdiv',
	divWidth : "200px",
    div1Height : "30px",
    div2Height : "120px",
    divLeft : "0px",
    divTop : "0px",
    divTitle: '',
	//div2content : "",
    // OK to declare value types in the prototype,boxdivWidth,boxdiv1Height,boxdiv2Height,boxdivtop,boxdivleft
	initialize : function(boxdivWidth,boxdiv1Height,boxdiv2Height,boxdivtop,boxdivleft,title) {

//var boxdiv = boxdiv;
		//var argc=this.initialize.arguments.length;
		//this.div = ;
        this.div1 = this.div+"1";
		this.div2 = this.div+"2";
		if (navigator.userAgent.indexOf("MSIE") <1)
		{
		//this.div2content = content1 || this.div2content;
			this.divWidth = boxdivWidth+"px" || this.divWidth+"px";
			this.div1Height = boxdiv1Height+"px" || this.div1Height+"px";
			this.div2Height = boxdiv2Height+"px" || this.div2Height+"px";
			this.divTop = boxdivtop+"px" || this.divTop+"px";
			this.divLeft = boxdivleft+"px" || this.divLeft+"px";
			this.div2Top = (this.divTop + this.div1Height)+"px";
		}else
		{
			this.divWidth = boxdivWidth || this.divWidth;
			this.div1Height = boxdiv1Height || this.div1Height;
			this.div2Height = boxdiv2Height || this.div2Height;
			this.divTop = boxdivtop || this.divTop;
			this.divLeft = boxdivleft || this.divLeft;
			this.div2Top = this.divTop + this.div1Height;
		}
		this.divTitle = title;
		
	},
	showboxbigdiv : function() {
		//var objBody = document.getElementsByTagName("body").item(0);
		if(document.getElementById('coverdiv') != null)
		    document.body.removeChild(document.getElementById('coverdiv'));
		if(document.getElementById('boxdigdiv') != null)
		    document.body.removeChild(document.getElementById('boxdigdiv'));
		if(document.getElementById('boxdivtitle') != null)
		    document.body.removeChild(document.getElementById('boxdivtitle'));		    				    
		var coverdiv = document.createElement("div");
		coverdiv.setAttribute('id','coverdiv');
		//div1.setAttribute('align','right');
		coverdiv.style.position = "absolute";
		coverdiv.style.display="block";
		coverdiv.style.zIndex = "9998";
		coverdiv.style.background="#ffffff";
		coverdiv.style.left = "0px";
		coverdiv.style.top = "0px";
		coverdiv.style.width = window.screen.width;
		coverdiv.style.height = document.body.clientHeight;
		coverdiv.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)"; 
		document.body.appendChild(coverdiv);
		

		var boxdiv = document.createElement("div");
		boxdiv.setAttribute('id',this.div);
		boxdiv.style.position = "absolute";
		boxdiv.style.display="block";
		boxdiv.style.zIndex = "9999";
		boxdiv.style.left = this.divLeft;
		boxdiv.style.top = this.divTop;
		boxdiv.style.background= "#ffffff";
		boxdiv.style.border = 1+"px solid "+bordercolor;
		boxdiv.style.padding = "2px";
		document.body.appendChild(boxdiv);
        
		var boxdiv1 = document.createElement("div");
		boxdiv1.setAttribute('id',this.div1);
		boxdiv1.setAttribute('align','left');			
		boxdiv1.style.display="block";
		//boxdiv1.style.background="#FFB000"; 
        boxdiv1.style.width = this.divWidth;
		boxdiv1.style.height = this.div1Height;
		boxdiv1.style.zIndex = "10001";
		boxdiv1.style.padding = "2px";
		if (navigator.userAgent.indexOf("MSIE") <1)
		{
			boxdiv1.setAttribute('class','popup_title_color');
		}
		else
		{
			boxdiv1.setAttribute('className','popup_title_color');
		}
		boxdiv.appendChild(boxdiv1);
		
	
		var fuckTitle = document.createElement("div");
		fuckTitle.setAttribute('id','boxdivtitle');
		fuckTitle.style.styleFloat = 'left';
		fuckTitle.style.padding="2px";	
		fuckTitle.style.fontSize = "14px";
		fuckTitle.style.fontWeight = "bold";
		fuckTitle.style.cssFloat = "left";	
		fuckTitle.style.color = "black";

		fuckTitle.innerHTML = this.divTitle;
		boxdiv1.appendChild(fuckTitle);
		
		var fuckTitle2 = document.createElement("div");
		fuckTitle2.style.styleFloat = 'right';
		boxdiv1.appendChild(fuckTitle2);
        
      
        var div1aclose = document.createElement("a");
		div1aclose.setAttribute('href','#');
		div1aclose.onclick = function() { boxdiv1.style.display="none"; boxdiv2.style.display="none"; boxdiv.style.display="none"; coverdiv.style.display="none";}
	    fuckTitle2.appendChild(div1aclose);

		var div1acloseimage = document.createElement("img");
		div1acloseimage.setAttribute('align','right');
		div1acloseimage.setAttribute('src', fileCloseImage);
		div1acloseimage.setAttribute('border','0');
		div1acloseimage.style.padding="2px";
		div1aclose.appendChild(div1acloseimage);
        
		var div1aflex = document.createElement("a");
		div1aflex.setAttribute('href','#');
		div1aflex.onclick = function() { if(boxdiv2.style.display == "block"){ boxdiv2.style.display="none"; div1afleximage.setAttribute('src', filedownImage); } else { boxdiv2.style.display = "block";div1afleximage.setAttribute('src', fileupImage); } }
	    fuckTitle2.appendChild(div1aflex);

		var div1afleximage = document.createElement("img");
		div1afleximage.setAttribute('align','right');
		div1afleximage.setAttribute('src', fileupImage);
		div1afleximage.setAttribute('border','0');
		div1afleximage.style.padding="2px";
		div1aflex.appendChild(div1afleximage);


        
		var boxdiv2 = document.createElement("div");
		boxdiv2.setAttribute('id',this.div2);
		boxdiv2.style.display="block";
	        boxdiv2.style.width = this.divWidth;
		boxdiv2.style.height = this.div2Height;
		boxdiv2.style.zIndex = "10000";
		boxdiv2.style.top = this.div2Top;
		boxdiv.appendChild(boxdiv2);
		return boxdiv2;
    },
	div2content : function(div2content1,boxdiv2) {
		if(typeof(div2content1)== "string") {
            boxdiv2.innerHTML = div2content1;
		} else if (typeof(div2content1)== "object") {
			boxdiv2.appendChild(div2content1);
		}
    }
}
function initdiv1div2content(a,boxdivWidth,boxdiv2Height) { 

	var content = document.createElement("div");
	content.innerHTML = "<Iframe src="+ a +" width="+ boxdivWidth +" height="+ boxdiv2Height +" noresize frameborder='0' marginheight='0' marginwidth='0'></iframe>";
	return content;
}
function initdiv1div2(a,boxdivWidth,boxdiv1Height,boxdiv2Height,boxdivtop,boxdivleft) { 
	var content = initdiv1div2content(a,boxdivWidth,boxdiv2Height);
	var highdiv = new HighDiv(boxdivWidth,boxdiv1Height,boxdiv2Height,boxdivtop,boxdivleft,'');
	var boxdiv2 = highdiv.showboxbigdiv();
	highdiv.div2content(content,boxdiv2);
    
}

function newinitdiv1div2(a,boxdivWidth,boxdiv1Height,boxdiv2Height,boxdivtop,boxdivleft,title) { 
	var content = initdiv1div2content(a,boxdivWidth,boxdiv2Height);
	var highdiv = new HighDiv(boxdivWidth,boxdiv1Height,boxdiv2Height,boxdivtop,boxdivleft,title);
	var boxdiv2 = highdiv.showboxbigdiv();
	highdiv.div2content(content,boxdiv2);
    
}
function closebigcover() {
document.getElementById('coverdiv').style.display="none";
document.getElementById('boxdigdiv').style.display="none";

}

function changeTitle(s) {
document.getElementById('boxdivtitle').innerHTML = s;

}


var chk;

function showdialog2(u,width,height)
{
        if(document.readyState=='complete'){
            showdialog(u,width,height);
            clearTimeout(chk);
        }
        else
            chk = setTimeout("showdialog('"+u+"','"+width+"','"+height+"')",10);
}      


function showdialog(u,width,height)
{
    var l=(document.documentElement.clientWidth-width)/2+document.documentElement.scrollLeft;
    var h=(document.documentElement.clientHeight-height)/2+document.documentElement.scrollTop;
    initdiv1div2(u,width,20,height,h,l);
}
