﻿function MM_swapImgRestore()
{
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages()
{
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_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];}}
}

function MM_findObj(n, d)
{
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length){
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openWin(n,u,w,h)
{
	var windowLeft = (window.screen.availWidth - w)/2;
	var windowTop = (window.screen.availHeight - h)/2;
	args = "left="+windowLeft+",top="+windowTop+",width="+w+",height="+h+",resizable=yes,scrollbars=yes,status=1";
	window.open(u,n,args);
}

function openWin(n,u,w,h)
{
	var windowLeft = (window.screen.availWidth - w)/2;
	var windowTop = (window.screen.availHeight - h)/2;
	args = "left="+windowLeft+",top="+windowTop+",width="+w+",height="+h+",status=yes,toolbar=no,menubar=no,location=no";
	window.open(u,n,args);
}

function view_360(wz,btn,id)
{
	var links=new Array();
	if(12==btn)
	{
		show360Msg(1,wz);
	}
	else if(13==btn)
	{
		id.href='';
	}
	else if(14==btn)
	{
		openWin();
	}
	else if(1==btn)
	{
		open_S_Win();
	}
	else
	{
		var url="";
		if(0==wz)
		{
			url=""
		}
		else
		{
			for(var i=1; i<=wz;i++)
			{
				url=url+"../";
			}
		}
	id.href=url+links[btn];
	}
}

function $id(a)
{
	return document.getElementById(a);
}

function $name(a)
{
	return document.getElementsByTagName(a);
}

function setStatusText(statusText)
{
	window.status = unescape(statusText);
	window.defaultStatus = unescape(statusText);
}

function Event(id,type,fun)
{
	if(id.addEventListener)
	{
		id.addEventListener(type,fun,false);
		id[type] = fun;
	}
	else if(id.attachEvent)
	{
		id.attachEvent(type,fun);
	}
	else
	{
		id[type] = fun;
	}
}


function setStatusText(statusText)
{
	window.status = unescape(statusText);
	window.defaultStatus = unescape(statusText);
}


function EventFun2()
{
	Event($id('nav_btn1'),'onmouseover',function(){$id('c_nav1').style.display="block";});
	Event($id('nav_btn1'),'onmouseout',function(){$id('c_nav1').style.display="none";});
	Event($id('c_nav1'),'onmouseover',function(){$id('c_nav1').style.display="block";});
	Event($id('c_nav1'),'onmouseout',function(){$id('c_nav1').style.display="none";});
}

function $ID( strID )
{
	if(document.all && !window.opera)
	{
		return document.all[ strID ];
	}
	else
	{
		return document.getElementById(strID);
	}
}

function bottom1()
{
	try {
		$ID("bottom").style.top=(document.documentElement.clientHeight + document.documentElement.scrollTop - $ID("bottom").offsetHeight);
	}
	catch(e)
	{
		
	}
}

function Bottom()
{
	document.getElementById("bottom").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("bottom").offsetHeight)+"px";
}

function addEvent(obj, eventType, func, useCaption)
{
	if (!obj || !eventType || !func)
	{
		return false;
	}
	else if(obj.addEventListener)
	{
		obj.addEventListener(eventType, func, useCaption);
		return true;
	}
	else if(obj.attachEvent)
	{
		var retVal = obj.attachEvent("on"+eventType, func);
		return retVal;
	}
	else
	{
		return false;
	}
}

function ReadV()
{
	if(window.XMLHttpRequest)
	{
		if(!window.ActiveXObject)
		{
			return 'X';
		}
		else
		{
			return '2';
		}
	}
	else
	{
		return '1';
	}
}

function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
 	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll = document.body.scrollWidth;yScroll = document.body.scrollHeight;
	}
 	else 
	{
		xScroll = document.body.offsetWidth;yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) 
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
 	else if (document.documentElement && document.documentElement.clientHeight)
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
 	else if (document.body) 
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
 	else 
	{
		pageHeight = yScroll;
	}
	
	if(xScroll < windowWidth)
	{
		pageWidth = windowWidth;
	}
 	else 
	{
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

function show360Msg(num,url)
{
	var Msgid=document.getElementById('msg');
	Msgid.innerHTML="";
	var div="";
	if(1==num)
	{
		if(0==url)
		{
			div="<div id=\"msg1\"><\/div><iframe frameborder=\"0\" scrolling=\"No\" src=\"http://s.mymb.com.cn/chinatest/templates/360.html\" class=\"msg360\" id=\"msg360\"><\/iframe>";
		}
		else if(1==url)
		{
			div="<div id=\"msg1\"><\/div><iframe frameborder=\"0\" scrolling=\"No\" src=\"http://s.mymb.com.cn/chinatest/templates/360.html\" class=\"msg360\" id=\"msg360\"><\/iframe>";
		}
		Msgid.innerHTML=div;
		var arrayPageSize = getPageSize();
		document.getElementById('msg1').style.height=arrayPageSize[1]+'px';
		if('1' == ReadV())
		{
			bottom();
			demo360();
			window.onscroll=function ()
			{
				bottom();
				demo360();
			}
		//;
			window.onresize=function ()
			{
				bottom();
				demo360();
			}
		//;
		}
	}
	else
	{
		window.onscroll=function ()
		{
			bottom();
		}
//;
		window.onresize=function ()
		{
			bottom();
		}
//;
	}
}

function open_S_Win(u)
{
	var w = window.screen.availWidth;
	var h = window.screen.availHeight;
	var a='left='+0+',top='+0+',width='+w+',height='+h+'channelmode=1,toolbar=1,location=1,directories=yes,status=1,menubar=1,scrollbars=1,resizable=1,alwaysRaised=yes,fullscreen=no';
	//;
	var Sc=window.open(u,'S_cless_G',a);
	Sc.focus();
}

function none()
{
	for (var i = 0; i < arguments.length; i++)
	{
		if(document.getElementById(arguments[i]))
		{
			document.getElementById(arguments[i]).style.display="none";
		}
	}
}

function block()
{
	for (var i = 0; i < arguments.length; i++)
	{
		if(document.getElementById(arguments[i]))
		{
			document.getElementById(arguments[i]).style.display="block";
		}
	}
}

function bottom()
{
	document.getElementById("bottom").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("bottom").offsetHeight)+"px";
}

function TVC_content()
{
	var arrayPageSize=getPageSize();
	document.getElementById("TVC_content").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-parseInt(arrayPageSize[3]/2))+"px";
}

function demo360()
{
	var arrayPageSize=getPageSize();
	document.getElementById("msg360").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-parseInt(arrayPageSize[3]/2))+"px";
}

function init()
{
	if('1' == ReadV())
	{
		window.onscroll=function ()
		{
			bottom();
		}
	//;
		window.onresize=function ()
		{
			bottom();
		}
	//;
	}

	EventFun2();
	MM_preloadImages('');
}
