// JavaScript Document

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//菜单

function menuhover() {
	var menu = document.getElementById("menu");
	var links = menu.getElementsByTagName("a");
	for(c=0; c<links.length; c++) {
		links[c].onmouseover = function() {
			for(m=0; m<links.length; m++) {
				links[m].className = '';
			}
			this.className = 'here';
		}
		links[c].onmouseout = function() {
			for(m=0; m<links.length; m++) {
				links[m].className = '';
			}
			links[0].className = 'here';
		}
	}
}
addLoadEvent(menuhover);

/* 搜索 */
function search(id)
{
for (var i = 1;i < 4;i++)
{
var search_title = document.getElementById("search_title" + i);
var search_main = document.getElementById("search_main" + i);
if (i == id)
{
search_title.className = 'nav';
search_main.style.display = "";
}
else
{
search_title.className = 'current';
search_main.style.display = "none";
}
}
}

/* 用户登录 */
function passport()
{
if (document.login_box.username.value=="")
    document.login_box.username.focus();
else
    document.login_box.username.select();
}
function checkform()
{
if(document.login_box.username.value=="")
{
alert("请输入通行证帐号！");
document.login_box.username.focus();
return false;
}
if(document.login_box.password.value == "")
{
alert("请输入登陆密码！");
document.login_box.password.focus();
return false;
}
    return true;
}
/* ==轮播{对象|对象属性}==对象属性{宽度|高度|文字大小|自动切换时间} */
function dk_slideplayer(object,config){
	this.obj = object;
	this.config = config ? config : {width:"293px",height:"207px",fontsize:"12px",right:"10px",bottom:"10px",time:"5000"};
	this.pause = false;
	var _this = this;
	if(!this.config.right){
		this.config.right = "0px"
	}
	if(!this.config.bottom){
		this.config.bottom = "3px"
	}
	if(this.config.fontsize == "12px" || !this.config.fontsize){
		this.size = "12px";
		this.height = "21px";
		this.right = "6px";
		this.bottom = "10px";
	}else if(this.config.fontsize == "14px"){
		this.size = "14px";
		this.height = "23px";
		this.right = "6px";
		this.bottom = "15px";
	}
	this.count = jQuery(this.obj + " li").size();
	this.n =0;
	this.j =0;
	var t;
	this.factory = function(){
		jQuery(this.obj).css({position:"relative",zIndex:"0",margin:"0",padding:"0",width:this.config.width,height:this.config.height,overflow:"hidden"})
		jQuery(this.obj).prepend("<div style='position:absolute;z-index:20;right:"+this.config.right+";bottom:"+this.config.bottom+"'></div>");
		jQuery(this.obj + " li").css({width:"100%",height:"100%",overflow:"hidden"}).each(function(i){jQuery(_this.obj + " div").append("<a>"+(i+1)+"</a>")});

		jQuery(this.obj + " img").css({border:"none",width:"100%",height:"100%"})

		this.resetclass(this.obj + " div a",0);

		jQuery(this.obj + " p").each(function(i){			
			jQuery(this).parent().append(jQuery(this).clone(true));
			jQuery(this).html("");
			jQuery(this).css({position:"absolute",margin:"0",padding:"0",zIndex:"1",bottom:"0",left:"0",height:_this.height,width:"100%",background:"#000",opacity:"0.4",overflow:"hidden"})
			jQuery(this).next().css({position:"absolute",margin:"0",padding:"0",zIndex:"2",bottom:"0",left:"0",height:_this.height,lineHeight:_this.height,textIndent:"5px",width:"100%",textDecoration:"none",fontSize:_this.size,color:"#ffffff",background:"none",zIndex:"1",opacity:"1",overflow:"hidden"})
			if(i!= 0){jQuery(this).hide().next().hide()}
		});

		this.slide();
		this.addhover();
		t = setInterval(this.autoplay,this.config.time);
	}
	
	this.slide = function(){
		jQuery(this.obj + " div a").mouseover(function(){
			_this.j = jQuery(this).text() - 1;
			_this.n = _this.j;
			if (_this.j >= _this.count){return;}
			jQuery(_this.obj + " li").hide();
			jQuery(_this.obj + " p").hide();
			jQuery(_this.obj + " li").eq(_this.j).fadeIn("slow");
			jQuery(_this.obj + " li").eq(_this.j).find("p").show();
			_this.resetclass(_this.obj + " div a",_this.j);
		});
	}

	this.addhover = function(){
		jQuery(this.obj).hover(function(){clearInterval(t);}, function(){t = setInterval(_this.autoplay,_this.config.time)});
	}
	
	this.autoplay = function(){
		_this.n = _this.n >= (_this.count - 1) ? 0 : ++_this.n;
		jQuery(_this.obj + " div a").eq(_this.n).trigger('mouseover');
	}
	
	this.resetclass =function(obj,i){
		jQuery(obj).css({float:"left",marginRight:"3px",width:"15px",height:"14px",lineHeight:"15px",textAlign:"center",fontWeight:"700",fontSize:"12px",color:"#000",background:"#ffffff",cursor:"pointer"});
		jQuery(obj).eq(i).css({color:"#ffffff",background:"#c90303",textDecoration:"none"});
	}

	this.factory();
}
/* 新闻 */
function news(id)
{
for (var i = 1;i < 6;i++)
{
var news_title = document.getElementById("news_title" + i);
var news_main = document.getElementById("news_main" + i);
if (i == id)
{
news_title.className = 'nav';
news_main.style.display = "";
}
else
{
news_title.className = 'current';
news_main.style.display = "none";
}
}
}
/* 论坛 */
function bbs(id)
{
for (var i = 1;i < 9;i++)
{
var bbs_title = document.getElementById("bbs_title" + i);
var bbs_main = document.getElementById("bbs_main" + i);
if (i == id)
{
bbs_title.className = 'nav';
bbs_main.style.display = "";
}
else
{
bbs_title.className = 'current';
bbs_main.style.display = "none";
}
}
}

/*便民*/
function bmserver(id)
{
for (var i = 1;i < 5;i++)
{
var bmserver_title = document.getElementById("bmserver_title" + i);
var bmserver_main = document.getElementById("bmserver_main" + i);
if (i == id)
{
bmserver_title.className = 'nav';
bmserver_main.style.display = "";
}
else
{
bmserver_title.className = 'current';
bmserver_main.style.display = "none";
}
}
}