﻿
function popWindowInit()
{
   // if(document.getElementById("mainContentID") == null)
//    {	 
//        var beforeDiv = '<div id="myPopWindows" style="z-index:2030;position:absolute;top:0;clear:both;left:0;0overflow:hidden;display:none;">'      
//
//        //+ '<div style="width:600px;height:9px;"></div>'
//        + '<div style="width:600px;margin:0px;">'
//        + '<div style="width:600px;margin:0px;">'
//        //+ '<div style="text-align:right;padding:0 10px 0 0;"><a href="#null" onclick="hidePopWindow();">×</a></div>'
//        + '<div id="mainContentID">内容</div>'
//
//        + '</div>'
//        + '</div><div style="width:600px;height:11px;margin:0px;"></div>'
//
//        + '</div>'
//
//        + '<div id="lockBackground" style="background:#000000;width:0px;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;z-index:2000;position:absolute;left:0px;width:100%;height:100%;display:none;"></div>';
//        jQuery("body").prepend (beforeDiv);        
//
//        ResizeBlockBackground();
//        hidePopWindow();
//        window.onresize = ResizeBlockBackground;	
//    }
}	
	
//隐藏弹出框
function hidePopWindow()
{
	jQuery("#myPopWindows").hide();
	jQuery("#lockBackground").hide();
	//popWindowInit();
}

//显示弹出框
function showPopWindow()
{
	jQuery("#myPopWindows").show();
	jQuery("#lockBackground").show();
}

//打开特定窗口
function openSelectWindow(targetUrl,targetWidth,targetHeight) {

    jQuery("#myPopWindows").remove();
    jQuery("#lockBackground").remove();
    
	 //if(document.getElementById("mainContentID") == null)
    //{	 
        var beforeDiv = '<div id="myPopWindows" style="z-index:2030;position:absolute;top:0;clear:both;left:0;0overflow:hidden;display:none;">'      

        //+ '<div style="width:600px;height:9px;"></div>'
        + '<div style="margin:0px;">'
        + '<div style="margin:0px;">'
        //+ '<div style="text-align:right;padding:0 10px 0 0;"><a href="#null" onclick="hidePopWindow();">×</a></div>'
        + '<div id="mainContentID">内容</div>'

        + '</div>'
        + '</div><div style="height:11px;margin:0px;"></div>'

        + '</div>'

        + '<div id="lockBackground" style="background:#000000;width:0px;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;z-index:2000;position:absolute;left:0px;width:100%;height:100%;display:none;"></div>';
        jQuery("body").prepend (beforeDiv);        

        ResizeBlockBackground();
        hidePopWindow();
        window.onresize = ResizeBlockBackground;	
   // }
	
	
    if (targetUrl.indexOf("?") == -1)
    {
        targetUrl = targetUrl + "?jsrnd=" + Math.random();
    }
    else
    {
        targetUrl = targetUrl + "&jsrnd=" + Math.random();
    }
	showPopWindow();
	var tableHeight = targetHeight - 34;
		//定义浏览器内高
	var windowsHeight = document.documentElement.clientHeight;
	//定义滚动条距上高
    var topValue = document.documentElement.scrollTop;
    
    //定义浏览器内宽
    var windowsWidth = document.documentElement.clientWidth;

	var topH = ( parseInt(windowsHeight) - parseInt(targetHeight))/2+15;//2
	//alert(windowsHeight);
	//alert(targetHeight);
	
	var leftW = (windowsWidth - targetWidth)/2;
	
	jQuery('#myPopWindows').css({left:leftW,top:topH,width:targetWidth,height:targetHeight})
	jQuery("#mainContentID").html("<table width=100% height=" + tableHeight + " border=0 ><tr><td class='guildTitle' align=center valign=center>正在打开页面，请稍候...</td></tr></table>");
    jQuery.ajax({url: targetUrl,
        success:function(msg){
            jQuery("#mainContentID").html(msg);
        } 
    });
}
//打开选择球队窗口
//打开特定窗口
function openSelectWindow1(targetUrl,targetWidth,targetHeight)
{
    if (targetUrl.indexOf("?") == -1)
    {
        targetUrl = targetUrl + "?jsrnd=" + Math.random();
    }
    else
    {
        targetUrl = targetUrl + "&jsrnd=" + Math.random();
    }
	showPopWindow();
	var tableHeight = targetHeight - 34;
	
	jQuery('#myPopWindows').css({left:'22%',top:'12%',width:targetWidth,height:targetHeight})
	jQuery("#mainContentID").html("<table width=100% height=" + tableHeight + " border=0 ><tr><td class='guildTitle' align=center valign=center>正在打开页面，请稍候...</td></tr></table>");
    jQuery.ajax({url: targetUrl,
        success:function(msg){
            jQuery("#mainContentID").html(msg);
        } 
    });
}



//重置背景尺寸
function ResizeBlockBackground()
{
	var isIE = document.all ? true : false;
	if (isIE)
	{
		var currentWidth = document.body.scrollWidth;
		var currentHight = document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight;
	}
	else
	{
		var currentWidth = document.documentElement.scrollWidth > document.documentElement.clientWidth ? document.documentElement.scrollWidth : document.documentElement.clientWidth;
		var currentHight = document.documentElement.scrollHeight > document.documentElement.clientHeight ? document.documentElement.scrollHeight : document.documentElement.clientHeight;
	}
	jQuery('#lockBackground').css({width:currentWidth + "px",height:currentHight + "px"});
}
