﻿function $(id){return document.getElementById(id);}

//重设所有图片宽高
function ResetImagesSize()
{ 
	var sImages=document.getElementsByTagName("img");
 	for(var ii=0;ii<sImages.length;ii++) {
		 sImages[ii].width=sImages[ii].width;
		 sImages[ii].height=sImages[ii].height;
	}
}

//设置左右高度自适应
function SameHigh2(div1,div2) {
	try {
		var a=Math.max($(div1).offsetHeight,$(div2).offsetHeight);
		$(div1).style.height = a + "px";
		$(div2).style.height = a + "px";
	}
	catch(e){
		//alert("error of SameHigh2: \n"+e.message);
	}
}

//设置左中右高度自适应
function SameHigh3(div1,div2,div3) {
	try {
		var a=Math.max(document.getElementById(div1).offsetHeight,document.getElementById(div2).offsetHeight,document.getElementById(div3).offsetHeight);
		document.getElementById(div1).style.height = a + "px";
		document.getElementById(div2).style.height = a + "px";
		document.getElementById(div3).style.height = a + "px";
	}
	catch(e){
		//alert("error of SameHigh3: \n"+e.message);
	}
}
//设置内容页面左右高度自适应
function SameAContHigh(div1,div2,div3) {
	try {
		var a=document.getElementById(div1);
		var b=document.getElementById(div2);
		var c=document.getElementById(div3);
		if (a.offsetHeight<b.offsetHeight-2) {
			a.style.height=b.offsetHeight-2 + "px";
		}
		else {
			c.style.height=a.offsetHeight-b.offsetHeight + c.offsetHeight - 7 + "px";
		}
	}
	catch(e){
		alert("error of SameAContHigh: \n"+e.message);
	}
}


//切换主菜单
var oldClassID=0;
function ShowMenu(i){
	document.getElementById("Menu2").innerHTML=menu[i];
	if(oldClassID!=0) document.getElementById("class" + oldClassID).className="";
	document.getElementById("class" + i).className="in";
	oldClassID=i;
}


//切换宣传品牌
var xMenu=new Array();
xMenu[1]="打造宣传文化品牌，展现汕头良好形象";
xMenu[2]="打造文艺传播品牌，促进文化成果共享";
xMenu[3]="打造文明创建品牌，提升城市文明程度";
xMenu[4]="打造理论教育品牌，提高思想引领水平";
xMenu[5]="打造对外宣传品牌，拓展城市对外影响";
function XcppMenu(i){$("MLine2").innerHTML=xMenu[i];}
function XcppClear(){$("MLine2").innerHTML="";}



//切换选项卡
function switchTab(identify,index,count) {
	for(i=0;i<count;i++) {
		var CurTabObj = document.getElementById("Tab_"+identify+"_"+i) ;
		var CurListObj = document.getElementById("List_"+identify+"_"+i) ;
		if (i != index) {
			fRemoveClass(CurTabObj , "UpTab") ;
			fRemoveClass(CurListObj , "UpList") ;
		}
	}
	fAddClass(document.getElementById("Tab_"+identify+"_"+index),"UpTab") ;
	fAddClass(document.getElementById("List_"+identify+"_"+index),"UpList") ;
}

function fAddClass(XEle, XClass)
{/* shawl.qiu code, void return */
  if(!XClass) throw new Error("XClass 不能为空!");
  if(XEle.className!="") 
  {
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = XEle.className.replace(Re, "");
	var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
	if (OldClassName == "" ) {
		 XEle.className = XClass;
	}
	else {
		XEle.className = OldClassName + " " + XClass;
	}
   
  }
  else XEle.className = XClass;
}/* end function fAddClass(XEle, XClass) */

function fRemoveClass(XEle, XClass)
{/* shawl.qiu code, void return */
  if(!XClass) throw new Error("XClass 不能为空!");
  var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
  if(OldClassName!="") 
  {
	
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = OldClassName.replace(Re, "");
  }
}/* function fRemoveClass(XEle, XClass) */
//切换选项卡end

//清除错误
function killErrors(){return true;}


//浮动窗口
var Obj='';
document.onmouseup=MUp;
document.onmousemove=MMove;

function MDown(Object){
Obj=Object.id;
document.all(Obj).setCapture();
pX=event.x-document.all(Obj).style.pixelLeft;
pY=event.y-document.all(Obj).style.pixelTop;
}
function MMove(){
if(Obj!=''){
  document.all(Obj).style.left=event.x-pX;
  document.all(Obj).style.top=event.y-pY;
  }
}
function MUp(){
if(Obj!=''){
  document.all(Obj).releaseCapture();
  Obj='';
  }
}
function open_msgbox(){
	var clientWidth = document.body.clientWidth;
	var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
	var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
	$("msg_box").style.left = (clientWidth-520)/2 + 'px';
	$("msg_box").style.top = ((clientHeight - 410) / 2 + scrollTop) + 'px';
	$("msg_mask").style.visibility='visible';
	$("msg_box").style.visibility='visible';
	return false;
}
function close_msgbox(){
	$("msg_box").style.visibility='hidden';
	$("msg_mask").style.visibility='hidden';
	$("msg_box").style.left = '0px';
	$("msg_box").style.top = '0px';
	return false;
}

//Talk
function OpenClose(o,id){
	if ($('ct' + id).style.height!="auto") {
		$('ct' + id).style.height="auto";
		o.src="images/talk/bClose.gif";
		}else{
		$('ct' + id).style.height="35px";
		o.src="images/talk/bOpen.gif";
	}
}


