// JavaScript Document
/**
 功能：获取鼠标坐标值
*/
function mousePosition(ev) {
 if(ev.pageX || ev.pageY){
    return {x:ev.pageX, y:ev.pageY};
 }
 //下面返回的是IE的坐标值
 return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop-document.body.clientTop
 };
}



/**显示产品中层的效果start*/
var isIe=(document.all)?true:false;
//设置select的可见状态
function setSelectState(state){
 var objl=document.getElementsByTagName('select');
 for(var i=0;i<objl.length;i++) {
     objl[i].style.visibility=state;
 }
}


var w3c=(document.getElementById)? true: false;
var agt=navigator.userAgent.toLowerCase();
var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));

function IeTrueBody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function GetScrollTop(){
 return ie ? IeTrueBody().scrollTop : window.pageYOffset;
}

//弹出方法
function showMessageBox(wTitle,content,pos,width,height){
 closeWindow();
 var bWidth=parseInt(document.documentElement.scrollWidth);
 var bHeight=parseInt(document.documentElement.scrollHeight);
 if(isIe){ setSelectState('hidden');}
 var back=document.createElement("div");
 back.id="back";
 var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
 styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
 back.style.cssText=styleStr;
 document.body.appendChild(back);
 showBackground(back,80);
 var mesW=document.createElement("div");
 mesW.id="mesWindow";
 mesW.className="mesWindow";
 mesW.innerHTML="<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>"+wTitle+"</td><td style='width:1px;'><img src='../images/close.gif' onclick='closeWindow();' style='cursor:pointer' alt='关闭'></td></tr></table></div><div class='mesWindowContent' id='mesWindowContent'>"+content+"</div><div class='mesWindowBottom'></div>";
 //styleStr="left:"+(((pos.x-width)>0)?(pos.x-width):pos.x)+"px;top:"+(pos.y)+"px;position:absolute;width:"+width+"px;";
 var  showx = (screen.width - width)/2 ; // + deltaX;
 var  showy = (screen.height - height-200)/2+parseInt(GetScrollTop()); // + deltaY;
 styleStr="left:"+showx+"px;top:"+showy+"px;width:"+width+"px;";
 mesW.style.cssText=styleStr;
 document.body.appendChild(mesW);
}

// 让背景渐渐变暗
function showBackground(obj,endInt){
 if(isIe){
    obj.filters.alpha.opacity+=1;
    if(obj.filters.alpha.opacity<endInt){
      setTimeout(function(){showBackground(obj,endInt)},0);
    }
  }else{
    var al=parseFloat(obj.style.opacity);al+=0.01;
    obj.style.opacity=al;
    if(al<(endInt/100)) {setTimeout(function(){showBackground(obj,endInt)},0);}
  }
}

//关闭窗口
function closeWindow() {
 if(document.getElementById('back')!=null) {
   document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
 }
 if(document.getElementById('mesWindow')!=null) {
   document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
 }
 if(isIe){ setSelectState('');}
}



//测试弹出

function testMessageBoxdemo(imgurl,id,ev,wWidth,height,htmlsrc,introduce) {
 var objPos = mousePosition(ev);
 var messContent="<div style='position:relative;z-index:99;'><iframe scrolling='no' frameborder='0' width='"+(wWidth-10)+"' height='"+height+"' src='"+htmlsrc+"'></div>";
 	//document.getElementById("content").style.backgroundColor="#EFEFEF";
/* if(document.getElementById("showBgId").value!=""){
	 document.getElementById(id).style.backgroundImage="url("+imgurl+")";
	 document.getElementById(id+"1").style.backgroundImage="url("+imgurl+")";
 }*/
 if(id!=document.getElementById("showBgId").value&&document.getElementById("showBgId").value!=""){
		//document.getElementById("showBgId").value="";
   document.getElementById(document.getElementById("showBgId").value).style.backgroundImage="url("+imgurl+")";
   document.getElementById(document.getElementById("showBgId").value+"1").style.backgroundImage="url("+imgurl+")";
 }
 document.getElementById("showBgId").value=id;
 showMessageBox(introduce,messContent,objPos,wWidth,height);
}

//设计中弹出窗口
function testMessageBox(ev,wWidth,height,imgsrc,introduce) {
 var objPos = mousePosition(ev);
 messContent="<div style='padding:20px 0 20px 0;text-align:center'><img src="+imgsrc+"></div>";
 showMessageBox(introduce,messContent,objPos,wWidth,height);
}

/**显示产品中层的效果end*/

/*左边功能小方块中显示效果*/
function showBg(id,imgurl3,imgurl2){
	document.getElementById(id).style.backgroundImage="url("+imgurl3+")";
	document.getElementById(id+"1").style.backgroundImage="url("+imgurl3+")";
}
function showBgout(id,imgurl){
	if(id!=document.getElementById("showBgId").value){
	 document.getElementById(id).style.backgroundImage="url("+imgurl+")";
	 document.getElementById(id+"1").style.backgroundImage="url("+imgurl+")";
	}
}