function Fun(){
	Fun.IEVerPattern = /MSIE( )(\d+(\.\d+)?)/;
	Fun.$ie = (document.all) ? true : false; //判断是否IE
	Fun.$IEVer = (Fun.IEVerPattern.test(window.navigator.userAgent)) ? parseFloat(RegExp.$2) : null; //获取IE版本号
	Fun.$id = function(id){return ("string" == typeof id) ? document.getElementById(id) : id;} //获取ID对象值：（对象ID名）
	//获取tag对象名集合：（对象Tag标签名）[父对象限定]
	Fun.$tag = function(tagName, parent){ return (parent) ? parent.getElementsByTagName(tagName) : document.getElementsByTagName(tagName) ; }
	//获取Class样式名对象集合：（class样式名），[Tag标签限定]，[父对象限定]
	Fun.$cl = function(cl, objName, parentNodeObj){
		var retnode = [], myclass = new RegExp('\\b' + cl + '\\b'), elem = (parentNodeObj == null) ? document.getElementsByTagName(objName) : parentNodeObj.getElementsByTagName(objName), classes;
		for (var j = 0; j < elem.length; j++) { classes = elem[j].className; if (myclass.test(classes)) retnode.push(elem[j]); }
		return retnode;
	}

	//设置链接文本：（待设置的文本），[链接目标地址]，[链接目标窗口]，[样式]
	Fun.$link = function(txt, url, target, style){ return (url) ? "<a href=\"" + url + "\" " + ((style) ? "style=\"" + style + "\"" : "") + ((target) ? " target=\"" + target + "\"" : "") + ">" + txt + "<\/a>" : txt; }
	//设置对象集合事件：（待设置的对象集合），[鼠标覆盖事件]，[鼠标移开事件]，[鼠标点击事件]，
	Fun.$action = function(objArray, mouseoverHandle, mouseoutHandle, mouseclickHandle){
		if(!objArray || objArray.length < 1) return;
		for(var i = 0; i < objArray.length; i++){
			if(mouseoverHandle) objArray[i].onmouseover = mouseoverHandle;
			if(mouseoutHandle) objArray[i].onmouseout = mouseoutHandle;
			if(mouseclickHandle) objArray[i].onclick = mouseclickHandle;
		}
	}
	//设置目标相对浮动：（对比源对象），（待设置目标对象），[左偏移量]，[上偏移量]
	Fun.$position = function(obj, targetObj, leftOffset, topOffset){
		var temp = obj.offsetParent, left = obj.offsetLeft, top = obj.offsetTop;
		while(temp){ left += temp.offsetLeft; top += temp.offsetTop; temp = temp.offsetParent; }
		targetObj.style.left = (left + leftOffset) + "px";targetObj.style.top = (top + topOffset) + "px";
	}
	//获取URL参数函数（参数名）
	Fun.$url = function(name){
		var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"), r = window.location.search.substr(1).match(reg);
		if (r != null) return unescape(r[2]); return null;
	}
	//设置添加收藏效果：（收藏地址），（收藏标题）
	Fun.$fav = function(url, title){ try{ (Fun.$ie) ? window.external.addFavorite(url, title) : window.sidebar.addPanel(url, title); }catch(e){ alert("收藏失败！请手动操作"); } }
	//设置设为首页效果：（触发源对象），（首页地址）
	Fun.$home = function(obj, url){ try{ obj.style.behavior = "url(#default#homepage)"; obj.setHomePage(url); }catch(e){ if(window.netscape) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }catch(e){ alert("您的浏览器不支持此功能！"); } } }

	Fun.$domain = function(url){ return (url.indexOf("http") > -1) ? url.split("/")[2] : url.split("/")[0]; }
	
}Fun();



// font Zoom
function doZoom(a,size){
var zoom=Fun.$id("content");
var font_b = Fun.$tag("a", Fun.$id("search_font"));
for(i=0;i<font_b.length;i++){
	font_b[i].className="";
	a.className = "b";
}
zoom.style.fontSize=size+'px';
}
			

//Add To My Favorite
function myAddPanel(homeName, homePage){
	if((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))//Gecko
		window.sidebar.addPanel(homeName,homePage,"");
	else//IE
		window.external.AddFavorite(homePage,homeName);
}

function footer(){
	document.writeln('<div class="wrapper">');
	document.writeln('<div class="footer clearfix">');
	document.writeln('<a href="http://www.pandaapp.com/" class="logo left" title="PandaApp.com">pandaapp.com</a>');
	document.writeln('<div class="copyright left">');
	document.writeln('<div>Copyright &copy; 2008-2010 Pandaapp.com,All Rights Reserved</div>');
	document.writeln('<div><a href="http://www.pandaapp.com/about/">About Us</a> | <a href="http://www.pandaapp.com/about/copyright.shtml">Copyright</a> | <a href="http://www.pandaapp.com/about/cooperation.shtml">Cooperation</a> | <a href="http://www.pandaapp.com/about/contact.shtml">Contact Us</a> | <a href="http://www.pandaapp.com/about/sitemap.shtml">Site Map</a></div>');
	document.writeln('</div>');
	document.writeln('<a href="javascript:scroll(0,0);" class="totop right"></a>');
	document.writeln('</div>');
	document.writeln('</div>');
}


//设置间进滚动通告
function SetAnn(id){
	var ul = Fun.$tag("ul", Fun.$id(id))[0], lis = Fun.$tag("li", ul), stepHeight = 20, height = stepHeight * lis.length, step = 0, time = null;
	ul.innerHTML += ul.innerHTML; ul.scrollTop = 0;
	function StartScroll(){
		if(++ul.scrollTop % stepHeight == 0){ SetStep(); return; }
		time = setTimeout(StartScroll, 0);
	}
	function SetStep(){
		clearTimeout(time);
		ul.scrollTop = (ul.scrollTop == height) ? 0 : ul.scrollTop;
		time = setTimeout(StartScroll, 3000);
	}SetStep();
}

function ue_tab( tab_menu,tab_main,cur_tab,mouse,time ){
	var pre_no;
	var timer,autoplay_timer;
	var tab;
	
	function $( id ){ return document.getElementById( id );}
	
	function run( no ){
		if( no != null ){
			if( timer != null )clearInterval( timer );
			timer = setInterval( function(){
				doChange(no);
			},200 );
		}
	}
	
	function addEvent(){
		for( var i = 0; i < tab.length; i++ ){
			tab[i].cur_no = i;
			if( mouse == null ){
				tab[i].onclick = function(){ 
					run( this.cur_no );
					return false;
				}
			} else {
				tab[i].onmouseover = tab[i].onmouseout= function(){
					run( this.cur_no );
					return false;
				}
			}
		}
	}
	
	function doChange( k ){
		if( tab[pre_no] != null && $(tab_main+(pre_no+1)) != null ){
			tab[pre_no].className = "off";
			$(tab_main+(pre_no+1)).style.display = "none";
		}
		
		if( tab[k] != null && $(tab_main+(k+1)) != null ){
			tab[k].className = "on";
			$(tab_main+(k+1)).style.display = "block";
		}
		
		pre_no = k;
		
		if( timer != null )clearInterval( timer );
	}
	
	function autoplay(){
		if( pre_no < tab.length ){
			doChange( pre_no+1 );
		} else {
			pre_no = tab.length-1;
			doChange( 0 );
		}
	}
	
	function init(){
		if( tab_menu == null || tab_main == null ) return;
		
		var tabs = tab_menu.split(" ");
		
		if( tabs[0] == null || tabs[1] == null || $( tabs[0] ) == null ) return;
		
		tab = $( tabs[0] ).getElementsByTagName( tabs[1] );

		pre_no = ( cur_tab == null ) ? 0:(cur_tab-1);
		
		doChange( pre_no );
		addEvent();
		
		if( time != null && time > 0 )
			autoplay_timer = setInterval( autoplay,time );
	}
	
	init();

}




//设置轮播广告
function SetTurnGG(conID, width, height, auto){
	var imgs = Fun.$tag("img", Fun.$id(conID)), imgInfos = [], value = "", temp, step = 0, turnName = "turn_gg_", stepTime = 3000;
	for(var i = 0; i < imgs.length; i++){
		temp = imgs[i].title.split("+++");
		imgInfos.push({ name:temp[0], pic:imgs[i].src, info:temp[1], url:imgs[i].parentNode.href, target:imgs[i].parentNode.target });
		value += "<li class=\"" + (turnName + (imgs.length - i)) + "\">" + (imgs.length - i) + "<\/li>";
	}
	var info = "<style type=\"text\/css\">." + turnName + "gg{ width:" + width + "px; height:" + height + "px; position:relative; overflow:hidden; border:1px solid #e6e6e6; }\n ." + turnName + "gg img{ width:" + width + "px; height:" + height + "px;}\n ."  + turnName + "pic{ width:100%; }\n ." + turnName + "txt, ." + turnName + "bg{ position:absolute; bottom:0; left:0; z-index:2; text-align:left; color:#fff; }\n ." + turnName + "txt{ width:" + (width - 14) + "px; padding:2px 5px 20px; white-space:nowrap; overflow:hidden; font-size:12px; }\n ." + turnName + "txt h5, ." + turnName + "txt h5 a{ text-align:left; font-size:14px; font-weight:bold; line-height:22px; color:#fff; } ." + turnName + "txt h5 a:hover{ color:#ffe300; }\n ." + turnName + "bg{ width:100%; height:65px; padding:0; background:#000; z-index:1; filter:alpha(opacity=70); opacity:0.7; }\n ." + turnName + "num{ width:100%; position:absolute; bottom:2px; right:0; z-index:3; }\n ." + turnName + "num li{ float:right; font-family:Tohoma; margin:0 1px; background-color:#000; height:14px; color:#fff; line-height:14px; padding:2px 5px; cursor:pointer; }<\/style><div class=\"" + turnName + "gg\" id=\"" + turnName + "gg\"><div class=\"" + turnName + "pic\" id=\"" + turnName + "pic\"><\/div><div class=\"" + turnName + "bg\" id=\"" + turnName + "bg\"><\/div><div class=\"" + turnName + "txt\" id=\"" + turnName + "gg_con\"><\/div><ul class=\"" + turnName + "num\" id=\"" + turnName + "num\">", con = Fun.$id(conID);
	document.writeln(info + value + "<\/ul><\/div>");
	var pic = Fun.$id(turnName + "pic"), content = Fun.$id(turnName + "gg_con"), bg = Fun.$id(turnName + "bg"), lis = Fun.$tag("li", Fun.$id(turnName + "num")), gg = Fun.$id(turnName + "gg"), tempLI = lis[step];
	function setData(){ 
		pic.innerHTML = Fun.$link("<img src=\"" + imgInfos[step].pic + "\" alt=\"" + imgInfos[step].name + "\" title=\"" + imgInfos[step].name + "\" \/>", imgInfos[step].url, imgInfos[step].target);
		content.innerHTML = "<h5>" + Fun.$link(imgInfos[step].name, imgInfos[step].url, imgInfos[step].target) + "<\/h5>" + ((imgInfos[step].info) ? imgInfos[step].info : "");
		tempLI.style.backgroundColor = "#000"; tempLI.style.color = "#fff";
		tempLI = lis[imgs.length - step - 1];
		tempLI.style.backgroundColor = "#aaa"; tempLI.style.color = "#fe0";
	}setData();
	function mouseover(){
		tempLI.style.backgroundColor = "#000"; tempLI.style.color = "#fff";
		tempLI = this;
		this.style.backgroundColor = "#aaa"; this.style.color = "#333";
		step = parseInt(this.className.replace(turnName, "")) - 1;
		setData();
	}
	function SetAutoTurn(){ step = (++step == imgs.length) ? 0 : step; setData(); time = setTimeout(SetAutoTurn, stepTime); }
	Fun.$action(lis, mouseover);
	if(auto){
		gg.onmouseover = function(){ clearTimeout(time); }
		gg.onmouseout = function(){ time = setTimeout(SetAutoTurn, stepTime); }
		time = setTimeout(SetAutoTurn, stepTime);
	}
}

//news share
function social_share(infoTitle){	
	var current_url=encodeURIComponent(window.location.href);
	var str_share='<div class="social_share">';
	str_share+='<ul>';
	str_share+='<li>Bookmark and share to your friends: </li>';
	str_share+='<li><a title="Buzz it" href="http://www.addtoany.com/add_to/google_buzz?linkurl='+current_url+'&linkname='+infoTitle+'"  class="buzz"></a></li>';
	str_share+='<li><a title="Tweet This" href="http://twitter.com/home?status='+infoTitle+' - '+current_url+'" class="twitter"></a></li>';
	str_share+='<li><a title="Sent to Facebook" href="http://www.facebook.com/sharer.php?u='+current_url+'&t= '+infoTitle+'"  class="facebook"></a></li>';
	str_share+='<li><a title="Digg This" href="http://digg.com/submit?url='+current_url+'&title= '+infoTitle+'" class="diggthis"></a></li>';
	str_share+='<li><a title="Delicious" href="http://delicious.com/post?url='+current_url+'&title= '+infoTitle+'" class="delicious"></a></li>';
	str_share+='<li><a title="Stumble" href="http://www.stumbleupon.com/submit?url='+current_url+'&title= '+infoTitle+'" class="stumble"></a></li>';
	str_share+='<li><a title="MySpace" href="http://www.myspace.com/Modules/PostTo/Pages/?u='+current_url+'&t= '+infoTitle+'" class="myspace"></a></li>';
	str_share+='</ul>';
	str_share+='</div>';
	document.writeln(str_share);
}
