﻿// JavaScript Document
var loginType = "";
var aActivityID = "";
var aTools = null;
function iARainbow()
{
	this.developer = "";
	this.skin = {images:"/iRainbow/images/",logo:"/iRainbow/images/"};
	this.tools = [];
	this.win = {width:750,height:420};
	this.flow = 1;
	this.cardInfo = {};
	this.SightID = "";
}
iARainbow.prototype = {
	init:function(){   //工具条初始化
		//this.skins();
		this.bindEvent();
		this.checkLogin();
	},
	skins:function(){
		var _this = this;
		var _html = '<div id="iRainbow_Tools"><img src="'+_this.skin.logo+'" width="128" height="30" /><ul id="iRainbowTools">';
		jQuery.each(_this.tools,function(index,tool){
			_html += '<li><a href="'+tool.url+'" title="'+tool.title+'" target="_blank">'+tool.title+'</a></li>';						 						 
		});
		//_html += '<li><a href="javascript:;" class="iRainbowFun" rel="shopping">年卡购买</a></li>'
		//_html += '<li><a href="javascript:;" class="iRainbowFun" rel="itinerary">游记攻略</a></li>';
		_html += '</ul><em>登录</em></div>';
		jQuery("body").prepend(_html);
	},
	bindEvent:function(){
		var _this = this;
		var _topF= insertFlash(_this.skin.images + "winTop.swf","iRainbowTF");
		var _leftF= insertFlash(_this.skin.images + "winLeft.swf","iRainbowLF");
		var _botF= insertFlash(_this.skin.images + "winBottom.swf","iRainbowBF");
		if(jQuery("#iRainbow_Win").html()==null)
		{
			var _win = '<div id="iRainbow_Win">\
				<div id="iRainbow_RoundTop"><span>'+_topF+'</span><ul><li class="current"><a href="javascript:;" id=\"iRainbowTitle\"></a></li></ul><em id="iRainbowClose"></em></div>\
				<div id="iRainbow_Mid"><div id="iRainbow_Left">'+_leftF+'</div><div id="iRainbow_Bg"><div id="iRainbow_Content">\
				</div></div><div id="iRainbow_Right">'+_leftF+'</div></div>\
				<div id="iRainbow_RoundBot">'+_botF+'</div>\
			</div>';
			jQuery("body").append(_win);
			jQuery("#iRainbowClose").click(function(){
				jQuery("#iRainbow_Win").animate({"top":"-500px"},500,'easeInOutExpo',function(){
											  
				});						   
			});
		}
		jQuery("#iRainbowLogin a").click(function(){
			var _fun = jQuery(this).attr("rel");
			var _position = _this.getPosition();
			var _scr = parseInt(_position.scrTop);
			var _left = parseInt(_position.offWidth-_this.win.width)/2;
			var _top = parseInt(_position.offHeight-_this.win.height)/2 + _scr;
			var _html = '';
			jQuery("#iRainbow_Win")
			.css({"left":_left + "px"})
			.animate({"top":_top + "px"},500,'easeInElastic',function(){
				switch(_fun){
				  case "reg":
				  	  jQuery("#iRainbowTitle").text("用户注册");
				  	  _html = '<div id="iRainbowLoginL"><h4 id="iRainMsg">马上注册 惊喜多多</h4>\
					  <span><label>用 户 名：</label><input id="txtLUserName" class="iRainbowTex" type="text" maxlength="15"/><em>*用户名只能由中文、英文和数字构成</em></span>\
					  <span><label>密　　码：</label><input id="txtLPassword" class="iRainbowTex" type="password" maxlength="16"/><em>*密码可以由6-16个任意字符组成</em></span>\
					  <span><label>确认密码：</label><input id="txtLPassword2" class="iRainbowTex" type="password" maxlength="16"/><em>*确认密码，有助于检测您输入的密码是否有误</em></span>\
					  <span><label>电子邮箱：</label><input id="txtLEmail" class="iRainbowTex" type="text" maxlength="50"/><em>*请确保邮箱有效，便于我们联系您</em></span>\
					  <span><h3>为方便兑奖时联系您，请填写以下信息！</h3></span>\
					  <span><label>真实姓名：</label><input id="txtLTrueName" class="iRainbowTex" type="text" maxlength="30"/><em>*请认真填写您的真实姓名，便于我们联系您</em></span>\
					  <span><label>手机号码：</label><input id="txtLMobile" class="iRainbowTex" type="text" maxlength="15" onkeypress="return event.keyCode>=48&&event.keyCode<=57||event.keyCode==46"/><em>*请确保您的手机号码有效</em></span><span><label>&nbsp;</label><button tabindex="100" value="true" id="regsubmit" type="submit"></button></span></div>';
					  _html += '<div id="iRainbowLoginR"><h4>已有账号？<a href="javascript:;" id="nowLogin">现在登录</a></h4></div>';
				  	  
					  jQuery("#iRainbow_Content").html(_html);
					  jQuery("#regsubmit")
					  .unbind()
					  .click(function(){_this.reg();});
					  jQuery("#nowLogin")
					  .unbind()
					  .click(function(){
						jQuery("#iRainbowLogin a:eq(1)").trigger("click");		  
						});
					  jQuery("#txtLUserName")
					  .unbind()
					  .blur(function(){_this.checkInfo("user",$(this).val())});
					  jQuery("#txtLEmail")
					  .unbind()
					  .blur(function(){_this.checkInfo("email",$(this).val())})
				  	  //_this.steps(3,"年卡信息登记")
					  break;
				  case "login":
				  	  jQuery("#iRainbowTitle").text("用户登录");
				  	  _html = '<div id="iRainbowLoginL"><h4  id="iRainMsg">登录</h4>\
					  <span><label>用户名：</label><input id="txtLUserName" class="iRainbowTex" style="width:200px;" type="text" maxlength="15"/><em></em></span>\
					  <span><label>密  码：</label><input id="txtLPassword" class="iRainbowTex" style="width:200px;"  type="password" maxlength="16"/><em></em></span>\
					  <span><label>&nbsp;</label><button tabindex="100" value="true" id="loginsubmit" type="submit" style="_margin-top:0px;_margin-left:0px;"></button></span></div>';
					  _html += '<div id="iRainbowLoginR"><h4>没有账号？<a href="javascript:;" id="nowReg">现在注册</a></h4></div>';
					  jQuery("#iRainbow_Content").html(_html);
				      
					  jQuery("#loginsubmit")
					  .unbind()
					  .click(function(){_this.login();});
					  jQuery("#nowReg")
					  .unbind()
					  .click(function(){
						jQuery("#iRainbowLogin a:eq(0)").trigger("click");		  
						});
				  	//_this.getTravels();
				  	break;
				  default:
					  break;
				}													  
																	  
			});								   
		});
	},
	reg:function(){
		var _this = this;
		var _username = $.trim($("#txtLUserName").val());
		var _password = $.trim($("#txtLPassword").val());
		var _password1 = $.trim($("#txtLPassword2").val());
		var _sex = "保密";//$("#iRainbowSex input:checked").val();
		var _email = $.trim($("#txtLEmail").val());
		var _truename = $.trim($("#txtLTrueName").val());
		var _mobile =  $.trim($("#txtLMobile").val());
		if (_username=="")
		{
			alert("请输入您的用户名：）");
			$("#txtLUserName").focus();
			return false;
		}
		if (_password=="")
		{
			alert("请输入您的密码：）");
			$("#txtLPassword").focus();
			return false;
		}
		if (_password1=="")
		{
			alert("请输入您的确认密码：）");
			$("#txtLPassword1").focus();
			return false;
		}
		else
		{
			if (_password!=_password1)
			{
				alert("密码和确认密码不一致：）");
				$("#txtLPassword").focus();
				return false;
			}
		}
		if (_email=="")
		{
			alert("请输入您的电子邮箱：）");
			$("#txtLEmail").focus();
			return false;
		}
		else
		{
			if (!isEmail(_email)) {
			  alert("您的电子邮箱格式错误！");
			  $("#txtLEmail").select();
			  return false;
			}
			else
			{
				this.checkInfo("email",_email);
			}
		}
		if (_mobile=="")
		{
			alert("请输入您的手机号码：）");
			$("#txtLMobile").select();
			return false;
		}
		else{
			if (!isMobile(_mobile)) {
				$("#txtLMobile").select();
				return false;
			}
    	}
		$("#regsubmit").attr("disabled","disabled");
		$.post("/bbs/ajaxUser.aspx?temp" + Math.random(),{Type:"reg",UserName:_username,Password:_password,Email:_email,Sex:_sex,TrueName:_truename,Mobile:_mobile},
		function(msg)
		{
			if(msg == "Ok")
			{
				jQuery("#iRainbow_Win").animate({"top":"-500px"},500,'easeInOutExpo',function(){
					document.cookie = "cdUserName=" + _username;
					$("#txtLUserName").val("");
					$("#txtLPassword").val("");
					$("#txtLPassword2").val("");
					$("#iRainbowSex input:eq(2)").attr("checked","checked");
					$("#regsubmit").attr("disabled","");
					$("#iRainbowLogin").html('<p>欢迎您！<strong>'+_username+'</strong>,</p><input type="button" id="iRLogout" value="退 出"/>');
					$("#iRLogout").click(function(){
						_this.Logout();						  
					});
					if (loginType=="saveC")
					{
						CheckUser();
					}
				});	
			}
			
		});
		
	},
	login:function(){
		var _this = this;
		var _username = $.trim($("#txtLUserName").val());
		var _password = $.trim($("#txtLPassword").val());
		if (_username=="")
		{
			alert("请输入您的用户名：）");
			$("#txtLUserName").focus();
			return false;
		}
		if (_password=="")
		{
			alert("请输入您的密码：）");
			$("#txtLPassword").focus();
			return false;
		}
		$.get("/bbs/ajaxUser.aspx?temp" + Math.random(),{Type:"userlogin",UserName:_username,Password:_password},
		function(msg)
		{
			if (msg=="Ok")
			{
				document.cookie = "cdUserName=" + _username;
				$("#iRainbowLogin").html('<p>欢迎您！<strong>'+_username+'</strong>,</p><input type="button" id="iRLogout" value="退 出"/>');
						$("#iRLogout").click(function(){
							_this.Logout();						  
						})
				jQuery("#iRainbow_Win").animate({"top":"-500px"},500,'easeInOutExpo',function(){
					$("#txtLUserName").val("");
					$("#txtLPassword").val("");
					$("#regsubmit").attr("disabled","");
				});
				if (loginType=="saveC")
				{
					CheckUser();
				}
			}
			else
			{
				$("#iRainMsg").text("用户名或者密码错误：）");
				deleteCookie("cdUserName");
				$("#txtLUserName").select();
				return false;
			}
		});
	},
	checkInfo:function(type,value){
		if (type == "user"&&value!="")
		{
			$.get("/bbs/ajaxUser.aspx?temp" + Math.random(),{Type:"checkUser",UserName:value},
			function(msg)
			{
				if (msg=="HaveUser"&&type=="user")
				{
					$("#iRainMsg").text("用户名已经存在：）");
					$("#txtLUserName").select();
					return false;
				}
				else
				{
					$("#iRainMsg").text("马上注册 惊喜多多");
				}
			})
		}
		else if (type == "email"&&value!="")
		{
			$.get("/bbs/ajaxUser.aspx?temp" + Math.random(),{Type:"checkEmail",Email:value},
			function(msg)
			{
				if (msg == "HaveEmail"&&type=="email")
				{
					$("#iRainMsg").text("邮箱已经注册：）");
					$("#txtLEmail").select();
					return false;
				}
				else
				{
					$("#iRainMsg").text("马上注册 惊喜多多");
				}
			})
		}
	},
	checkLogin:function(){
		var _this = this;
		$.get("/bbs/ajaxUser.aspx?temp" + Math.random(),{Type:"checklogin"},
			function(msg)
			{
				if(msg!="NoLog"&&msg.length>3)
				{
					msg = msg.split('|');
					if (msg.length>0)
					{
						document.cookie = "cdUserName=" + msg[1];
						$("#iRainbowLogin").html('<p>欢迎您！<strong>'+msg[1]+'</strong>,</p><input type="button" id="iRLogout" value="退 出"/>');
						$("#iRLogout").click(function(){
							_this.Logout();						  
						})
					}
				}
				else
				{
					deleteCookie("cdUserName");
				}
			});
	},
	Logout:function(){
		var _this = this;
		$.get("/bbs/ajaxUser.aspx?temp" + Math.random(),{Type:"logout"},
			function(msg)
			{
				if(msg=="Ok")
				{
					deleteCookie("cdUserName");
					$("#iRainbowLogin").html('<a id="btnReg" href="javascript:;"  rel="reg">注册</a><em>|</em>\
        <a id="btnLogin" href="javascript:;" rel="login">登录</a>');
					_this.bindEvent();
				}
			});
	},
	steps:function(step,title){
		var _this = this;
		var _menu = jQuery("#iRainbow_Menu ul li");
		var _tip = jQuery("#iRainbow_Tip2 h2");
		var _con = jQuery("#iRainbowIn");
		var _control = jQuery("#iRainbowCtl");
		var _next = jQuery("#iRainBtnN");
		_tip.text(title);
		var _html = "";
		_menu.removeClass("current1").parent().find("li:eq("+parseInt(step-1)+")").addClass("current1");
		switch(step){
			case 1:   //年卡类别选择
				_html = '<div id="iRainbowDdrT"><span>请选择年卡类型</span><ul><li><a href="javascript:;">单人行</a></li><li><a href="javascript:;">兑换卡</a></li></ul></div>'
				_con.html(_html);
				jQuery("#iRainbowDdrT").dropdown();
				_next
				.unbind()
				.click(function(){
					_this.cardInfo.type = jQuery("#iRainbowDdrT span").text();
					jQuery("#iRainbow_Content").slideUp("fast",function(){
						_this.flow = 2;
						_this.steps(_this.flow,"年卡须知");											  
					})
					
				});
				break;
			case 2:
				_html = '<p>年卡须知</p>';
				_con.html(_html);			
				jQuery("#iRainbow_Content").slideDown("fast",function(){
					_next
					.unbind()
					.click(function(){
						jQuery("#iRainbow_Content").slideUp("fast",function(){
							_this.flow = 3;
							_this.steps(_this.flow,"年卡信息登记");	
						});
					});				  
				});
				
				break;
			case 3:
				_html = '<div id="iRainbow_Crop"><img src="'+_this.skin.images+'flowers.jpg"></div>';
				_con.html(_html);			
				jQuery("#iRainbow_Content").slideDown("fast",function(){
					_next
					.unbind()
					.click(function(){
					});															  
				});
				break;
			default:
				break;
		}
	},
	getTravels:function(){
		_html = '<div id=\"iRainbow_Article\"><div id=\"iRainbow_Tip2\"><h2>游记攻略</h2></div><div id=\"iRainbow_List\">';
		for(var i=0;i<3;i++){
		_html += '<a href=\"#\" class=\"iRList\">';
		_html += '	<img src=\"http://img1.ipow.cn/remote/2009-4/i20094291242186484.jpg\" width=\"81px\" height=\"75px\">';
		_html += '	<div><span><h4>《北京欢乐谷一日游》</h4><em>浏览次数：2039</em></span><p>深圳市已启动编制民用建筑能耗定额标准，为实行超定额加价机制奠定基础。这意味着，今后居民住宅用电量超过一定标准，将被征收用电附加费。</p></div>';
		_html += '</a>'
		}
		_html += '</div>';
		_html += '<div id=\"iRainbow_Page\"><a href=\"#\" class=\"iRNext\"></a><a href=\"#\">5</a><a href=\"#\">4</a><a href=\"#\">3</a><a href=\"#\">2</a><span>1</span><a href=\"#\" class=\"iRPrev\"></a></div>'
		_html += '</div>';
		
		jQuery("#iRainbow_Content").html(_html);
	},
	getPosition:function(){
		var _position=[];
		_position.offWidth = document.documentElement.clientWidth;
		_position.offHeight = document.documentElement.clientHeight;
		var sPos,sLeft,_offsetLeft;
		if (typeof window.pageYOffset != 'undefined') {
			sPos = window.pageYOffset;
			sLeft = 0;
		}
		else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
			sPos = document.documentElement.scrollTop;
			sLeft = document.documentElement.scrollLeft;
		}
		else if (typeof document.body != 'undefined') {
			sPos = document.body.scrollTop;
			sLeft = document.body.scrollLeft;
		}
		if (_position.offWidth>1003)
			_offsetLeft = parseFloat(_position.offWidth - 1003)/2;
		else
			_offsetLeft = 0;
		_position.scrTop = sPos;
		_position.scrLeft = sLeft;
		_position.offsetLeft = _offsetLeft;
		return _position;	
	},
	GoWant:function(){
		//if (aActivityID!=undefined)
		{
			jQuery.getScript("http://sys.ipow.cn/IpowAPI/Client/Activity.ashx?Type=want&ActID="+aActivityID+"&CallBack=aTools.GetWants&temp" + Math.random(),function()
			{
			});
		}
	},
	GetWants:function(obj){
		if (obj.Type == "OK")
		{
			if($.browser.mozilla)
				thisMovie("iPowEyes1").GetWants(obj.Wants);
			else
				thisMovie("iPowEyes").GetWants(obj.Wants);
			
		}
		else
		{
			try
			{
			jQuery.getScript("http://sys.ipow.cn/IpowAPI/Client/Activity.ashx?Type=getwant&ActID="+aActivityID+"&CallBack=aTools.GetWants&temp" + Math.random());
			}
			catch(e){}
		}
	},
	GetActData:function(obj){
		if (obj.Type == "OK")
		{
			if($.browser.mozilla)
			{
				thisMovie("iPowEyes1").GetWants(obj.Wants);
				thisMovie("iPowEyes1").GetVisits(obj.Visits);
			}
			else
			{
				thisMovie("iPowEyes").GetWants(obj.Wants);
				thisMovie("iPowEyes").GetVisits(obj.Visits);
			}
			
		}
		else
		{
			try
			{
			jQuery.getScript("http://sys.ipow.cn/IpowAPI/Client/Activity.ashx?Type=getwant&ActID="+aActivityID+"&CallBack=aTools.GetActData&temp" + Math.random());
			}
			catch(e){}
		}
	},
	GoVisit:function(){
		try
		{
		jQuery.getScript("http://sys.ipow.cn/IpowAPI/Client/Activity.ashx?Type=visit&ActID="+aActivityID+"&CallBack=aTools.GetVisits&temp" + Math.random());
		}
		catch(e){}
	},
	GetVisits:function(obj){
		if (obj.Type == "OK")
		{
			if($.browser.mozilla)
				thisMovie("iPowEyes1").GetVisits(obj.Visits);
			else
			{
				thisMovie("iPowEyes").GetVisits(obj.Visits);
			}
		}
	}
}

//动画效果
jQuery.extend(jQuery.easing,
{
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	}
});

function insertFlash(ur,id){
	var fHtml = '';
	fHtml += '<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="'+id+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="100%" height="100%">';
	fHtml +='<param name="movie" value="'+ur+'">';
	fHtml +='<param name="quality" value="high"> ';
	fHtml +='<param name="wmode" value="transparent">';
	fHtml +='<param name="menu" value="false">';
	fHtml +='<embed src="'+ur+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="'+id+'" width="100%" height="100%" quality="High" wmode="transparent" style="overflow:hidden">';
	fHtml +='</embed>';
	fHtml +='</object>';
	return fHtml;
}
$.fn.dropdown=function(){
	return this.each(function() {
		var _self = this;
		var _span = $(_self).find("span");
		_span.click(function(){
			$(_self).find("ul").slideToggle("fast");
		});
		$(_self).find("ul li a").click(function(){
			var a_self = $(this);
			$(_self).find("ul").slideToggle("fast",function(){
				_span.text(a_self.text());												
			});							
		})
	});
}

jQuery.fn.GameComm = function(gsettings){
	gsettings = jQuery.extend({
		pagesize:5,
		cardid:2,
		cardname:""
  }, gsettings);
	return this.each(function(){
		var _selft = this;
		$("#btnSubmitComm")
		.unbind()
		.click(function(){
			saveComm();
		});
		$("#btnResetComm")
		.unbind()
		.click(function(){
			$("#txtCommContent").val("");
			$("#txtUserName").val("");	
		});
		var initComm = function(page){
			getCommList(page,gsettings.cardid)
		};
		var getCommList = function(page,cardid){
			var _html = "";
			$.getJSON("/webmanage/game/gamecomm.aspx?temp" + Math.random(),{Type:"GetList",PageSize:gsettings.pagesize,PageIndex:page,CardID:cardid},
		    function(ResultObj)
		   	{
				if (ResultObj.Type=="OK")
				{
				cPageUi(page,ResultObj.TotalPage);
				$.each(ResultObj.List,function(index,commjson){
					_html += '<li>\
                    	<img src="/activity/halloween/gahtm/images/tx.gif" width="58" height="63" />\
                        <span><h4>'+commjson.UserName+'</h4><em>'+commjson.AddTime+'</em></span>\
                        <p>'+commjson.Content+'</p>\
                    </li>';						   
				});
				$(_selft).html(_html);
				}
			});
		};
		var cPageUi = function(pcurrent,totalPages){
			var _pagehtml = UiPage(pcurrent,totalPages);
			$("#CommPageInfo").html(_pagehtml);
			$("#CommPageInfo a").unbind();
			$("#CommPageInfo a").click(function(){
				var aText = $(this).text();
				var pagecurrent = pcurrent;
				switch (aText)
				{
					case "上一页":
						pagecurrent = parseInt(pagecurrent-1);
						initComm(pagecurrent);
						break;
					case "下一页":
						pagecurrent = parseInt(pagecurrent+1);
						initComm(pagecurrent);
						break;
					default:
						initComm(parseInt($(this).text()));
						break;
				}		 					 
			})
		};
		var saveComm = function(){
			var _username = $("#txtUserName").val();
			_username = _username.replace(/　/g,"");
			var _content = $("#txtCommContent").val();
			_content = _content.replace(/　/g,"");
			var _sex = $("#rPSex input:checked").val();
			if (_username=="")
			{
				alert("请输入您的用户名：）");
				$("#txtUserName").focus();
				return false;
			}
			if (_content=="")
			{
				alert("请输入您的评论内容：）");
				$("#txtCommContent").focus();
				return false;
			}
			else
			{
				if (_content.length<5)
				{
					alert("评论内容至少五个字：）");
					$("#txtCommContent").focus();
					return false;
				}
			}
			$("#AddCommCon").slideUp("slow",function(){
				var _this = this;
				$.getJSON("/webmanage/game/gamecomm.aspx?temp" + Math.random(),{Type:"AddComm",CardID:gsettings.cardid,Content:_content,UserName:_username,Sex:_sex},
				function(msg)
				{
					$("#txtCommContent").val("");
					$("#txtUserName").val("");
					$(_this).show();
					initComm(1);
				});
			});
		}
		
		initComm(1);
	});
}

//格式化时间
function initDate(value)
{
	  var commDate = eval(value);
	  commDate = commDate.toLocaleDateString() + " " + commDate.toLocaleTimeString()
	  return commDate;
}

//分页UI
function UiPage(pcurrent,totalPages){
  var _pagehtml = "";
  if (pcurrent < 1)
  {
	  pcurrent = 1;
  }
  if (pcurrent > totalPages)
  {
	  pcurrent = totalPages;
  }
  if (pcurrent <= 1)
  {
  }
  else
  {
	  _pagehtml = '<a href="javascript:;" class="prev" id="turnPrev">上一页</a>' + _pagehtml;
  }
  var i;
  if (pcurrent <= 10 && totalPages <= 10)
  {
	  for (i = 1; i <= totalPages; i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml = "    <b>" + i + "</b>" + _pagehtml;
		  }
		  else
		  {
			  _pagehtml = '<a href="javascript:;" id="bookpage'+i+'">' + i + '</a>' + _pagehtml;
		  }
	  }
  }
  else if (totalPages >= 10 && pcurrent <= 5)
  {
	  for (i = 1; i <= 10; i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml = "    <b>" + i + "</b>" + _pagehtml;
		  }
		  else
		  {
			  _pagehtml = '<a href="javascript:;" id="bookpage'+i+'">' + i + ' </a>' + _pagehtml;
		  }
	  }
  }
  else if ((pcurrent + 5) <= totalPages)
  {
	  for (i = (pcurrent - 4); i <= (pcurrent + 5); i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml = "    <b>" + i + "</b>" + _pagehtml;
		  }
		  else
		  {
			  _pagehtml = '<a href="javascript:;" id="bookpage'+i+'">' + i + ' </a>' + _pagehtml;
		  }
	  }
  }
  else
  {
	  for (i = (pcurrent - 4); i <= totalPages; i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml = "    <b>" + i + "</b>" + _pagehtml;
		  }
		  else
		  {
			  _pagehtml = '<a href="javascript:;" id="bookpage'+i+'">' + i + ' </a>' + _pagehtml;
		  }
	  }	
  }
  if (pcurrent >= totalPages)
  {
  }
  else
  {
	  _pagehtml = '<a href="javascript:;" class="next" id="turnNext">下一页</a>'+ _pagehtml;
  }
  return _pagehtml;
}
//校验邮箱
function isEmail(s){
    var patrn = /^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/;
    if (!patrn.exec(s)) {
        return false;
    }
    return true;
}

//校验手机号码：必须以数字开头，除数字外，可含有“-”
function isMobile(mobile){
    if (mobile.length == 0) {
        alert('请输入手机号码！');
        return false;
    }
    if (mobile.length != 11) {
        alert('请输入有效的手机号码！');
        return false;
    }
    
    var myreg = /^(((13[0-9]{1})|159|153|158|150|189)+\d{8})$/;
    if (!myreg.test(mobile)) {
        alert('请输入有效的手机号码！');
        return false;
    }
    return true;
    
}

function get_cookie(cookiename){
    var CookieValue = "";
    //获取cookie字符串
    var strCookie = document.cookie;
    if (strCookie != "") {
        //将多cookie切割为多个名/值对
        var arrCookie = strCookie.split("; ");
        //遍历cookie数组，处理每个cookie对
        for (var i = 0; i < arrCookie.length; i++) {
            var arr = arrCookie[i].split("=");
            //找到对应名称的cookie，并返回它的值
            if (cookiename == arr[0]) {
                CookieValue = arr[1];
                break;
            }
        }
    }
    if (CookieValue != "undefined") 
        return CookieValue;
    else 
        return "";
}

//删除cookie
function deleteCookie(name){
    var date = new Date();
    date.setTime(date.getTime() - 10000);
    document.cookie = name + "=No; expire=" + date.toGMTString();
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}
function SaveCard(){
	thisMovie("GameFlash").saveC();
}
function CheckUser()
{
	var _username = get_cookie("cdUserName");
	if(_username=="No"||_username=="")
	{
		loginType = "saveC";
		jQuery("#iRainbowLogin a:eq(1)").trigger("click");
		return false;
	}
	else
	{
		SaveCard();
		return false;
	}
}

//快速导航
jQuery.fn.quickMenu = function(qro) {
	qro = jQuery.extend({
		index:0
	}, qro);
	return this.each(function(){
		var _dom = $(this);
		_dom.click(function(){
			_dom.find("span").fadeIn("500");
		});
		_dom.mouseleave(function(){
			_dom.find("span").fadeOut("500");


		});
		
	});
}

function actTools()
{
	aActivityID = jQuery("#aActivityID").val();
	$("#iRainQuick").quickMenu({});
	aTools.GoVisit();
	aTools.GetWants({Type:"Get"});
	var vIntime = setInterval(function(){aTools.GetActData({Type:"Get"});}, 10000);
}

jQuery(document).ready(function(){
	aTools = new iARainbow();
	aTools.init();
	actTools();
});

