//***************************************************************/
// 作者：冯岩
// 日期：2007-10-25 14：18
// 功能：创建蔗罩层效果
// 修改：修改日期,修改人加说明
//***************************************************************/
var bodyScrollWidth=0;
var bodyScrollHeight=0;
function getWidth()
{
     var strWidth,clientWidth,bodyWidth;
     clientWidth = document.documentElement.clientWidth;
     bodyWidth = document.body.clientWidth;
     if(bodyWidth > clientWidth){
         strWidth = bodyWidth + 20;
     } else {
         strWidth = clientWidth;
     }
     return strWidth;
}
function getHeight()
{
     var strHeight,clientHeight,bodyHeight;
     clientHeight = document.documentElement.clientHeight;
     bodyHeight = document.body.clientHeight;
     if(bodyHeight > clientHeight){
         strHeight = bodyHeight + 30;
     } else {
         strHeight = clientHeight;
     }
    /* 
     if(window.screen.height > strHeight)
     {
        strHeight = window.screen.height;
     }
     */
     return strHeight;
}
function reCalBodySize(){
		try
		{
			bodyScrollWidth=getWidth();//document.body.scrollWidth;
			bodyScrollHeight= getHeight();//document.body.scrollHeight;	
		}
		catch(e)
		{
		}
				
}
reCalBodySize();
if(navigator.appName.indexOf("Explorer") > -1){//ie
	var exp=1;
} 
else{//for ff
	var exp=2;
}
function buildGlobalDiv(){
		reCalBodySize();
		var globalDiv=document.createElement('div');
		globalDiv.id='globalDiv';
		globalDiv.style.display='none';
		globalDiv.style.zIndex='98';					
		globalDiv = set_div_style(globalDiv,'globalDiv','0px','0px',bodyScrollWidth+'px',bodyScrollHeight+'px',"absolute"," #333333 0px solid","default","darkgray");
		globalDiv.onselectstart=function(){return false}	
		if ( 1 == exp ) {						
						globalDiv.style.filter="alpha(opacity=30)";
			}
			else {
						
				globalDiv.style.opacity=30/100;
			}
	document.body.appendChild(globalDiv);
	
	
	
}
function set_div_style(obj,id,top,left,width,height,position,border,cursor,background) {
		var obj = obj;
		obj.id = id?id:null;
		obj.style.top = top?top:'0px';
		obj.style.left = left?left:'0px';
		obj.style.width = width?width:'0px';
		obj.style.height = height?height:'0px';
		obj.style.position = position?position:"static";
		obj.style.border = border?border:"1px #000 solid";
		obj.style.cursor = cursor?cursor:"default";
		obj.style.background = background?background:"";					
				
		return obj
}
function synSizeByBody() {				
		var argArr=synSizeByBody.arguments;
		for ( var i=0;i<argArr.length;i++ ) {
			if ( document.getElementById(argArr[i]) != null ) {
					
				document.getElementById(argArr[i]).style.width = (bodyScrollWidth)+'px';
				document.getElementById(argArr[i]).style.height = (bodyScrollHeight)+'px';
			}
		}
}
function hide() {
	buildGlobalDiv();
	synSizeByBody("globalDiv");
	//if(document.getElementById("showIndustryRs")!=null)
	//document.getElementById("showIndustryRs").style.display = "none";
		document.getElementById("globalDiv").style.display = "block";
	if ( 1 == exp ) {
		hideElementAll();
	}
}
function hideElementAll(){
				HideElement("SELECT");
				HideElement("OBJECT");
				//HideElement("IFRAME");
			}

function showElementAll(){
		ShowElement("SELECT");
		ShowElement("OBJECT");
		ShowElement("IFRAME");
}
function HideElement(strElementTagName){
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "hidden";
		}
	}catch(e){
		alert(e.message);
	}
}

function ShowElement(strElementTagName){
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "visible";
		}
	}catch(e){
		alert(e.message);
	}
}

function GetCenterXY_ForLayer(objdiv){
	var bodyScrollWidth=0;
var bodyScrollHeight=0;

	objdiv.style.display='block';
	var styleWidth=objdiv.style.width.substring(0,objdiv.style.width.length-2);
	var clientHeight=objdiv.firstChild.clientHeight;
	var objLeft = parseInt(document.body.scrollLeft+(document.body.clientWidth - styleWidth)/2)+'px';
	var relTop=(document.body.clientHeight-clientHeight)/2 > 0 ? (document.body.clientHeight-clientHeight)/2:0;
	var objTop = parseInt(document.body.scrollTop+relTop)+'px';
	objdiv.style.top = objTop;
	objdiv.style.left = objLeft;
	checkAndResetStyleTop(objdiv);
}
function checkAndResetStyleTop (obj) {
	var clientHeight=obj.firstChild.clientHeight;
	var styleTop=parseInt(obj.style.top.substring(0,obj.style.top.length-2));
	if ( clientHeight+styleTop>bodyScrollHeight ) {
		obj.style.top=(bodyScrollHeight- clientHeight)+'px';
	}
}


function cancel() {
	document.getElementById("globalDiv").style.display = "none";
	if ( 1 == exp ) {
		showElementAll();
	}
}
function CloseDiv(divName){
	var dv = document.getElementById(divName);
	dv.style.display = "none";
	
	if(document.getElementById("ctl00_Master_main_txtSelectID").value.length>1)
	{
		if(document.getElementById("showIndustryRs")!=null)
		document.getElementById("showIndustryRs").style.display = "inline";
	}
	else
	{
		if(document.getElementById("showIndustryRs")!=null)
		document.getElementById("showIndustryRs").style.display = "none";
	}
	
}




function select(name) {  
   var el = document.getElementsByTagName('input');     
   var len = el.length;     
   for(var i=0; i<len; i++){         
		if((el[i].type=="checkbox") && (el[i].name==name))         
		{             
			el[i].checked = true;  
			alert(el[i].Text);      
		}     
   } 
  } 
  function showUserSelectedIndustry(selectObj)
    {
	    try{
		        var obj = document.getElementById("showUserSelectIndustry");
			    obj.innerHTML = "";
			    document.getElementById("ctl00_Master_main_txtSelectID").value = "";
			    var selectNo = 0;
			    document.getElementById("ctl00_Master_main_tdShowAfterSubmit").innerHTML = "";
		        var chk=document.getElementsByTagName("INPUT");
		        for(var i=0;i<chk.length;i++)
		        {
			        if(chk[i].checked  && chk[i].id.indexOf("chkBox")!=-1 && selectNo<6)
			        {	
				        selectNo++;
				        obj.innerHTML += chk[i].text + "&nbsp;&nbsp;&nbsp;&nbsp;";
				        document.getElementById("ctl00_Master_main_txtSelectID").value +=  chk[i].value + "|";
				        document.getElementById("ctl00_Master_main_tdShowAfterSubmit").innerHTML += chk[i].text + "&nbsp;&nbsp;&nbsp;&nbsp;";
			        }
			        else if(selectNo >= 6 )
			        {
				        selectObj.checked = false;
				        showUserSelectedIndustry(null);
				        alert("最多选五项");
				        return false;
			        }
		       }
	    }catch(e){}
    }	