﻿//====================================
//功能：页面框架
//日期：2009年8月11日
//====================================
function iPowUi()
{
	this.developer = "深圳市互动力科技有限公司（http://www.ipow.cn）";
}
iPowUi.prototype = {
	init:function(type){
		$("#itemContainer").codaSlider();
		//项目相关链接效果
		$('#itemInfo a')
		.css( {backgroundPosition: "0px -90px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:600})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-80px -90px)"}, {duration:300, complete:function(){
				$(this).css({backgroundPosition: "0px -90px"})
			}})
		})
		if (type==undefined)
			this.lRoll();
	},
	lRoll:function(){
		$("#cirPlayInfo").iRoll({
			btnNext: "#scrollRight",
			btnPrev: "#scrollLeft"
		});
	
	}
}
//左右图片滚动
$.fn.iRoll = function(parameters) {
    parameters = $.extend({
        btnPrev: null,
        btnNext: null,
        speed: 200,
        easing: null,
        visible: 6,
        start: 0,
        scroll: 1,
        beforeStart: null,
        afterEnd: null,
		width:109
    }, parameters || {});
    return this.each(function() {
        var running = false;
        var div = $(this),tSpan = $("#cirPlayInfo span"),tA = $("#cirPlayInfo a"), sL = parameters.visible;
		var itemLength = $("#cirPlayInfo").find("a").size(), curr = parameters.start;
        var divSize = parameters.width * parameters.visible,spanSize=parameters.width*itemLength;
		tSpan.css("width", spanSize+"px");
        div.css("width", divSize+"px");
		
		if(parameters.btnPrev)
            $(parameters.btnPrev).click(function() {
                return goRoll(curr-parameters.scroll);
            });
		if(parameters.btnNext)
            $(parameters.btnNext).click(function() {
                return goRoll(curr+parameters.scroll);
            });
		function vis() {
            return tA.slice(curr).slice(0,parameters.visible);
        };
		
		function goRoll(to) {
            if(!running) {
                if(parameters.beforeStart)
                    parameters.beforeStart.call(this, vis());
				if(to<0 || to>itemLength-parameters.visible) return;
				else curr = to;
                running = true;
                tSpan.animate(
                    { marginLeft: -(curr*parameters.width) }, parameters.speed, parameters.easing,
                    function() {
                        if(parameters.afterEnd)
                            parameters.afterEnd.call(this, vis());
                        running = false;
                    }
                );
				$(parameters.btnPrev).attr("class","btnPrev");
				$(parameters.btnNext).attr("class","btnNext");
				$(curr-parameters.scroll<0 && parameters.btnPrev).attr("class","btnPrevDis");
				$(curr+parameters.scroll > itemLength-parameters.visible && parameters.btnNext).attr("class","btnNextDis");
            }
            return false;
        };
    });
};
//主题活动上下滚动
$.fn.aRoll = function() {
    return this.each(function() {
        var running = false,height = 113;
        var div = $(this),tSpan = $("#activityList div"),tU = $("#activityList div ul"),tA = $("#activityList ul li"), sL = 3;
		var itemLength = $("#activityList ul li").size(), curr = 0;
        var divSize = height * 3,spanSize=height*itemLength;
		tSpan.css("height", divSize+"px");
        tU.css("height", spanSize+"px");
		$("#btnPrevA").click(function() {
			return goRoll(curr-1);
		});
		$("#btnNextA").click(function() {
			return goRoll(curr+1);
		});
		function vis() {
            return tA.slice(curr).slice(0,3);
        };
		function goRoll(to) {
            if(!running) {
				if(to<0 || to>parseInt(itemLength-3)) return;
				else curr = to;
                running = true;
                tU.animate(
                    { marginTop: -parseInt(curr*113) }, 750, "easeInOutExpo",function() {
                        running = false;
                    }
                );
            }
            return false;
        };
    });
};
//背景位置变化
$.extend($.fx.step,{
	backgroundPosition: function(fx) {
		if (fx.state === 0 && typeof fx.end == 'string') {
			var start = $.curCSS(fx.elem,'backgroundPosition');
			start = toArray(start);
			fx.start = [start[0],start[2]];
			var end = toArray(fx.end);
			fx.end = [end[0],end[2]];
			fx.unit = [end[1],end[3]];
		}
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
		try
		{
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
		}
		catch(e){
		}
	   function toArray(strg){
		   strg = strg.replace(/left|top/g,'0px');
		   strg = strg.replace(/right|bottom/g,'100%');
		   strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		   var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		   return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	   }
	}
});
//导航
jQuery.fn.navMenu = function(pro) {
	pro = jQuery.extend({
		index:0
	}, pro);
	return this.each(function(){
		var _dom = $(this);
		_dom.find("a").click(function(){
			$(this).blur();
		});
		_dom.find("li.main").hover(function(){
			_dom.find("li.main .sub").hide();
			$(this).find(".sub")
			.css("top",'0px')
			.show();
		},function(){
			$(this).find(".sub").hide();
			_current(pro.index);
		});
		_current(pro.index);
		function _current(index){
			_dom.find("li.main .sub").hide();
			if (_dom.find("li.main:eq("+index+") .sub").size() == 0)
			{
				_dom.find("li.main:eq("+index+") a").css("background-position","left -1px");
			}
			else
			{
				_dom.find("li.main:eq("+index+") .sub")
				.css("top",'0px')
				.show()
				.prev().css("background-position","left -1px");
			}
		}
	});
}
//新闻轮换
jQuery.fn.focusNews=function(parameters)
{
	parameters = jQuery.extend({
		time:6000						   
	},parameters);
	return this.each(function(){
		var $current = 0;
		var $local = $(this);
		var $count = $local.find("#newsFocusInfo a").size();
		var t = 0;
		var _init = function(){
			$("#newsFocusInfo a:not(:first-child)").hide();
			$("#newsFocusNum li:first-child").css({"background":"#74A8ED",'color':'#fff'});
			$("#newsFocusNum li").click(function() {
				var i = $(this).text() - 1;
				$current = i;
				if (i >= $count) return;
				$("#newsFocusInfo a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
				$(this).css({"background":"#74A8ED",'color':'#fff'}).siblings().css({"background":"#198E19",'color':'#fff'});
			});
			t = setInterval(function(){_showauto();}, parameters.time);
			$local.hover(function(){clearInterval(t)}, function(){t = setInterval(function(){_showauto();}, 4000);});
		}
		var _showauto = function()
		{
			$current = $current >= ($count - 1) ? 0 : ++$current;
			$("#newsFocusNum li").eq($current).trigger('click'); 
		}
		if ($count>1)
			_init();
	});
}
//内容切屏
jQuery.fn.codaSlider = function(settings) {
	 settings = jQuery.extend({
     easeFunc: "easeInOutExpo",
     easeTime: 750,
	 menu:"cirPlayInfo",   //菜单DOM
	 width:699,    //内容宽度
	 height:314
  }, settings);
	return this.each(function(){
		var container = $(this);
		var _menu = $("#" + settings.menu);
		var _cLength = container.find(".itemListInfo").size();
		var _listinfo = container.find(".itemListInfo");
		var _mLength = _menu.find("a").size();
		var containerWidth = settings.width*_mLength;
		container.css("width",containerWidth + "px");
		_menu.find("a").click(function(){
			$("#addCommInfo").hide();
			var _href = $(this).attr("href");
			if (_href==""||_href==undefined) return false ;
			var _itemid = parseInt($(this).attr("rel"));
			var _itemname = $(this).attr("title");
			var _index = $("#" + settings.menu +" span a").index($(this));
			var _marginLeft = settings.width*_index;
			container.animate({marginLeft:-_marginLeft + 'px'},500,"easeInOutExpo",function(){
				$("#loading").show();
				var cThis = this;
				_href = _href+"?temp="+Math.random;
				try
				{
					$.ajax({
						type: "GET",
						url: ""+_href+"?temp="+Math.random,
						success: function(msg){
							var patrn = /<body>([\s\S]*?)<\/body>/;
							_listinfo.html("");
							$(cThis).css("margin-top","0px");
							_listinfo.eq(_index).html(patrn.exec(msg)[1]);
							vertical(cThis);
							$("#commList").ItemComm({itemid:_itemid,itemname:_itemname});
							$("#loading").hide();
						}
					});
					
				}
				catch(e){}
			});	
		});
		_menu.find("a:first").trigger("click");
		var vertical = function(obj)
		{
			$("#itemInfo a").unbind("click")
			.click(function(){
				$("#addCommInfo").hide();
				var _aindex = $("#itemInfo a").index($(this));
				var _marginTop = settings.height*_aindex;
				$(obj).animate({marginTop:-_marginTop + 'px'},750,"easeInOutExpo");
			});
		}
	});
}
//竖向滚动条
jQuery.fn.Slider = function(ssettings){
	ssettings = jQuery.extend({
		scrollh:370,
		sliderh:55,
		height:445
  }, ssettings);
	return this.each(function(){
		var _self = this;
		var rtime,_marginTop=0;
		var _selfId = $(this).attr("id");
		var _height = document.getElementById("scrollC").scrollHeight > document.getElementById("scrollC").offsetHeight ? document.getElementById("scrollC").scrollHeight : document.getElementById("scrollC").offsetHeight;
		var _unit = parseFloat(parseInt(_height-ssettings.height)/parseInt(ssettings.scrollh-ssettings.sliderh));
		if (_height<=ssettings.height)
		{
			$(_self).hide();
			return false;
		}
		else
		{
			$(_self).show();
		}
		var _runH = ssettings.scrollh-ssettings.sliderh;
		var _runit = parseFloat(ssettings.height/(6*_unit));
		if($.browser.msie){document.execCommand("BackgroundImageCache", false, true);}
		$("#scrSlide").bind("mousedown",function(e){
			var selef = this;
			$(selef).css("background","url(../images/newsInsidebut.jpg) -19px top no-repeat");
			var pageY = e.pageY,mt = parseInt($(this).css("margin-top"));
			$(document).mousemove(function(e2){
				_marginTop = parseInt(mt + e2.pageY - pageY);
				setData();
			});
			$(document).mouseup(function(){
				$(selef).css("background","url(../images/newsInsidebut.jpg) left top no-repeat");
				$(document).unbind();
			});
			return false;
		});
		$("#scrollUp").bind("mousedown",function(e){   //up
			var self = this;
			var mt = parseInt($("#scrSlide").css("margin-top"));
			$(self).css("background","url(../images/scrollBG.jpg) -34px top no-repeat");
			_self.timeSetT("up");
			$(document).mouseup(function(){
				$(self).css("background","url(../images/scrollBG.jpg) left top no-repeat")
				$(document).unbind();
				clearTimeout(rtime);
			});
			return false;
		});
		$("#scrollDown").bind("mousedown",function(e){   //down
			var self = this;
			$(self).css("background","url(../images/scrollBG.jpg) -34px -16px no-repeat");
			var mt = parseInt($("#scrSlide").css("margin-top"));
			_self.timeSetT("down");
			$(document).mouseup(function(){
				$(self).css("background","url(../images/scrollBG.jpg) left -16px no-repeat");
				$(document).unbind();
				clearTimeout(rtime);
			});
			return false;
		});
		_self.timeSetT = function(vector){
			var self=this;
			if(vector=="up")
			{
				_marginTop-=_runit;
			}
			else
			{
				_marginTop+=_runit;
			}
			setData();
			rtime = setTimeout(function(){self.timeSetT(vector);},500);
		}
		function setData(){
			if (_marginTop<_runH && _marginTop>0)
				_marginTop = _marginTop;
			else if (_marginTop>_runH)
				_marginTop = _runH;
			else if(_marginTop<0)
				_marginTop = 0;
			$("#scrSlide").css("margin-top",""+_marginTop+"px");
			var _scrollCH = parseInt(_unit*_marginTop);
			$("#scrollC").css("margin-top","-"+_scrollCH+"px");
		}
		$("#scrollC").mousewheel(function(){
			if(this.D>0)
			{
				_marginTop-=_runit;
			}
			else
			{
				_marginTop+=_runit;
			};
			setData();
		});
	})
}
//动画效果
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;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	}
});
//====================================
//功能：获取对象位置信息
//日期：2009年8月11日
//参数：Document对象
//====================================
function getAllPosition(obj){
	var displayPosition=[];
	if (obj!=undefined)
	{
		var objPosition = $(obj).offset();
		displayPosition.offLeft=objPosition.left;
		displayPosition.offTop = objPosition.top;
	}
	displayPosition.offWidth = document.documentElement.clientWidth;
	displayPosition.offHeight = document.documentElement.clientHeight;
	var scrollPos,scrollLeft,_offsetLeft;
	if (typeof window.pageYOffset != 'undefined') {
		scrollPos = window.pageYOffset;
		scrollLeft = 0;
	}
	else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
		scrollPos = document.documentElement.scrollTop;
		scrollLeft = document.documentElement.scrollLeft;
		
	}
	else if (typeof document.body != 'undefined') {
		scrollPos = document.body.scrollTop;
		scrollLeft = document.body.scrollLeft;
	}
	if (displayPosition.offWidth>1003)
		_offsetLeft = parseFloat(displayPosition.offWidth - 1003)/2;
	else
		_offsetLeft = 0;
	displayPosition.scrTop = scrollPos;
	displayPosition.scrLeft = scrollLeft;
	displayPosition.offsetLeft = _offsetLeft;
	return displayPosition;
}
//使链接无效
function doVain(event) {
	e = event ? event : window.event;
	try
	{
		if($.browser.msie) {
			e.returnValue = false;
			e.cancelBubble = true;
		} else if(e) {
			e.stopPropagation();
			e.preventDefault();
		}
	}
	catch(e){
	}
}

//插入FLASH
function insertFlash(ur,w,h,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="'+w+'" height="'+h+'">';
	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="'+w+'" height="'+h+'" quality="High" wmode="transparent" style="overflow:hidden">';
	fHtml +='</embed>';
	fHtml +='</object>';
	return fHtml;
}
//初始化FLASH，页面三个修饰过山车
function initFlash()
{
	_resizeFlash();
	$(window).resize(function(){
		_resizeFlash();
	});
	function _resizeFlash(){
		var _width = document.body.offsetWidth;
		if (_width>1010)
		{
			var fHtml1 = insertFlash("/flash/gsc.swf","100%","100%","rtGsc");
			var fHtml2 = insertFlash("/flash/gsc2.swf","100%","100%","rbGsc");
			var fHtml3 = insertFlash("/flash/gsc3.swf","100%","100%","lbGsc");
			$("#floatRightTop").css("width","190px");
			$("#floatRightBot").css("width","50px")
			$("#floatRightTop").html(fHtml1);
			$("#floatRightBot").html(fHtml2);
			$("#leftBottomFloat").html(fHtml3);
		}
		else
		{
			var fHtml1 = insertFlash("/flash/gsc.swf","190","140","rtGsc");
			var fHtml2 = insertFlash("/flash/gsc2.swf","50","196","rbGsc");
			$("#floatRightTop").css("width","176px");
			$("#floatRightBot").css("width","30px")
			$("#floatRightTop").html(fHtml1);
			$("#floatRightBot").html(fHtml2);
			$("#leftBottomFloat").html("");
		}	
	}
}
//项目评论
jQuery.fn.ItemComm = function(gsettings){
	gsettings = jQuery.extend({
		pagesize:6,
		itemid:2,
		itemname:""
  }, gsettings);
	return this.each(function(){
		var _self = this;
		var _layIndex = 999;
		var json = null;
		$("#btnAddCommInfo").click(function(){
			$("#addCommInfo").show();
			$("#commPanel").show();							   
			$("#closeAddComm").click(function(){
				$("#commPanel").hide();
				$("#addCommInfo").hide();				  
			});
			$("#btnReset")
			.unbind()
			.click(function(){
				$("#txtUserName").val("");
				$("#txtCommon").val("");
				$("#txtUserName").focus();
			});
			$("#btnSendComm")
			.unbind()
			.click(function(){
				var _username = $.trim($("#txtUserName").val());
				var _comm = $.trim($("#txtCommon").val());
				if (_username=="")
				{
					alert("请输入您的姓名:)");
					$("#txtUserName").focus();
					return false;
				}
				else if (_username.length>10)
				{
					alert("姓名长度不能超过10个字:)");
					$("#txtUserName").select();
					return false;
				}
				if (_comm=="")
				{
					alert("请输入评论内容:)");
					$("#txtCommon").focus();
					return false;
				}
				else if (_comm.length>50)
				{
					alert("评论内容长度不能超过50个字:)");
					$("#txtCommon").select();
					return false;
				}
				var objComm = {
        			UserName: _username,
        			Content: _comm,
        			Sex: '保密',
        			ItemsID: gsettings.itemid,
					ItemsName:gsettings.itemname
				};
    			objComm = JSON.stringify(objComm);
				var paramObj = {
					Comment: objComm,
					Type: "AddComm"
				};
				$.post("/WebManage/Book/ItemsCommAjax.aspx?Temp=" + Math.random(), paramObj, function(data){
        			if (data == "strture") {
						 $("#txtUserName").val("");
						 $("#txtCommon").val("");
						 $("#commPanel").hide();
						 $("#addCommInfo").hide();	
						 getFullHtml(1,gsettings.itemid);
					}
				});

			});
		});
		$(_self).html('<iframe id="ifCommList" name="ifCommList" frameBorder="0" width="100%" scrolling="no" height="263px"></iframe>');
		var initComm = function(page,itemid){
			getFullHtml(page,gsettings.itemid)
		};
		var getFullHtml = function(page,itemid) {
        	var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
        	html += '<html xmlns="http://www.w3.org/1999/xhtml">';
        	html += '<head>';
        	html += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
       		html += '<title>iPowComm</title>';
			html += '<link href="/style/glogbal.css" rel="stylesheet" type="text/css" />\
					 <link href="/style/master.css" rel="stylesheet" type="text/css" />\
					 <script type="text/javascript" src="/js/commList.js"></script>';
       	 	html += '</head>';
        	html += '<body class="comm-Content">';
			html += '<div id="frmCommList">';
			
			$.getJSON("/WebManage/Book/ItemsCommAjax.aspx?Type=GetComm&PageIndex="+page+"&ItemsID="+itemid+"&PageSize="+gsettings.pagesize+"&temp" + Math.random(),
		    function(ResultObj)
		   	{
				pageUi(page,ResultObj.TotalPage,itemid);
				var i = 0;
				$.map(ResultObj.CommList,function(commjson){
					var _top = (i%2)*100 + 10;//parseInt(Math.random()*(1-213+1) + 213);
					var _left = i*80 + 10 ;//parseInt(Math.random()*(0-513+1) + 513);
					var _zindex = parseInt(Math.random()*(10-50+1) + 50);
					html += '<span class="commlayer" onmousedown="Move(this,event)" style="left:'+_left+'px;top:'+_top+'px;z-index:'+commjson.CommkID+'"\
					id="comm'+commjson.CommkID.toString()+'"><h4>'+commjson.CommkID+'楼：</h4><p>'+commjson.Content+'</p><em style="text-align:left;">'+commjson.UserName+'</em><em>'+initDate(commjson.AddTime)+'</em></span>';				
					i++;
				});
				html +='</div>';
				html += '</body>';
        		html += '</html>';
        		var commFrame = document.getElementById("ifCommList").contentDocument || document.getElementById("ifCommList").contentWindow.document;
				commFrame.open();
				commFrame.write(html);
				commFrame.close();
				
		    })
    	};
		var pageUi = function(pcurrent,totalPages,itemid){
			var _pagehtml = UiPage(pcurrent,totalPages);
			$("#commPageC").html(_pagehtml);
			$("#commPageC a").unbind();
			$("#commPageC a").click(function(){
				var aText = $(this).text();
				var pagecurrent = pcurrent;
				switch (aText)
				{
					case "上一页":
						pagecurrent = parseInt(pagecurrent-1);
						getFullHtml(pagecurrent,itemid);
						break;
					case "下一页":
						pagecurrent = parseInt(pagecurrent+1);
						getFullHtml(pagecurrent,itemid);
						break;
					default:
						getFullHtml(parseInt($(this).text()),itemid);
						break;
				}		 					 
			})
		 }
		initComm(1,1);
	})
}
//分页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>';
  }
  var i;
  if (pcurrent <= 10 && totalPages <= 10)
  {
	  for (i = 1; i <= totalPages; i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml += "    <b>" + i + "</b>";
		  }
		  else
		  {
			  _pagehtml += '<a href="javascript:;" id="bookpage'+i+'">' + i + '</a>';
		  }
	  }
  }
  else if (totalPages >= 10 && pcurrent <= 5)
  {
	  for (i = 1; i <= 10; i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml += "    <b>" + i + "</b>";
		  }
		  else
		  {
			  _pagehtml += '<a href="javascript:;" id="bookpage'+i+'">' + i + ' </a>';
		  }
	  }
  }
  else if ((pcurrent + 5) <= totalPages)
  {
	  for (i = (pcurrent - 4); i <= (pcurrent + 5); i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml += "    <b>" + i + "</b>";
		  }
		  else
		  {
			  _pagehtml += '<a href="javascript:;" id="bookpage'+i+'">' + i + ' </a>';
		  }
	  }
  }
  else
  {
	  for (i = (pcurrent - 4); i <= totalPages; i++)
	  {
		  if (i == pcurrent)
		  {
			  _pagehtml += "    <b>" + i + "</b>";
		  }
		  else
		  {
			  _pagehtml += '<a href="javascript:;" id="bookpage'+i+'">' + i + ' </a>';
		  }
	  }	
  }
  if (pcurrent >= totalPages)
  {
  }
  else
  {
	  _pagehtml += '<a href="javascript:;" class="next" id="turnNext">下一页</a>';
  }
  return _pagehtml;
}
//格式化时间
function initDate(value)
{
	  var bookDate = value;
	  bookDate = bookDate.replace("/Date(", "");
	  bookDate = bookDate.replace("+0800)/", "");
	　 bookDate = new Date(parseInt(bookDate));
	  bookDate = bookDate.getFullYear() + "-" + (bookDate.getMonth() + 1) + "-" + bookDate.getDate()+"&nbsp;&nbsp;";//+bookDate.getHours()+":"+bookDate.getMinutes()+":"+bookDate.getSeconds();
	  return bookDate;
}
//游客留言
jQuery.fn.GuestBook = function(bsettings){
	bsettings = jQuery.extend({
		pagesize:5
  }, bsettings);
	return this.each(function(){
		var _self = this;	
		var _initBook = function(){
			$("#btnAddMesInfo").click(function(){
				$("#msgContainer").show();
				$("#addMesInfo").show();							
			});
			$("#closeAddGuest").click(function(){
				$("#addMesInfo").hide();
				$("#msgContainer").hide();								   
			});
			_getBookList(1);
			$("#btnAddGuestBook").click(function(){
				$(this).blur();
				var _username = $.trim($("#txtUserName").val());
				var _title = $.trim($("#txtTitle").val());
				var _phone = $.trim($("#txtPhone").val());
				var _email = $.trim($("#txtEmail").val());
				var _content = $.trim($("#txtContent").val());
				if (_username=="")
				{
					alert("请输入您的姓名:)");
					$("#txtUserName").focus();
					return false;
				}
				if (_title=="")
				{
					alert("请输入留言主题:)");
					$("#txtTitle").focus();
					return false;
				}
				if (_phone=="")
				{
					alert("请输入联系电话:)");
					$("#txtPhone").focus();
					return false;
				}
				if (_email=="")
				{
					alert("请输入电子邮箱:)");
					$("#txtEmail").focus();
					return false;
				}
				else {
					if (!isEmail(_email)) {
						alert("您的电子邮箱格式错误:)");
						$("#txtEmail").select();
						return false;
					}
				}
				if(_content=="")
				{
					alert("请输入留言内容:)");
					$("#txtContent").focus();
					return false;
				}
				var objbook = {
        			UserName: _username,
					Telephone:_phone,
					Email:_email,
					Title:_title,
        			Content: _content
				};
				objbook = JSON.stringify(objbook);






				var paramObj = {
					Comment: objbook,
					Type: "AddComm"
				};
				$("#msgContainer").slideUp("slow",function(){
					$.post("/WebManage/Common/CommAjax.aspx?Temp=" + Math.random(),paramObj,function(data){
						if (data == "strture") {
							 $("#addMesInfo").hide();
							 $("#msgContainer input").val("");		
							 $("#msgContainer textarea").val("");
							 _getBookList(1);
						}
					});								   
				});
			});
			$("#btnResetBook").click(function(){
				$(this).blur();	
				$("#msgContainer input").val("");		
				$("#msgContainer textarea").val("");
			});
		};
		var _getBookList = function(pagec){
			pagec = parseInt(pagec);
			var _html = '';
			$.getJSON("/WebManage/Common/CommAjax.aspx?Type=GetComm&PageIndex="+pagec+"&PageSize="+bsettings.pagesize+"&temp" + Math.random(),
		    function(ResultObj)
		   	{
				var iNo=0;
				var replayH = '';
				bPageUi(pagec,ResultObj.TotalPage);
				$.each(ResultObj.CommList,function(index,bookjson){
					_html += '<div class="GuestList"><h2>主题：'+bookjson.Title+'</h2>';
					if (bookjson.ReName!=undefined)
					{
						replayH = '<a href="javascript:;" rel="reply'+bookjson.BookID+'"></a>';
						_html += '<span class="reply" id="reply'+bookjson.BookID+'"><img src="/images/mesAdmin.jpg" width="53px" height="88px"/><h4><strong>成都欢乐谷</strong><em>回复于：'+bookjson.ReAddTime+'</em></h4><p>'+bookjson.ReContent+'</p></span>';
					}
					else
					{
						replayH='';
					}
					if(index%2==0)
					{
						_html += '<span class="bookinfo2" id="guestbook'+bookjson.BookID+'">';
						_html += '<img src="/images/yklyboy.gif" width="53px" height="88px"/>';
					}
					else
					{
						_html += '<span class="bookinfo" id="guestbook'+bookjson.BookID+'">';
						_html += '<img src="/images/yklygirl.gif" width="53px" height="88px"/>';
					}
					_html += '<h4><strong>'+bookjson.UserName+'</strong><em>发布于：'+bookjson.AddTime+'</em>'+replayH+'</h4><p>'+bookjson.Content+'</p></span></div>';
				});
				$(_self).html(_html);
				$("#newsslider").Slider({height:350,scrollh:300});
				_bindReplay();
			});
		};
		var bPageUi = function(pcurrent,totalPages){
			var _pagehtml = UiPage(pcurrent,totalPages);
			$("#bookPageInfo").html(_pagehtml);
			$("#bookPageInfo a").unbind();
			$("#bookPageInfo a").click(function(){
				var aText = $(this).text();
				var pagecurrent = pcurrent;
				switch (aText)
				{
					case "上一页":
						pagecurrent = parseInt(pagecurrent-1);
						_getBookList(pagecurrent);
						break;
					case "下一页":
						pagecurrent = parseInt(pagecurrent+1);
						_getBookList(pagecurrent);
						break;
					default:
						_getBookList(parseInt($(this).text()));
						break;
				}		 					 
			})
		}
		var _bindReplay = function(){
			$(_self).find(".GuestList a").bind("mouseenter",function(){
				var _replyObj = $(this).attr("rel");
				var _replyID = $("#"+_replyObj).attr("id");
				var _msgObj = $("#"+_replyObj).next();
				var _msgID = _msgObj.attr("id");
				var _height = document.getElementById(""+_msgID+"").scrollHeight > document.getElementById(""+_msgID+"").offsetHeight ? document.getElementById(""+_msgID+"").scrollHeight : document.getElementById(""+_msgID+"").offsetHeight;
				var _rheight = document.getElementById(""+_replyID+"").scrollHeight > document.getElementById(""+_replyID+"").offsetHeight ? document.getElementById(""+_replyID+"").scrollHeight : document.getElementById(""+_replyID+"").offsetHeight;
				if (_rheight>_height)
				{
					$(_msgObj).animate({height:_rheight + 'px'},200,function(){
						_changeM(_msgObj,_replyID,_height,_rheight);												 
					})
				}
				else
				{
					_changeM(_msgObj,_replyID,_height,_rheight);
				}
			})	
		}
		var _changeM = function(msgID,objID,height,rheight){
			if (rheight>height)
			{
				$("#"+objID).css("margin-bottom",-rheight+"px");
				$("#"+objID).unbind();
				$("#"+objID).bind("mouseleave",function(){
					$(this).animate({height:0 + 'px'},300,"easeOutCubic",function(){
						$(msgID).animate({"height":height+"px"},200);													  
					});					
				});
				$("#"+objID).animate({height:rheight + 'px'},300,"easeInCubic");	
			}
			else
			{
				$("#"+objID).css("margin-bottom",-height+"px");
				$("#"+objID).unbind();
				$("#"+objID).bind("mouseleave",function(){
					$(this).animate({height:0 + 'px'},300,"easeOutCubic");						
				});
				$("#"+objID).animate({height:height + 'px'},300,"easeInCubic");	
			}
			
		}
		_initBook();
	});
}
//回车切换
function transferFocus(){
    var keyCode = event.keyCode;
    if (keyCode == 13) 
        event.keyCode = 9;
}
//校验邮箱
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;
}
//获取COOKIE
function getCookie(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 "";
}

function onKeyPressBlockNumbers(e)
{
	var key = window.event ? e.keyCode:e.which;
	var keychar = String.fromCharCode(key);
	reg = /\d/;
	return reg.test(keychar);
}
//统计门票总价格
function StatPrice(value,p){
	//jQuery("#txtAdults"+_value).attr("disabled","");
	
	var _tickets = jQuery("#txtTicket" + value).val();
	if (CheckInt(_tickets))
	{
		var _all = _tickets*p;
		jQuery("#txtAdultPrice"+value).text(_all);
		jQuery("#txtAdultPrice"+value).attr("rel",jQuery("#txtAdultPrice"+value).text());
		iRTatal();
	}
}
function CheckInt(_value){
    if (!_isInt(_value)) {
        alert("票的张数错误，请输入正确的张数！");
        return false;
    }
    return true;
}
function _isInt(s){
    var pattern = /^-?\d+$/;
    if (s.search(pattern) != 0) {
        return false;
    }
    return true;
}
function iRTatal()
{
	var _total = 0;
	jQuery("#mptable em").each(function(){
		_total += parseInt(jQuery(this).attr("rel"));
	})
	if (_total>0)
		jQuery("#aNextB").show();
	else
		jQuery("#aNextB").hide();
	jQuery("#iRTotal").text(_total);
}
	function inputContent()
	{
		var v= $("#txtCardCon").val();
		if($.browser.mozilla)
		{
			thisMovie("HappyCard1").ViewCard(v);
		}
		else
			thisMovie("HappyCard").ViewCard(v);
	}
	function inputSendName()
	{
		var v= $("#txtReceiveName").val();
		if($.browser.mozilla)
		{
			thisMovie("HappyCard1").UserName(v);
		}
		else
			thisMovie("HappyCard").UserName(v);
	}
	function cardComplete()
	{
		var _happyCard = $("#HappyCardID").val();
		if (_happyCard>0)
		{
			$("#txtReceiveName")
			.attr("disabled","")
			.unbind()
			.click(function(){
				clearDefaultText(this,'请输入您姓名');				
			});
			$("#txtCardCon")
			.attr("disabled","")
			.unbind()
			.click(function(){
				clearDefaultText(this,'点击填入祝福语，最长80个汉字');		
			});
			if($.browser.mozilla)
			{
				document.getElementById('txtReceiveName').addEventListener("input",inputSendName,false);
			}
			else
				document.getElementById('txtReceiveName').attachEvent('onpropertychange',function(e){
			  inputSendName();
			});
			if($.browser.mozilla)
			{
				document.getElementById('txtCardCon').addEventListener("input",inputContent,false);
			}
			else
				document.getElementById('txtCardCon').attachEvent('onpropertychange',function(e){
			  inputContent();
			});
			$("#aSendCard")
			.unbind()
			.click(function(){
				var _email = $("#txtReceive").val();
				var _content = $("#txtCardCon").val().replace("点击填入祝福语，最长80个汉字","");
				var _sendname = $("#txtReceiveName").val().replace("请输入您姓名","");
				  if (_email=="")
				  {
					  alert("请输入接收人的电子邮箱：）");
					  $("#txtReceive").focus();
				  }
				  else
				  {
					  if (!isEmail(_email)) {
						  alert("您的电子邮箱格式错误:)");
						  $("#txtReceive").select();
						  return false;
					  }
				  }
				  if (_sendname=="")
				  {
					  alert("请输入您的姓名：）");
					  $("#txtReceiveName")
					  .val("")
					  .focus();
					  return false;
				  }
				  if (_content=="")
				  {
					  alert("请输入您的祝福语：）");
					  $("#txtCardCon")
					  .val("")
					  .select();
					  return false;
				  }
				  else
				  {
					  if (_content.length>80)
					  {
						  alert("您输入的祝福语超过80个字了：）");
						  $("#txtCardCon").focus();
						  return false;
					  }
				  }
				  $("#card_sending").show();
				  $.getJSON("/WebManage/Card/ReceiveMessage.aspx?SendName="+escape(_sendname)+"&Email="+escape(_email)+"&CardID="+_happyCard+"&Content="+escape(_content)+"&temp" + Math.random(),
				  function(ResultObj)
				  {
					  if (ResultObj.Type == "OK")
					  {
						  $("#card_sending").hide();
						  $("#txtReceive").val("请输入接收人邮箱");
						  $("#txtCardCon").val("");
						  $("#txtReceiveName").val("请输入您姓名");
						  alert("贺卡发送成功！谢谢使用:)");
					  }
				  });
				
			});
		}
		else
		{
	 	 	  var v= $("#HappyCardContent").val();
			  var vs=$("#CSendName").val();
			  if($.browser.mozilla)
			  {
				  thisMovie("HappyCard1").ViewCard(v);
				  thisMovie("HappyCard1").UserName(vs);
			  }
			  else
				  thisMovie("HappyCard").ViewCard(v);
				  thisMovie("HappyCard").UserName(vs);
			  }
	}
	
	function viewCard()
	{
		var _html = '';
		var _mesID = strUrlPara("id");
		if (!_isInt(_mesID)) {
        	localhost.href="http://cd.happyvalley.cn/share/heka_3.shtml";
        	return false;
    	}
		  $.getJSON("/WebManage/Card/CardAjax.aspx?MessageID="+_mesID+"&temp" + Math.random(),
		  function(ResultObj)
		  {
			  if (ResultObj.Type == "OK")
			  {
				  var _cardinfo = ResultObj.MessageInfo;
				  var _flashPath = ResultObj.CardInfo.flashpath;
				  _html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" \codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="100%" height="100%" id="HappyCard" name="HappyCard">\
              <param name="movie" value="'+_flashPath+'" />\
              <param name="quality" value="high" />\
              <param name="allowScriptAccess" value="sameDomain" />\
              <param name="wmode" value="transparent" />\
              <embed src="'+_flashPath+'" name="HappyCard" id="HappyCard1" quality="high" \pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100%" height="100%"\ wmode="transparent" allowscriptaccess="sameDomain" allowfullscreen="false"> </embed>\
        	</object>';
				  $("#scrollC").html(ResultObj.ListHtml);
				  $("#HappyCardContent").val(_cardinfo.hekaContent);
				  $("#CSendName").val(_cardinfo.hekaSendName);
				  document.getElementById("CardContainer").innerHTML = _html;
			  }
		  });
	}
	function thisMovie(movieName) {
	  if (navigator.appName.indexOf("Microsoft") != -1) {
		  return window[""+movieName+""];
	  } else {
		  return document[""+movieName+""];
	  }
	}

function clearDefaultText (el,message)
{
	var obj = el;
	if(typeof(el) == "string")
		obj = document.getElementById(id);
	if(obj.value == message)
	{
		obj.value = "";
	}
	obj.onblur = function()
	{
		if(obj.value == "")
		{
   			obj.value = message;
		}
	}
}

function strUrlPara(Para) 
{
	var _url = location.href + "&";	
	var regex = new RegExp("(\\?|\\&)" + Para + "=([^\\&\\?]*)\\&", "gi");
	if (!regex.test(_url)) 
	{
		return "";
	}
	var arr = regex.exec(_url);
	return (RegExp.$2);
}
function _isInt(s){
    var pattern = /^-?\d+$/;
    if (s.search(pattern) != 0) {
        return false;
    }
    return true;
}

$.fn.readNews = function(nx){
	    nx = $.extend({
    }, nx || {});
    return this.each(function() {
		var $localPosition;
		var _this = this;
		function init(){
			$(_this).click(function(){
				$('<div id="NewsWin">\
				  		<div id="NewsWinLeft">\
							<ul>\
								<li><a href="#"><span>无私的“母爱”点燃了小白狮的生...</span><em>2009-10-10</em></a></li>\
								<li class="color1"><a href="#"><span>新春小寿星--犀牛犇犇</span><em>2009-10-10</em></a></li>\
								<li></li>\
								<li class="color1"></li>\
								<li></li>\
								<li class="color1"></li>\
								<li></li>\
								<li class="color1"></li>\
								<li></li>\
								<li class="color1"></li>\
							</ul>\
							<span id="NewsTools"></span>\
						</div>\
						<div id="NewsWinRight">\
							<span id="NewsTitle"><ins></ins><h3><em>Tips:浏览时双击可以自动滚屏</em><a id="NewsCommon" href="javascript:;"></a></h3></span>\
							<div id="NewWContent">\
								<div id="NWCoon">\
									<div id="NWCon2"><h4>浏览时双击可以自动滚屏</h4><p class="newsinfo2">asdfsdf</p>\
									<div id="NWContent1"><p>sdfsdf</p></div>\
									</div><div class="clear"></div>\
								</div>\
							</div>\
						</div>\
					</div>').appendTo("body");
				showBg(this);	
				showNews(this);
				$("#NewsCommon")
				.unbind()
				.click(function(){
					closeNews()
				});
				showList();
				$(window).resize(function(){
					resize(this);					  
				});
			});
		}
		function showList(){
			$("#NewsTools")
			.unbind()
			.click(function(){
				
				$("#NewsWinLeft").animate({marginLeft:"-348px"},750,"easeInOutCubic",function(){
					$("#NewsWinRight").animate({marginLeft:"15px"},200);
					hideList();
				});
			});	
		}
		function hideList()
		{
			$("#NewsTools")
			.unbind()
			.click(function(){
					$("#NewsWinRight").animate({marginLeft:"363px"},200);
					$("#NewsWinLeft").animate({marginLeft:"0px"},750,"easeInOutCubic",function(){
						showList();
					});	
			});
			
		}
		function closeNews(){
			$("#NewsWin").animate({
                opacity: "hide",
                width: 0,
                height: 0
            }, 500,function(){
				$("#TB_NewsBg").remove();
			});
		}
		function showBg(obj){
			var _winHtml = '<div id="TB_NewsBg"></div>';
			$localPosition = getAllPosition(obj);
			var _height = document.documentElement.scrollHeight > document.documentElement.offsetHeight ? document.documentElement.scrollHeight : document.documentElement.offsetHeight;
			$("#TB_NewsBg").remove();
			$("body").append(_winHtml);
			if ((typeof document.body.style.maxHeight === "undefined")&&jQuery.browser.version != 6)
			{
				$("body","html").css({height: "100%", width: "100%"});   
				$("html").css("overflow","hidden"); 
			}	
			else
			{
				$("#TB_NewsBg").css("height",""+_height+"px"); 
			}
		}
		function showNews(obj){
			$localPosition = getAllPosition(obj);
			var msgTop = parseInt($localPosition.scrTop);
			var w = document.documentElement.clientWidth;
			if (w<=1280)
				w = w * 0.95;
			else
				w = 1280*0.95;
			var h = (document.documentElement.offsetHeight-20) * 0.90;
			var msgLeft = 0;
			if (!$("#NewsWin").is(":hidden")) {
				//_disload(obj);
			}
			else {
				
				$("#NewsWin").css({
					"left": $localPosition.offLeft,
					"top": $localPosition.offTop
				});
				msgLeft = parseInt(($localPosition.offWidth - w) / 2);
				msgTop = msgTop + parseInt(($localPosition.offHeight - h) / 2);
				$("#NewsWin").animate({
					opacity: "show",
					width: w,
					height: h,
					top: msgTop,
					left: msgLeft
				}, 500,"easeInOutCubic",function(){
				});
				
			}
		}
		function resize(obj){
			var w = document.documentElement.clientWidth * 0.95;
			var h = (document.documentElement.clientHeight-20) * 0.90;
			$localPosition = getAllPosition();
			var l = parseInt(($localPosition.offWidth-w)/2);
			var t = parseInt(($localPosition.offHeight-h)/2)+parseInt($localPosition.scrTop);
			$("#NewsWin").animate({
						width: w,
						height: h,
						left:l,
						top:t
					}, 750,"easeInOutCubic",function(){
					});
		}
		init();
							  
	});
}
//网络调查
$.fn.Vote = function(vx){
	vx = $.extend({
		voteid:34
    }, vx || {});
	return this.each(function() {
		function init(){
			loadvote();
		}
		function loadvote(){
			var _url = "/vote/vote.php?sid="+vx.voteid;
			var i = 1;
			
			$.getJSON(_url,function(ResultObj){
				var _html='<ul class="ulVote">';
				$.map(ResultObj,function(vjson){
					_html += '<li>&nbsp;&nbsp;'+i+'、'+vjson.title+'</li><li>'
					_html += '<ul>';
					$.map(vjson.question,function(qjson){
						if(vjson.type == 2)
						{
							_html+= '<li><input type="checkbox" rel="vote'+vx.voteid+'" name="chk'+qjson.tid+'" id="chk'+qjson.qid+'" value="'+qjson.qid+'" />&nbsp;'+qjson.question+'</li>';		
						}
						else
						{
							_html+= '<li><input type="radio" rel="vote'+vx.voteid+'"  name="rad'+qjson.tid+'" id="rad'+qjson.qid+'" value="'+qjson.qid+'" />&nbsp;'+qjson.question+'</li>';	
						}
					})
					_html += '</ul></li>';
					i++;
				});
				_html += '</ul>';
				_html += '<a href="javascript:;" id="btnVote" title="投票"><img src="/images/btnSubmit.gif"></a><a id="btnLookVote" href="/trip/showvote.shtml" title="查看投票"><img src="/images/btnLookVote.gif"></a>'
				$("#voteCon").html(_html);
				$("#btnVote")
				.unbind()
				.click(function(){
					addVote()			
				});
				
			});
		}
		function addVote(){
			var _choose = "",_list = "",_listi = 0;
			$("input[rel='vote"+vx.voteid+"']:checked").each(function(i,v){
				if(_list!=$(v).attr("name"))
				{
					_listi ++;
					_list = $(v).attr("name");
				}
				_choose += $(v).val()+",";														
			});
			alert(_listi)
			if (_choose==""||_listi!=2)
			{
				alert("请选择您的选项！:)")
				return false;
			}
			$("#btnVote").hide();
			jQuery.getJSON("/vote/showvote.php?rdm="+Math.random(),{sid:vx.voteid,qid:_choose,action:"dovote"},
			function(data)
			{
				if (data.Suc == "OK")
				{
					alert("谢谢您的参与:)");
					$("#voteCon input").attr("checked","");
					location.href = "/trip/showvote.shtml";
				}
				else
				{
					alert("您已经投过票了:)");
				}
			});
			
		}
		init();
	});
}
//活动评论
$.fn.ActComm = function(ax){
	ax = $.extend({
		activityid:1
    }, ax || {});
    return this.each(function() {
		function init(){
			loadcomm(1);
			$("#btnSubmit")
			.click(function(){
				addComm();	
			});
			$("#btnCloseComm")
			.click(function(){
				closePanel();		
			});
			$("#btnAddPanel")
			.click(function(){
				$("#lyck").slideDown("fast");		
			});
			$("#txtContent")
			.unbind()
			.click(function(){
				clearDefaultText(this,'请输入您的评论内容');		
			});
			$("#txtUserName")
			.unbind()
			.click(function(){
				clearDefaultText(this,'请输入您的昵称');		
			});
			$("#btnClearInput")
			.unbind()
			.click(function(){
				clearInput();
			});
		}
		function loadcomm(page){
			var _url = "/webmanage/activity/activitycomm.aspx?Type=GetCommList&ActivityID="+ax.activityid+"&PageIndex="+page+"&temp" + Math.random();
			$.getJSON(_url,function(ResultObj){
				pageUi(page,ResultObj.TotalPage);
				var i=parseInt(page-1)*5+1;
				var _html = "";
				$.map(ResultObj.CommListHtml,function(bookjson){
					_html += '<li><img src="images/listtop.jpg" />\
              <p class="ptop"><span>'+bookjson.UserName+'发布于：'+bookjson.AddTime+'</span><em>'+i+'楼</em></p>\
              <p class="pcon">'+bookjson.Content+'</p>\
              <img src="images/listbtmbg.jpg" /> </li>';
			  		i++;
				});
				$("#activityComminfo").html(_html);
			})
		}
		function pageUi(pcurrent,totalPages){
			var _this=this;
			var _pagehtml = UiPage(pcurrent,totalPages);
			$("#guestCommPage").html(_pagehtml);
			$("#guestCommPage a")
			.unbind()
			.click(function(){
				var aText = $(this).text();
				var pagecurrent = pcurrent;
				switch (aText)
				{
					case "上一页":
						pagecurrent = parseInt(pagecurrent-1);
						loadcomm(pagecurrent);
						break;
					case "下一页":
						pagecurrent = parseInt(pagecurrent+1);
						loadcomm(pagecurrent);
						break;
					default:
						loadcomm(parseInt($(this).text()));
						break;
				}		 					 
			});
		}
		function addComm(){
			var _username = $("#txtUserName").val().replace('请输入您的昵称','').trim();	
			var _content = $("#txtContent").val().replace('请输入您的评论内容','').trim();
			if(_content == "")
			{
				alert("请留下您的评论内容：）");
				$("#txtContent").focus();
				return false;
			}
			if(_username == "")
			{
				alert("请输入您的昵称：）");
				$("#txtUserName").focus();
				return false;
			}
			$("#lyck").slideUp("fast",function(){
				$.getJSON('/webmanage/activity/activitycomm.aspx?Type=AddComm&UserName='+escape(_username)+'&Content='+escape(_content)+'&ActivityID='+ax.activityid+'&temp' + Math.random(),function(json){
				  if (json.Type=="OK")
				  {
					  loadcomm(1);
					  clearInput();
					  //$("#lyck").slideDown("fast");
				  }
			  })
			})

		}
		function closePanel(){
			$("#lyck").slideUp("fast")
		}
		function clearInput(){
			$("#txtUserName").val("");
			$("#txtContent").val("");
		}
		init()
	});
}
String.prototype.trim=function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
function checkcount(len,objid,err)
{
	document.getElementById(objid).onfocus = document.getElementById(objid).onkeydown = document.getElementById(objid).onkeyup = function(){
		var charlen = parseInt($("#"+objid).val().length);
		if (charlen > len) {
			var v = $.trim($("#"+objid).val());
			$("#"+objid).val(v.substring(0, len));
		}else { 
			document.getElementById(err).innerHTML = len - charlen;
		} 
				
		}	
}