﻿/*********************************/
/*
/*	市北网站
/*	file: Common/JavaScript/common.js
/*
/*	Copyright Shanghai3h 2005
/*	Cleaner1912@Gmail.com
********************************/

//Main Menu onMouseOver:
function MMOn(obj)
{
	with(obj.style) {
		background	= 'URL(images/MainMenuOn.gif) center no-repeat';
		cursor		= 'hand';
	}
}
//Main Menu onMouseOut:
function MMOut(obj)
{
	with(obj.style) {
		background	= '';
		cursor		= 'hand';
	}
}

//onclick fGo()
function fGo(mUrl)
{
	window.location = mUrl;
}
//onclick fGo()
function fGo3(mUrl)
{
	window.open(mUrl, "", "", "_blank");
}

//PreloadImage
function PreloadImages() 
{ 
	var d = document; 
	if(d.images)
	{ 
		if(!d.MM_p) 
		{
			d.MM_p = new Array();
		}
		var i,j = d.MM_p.length, a = PreloadImages.arguments; 
		
		for(i = 0; i < a.length; i++)
		{
			if (a[i].indexOf("#") != 0)
			{ 
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
		}
	}
}

//Online Services onMouseOver:
function sOver(index)
{
	n = index.toString();
	d = document.getElementById;
	obj0 = eval(d("S0" + n));
	obj1 = eval(d("S0" + n + "Icon"));
	obj2 = eval(d("S0" + n + "Text"));
	
	obj0.style.background	= "URL(images/ServiceItemOn.gif)";
	obj1.src				= "images/icon_S0" + n + "On.gif";
	obj2.style.color		= "#0042FF";
	obj2.style.filter		= "progid:DXImageTransform.Microsoft.DropShadow(Color='#D6D5D5', OffX=1, OffY=1, Positive='true')";
}
//Online Services onMouseOut:
function sOut(index)
{
	n = index.toString();
	d = document.getElementById;
	obj0 = eval(d("S0" + n));
	obj1 = eval(d("S0" + n + "Icon"));
	obj2 = eval(d("S0" + n + "Text"));
	
	obj0.style.background	= "";
	obj1.src				= "images/icon_S0" + n + ".gif";
	obj2.style.color		= "#00256F";
	obj2.style.filter		= "progid:DXImageTransform.Microsoft.Glow(Color='#FFFFFF', strength=2)";
}
/*
function SubMenuOut(obj)
{
	var b = obj.style.backgroundImage;
	if(b != "URL(images/SubMenuBgOn.gif)" )
	{
		b = "URL(images/SubMenuBg.gif)";
	}
}
function SubMenuOn(obj)
{
	var b = obj.style.backgroundImage;
	if(b != "URL(images/SubMenuBg.gif)" )
	{
		b = "URL(images/SubMenuBgOn.gif)";
	}
}
*/

//Sub Menu State
//o = obj(for use, this)
//s = "Over" "Out"
//onMouseOver = SubMenuState(this, Over), onMouseOut = SubMenuState(this, Out)
function SubMenuState(o, s)
{
	switch(s) {
	case "Over":
		o.style.backgroundImage = "URL(images/SubMenuBgOn.gif)";
		break;
	case "Out":
		o.style.backgroundImage = "URL(images/SubMenuBg.gif)";
		break;
	}
}

function fGo2(top, url)
{
	window.open("temp.aspx?top=" + top + "&page="+url, "_self");
}


function show(o)
{
	if(o.style.display == 'none')
	{
		o.filters[0].Apply();
		o.style.display = '';
		o.filters[0].Play();
	}
	else
	{
		o.filters[0].Apply();
		o.style.display = 'none';
		o.filters[0].Play();
	}
}

function CSubQbgOver()
{
	var o = event.srcElement;
	o.filters[0].Apply();
	o.style.color = "#FF3000";
	o.style.background = "#D8F0FE";
	o.filters[0].Play();
}

function CSubQbgOut()
{
	var o = event.srcElement;
	o.filters[0].Apply();
	o.style.color = "";
	o.style.background = "";
	o.filters[0].Play();
}

IsHotVoteDisplay = false;

//Set iFrame Height(Beta)::
function setFrameHeight()
{
	var oFrame	=	document.getElementById("BodyContents1");
	var oBody	=	BodyContents.document.body;
	var oDiv	=	BodyContents.document.getElementById("SubBody");
	if(oDiv==null)
	{
		oDiv	=	BodyContents.document.getElementById("SubBodyg");

	}

	try
	{	
		if (oBody.scrollHeight < 450)
		{
			oDiv.style.height	= "450px";
			oFrame.style.height = "496px";
			IsHotVoteDisplay = false;
		}
		else
		{
			IsHotVoteDisplay = true;
			//oDiv.style.height	= "520px";
			oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight);
		}
		//alert(oBody.scrollHeight);
	}
	catch(e)
	{
//		window.status =	'Error: ' + e.number + '; ' + e.description;
	}
}
function btnOn(o)
{
	o.style.filter = "progid:DXImagetransForm.Microsoft.AlphaImageLoader(src='../images/btnOn.png')";
}
function btnOff(o)
{
	o.style.filter = "progid:DXImagetransForm.Microsoft.AlphaImageLoader(src='../images/btnOff.png')";
}

function sbLink(url)
{
	window.location = url;
}

//Show All::
//
var bFlag = 0;
function shAll(n)
{
	if(bFlag == 1)
	{
		for(var i=1; i<=n; i++)
		{
			var a = eval("A" + i);
			a.filters[0].Apply();
			a.style.display = "none";
			shAll_ID.innerText = "显示全部";
			a.filters[0].Play();
			Q0.style.visibility = "";
		}
		bFlag = 0;
	}
	else
	{
		for(var i=1; i<=n; i++)
		{
			var a = eval("A" + i);
			a.filters[0].Apply();
			a.style.display = "";
			shAll_ID.innerText = "隐藏全部";
			a.filters[0].Play();
			Q0.style.visibility = "hidden";
		}
		bFlag = 1;
	}
	setHeight1();
}

//reset parent.iframe's height
function setHeight1()
{
	parent.document.all.BodyContents1.style.height = document.body.scrollHeight;
	//alert(parent.document.all.BodyContents1.style.height);
}

//For Friend Links, show More(all) or show some
var bFlagLinks = 1;
function showMoreLinks()
{
	if(bFlagLinks == 1)
	{
		otherLinks.style.display = "block";
		moreLinksID.innerText = "显示部分";
		bFlagLinks = 0;
	} else {
		otherLinks.style.display = "none";
		moreLinksID.innerText = "显示全部";
		bFlagLinks = 1;
	}
	setHeight1();
}

//home page list item(links) onMouseOver(Out) State
function mlState(s)
{
	var o = event.srcElement;
	switch(s.toUpperCase()) {
	case "OVER":
		o.style.color = "#049dfe";
		break;
	case "OUT":
		o.style.color = "";
		break;
	}
}


//市北水情：等压区域图选择季度按钮，鼠标状态
function sb_dyqyt_td_State(obj, state)
{
	s = state.toUpperCase();
	
	switch(s) {
	case "OVER":
		obj.style.background = "#adfeff";
		obj.style.color = "#0658ff";
		break;
	case "OUT":
		if(obj.className == "sb-dyqyt-td-selected") 
			obj.style.background = "#adddff";
		else
			obj.style.background = "";
		obj.style.color = "#000000";
		break;
	}
}


function showDYQYT(url)
{
	var obj = document.getElementById("mainPic");
	obj.style.filter = "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='push')";
	obj.filters[0].Apply();
	obj.src = url;
	obj.filters[0].Play();
}

function show_sbsq(who)
{
	var sbqs = document.getElementById("sb-sbsq");
	var tsgg = document.getElementById("sb-tsgg");
	
	//sbqs.style.filter = "progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0, wipeStyle=1, motion='forward')";
	//tsgg.style.filter = "progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0, wipeStyle=1, motion='forward')";
	
	//sbsq.filters[0].Apply();
	//tsgg.filters[0].Apply();
	
	if(who == "sb-tsgg") {
		sbqs.style.display = "none";
		tsgg.style.display = "block";
	}
	else if(who == "sb-sbsq") {
		sbqs.style.display = "block";
		tsgg.style.display = "none";
	}
	
	//sbqs.filters[0].Play();
	//tsgg.filters[0].Play();

}

function go_back(s)
{
	var goBack = document.getElementById("goBack");
	var f = "progid:DXImageTransform.Microsoft.";
	
	switch(s.toUpperCase()) {
	case "BACK":
		history.back();
		break;
	case "OVER":
		//goBack.style.cursor = "hand";
		goBack.style.filter = f + "AlphaImageLoader(src='images/goBack_Over.png')";
		break;
	case "OUT":
		goBack.style.filter = f + "AlphaImageLoader(src='images/goBack.png')";
		break;
	}
}

/* sb WinOpen() */
function sb_winopen(url)
{	
	window.open(url, "", "width=800, height=600;");
}

/******************************************/
/*	自来水展示馆照片集
/******************************************/

/* writeImages */
function writeImg(stage, start, count)
{
	var s, imgId;
	
	for(var i = 0; i < count; i++) {
		imgId = start + i;
		s = '<td><img style=\"cursor:hand;filter:alpha(opacity=78)\"' + 
		'src=\"images/ZSG/Z' + stage + 's' + imgId + '.jpg\"' + 
		'onmouseover=\"this.style.filter=\'alpha(opacity=100)\'"' +			
		'onmouseout=\"this.style.filter=\'alpha(opacity=78)\'"' +			
		'onclick=\"showPic(' + stage + ', ' + imgId + ')\"></td>';
		
		//s = '<td><img style=\"cursor:hand;\" src=\"images/ZSG/Z' + stage + 's' + imgId + '.jpg\"' + 
		//'onmouseover=\"this.src=\'images/ZSG/Z' + stage + 's' + imgId + '_O.jpg\'\"' +			
		//'onmouseout=\"this.src=\'images/ZSG/Z' + stage + 's' + imgId + '.jpg\'\"' +			
		//'onclick=\"showPic(' + stage + ', ' + imgId + ')\"></td>';
		document.write(s);
	}
}

/* produce a filter */
function pf()
{
	//for shorthand use set fPre = "progid:DXImageTransform.Microsoft."
	var fPre = "progid:DXImageTransform.Microsoft.";

	//all filters
	f0 = "zigzag(GridSizeX=16, GridSizeY=16)";
	f1 = "Barn(orientation=horizontal, motion=in)";
	f2 = "Blinds(bands=8, direction='RIGHT') ";
	f3 = "Checkerboard(squaresX=12, squaresY=8, direction='down', duration=1)";
	f4 = "Fade(duration=1.0,overlap=1.0)";
	f5 = "Wipe(GradientSize=1.0, wipeStyle=1, motion='reverse')";
	f6 = "Iris(irisStyle='CIRCLE', motion='out')";
	f7 = "Pixelate(MaxSquare=20, Duration=1, Enabled=false)";
	f8 = "RadialWipe(wipeStyle='clock')";
	f9 = "RandomBars(orientation='horizontal') ";
	f10 = "RandomDissolve()";
	f11 = "Slide(slideStyle='SWAP', bands=6)";
	f12 = "Spiral(GridSizeX=16, GridSizeY=16)";
	f13 = "Stretch(stretchStyle='spin')";
	f14 = "Strips(Duration=1, Motion='leftdown')";
	f15 = "Wheel(spokes=16)";
	f16 = "Iris(irisStyle='CIRCLE', motion='out')";
	f17 = "Inset()";
	f18 = "RandomBars(orientation='vertical') ";
	f19 = "Iris(irisStyle='CROSS', motion='in')";
	f20 = "Iris(irisStyle='PLUS', motion='out')";
	f21 = "RadialWipe(wipeStyle='wedge')";
	f22 = "RadialWipe(wipeStyle='wedge')";
	f23 = "RadialWipe(wipeStyle='wedge')";
	f24 = "RadialWipe(wipeStyle='wedge')";
	f25 = "RadialWipe(wipeStyle='wedge')";
	
	fn = 26;
	
	//new Array to store all filters
	var fs = new Array(fn);
	//assign filter to Array[i]
	for(var i = 0; i < fn; i++) {
		fs[i] = fPre + eval("f" + i);
	}
	
	//
	var n = Math.ceil(Math.random() * fs.length) - 1;
	return fs[n];
}

function showZSGLink(id)
{
	var n = 4;
	for(var i = 0; i <=n; i++ ) {
		eval("ZSGLink" + i).style.display = "none";
	}
	eval("ZSGLink" + id).style.display = "block";
	setHeight1();
}

function showPic(ZSGId, PicId)
{
	tf = pf();
	ZSGBigPic.style.filter = tf;
	ZSGBigPic.filters[0].Apply();
	ZSGBigPic.src = "images/ZSG/Z" + ZSGId + "b" + PicId + ".jpg";
	ZSGBigPic.filters[0].Play();
	setHeight1();
}

function openImg_WY(WYId, PicId)
{

	tf = pf();
	bigPicWY.style.filter = tf;
	bigPicWY.filters[0].Apply();
	bigPicWY.src = "images/zgwy-" + WYId + PicId + ".jpg";
	bigPicWY.filters[0].Play();
	setHeight1();
}

function showMedia()
{
	window.open("bszg.html", "", "width=320, height=285", "_blank");
}

function resizeWindow()
{
	var d = document;

	var x = d.body.scrollWidth + 10;
	var y = d.body.scrollHeight + 65;
	var a = (screen.width - x)/2;
	var b = (screen.height - y)/2;
	
	self.moveTo(a, b);
	self.resizeTo(x, y);
}

//市北水情：等压区域图选择季度按钮，鼠标状态
function sb_siteMap_td_State(obj, state)
{
	s = state.toUpperCase();
	
	switch(s) {
	case "OVER":
		obj.style.background = "#FFFFFF";
		obj.style.color = "#0658ff";
		break;
	case "OUT":
		if(obj.className == "sb-siteMap-tdHead") {
			obj.style.background = "#b6d4fd";
		}
		else {
			obj.style.background = "#dbf3ff";
		}
		obj.style.color = "#006bfc";
		break;
	}
}

/* set main menu's position */
function setHotVote()
{
	var oFrame	=	document.getElementById("BodyContents1");
	var oBody	=	BodyContents.document.body;
	var oDiv	=	BodyContents.document.getElementById("SubBody");
	
	if (oBody.scrollHeight < 500) {
		Hotline.style.display = "none";
		theVote.style.display = "none";
	}
	else {
		Hotline.style.display = "block";
		theVote.style.display = "block";
	}
	
	if(window.screen.height <= 1024 || document.body.clientHeight <= 1024) {
		if(document.getElementById("subMenu")) {
			subMenuHeight = subMenu.scrollHeight;
		}
		else {
			subMenuHeight = 198;
			Hotline.style.display = "block";
			theVote.style.display = "block";
		}
		
		hotVoteHeight = 436;
		myTop = document.body.scrollTop + document.body.offsetHeight - hotVoteHeight - subMenuHeight;
		
		if(myTop < 234) myTop = 234;
		
		if((document.body.scrollHeight - document.body.scrollTop) > (document.body.clientHeight + 186)) {
			HotVote.style.top = myTop;
		}
		//window.status = "subMenuHeight=" + subMenuHeight + "; myTop=" + myTop + "; document.body.scrollHeight - document.body.scrollTop=" + (document.body.scrollHeight - document.body.scrollTop);
		
		setTimeout("setHotVote()", 50);
	}
}


