﻿var _flashid,_gametitle;
var flash,html;
var userboxhtm = '';
var yadd=0;
$(document).ready(function() {
	var pageid = $('body').attr("pageid");
	if($('#ht').length>0){
		var cookie0 = $.cookie("mylist");
				var j = 0;
				if(cookie0!=null&&cookie0!=''){
				html="";
				var flashlist = cookie0.split('[flash|flash]');
				for(var i=flashlist.length-2;i>=0;i--){
					j++;
					if(j<=5){
					flash = flashlist[i].split('[tit|id]');
					html+='<li><a href="/game/flash/'+flash[1]+'">'+flash[0]+'</a></li>';}
					}
				$("#ht").append(html);
				};
	}
	if($('#seachbox').length>0&&pageid!="play"){
		if($('#loading0').length<=0){
			$('#seachbox').after('<div id="loading0" style="display:none"></div>');
		}
		$("#loading0").load('/htmldate/tags.htm',function(){topMenu();});
	}
	$('#soubox').find('form').submit(function(){
											  window.location='/htmlDate/Games.htm?k='+encodeURIComponent($('#soubox').find('input[type="text"]').val());
											  return false;
											  })
	$('#soubox').find('input[type="button"]').click(function(){
															 $('#soubox').find('form').submit();
															 });
	$("#bigclass li").hover(function() {
		$(this).addClass("newhang");
	}, function() {
		$(this).removeClass("newhang");
	});
});

function topMenu(){
	userboxhtm = $('#user_box').html();
	$("#seachbox").append('<div id="mtagsbox" style="display:none"> <span class="boxleft"></span><ul id="tagsmenu"></ul><div class="zbox"></div><span class="boxright"></span></div>');
	$("#smclass").find("a").mouseover(function(){
		var cid = $(this).attr("cid");
		if(cid>0){
			$('#user_box').empty();
			var w = $(window).width();
			$(".sel").removeClass("sel");
			$("#mtagsbox").css("left",(w-965)/2);
			$("#mtagsbox").show();
			$("#mtagsbox").find('.zbox').html(userboxhtm);
			$("#tagsmenu").html($("#mdata"+cid).html());
			$(document).bind("mousemove",function(event){
								var y =event.clientY;
								if(y>(298+yadd)){
									$("#mtagsbox").find('.zbox').empty();
									$('#user_box').html(userboxhtm);
									$("#mtagsbox").hide();
									$(document).unbind("mousemove");
									$(".sel").removeClass("sel");}
							});
			$(this).addClass("sel");
			}
		});
}

function getCookie(name){
	var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr!=null){
	   return unescape(arr[2]);
	   return null;
	}
}

function showFrame(u){
	$.getScript("/skins/default/js/jquery.flash.js",function(){
				$("body").append('<div id="flash_frame"></div>');
				$('#flash_frame').flash({'src':u,'width':'300','height':'240','wmode':'transparent'});
	});
}

function getGem(){
	var userid = getCookie("userid");
	if(userid>0){
		$.getScript('/u/do.asp?action=pickGem');
	}else{
		var q = confirm("捡起宝石需要登录。\n是否现在登录？"); 
		if (q !="0"){window.location='/login';}
	}
}

function showArea(e,obj){
	$(obj).addClass('show');
	yadd = 60;
	$(e).blur(function(){
		setTimeout(function(){
							$(obj).removeClass('show');
							yadd=0;
							},600);
	})
}
