﻿
$(function(){

	window.setTimeout(function(){
			//$('body').addClass("mainBackground");
			
			$('#mainTd1').addClass("backjpg1");
			$('#mainTd2').addClass("backjpg2");
			$('#mainTd3').addClass("backjpg3");
			$('#mainTd4').addClass("backjpg4");
			$('#mainTd5').addClass("backjpg5");
			
			$('#mainTd6').addClass("backjpg6");
			$('#mainTd7').addClass("backjpg7");
			$('#mainTd8').addClass("backjpg8");
			$('#mainTd9').addClass("backjpg9");
			$('#mainTd10').addClass("backjpg10");
			
			$('#mainTd11').addClass("backjpg11");
			
	},0);

	var mainavImgB='images/#.png';
	var mainavImgM='images/#M.png';
	var mainavList={
		'homePage':{
			'b':{width:'108px',height:'36px'},
			'm':{width:'43px',height:'36px'}
		},
		'gameNews':{
			'b':{width:'176px',height:'36px'},
			'm':{width:'83px',height:'36px'}
		},
		'gameMaterial':{
			'b':{width:'168px',height:'36px'},
			'm':{width:'83px',height:'36px'}
		},
		'tutorials':{
			'b':{width:'188px',height:'36px'},
			'm':{width:'84px',height:'36px'}
		},
		'gameStrategy':{
			'b':{width:'193px',height:'36px'},
			'm':{width:'83px',height:'36px'}
		},
		'gameBBS':{
			'b':{width:'179px',height:'36px'},
			'm':{width:'84px',height:'36px'}
		}
	};
	
	var $top=$('#top');
	var $mainav=$top.find('#mainav');
	var $mainavImgs=$mainav.find('img');
	//导航条鼠标悬浮事件和点击事件
	$mainavImgs.hover(function(){
		this.src=mainavImgB.replace('#',this.name);
		/*
		改变图片大小的特效
		elId 要修改的元素的id
		widthStop width止点
		heightStop height止点
		iod 是变大(1)还是减小(0)
		range 幅度:1,2,3...
		interval 函数执行的时间间隔
		effect.chageSize(this,
						mainavList[this.name].b.width,
						mainavList[this.name].b.height,
						1,1,200);
		*/
		
	
		this.style.width=mainavList[this.name].b.width;
		this.style.height=mainavList[this.name].b.height;
	},function(){
		this.src=mainavImgM.replace('#',this.name);
		this.style.width=mainavList[this.name].m.width;
		this.style.height=mainavList[this.name].m.height;
	});
	
	var $netList= $('#netList');
	var imgOt=null;
	var $img=null;
	var first=false;
/*
	$('#loginPanel a').click(function(){
		first=false;
		if($img==null){
			$img= $(this).find('img');
			first=true;		
		}
		
		if(imgOt==null)
			imgOt= $img.offset();
		
		$netList.show();
		
		if(first)
			$netList.css({left:imgOt.left+$img.width(),top:imgOt.top});
		
	}); */
	
	$netList.bind('mouseleave',function(){
		this.style.display='none';
	});
	
	
	var $netList=$('#netList');
	
	function isUpdating(isUpdateFunc){
		$util.doPost({
			url:'Config_isUpdating.do',
			params:{},
			func:function(txt){ isUpdateFunc(txt); },
			type:'html'
		});
	}
	
	var isUpdatingAlert='感谢您的支持，游戏正在维护更新.....';
	
	$netList.find('a:eq(0)').click(function(){
		
		isUpdating(
			function(txt){
				if(txt=='1'){
					location.href=$util.urlAddTimestamp('OnlineGame.html?');
				}else{
					alert(isUpdatingAlert);
				}
			}
		);
		
	});
	$netList.find('a:eq(1)').click(function(){
		isUpdating(
			function(txt){
				if(txt=='1'){
					location.href=$util.urlAddTimestamp('http://58.255.252.200:80/OnlineGame.html?');
				}else{
					alert(isUpdatingAlert);
				}
			}
		);
	});
	
	
});

