/**
 * 弹出层DIV对象
 * author duncan
 */
var Div=new Object();
/**
 *  创建层
 * @param {Object} width  层的宽度
 * @param {Object} height 层的高度
 * @param {Object} title  层的标题
 * @param {Object} divId  层的ID
 */
Div.createDiv=function(width,height,title,divId,shadowDivId){
	
	var arrayPageSize=this.getWindowSize();
	var windowWidth=arrayPageSize[2];
	var windowHeight=arrayPageSize[3];
	var shadowDIV=document.createElement("div");
	shadowDIV.setAttribute("id",shadowDivId);
	shadowDIV.style.position="absolute";
	shadowDIV.style.top="0";
	shadowDIV.style.background="#CCC";
	shadowDIV.style.filter="alpha(opacity=70)";
    shadowDIV.style.MozOpacity = "166%";
    shadowDIV.style.left="0";

    //获取pageWindth
    shadowDIV.style.width= arrayPageSize[0]+ "px";
    //获取pageHeight
    shadowDIV.style.height= arrayPageSize[1] + "px";
    shadowDIV.style.zIndex = "0";
    //将创建的阴影div加入到body对象中
	document.body.appendChild(shadowDIV);
	
	
	//由于浏览器差别,获取scroll值不同

	var scrollPos; 
	if (typeof window.pageYOffset != 'undefined') { 
	   scrollPos = window.pageYOffset; 
	} 
	else if (typeof document.compatMode != 'undefined' && 
	     document.compatMode != 'BackCompat') { 
	     scrollPos = document.documentElement.scrollTop; 
	} 
	else if (typeof document.body != 'undefined') { 
	   scrollPos = document.body.scrollTop; 
	}  
	

    var borderDiv = document.createElement("div");

    borderDiv.setAttribute("id" ,"borderDiv");
    borderDiv.style.top=((windowHeight/2)-(height/2)+scrollPos) +"px";
    borderDiv.style.position="absolute";    
    borderDiv.style.left=(windowWidth/2)-(width/2)+"px";
    borderDiv.style.width = width + "px";
    borderDiv.style.height = height + "px";
    borderDiv.style.zIndex = "1000";  
    document.body.appendChild(borderDiv);
	


    /**
     *  创建弹出窗口的中间层此层用
     * 窗口的总宽度减去左、右两边的图片宽度等于中意层的宽度
     */
    var titleCenterDiv = document.createElement("div");
    titleCenterDiv.style.cssText = "float:left";
    titleCenterDiv.style.width = document.getElementById('borderDiv').style.width;
   //titleCenterDiv.style.height = "20px";
   
	//titleCenterDiv.style.fontSize="17px";
	//titleCenterDiv.style.fontWeight = "bold";
	//titleCenterDiv.innerText=title;
    borderDiv.appendChild(titleCenterDiv);



    /**
     * 创建弹出窗口的关闭窗口的按扭层
     */
    var closeDiv = document.createElement("div");
    closeDiv.setAttribute("id" ,"closeDiv");
    closeDiv.style.cssText = "float:right";
	closeDiv.style.left=(width+75)+"px";
	closeDiv.style.position="absolute";
	closeDiv.style.top=titleCenterDiv.style.top+2;
    closeDiv.style.width = "20px";
    closeDiv.style.height = "20px";
    closeDiv.style.backgroundImage = "url('/movie_detail/img/btn_close_on.png')";
    closeDiv.style.backgroundRepeat = "no-repeat";
    closeDiv.style.cursor = "pointer";
    closeDiv.attachEvent("onclick" ,function(){Div.closeDiv(shadowDivId)});

    titleCenterDiv.appendChild(closeDiv);

    /**	  
     * 创建弹出窗口的窗体，用来在此窗口中显示不同的信息
     * 总窗体的宽度减去窗体边的宽度等于实际窗体的宽度
     * 
     */

    var bodyDiv = document.createElement("div");
    bodyDiv.setAttribute("id" ,divId)
    bodyDiv.style.width = (width-6) + "px";
    bodyDiv.style.height = "100%";
    bodyDiv.style.textAlign="center";
    bodyDiv.style.backgroundColor="#FFF";
    bodyDiv.style.border = "3px #EBEBE9 solid";
    borderDiv.appendChild(bodyDiv);	
};
Div.closeDiv=function(shadowDivId){
	
	document.getElementById('borderDiv').style.display = "none";
    document.getElementById('borderDiv').removeNode(true);
	if(shadowDivId!=""){
		document.getElementById(shadowDivId).style.display = "none";
        document.getElementById(shadowDivId).removeNode(true);
	}	
	if($('scoreSelectDiv')!=null){
		$('scoreSelectDiv').style.visibility="visible";//隐藏投票下拉列表
	}	
};

/**
     *  获取屏幕的大小
     * 并返回
     * pageWidth－－页面宽度
     * pageHeight－－页面高度
     * windowWidth－－窗口宽度
     * windowHeigh－－窗口高度
     *
     */
Div.getWindowSize = function()
	{
	//定义window的x和y的坐标点
	var xScroll, yScroll,pageWidth,pageHeight,arrayPageSize;	
	if( window.innerHeight && window.scrollMaxY )	{
	    xScroll = document.body.scrollWidth;
	    yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body.scrollHeight > document.body.offsetHeight )	{ // all but Explorer Mac
	    xScroll = document.body.scrollWidth;
	    yScroll = document.body.scrollHeight;
	}
	else{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	    xScroll = document.body.offsetWidth;
	    yScroll = document.body.offsetHeight;
	}
	//－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－
	//定义window的宽度和高度
	var windowWidth, windowHeight;
	if( self.innerHeight ){    // all except Explorer
	    windowWidth = self.innerWidth;
	    windowHeight = self.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight ){ // Explorer 6 Strict Mode
	    windowWidth = document.documentElement.clientWidth;
	    windowHeight = document.documentElement.clientHeight;
	}
	else if( document.body ){ // other Explorers
	    windowWidth = document.body.clientWidth;
	    windowHeight = document.body.clientHeight;
	}
	//如果yScroll小于windowHeight那么页面的高度pageHeight=windowHeingt,否则等于yScroll
	if( yScroll < windowHeight ){
	    pageHeight = windowHeight;
	}
	else{
	    pageHeight = yScroll;
	}	
	//如果xScroll小于windowHeight那么页面的宽度pageWidth = windowWidth,否则等于xScroll
	if( xScroll < windowWidth )	{
	    pageWidth = windowWidth;
	}else{
	    pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth ,pageHeight ,windowWidth ,windowHeight);	
	return arrayPageSize;
};
