﻿$(document).ready(function() {

	$('#post_ajax').click(function(){
		var game_id  = $('#id').val();
		var enpinpai = $('#enpinpai').val();
		var xinghao  = $('#xinghao').val();
		
		if(enpinpai == "请选择手机品牌"){
			alert('请选择手机品牌');
			return false; 
		};
		if(xinghao == "手机型号"){
			alert('请选择手机型号');
			return false; 
		};
		//alert(enpinpai)
		$("#ajax_html").load("http://www.kxsy.com/download.asp?id="+game_id+"&enpinpai="+enpinpai+"&xinghao="+xinghao+"");
	});
	$('#get_game_list').click(function(){
		$("#ajax_html").load($(this).attr('href'));
		return false; 
	});
	$('#searchMenu label').click(function(){
		$('#searchMenu label').removeClass('current');
		$(this).addClass('current');
	});

	$('#searchSubmit').click(function(){
		var v = $("#searchText").val();
		if(v == '请输入关键字...' || v == ''){
			alert('请输入关键字'); return false; 
		}else{
			var n = $('#searchMenu .current').attr('for');
			$('#searchForm').attr('action', 'http://www.kxsy.com/' +  n );
		};
	});
	
	
	$('#featuredGames,#gamePics').cycle({
		fx:     'fade',
		speed:   800,
		timeout: 4000,
        after:   onAfter,
		pager:  '#feaNavi',
		next:   '#next',
		prev:   '#prev'
	});
	$('.featuredGames').hover(function(){
		$('#featuredGames').cycle('pause'); return false;								   
	},function(){
		$('#featuredGames').cycle('resume'); return false; 
	});
	function onAfter() {
		$('#feaTitle').html('<h3><a href="' + this.href + '">' + this.title + '</a></h3><p>' + this.lang + '</p><div class="bg"></div>');
	};
	$('.topGames li:odd,.articleList_1 li:odd').addClass('odd');
	$('.topGames li:last,.articleList_1 li:last').addClass('nobd');
	$('#subMenuButton').hover(function(){
		$('#subMenuBox').show()	 
	 },function(){
		 $('#subMenuBox').hide();
	 });
	
	$('#mobileTopType').hover(function(){
		$(this).find('.mobileTopTypeBox').show()	 
		$(this).addClass('mobileTopTypeShow')	 
	},function(){
		$(this).find('.mobileTopTypeBox').hide()	 
		$(this).removeClass('mobileTopTypeShow')	 
	});
	
	  $('#mobileMenu li').click(function(_thisItem){
		  var _thisItem = eval($(this).attr('lang'));
		  $('#mobileMenu li').removeClass('current');
		  $(this).addClass('current');
		  $('#mobileBox').show();
		  $("#mobileType ul").empty();
		  
		  for(i=0;i<_thisItem.length;i++){
			  var p = i+1;
			  $("#mobileType ul").append("<li class='class_"+ p +"'><a href='"+_thisItem[i].url+"'>"+_thisItem[i].name+"</a></li>"); 
		  };
		  
			var num = _thisItem.length;
			num+= " "; 
			spstr = num.split("");
			var numA = spstr[spstr.length-2];
			if(numA == '0'){
				var n = 0;
			}else{
				var n = 10-parseInt(numA);
			}
			var numB = (num-11) + n;
			
			$('#mobileType li:gt('+ numB +')').css('borderBottom','none');
			$('#mobileType li a:last').css('color','#f06000');
		  
		  return false
	  });
	  $('#closeMobileType').click(function(){
		  $('#mobileBox').hide();		   
		  $('#mobileMenu li').removeClass('current');
	  });
	  $('#enpinpai').change(function(){
		  var _thisItem = $(this).find('option:selected').index();
		  
		  $("#xinghao").empty(); 
		  for(i=0;i<arr[_thisItem].length;i++){
			  $("#xinghao").append("<option value='"+arr[_thisItem][i]+"'>"+arr[_thisItem][i]+"</option>"); 
		  };
	  });
	  

});

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';5(29.1j)(7($){5($.1L.1J)1I{1t.1H("1K",J,H)}1M(e){};$.n.3=7(i){5(4.Q==0)k 4;5(A I[0]==\'1h\'){5(4.Q>1){8 j=I;k 4.W(7(){$.n.3.y($(4),j)})};$.n.3[I[0]].y(4,$.1T(I).1U(1)||[]);k 4};8 i=$.12({},$.n.3.1s,i||{});$.n.3.K++;4.2a(\'.9-3-1f\').o(\'9-3-1f\').W(7(){8 a,l=$(4);8 b=(4.23||\'21-3\').1v(/\\[|\\]/g,\'Z\').1v(/^\\Z+|\\Z+$/g,\'\');8 c=$(4.1X||1t.1W);8 d=c.6(\'3\');5(!d||d.18!=$.n.3.K)d={z:0,18:$.n.3.K};8 e=d[b];5(e)a=e.6(\'3\');5(e&&a)a.z++;x{a=$.12({},i||{},($.1b?l.1b():($.1S?l.6():s))||{},{z:0,F:[],v:[]});a.w=d.z++;e=$(\'<1R V="9-3-1Q"/>\');l.1P(e);e.o(\'3-15-T-17\');5(l.S(\'R\'))a.m=H;e.1c(a.E=$(\'<P V="3-E"><a 14="\'+a.E+\'">\'+a.1d+\'</a></P>\').1g(7(){$(4).3(\'O\');$(4).o(\'9-3-N\')}).1i(7(){$(4).3(\'u\');$(4).G(\'9-3-N\')}).1l(7(){$(4).3(\'r\')}).6(\'3\',a))};8 f=$(\'<P V="9-3 q-\'+a.w+\'"><a 14="\'+(4.14||4.1p)+\'">\'+4.1p+\'</a></P>\');e.1c(f);5(4.11)f.S(\'11\',4.11);5(4.1r)f.o(4.1r);5(a.1F)a.t=2;5(A a.t==\'1u\'&&a.t>0){8 g=($.n.10?f.10():0)||a.1w;8 h=(a.z%a.t),Y=1y.1z(g/a.t);f.10(Y).1A(\'a\').1B({\'1C-1D\':\'-\'+(h*Y)+\'1E\'})};5(a.m)f.o(\'9-3-1o\');x f.o(\'9-3-1G\').1g(7(){$(4).3(\'1n\');$(4).3(\'D\')}).1i(7(){$(4).3(\'u\');$(4).3(\'C\')}).1l(7(){$(4).3(\'r\')});5(4.L)a.p=f;l.1q();l.1N(7(){$(4).3(\'r\')});f.6(\'3.l\',l.6(\'3.9\',f));a.F[a.F.Q]=f[0];a.v[a.v.Q]=l[0];a.q=d[b]=e;a.1O=c;l.6(\'3\',a);e.6(\'3\',a);f.6(\'3\',a);c.6(\'3\',d)});$(\'.3-15-T-17\').3(\'u\').G(\'3-15-T-17\');k 4};$.12($.n.3,{K:0,D:7(){8 a=4.6(\'3\');5(!a)k 4;5(!a.D)k 4;8 b=$(4).6(\'3.l\')||$(4.U==\'13\'?4:s);5(a.D)a.D.y(b[0],[b.M(),$(\'a\',b.6(\'3.9\'))[0]])},C:7(){8 a=4.6(\'3\');5(!a)k 4;5(!a.C)k 4;8 b=$(4).6(\'3.l\')||$(4.U==\'13\'?4:s);5(a.C)a.C.y(b[0],[b.M(),$(\'a\',b.6(\'3.9\'))[0]])},1n:7(){8 a=4.6(\'3\');5(!a)k 4;5(a.m)k;4.3(\'O\');4.1a().19().X(\'.q-\'+a.w).o(\'9-3-N\')},O:7(){8 a=4.6(\'3\');5(!a)k 4;5(a.m)k;a.q.1V().X(\'.q-\'+a.w).G(\'9-3-1k\').G(\'9-3-N\')},u:7(){8 a=4.6(\'3\');5(!a)k 4;4.3(\'O\');5(a.p){a.p.6(\'3.l\').S(\'L\',\'L\');a.p.1a().19().X(\'.q-\'+a.w).o(\'9-3-1k\')}x $(a.v).1m(\'L\');a.E[a.m||a.1Y?\'1q\':\'1Z\']();4.20()[a.m?\'o\':\'G\'](\'9-3-1o\')},r:7(a,b){8 c=4.6(\'3\');5(!c)k 4;5(c.m)k;c.p=s;5(A a!=\'B\'){5(A a==\'1u\')k $(c.F[a]).3(\'r\',B,b);5(A a==\'1h\')$.W(c.F,7(){5($(4).6(\'3.l\').M()==a)$(4).3(\'r\',B,b)})}x c.p=4[0].U==\'13\'?4.6(\'3.9\'):(4.22(\'.q-\'+c.w)?4:s);4.6(\'3\',c);4.3(\'u\');8 d=$(c.p?c.p.6(\'3.l\'):s);5((b||b==B)&&c.1e)c.1e.y(d[0],[d.M(),$(\'a\',c.p)[0]])},m:7(a,b){8 c=4.6(\'3\');5(!c)k 4;c.m=a||a==B?H:J;5(b)$(c.v).S("R","R");x $(c.v).1m("R");4.6(\'3\',c);4.3(\'u\')},1x:7(){4.3(\'m\',H,H)},24:7(){4.3(\'m\',J,J)}});$.n.3.1s={E:\'25 26\',1d:\'\',t:0,1w:16};$(7(){$(\'l[27=28].9\').3()})})(1j);',62,135,'|||rating|this|if|data|function|var|star|||||||||||return|input|readOnly|fn|addClass|current|rater|select|null|split|draw|inputs|serial|else|apply|count|typeof|undefined|blur|focus|cancel|stars|removeClass|true|arguments|false|calls|checked|val|hover|drain|div|length|disabled|attr|be|tagName|class|each|filter|spw|_|width|id|extend|INPUT|title|to||drawn|call|andSelf|prevAll|metadata|append|cancelValue|callback|applied|mouseover|string|mouseout|jQuery|on|click|removeAttr|fill|readonly|value|hide|className|options|document|number|replace|starWidth|disable|Math|floor|find|css|margin|left|px|half|live|execCommand|try|msie|BackgroundImageCache|browser|catch|change|context|before|control|span|meta|makeArray|slice|children|body|form|required|show|siblings|unnamed|is|name|enable|Cancel|Rating|type|radio|window|not'.split('|'),0,{}))

;eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(4($){7 n=\'2.26\';7 q=$.1s.1t&&/2s 6.0/.2t(2u.2v);4 U(){3(1u.1v&&1u.1v.U)1u.1v.U(\'[A] \'+2w.2x.2y.2z(2A,\'\'))};$.D.A=4(m){x 8.V(4(){3(m===2B||m===u)m={};3(m.1w==1W){2C(m){1x\'2D\':3(8.B)12(8.B);8.B=0;$(8).19(\'A.1y\',\'\');x;1x\'1z\':8.P=1;x;1x\'2E\':8.P=0;x;2F:m={W:m}}}I 3(m.1w==2G){7 c=m;m=$(8).19(\'A.1y\');3(!m){U(\'2H 1a 2I, 2J 1a 1b 1X\');x}3(c<0||c>=m.1A.9){U(\'2K 1X 1Y: \'+c);x}m.r=c;3(8.B){12(8.B);8.B=0}Q(m.1A,m,1,c>=m.J);x}3(8.B)12(8.B);8.B=0;8.P=0;7 d=$(8);7 e=m.1B?$(m.1B,8):d.2L();7 f=e.2M();3(f.9<2){U(\'2N; 2O 2P 2Q: \'+f.9);x}7 g=$.2R({},$.D.A.1Z,m||{},$.20?d.20():$.2S?d.19():{});3(g.1C)g.1D=g.1E||f.9;d.19(\'A.1y\',g);g.1c=8;g.1A=f;g.L=g.L?[g.L]:[];g.M=g.M?[g.M]:[];g.M.2T(4(){g.1F=0});3(g.Y)g.M.13(4(){Q(f,g,0,!g.Z)});3(q&&g.1d&&!g.21)1G(e);7 h=8.2U;g.C=1e((h.1f(/w:(\\d+)/)||[])[1])||g.C;g.y=1e((h.1f(/h:(\\d+)/)||[])[1])||g.y;g.E=1e((h.1f(/t:(\\d+)/)||[])[1])||g.E;3(d.G(\'1g\')==\'2V\')d.G(\'1g\',\'2W\');3(g.C)d.C(g.C);3(g.y&&g.y!=\'1h\')d.y(g.y);3(g.R){g.S=[];22(7 i=0;i<f.9;i++)g.S.13(i);g.S.2X(4(a,b){x 2Y.R()-0.5});g.F=0;g.N=g.S[0]}I 3(g.N>=f.9)g.N=0;7 j=g.N||0;e.G({1g:\'23\',2Z:0,30:0}).31().V(4(i){7 z=j?i>=j?f.9-(i-j):j-i:f.9-i;$(8).G(\'z-1Y\',z)});$(f[j]).G(\'14\',1).24();3($.1s.1t)f[j].25.27(\'1H\');3(g.O&&g.C)e.C(g.C);3(g.O&&g.y&&g.y!=\'1h\')e.y(g.y);3(g.1z)d.32(4(){8.P=1},4(){8.P=0});7 k=$.D.A.28[g.W];3($.29(k))k(d,e,g);I 3(g.W!=\'1I\')U(\'33 34: \'+g.W);e.V(4(){7 a=$(8);8.2a=(g.O&&g.y)?g.y:a.y();8.2b=(g.O&&g.C)?g.C:a.C()});g.X=g.X||{};g.15=g.15||{};g.17=g.17||{};e.1a(\':1J(\'+j+\')\').G(g.X);3(g.2c)$(e[j]).G(g.2c);3(g.E){3(g.K.1w==1W)g.K={35:36,37:38}[g.K]||39;3(!g.1i)g.K=g.K/2;3a((g.E-g.K)<3b)g.E+=g.K}3(g.1K)g.1L=g.1M=g.1K;3(!g.1j)g.1j=g.K;3(!g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.X);7 g=e?1:c.1j;7 h=e?1:c.1k;7 i=e?u:c.1L;7 j=e?u:c.1M;7 k=4(){$n.2q(c.15,g,i,d)};f.2q(c.17,h,j,4(){3(c.1r)f.G(c.1r);3(!c.1i)k()});3(c.1i)k()};$.D.A.28={2r:4(a,b,c){b.1a(\':1J(\'+c.N+\')\').G(\'14\',0);c.L.13(4(){$(8).24()});c.15={14:1};c.17={14:0};c.X={14:0};c.1r={3s:\'3t\'}}};$.D.A.3u=4(){x n};$.D.A.1Z={W:\'2r\',E:3v,Y:0,K:3w,1j:u,1k:u,H:u,1O:u,1p:u,T:u,1V:u,2m:\'18\',1U:u,L:u,M:u,1R:u,1K:u,1L:u,1M:u,3x:u,15:u,17:u,X:u,1r:u,1S:u,y:\'1h\',N:0,1i:1,R:0,O:0,1z:0,1C:0,1E:0,2j:0,1B:u,1d:0,1n:0,2k:0}})(3y);',62,221,'|||if|function|||var|this|length||||||||||||||||||nextSlide|||null|||return|height||cycle|cycleTimeout|width|fn|timeout|randomIndex|css|next|else|currSlide|speed|before|after|startingSlide|fit|cyclePause|go|random|randomMap|pager|log|each|fx|cssBefore|continuous|rev||curr|clearTimeout|push|opacity|animIn||animOut|click|data|not|advance|container|cleartype|parseInt|match|position|auto|sync|speedIn|speedOut|apply|typeof|nowrap|false|prevNextClick|hex|cssAfter|browser|msie|window|console|constructor|case|opts|pause|elements|slideExpr|autostop|countdown|autostopCount|busy|clearTypeFix|filter|custom|eq|easing|easeIn|easeOut|bind|prev|createPagerAnchor|setTimeout|end|fxFn|updateActivePagerLink|pagerAnchorBuilder|pagerClick|String|slide|index|defaults|metadata|cleartypeNoBg|for|absolute|show|style||removeAttribute|transitions|isFunction|cycleH|cycleW|cssFirst|slideCount|true|buildPager|els|appendTo|onAddSlide|delay|fastOnEvent|activeSlide|pagerEvent|getBg|background|color|animate|fade|MSIE|test|navigator|userAgent|Array|prototype|join|call|arguments|undefined|switch|stop|resume|default|Number|options|found|can|invalid|children|get|terminating|too|few|slides|extend|meta|unshift|className|static|relative|sort|Math|top|left|hide|hover|unknown|transition|slow|600|fast|200|400|while|250|addSlide|find|removeClass|addClass|href|parents|body|toString|nodeName|toLowerCase|html|parentNode|indexOf|rgb|transparent|ffffff|display|none|ver|4000|1000|shuffle|jQuery'.split('|'),0,{}));

(function($) {
	$('a[data-reveal-id]').live('click', function(e) {
		e.preventDefault();
		var modalLocation = $(this).attr('data-reveal-id');
		$('#'+modalLocation).reveal($(this).data());
	});

    $.fn.reveal = function(options) {
        var defaults = {  
	    	animation: 'fadeAndPop', 
		    animationspeed: 300,
		    closeonbackgroundclick: true, 
		    dismissmodalclass: 'close-reveal-modal'
    	}; 
    	
        var options = $.extend({}, defaults, options); 
	
        return this.each(function() {
        	var modal = $(this),
        		topMeasure  = parseInt(modal.css('top')),
				topOffset = modal.height() + topMeasure,
          		locked = false,
				modalBG = $('.reveal-modal-bg');
			if(modalBG.length == 0) {
				modalBG = $('<div class="reveal-modal-bg" title="点击关闭" />').css("opacity" , 0.6).insertAfter(modal);
			}		    
    		openModal();
			
			var closeButton = $('.' + options.dismissmodalclass).bind('click.modalEvent',closeModal)
			if(options.closeonbackgroundclick) {
				modalBG.css({"cursor":"pointer"})
				modalBG.bind('click.modalEvent',closeModal)
			}
			function openModal() {
				modalBG.unbind('click.modalEvent');
				$('.' + options.dismissmodalclass).unbind('click.modalEvent');
				if(!locked) {
					lockModal();
					if(options.animation == "fadeAndPop") {
						modal.css({'top': $(document).scrollTop()-topOffset, 'opacity' : 0, 'visibility' : 'visible'});
						modalBG.fadeIn(options.animationspeed/2);
						modal.delay(options.animationspeed/2).animate({
							"top": $(document).scrollTop()+topMeasure,
							"opacity" : 1
						}, options.animationspeed,unlockModal());
					}
					if(options.animation == "fade") {
						modal.css({'opacity' : 0, 'visibility' : 'visible', 'top': $(document).scrollTop()+topMeasure});
						modalBG.fadeIn(options.animationspeed/2);
						modal.delay(options.animationspeed/2).animate({
							"opacity" : 1
						}, options.animationspeed,unlockModal());					
					} 
					if(options.animation == "none") {
						modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure});
						modalBG.css({"display":"block"});	
						unlockModal()				
					}   
				}
			}    	
			
			function closeModal() {
				if(!locked) {
					lockModal();
					if(options.animation == "fadeAndPop") {
						modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
						modal.animate({
							"top":  $(document).scrollTop()-topOffset,
							"opacity" : 0
						}, options.animationspeed/2, function() {
							modal.css({'top':topMeasure, 'opacity' : 1, 'visibility' : 'hidden'});
							unlockModal();
						});					
					}  	
					if(options.animation == "fade") {
						modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
						modal.animate({
							"opacity" : 0
						}, options.animationspeed, function() {
							modal.css({'opacity' : 1, 'visibility' : 'hidden', 'top' : topMeasure});
							unlockModal();
						});					
					}  	
					if(options.animation == "none") {
						modal.css({'visibility' : 'hidden', 'top' : topMeasure});
						modalBG.css({'display' : 'none'});	
					}   			
				}
			}
			
			function unlockModal() { 
				locked = false;
			}
			function lockModal() {
				locked = true;
			}	
			
        });
    }
})(jQuery);
        

