

window.WebSiteAdminDir = "/admin001";


window.isfoucs=0;

/*+++++++++++++++++++++++++++++++++++++
+ 功能:通用字符串两端去空
+ 研发:宗帝
+ 时间:2010-11-27
+++++++++++++++++++++++++++++++++++++*/
String.prototype.trim = function(){return $.trim(this);} 

/*
var sys = {};
var navua = navigator.userAgent.toLowerCase();
var browser;
(browser = navua.match(/msie ([\d.]+)/)) ? sys.ie = browser[1] :
(browser = navua.match(/firefox\/([\d.]+)/)) ? sys.firefox = browser[1] :
(browser = navua.match(/chrome\/([\d.]+)/)) ? sys.chrome = browser[1] :
(browser = navua.match(/opera.([\d.]+)/)) ? sys.opera = browser[1] :
(browser = navua.match(/version\/([\d.]+).*safari/)) ? sys.safari = browser[1] : 0;

*/



	var sys = {};
	var navua = navigator.userAgent.toLowerCase();
	var browser;
	(browser = navua.match(/msie ([\d.]+)/)) ? sys.ie = browser[1] :
	(browser = navua.match(/firefox\/([\d.]+)/)) ? sys.firefox = browser[1] :
	(browser = navua.match(/chrome\/([\d.]+)/)) ? sys.chrome = browser[1] :
	(browser = navua.match(/opera.([\d.]+)/)) ? sys.opera = browser[1] :
	(browser = navua.match(/version\/([\d.]+).*safari/)) ? sys.safari = browser[1] : 0;

/*+++++++++++++++++++++++++++++++++++++
+ 功能:获取当前页的顶和左像素值，为后续的弹出层界面居中作准备。
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
function Common_GetTagCenterXY(_width,_height)
{
	var sys = {};
	var navua = navigator.userAgent.toLowerCase();
	var browser;
	(browser = navua.match(/msie ([\d.]+)/)) ? sys.ie = browser[1] :
	(browser = navua.match(/firefox\/([\d.]+)/)) ? sys.firefox = browser[1] :
	(browser = navua.match(/chrome\/([\d.]+)/)) ? sys.chrome = browser[1] :
	(browser = navua.match(/opera.([\d.]+)/)) ? sys.opera = browser[1] :
	(browser = navua.match(/version\/([\d.]+).*safari/)) ? sys.safari = browser[1] : 0;

	var win = jQuery(window);
	var sTop = (document.compatMode == "CSS1Compat") ? document.documentElement.scrollTop : document.body.scrollTop;
	if (sys.chrome){sTop = document.body.scrollTop;}
	var docBodyScrollTop = (win.height()- _height)/2 + sTop;//  /7;
	var sLeft = (win.width() - _width)/2;
	var r={"Left":sLeft,"Top":docBodyScrollTop};//xy
	return r;
}





/* 屏幕遮罩 quitScreenMask()设置了单击或按esc退出遮罩 */
function addScreenMask(id)
{
	if(id==null) id="";//2010-09-27 Add
	
	var screenMaskA = '<div id="screenMask'+ id +'" style=" position:absolute; z-index:10000; top:0; left:0; display:none; width:100%; background:#000; opacity:0.5;"></div>';
	var screenMaskB = '<iframe frameborder="0" scrolling="no" id="screenMask'+ id +'" style=" position:absolute; z-index:10000; top:0; left:0; display:none; width:100%; background:#000; filter:alpha(opacity=30);"></iframe>';
	var screenMask = (!sys.ie) ? screenMaskA : screenMaskB;

	$(document.body).prepend(screenMask);
	$("#screenMask"+ id +"").height($(document).height()).fadeIn("fast");
}

//+---------------------------------------------------
//|	addScreenMask 
//@Author: WisdomStar
//@Date  : 2010-10-09 
//@gneng : 重载,在当前对话框内生成新对话框   
//+---------------------------------------------------
function addScreenMask(id,zIndex)
{
	if(id==null) id="";//2010-09-27 Add
	if(zIndex==null) zIndex = 10000;
	
	var screenMaskA = '<div id="screenMask'+ id +'" style=" position:absolute; z-index:'+ zIndex +'; top:0; left:0; display:none; width:100%; background:#000; opacity:0.5;"></div>';
	var screenMaskB = '<iframe frameborder="0" scrolling="no" id="screenMask'+ id +'" style=" position:absolute; z-index:'+ zIndex +'; top:0; left:0; display:none; width:100%; background:#000; filter:alpha(opacity=30);"></iframe>';
	var screenMask = (!sys.ie) ? screenMaskA : screenMaskB;

	$(document.body).prepend(screenMask);
	$("#screenMask"+ id +"").height($(document).height()).fadeIn("fast");
}


function removeScreenMask(id)
{
	if(id==null) id="";//2010-09-27 Add
	$("#screenMask"+ id ).fadeOut("fast",function(){
		$(this).remove();
	});
}


/*+++++++++++++++++++++++++++++++++++++
+ 功能:通用弹出对话框提交
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
function AddDialogbox(objId,title,zIndex,objWidth,ScreenMaskId,zIndex_Sub,IsShowClose,strContent,DialogTitle){
	if(ScreenMaskId==null) ScreenMaskId="";//2010-09-27 Add
	addScreenMask(ScreenMaskId,zIndex_Sub);

	var objIdInHTML = objId.replace(/#/,"");
	var sTop = (document.compatMode == "CSS1Compat") ? document.documentElement.scrollTop : document.body.scrollTop;

	//why document.body.scrollTop == 0 on chrome?
//	if (sys.chrome){sTop = document.body.scrollTop;}

	var docBodyScrollTop = sTop + $(window).height()/7;
	var left = $(window).width()/2 - objWidth/2;

	if(!DialogTitle)DialogTitle = "提示";
	
	//处理子框生成
	if(zIndex_Sub!=null)
	{
		docBodyScrollTop = docBodyScrollTop + 100;
	}
	//IsShowClose==true?

	var strCloseDiv="<img style=\"width:150px;cursor:pointer\" src=\"/images/big_tuan.png\" alt=\"关闭\">";
	strCloseDiv = '<div style="line-height:25px;text-align:right;height:100%;"><div style="width:80%;float:left;text-align:left;font-weight:bold;">&nbsp;'+ DialogTitle +':</div><a href="javascript:;" style="margin:5px 5px 0 0;display:block;width:16px;float:right"><img alt="关闭" src="/images/Dlg_close.gif" /></a></div>';

	$(document.body).prepend(
		'<div id='+objIdInHTML+' style="position:absolute;top:'+docBodyScrollTop+'px; left:'+left+'px; z-index:'+(zIndex)+'; width:'+objWidth+'px;padding:0px;background-color:#f1f1f1;border:1px solid #cdcdcd">'+
		(IsShowClose==true?'<div style="width:' + (objWidth) + 'px;height:25px;display:block;background-color:#BBBBBB;margin:0px;border-bottom:1px solid #AAAAAA" id="'+objIdInHTML+'_close">'+strCloseDiv+'</div>':"")+
		'<div id="'+objIdInHTML+'_Content" style="margin:0px;overflow-x:hidden;background:#f1f1f1; width:'+(objWidth)+'px;"><div>' +
		
		'</div>'
	);
	$("#"+objIdInHTML+"_Content").html(strContent);
	$("#"+objId).fadeIn("fast");
	$("#"+objId+" img[src*='Dlg_close.gif']").bind("click",function(){
		RemoveDialogbox(objId,ScreenMaskId);
	});
}
function AddDialogbox_FillContent(objId,strContent)
{
	var objIdInHTML = objId.replace(/#/,"");	
	$("#"+objIdInHTML+"_Content").html(strContent);
}


function RemoveDialogbox(objId,ScreenMaskId){
	if(ScreenMaskId==null || ScreenMaskId=="") ScreenMaskId="";//2010-09-27 Add
	var objIdInHTML = objId.replace(/#/,"");
	$("#"+objIdInHTML).fadeOut("fast",function(){
		removeScreenMask(ScreenMaskId);
		$(this).remove();//从DOM中删除本对象
	});
}


/*+++++++++++++++++++++++++++++++++++++
+ 功能:通用 Ajax 提交
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
function AjaxSubmit(_Type,_Url,_data,_success,_error,_dataType){
	if(!_dataType || _dataType=="") _dataType ="html";
	//_dataType=(!_dataType)?"html":_dataType;
	$.ajax({
		type: (_Type?_Type.toUpperCase():'POST'),
		url: (_Url?_Url:''),
		"dataType":(_dataType),//dataType: "script"
		data: (_data?_data:''),
		cache: false,
		success: (_success?_success:null),
		error: (_error?_error:null)
	});
}

/*
function ShowErrorMsg(msg)
{
	alert(msg);
}
*/
/*+++++++++++++++++++++++++++++++++++++
+ 功能:快速登陆
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/

function Fast_Login(uNameId,uPassId,datatype){
	if(!datatype) datatype = 0;
	var uName = (datatype==0)?$("#"+uNameId).val():uNameId;
	var uPass = (datatype==0)?$("#"+uPassId).val():uPassId;
	//alert(uName + "|" + uPass);
	if($.trim(uName).length<1 || $.trim(uPass).length<1)	{
		AlertErr("请输入用户名和密码。",1);
		return false;
	}
	AjaxSubmit(
		null,
		"/index.aspx?s=/User/FastUserLogin/&IsAdd=101",
		{"username":uName,"password":uPass},
		function(msg){ 
			if(msg==1){
				AjaxLoginBoxClose();
				Fast_GetUserInfo();
			} 
			else 
			{
				AlertErr("用户登陆有误,可能的原因:\r\n\r\n\t1.用户名或密码错误;\r\n\t2.网络故障.","会员登陆");//。
				
			}
		},null
		//function(msg){ShowErrorMsg("用户登陆有误:"+(msg.responseText?msg.responseText:"ErrorAjax") +"。");}
	);
	return true;
}

/*+++++++++++++++++++++++++++++++++++++
+ 功能:快速注销
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
function Fast_Logout(isAutoExit)
{
	
	if(!isAutoExit && confirm("您是否确定退出？")==false)
	return ;

	AjaxSubmit(
		null,
		"/index.aspx?s=/User/FastUserLogout/&IsAdd=102",
		"",
		function(msg){ 
			if(msg==1){Fast_GetUserInfo();} 
			else {
				ShowErrorMsg("用户安全退出有误（错误代码："+msg+")。");
			}
		},null
		//function(msg){ShowErrorMsg("用户安全退出有误（异常值："+　(msg.responseBody!=null?msg.responseBody:"") + ")。");}
	);
}
/*+++++++++++++++++++++++++++++++++++++
+ 功能:读取登陆后的信息
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/

function Fast_GetUserInfo()
{
	AjaxSubmit(
		null,
		"/index.aspx?s=/User/FastUserInfo/",
		"",
		function(msg)
		{
		 	if(msg) $("#div_UserInfo").html(msg);
		},null
		//function(msg){alert(msg)}
	);
}
/*+++++++++++++++++++++++++++++++++++++
+ 功能:更新用户状态
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
function Fast_UpdateUserState() {
	if(window.isfoucs==0){//如果当前页面不是在激活的状态
		return;
	}
	AjaxSubmit(
		null,
		"/index.aspx?s=/User/FastUserInfo/",
		"",
		function(msg)
		{
		 	if(msg) $("#div_UserInfo").html(msg);
		 	else setTimeout("Fast_UpdateUserState()", 6 *1000);//60S
		 		
		},
		function(msg){
		setTimeout(function(){Fast_UpdateUserState()}, 6 *1000);//60S
		}
	);

}

function GetIsLogin()
{
	return Common.getCookie('islogin');
}



/*+++++++++++++++++++++++++++++++++++++
+ 功能:弹出登陆框
+ 研发:宗帝
+ 时间:2010-11-19 
+++++++++++++++++++++++++++++++++++++*/

function AjaxLoginBox()
{
	
	//访问类型,AJAX路径,数据JSON,弹出框ID,弹出框标题,等执行的函数名;
	var _url="/User/LoginBox.aspx";
	var _data = {"id":0};	
	//Common.EditFunction("POST",_url,_data,"userloginbox","会员登陆","SubmitAjaxLogin");	
	//11:11 2012-01-11
	_url = "/user/tishi.html";
	var config={
		id:"iframdlgLogin"
		,title:"登陆/注册"
		,padding:0
		,opacity:0.5
		,lock:true
		,border:0
		//,cancel:true	
		,init:function(){
//			jQuery(".aui_nw").addClass("bd0");
//			jQuery(".aui_ne").addClass("bd0");
//			jQuery(".aui_sw").addClass("bd0");
//			jQuery(".aui_se").addClass("bd0");
			
		}	
	}
	Common.IframDialog(_url,config);
		//	jQuery(".aui_nw").addClass("bd0");
		//	jQuery(".aui_ne").addClass("bd0");
	//		jQuery(".aui_sw").addClass("bd0");
		//	jQuery(".aui_se").addClass("bd0");	
		jQuery(".aui_nw, .aui_ne, .aui_sw, .aui_se").addClass("bd0");
		jQuery(".aui_state_drag .aui_outer, .aui_outer").addClass("bd0_2");
}
function AjaxLoginBoxClose(){Common.EditDialogClose("userloginbox");}
/*+++++++++++++++++++++++++++++++++++++
+ 功能:修改密码(旧密码,新密码)
+ 研发:宗帝
+ 时间:2010-11-19
+ 入参:旧密码,新密码
+++++++++++++++++++++++++++++++++++++*/

function Fast_UpdateUserPass(uNameId,uPassId,datatype)
{
	if(!datatype) datatype = 0;
	var uName = (datatype==0)?$("#"+uNameId).val():uNameId;
	var uPass = (datatype==0)?$("#"+uPassId).val():uPassId;
	AjaxSubmit(
		null,
		"/index.aspx?s=/UserInfo/UserPassUpdate/&IsAdd=9",
		{"oldUserPassWord":uName,"UserPassword":uPass},
		function(msg)
		{
		 	if(msg>0) alert("密码已修改.") ;
			else alert("密码修改失败,可能的原因:\r\n 1.旧密码不正确;\r\n 2.登陆超时;\r\n 3.系统故障.");
			
		},null
		
	);
}

/*+++++++++++++++++++++++++++++++++++++
+ 命名空间:PaiPaiCMS
+ 功能:默认弹出框配置
+ 研发:宗帝 prototype
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
var PaiPaiCMS = {
	PaiPaiCmsDialogBoxId:"PaiPaiCMS_Dialog_Box",
	PaiPaiCmsDialogBox_ScreenMaskId:"PaiPaiCMS_Dialog_Box_screenMask",	
	DefaultShowSimpleDivID:"ShowSimpleTipDiv",
	DefaultShowSimpleShowSecond:1500,//毫秒
	DefaultShowSimpleShowTimeObj:0,
	DialogBox : {
		Show : function (data){
			if(!data) data="";AddDialogbox(PaiPaiCMS.PaiPaiCmsDialogBoxId,"",60001,300,PaiPaiCMS.PaiPaiCmsDialogBox_ScreenMaskId,10000,true,data);
		}
		,ShowSimple : function (data,FontBold,FontColor,FontSize,TextAlign,DialogBoxWidth,Caption){
			if(!DialogBoxWidth || isNaN(parseInt(DialogBoxWidth,10)))DialogBoxWidth = 300;
			if(!data) data="";
			
			if(!Caption)Caption = "出价提示";
			
			if(!FontColor || FontColor.trim().length<1) FontColor = "#888888";//默认
			if(!FontBold || FontBold.toLowerCase()!="bold") FontBold = "normal";else FontBold = "bold";	
			if(!FontSize || isNaN(parseInt(FontSize,10))) FontSize = 12;
			if(!TextAlign || TextAlign.trim().length<1) TextAlign = "center";//默认
			
			var content = '<div style="text-align:'+TextAlign+';font-size:'+ FontSize +'px;font-weight:'+ FontBold +';color:'+ FontColor +';margin:20px 20px 20px 20px;line-height:30px;border:3px double #cccccc;">' 
				+ '<div style="margin:10px;">'				
				+ data 
				+ '</div>'
				+ '</div>';
			AddDialogbox(PaiPaiCMS.PaiPaiCmsDialogBoxId,"",60001,DialogBoxWidth,PaiPaiCMS.PaiPaiCmsDialogBox_ScreenMaskId,10000,true,content,Caption);
		}	
		//16:28 2010-12-09
		,ShowSimpleTip : function (data,FontBold,FontColor,FontSize,TextAlign,DialogBoxWidth,oDiv){
			var _this = this;
			if(!DialogBoxWidth || isNaN(parseInt(DialogBoxWidth,10)))DialogBoxWidth = 300;
			if(!data) data="";

			if(!FontColor || FontColor.trim().length<1) FontColor = "#888888";//默认
			if(!FontBold || FontBold.toLowerCase()!="bold") FontBold = "normal";else FontBold = "bold";	
			if(!FontSize || isNaN(parseInt(FontSize,10))) FontSize = 12;
			if(!TextAlign || TextAlign.trim().length<1) TextAlign = "left";//默认
			//else TextAlign = "left";//默认
			
			if(data.length>0) DialogBoxWidth = (data.length + 4) * (FontSize) ;//1个中文须按2个字节计算。
			if(DialogBoxWidth>600) DialogBoxWidth = 600;
			
			//var oDivID = "ShowSimpleTipDiv";
			if(oDiv==null)
			{
				//'<div style="background-color:red;border:1px solid red;display:block;"></div>top:-50px;right:0px;padding:2px 0px 2px 0px;'
				var content = ""
				+ ' <div id="'+ PaiPaiCMS.DefaultShowSimpleDivID+'"'
				+ ' style="background-color:#EEEEEE;margin:0px 0px 0px 0px;height:auto;width:'+ DialogBoxWidth +'px;'
				+ ' z-Index:90000; position:absolute;text-indent:' + 0 + 'px">'
				+ ' <div style="text-align:'+TextAlign+';font-size:'+ FontSize +'px;font-weight:'+ FontBold +';'
				+ ' color:'+ FontColor +';margin:6px 6px 6px 6px;line-height:20px;border:3px double #cccccc;">' 
				+ ' <div style="margin:5px;vertical-align: middle;" id="div_DataDiv">'//数据显示区
				+ ' </div>'
				+ ' </div>'
				+ ' </div>';				
				
				jQuery(document.body).prepend(content);
				oDiv = jQuery("#"+ PaiPaiCMS.DefaultShowSimpleDivID);	
				//oDiv.css("margin","-22px 0px 0px -20px")
				/*
				oDiv.css("position","absolute")
					.css("z-Index","90000")
					.css("background-color","red")
					.css("width",DialogBoxWidth);
					//.html(content);
					*/
			}
		//	_this.CloseSimpleTip(oDiv);//先隐后显。
			if(oDiv){
				//.css("display","block")
				var str = data.trim() ;//+ new Date().getTime();
				var div_DataDiv = jQuery("#div_DataDiv");
				div_DataDiv.html(str);
				var o = oDiv.find("div");
				var h = 30;
				if(o) h = o.height();
				var r = Common_GetTagCenterXY(DialogBoxWidth,h);
				oDiv.css("left",r.Left+"px").css("top",r.Top+"px").show(2000);
			}
			PaiPaiCMS.DefaultShowSimpleShowTimeObj = setTimeout(function(){
					_this.CloseSimpleTip(oDiv);
					clearInterval(PaiPaiCMS.DefaultShowSimpleShowTimeObj);
				}
				,PaiPaiCMS.DefaultShowSimpleShowSecond);
		}				
		,AjaxAlert : function (url,data,width,IsShowCaption){
			if(!width) width = 300;IsShowCaption = (IsShowCaption==true) ;
			if(url){if(!data)data="";
				AjaxSubmit(null,url,data
					,function(msg){AddDialogbox(PaiPaiCMS.PaiPaiCmsDialogBoxId,"",60001,width,PaiPaiCMS.PaiPaiCmsDialogBox_ScreenMaskId,10000,IsShowCaption,msg);}
					,function(msg){}
				);
			}
			else{alert(url);}
			
		}
		,Close : function(){RemoveDialogbox(PaiPaiCMS.PaiPaiCmsDialogBoxId,PaiPaiCMS.PaiPaiCmsDialogBox_ScreenMaskId);}
		,CloseSimpleTip:function(oDiv){ 
			var _this = this;
			if(oDiv==null) oDiv = jQuery("#"+ PaiPaiCMS.DefaultShowSimpleDivID);	
			if(oDiv) oDiv.hide();
			if(PaiPaiCMS.DefaultShowSimpleShowTimeObj)
			{	//不断的关闭。
				PaiPaiCMS.DefaultShowSimpleShowTimeObj = setTimeout(function(){
						_this.CloseSimpleTip(oDiv);
						clearInterval(PaiPaiCMS.DefaultShowSimpleShowTimeObj);
					},PaiPaiCMS.DefaultShowSimpleShowSecond	);			
			}
		}
	},ErrorBox:{
		 ShowErrorMsg:function(msg,strTitle){
			var mymsg = '<div style="width:586px;height:330px;margin:0px;border:1px solid #AAAAAA;background-color:menu"><textarea style="width:558px;height:300px;margin:12px 3px 3px 3px;border:0px solid #EEEEEE;background-color:menu;">'
				+ msg +'</textarea></div>';
			AddDialogbox("Ajax_Err","",61000,588,"Ajax_Err_screenMask",10000,true,mymsg,strTitle);
		}
	},PicBox:{
		UserLogo:{
			Show:function(_PhotoType,_PhotoUserType,_SystemType,_url,_InfoId,_DlgTitle){
				//alert("PaiPaiCMS.PicBox.UserLogo.Show();");
				//加载头像处理页面内容:参数表:头像类(0),前台类型(1),系统提供头像列表(0)
				if(!_PhotoType) _PhotoType = 0;
				if(!_PhotoUserType) _PhotoUserType=1;
				if(!_SystemType) _SystemType=0;
				if(!_url) _url = "/UpPic/UserLogo.aspx";
				if(!_DlgTitle)_DlgTitle="会员头像";
				//var data = {"PhotoType":0,"PhotoUserType":1,"SystemType":0};
				//var url = "/UpPic/UserLogo.aspx";
				var data = {"PhotoType":_PhotoType,"PhotoUserType":_PhotoUserType,"SystemType":_SystemType,"InfoId":_InfoId};
				var url = _url;
				var IsShowCaption = true;
				var width = 572;
				AjaxSubmit(null,url,data
					,function(msg){
					AddDialogbox(PaiPaiCMS.PaiPaiCmsDialogBoxId,"",60001,width,PaiPaiCMS.PaiPaiCmsDialogBox_ScreenMaskId,10000,IsShowCaption,msg,_DlgTitle);
					}
					,null
				);
			}
		}
	}	 
};


/*+++++++++++++++++++++++++++++++++++++
+ 功能:弹出异常代码
+ 研发:宗帝
+ 时间:2010-11-19
+++++++++++++++++++++++++++++++++++++*/
function ShowErrorMsg(msg)
{
	var mymsg = '<div style="width:586px;height:330px;margin:0px;border:1px solid #AAAAAA;background-color:menu"><textarea style="width:558px;height:300px;margin:12px 3px 3px 3px;border:0px solid #EEEEEE;background-color:menu;">'
		+msg
		+'</textarea></div>';
	AddDialogbox("Ajax_Err","",61000,588,"Ajax_Err_screenMask",10000,true,mymsg,"异常信息");
}	
function ShowErrorMsg(msg,strTitle)
{
	var mymsg = '<div style="width:586px;height:330px;margin:0px;border:1px solid #AAAAAA;background-color:menu"><textarea style="width:558px;height:300px;margin:12px 3px 3px 3px;border:0px solid #EEEEEE;background-color:menu;">'
		+msg
		+'</textarea></div>';
	AddDialogbox("Ajax_Err","",61000,588,"Ajax_Err_screenMask",10000,true,mymsg,strTitle);
}	

/*+++++++++++++++++++++++++++++++++++++
+ 功能:产品喜好投票
+ 研发:宗帝
+ 时间:2011-06-10
+++++++++++++++++++++++++++++++++++++*/
function UserPollABAdd(pid,IsEnjoy)
{
	var url = "/CommonTools/Update.aspx?IsAdd=1001";
	//return false;
	Common.Ajax("POST",url,{"pid":pid,"IsEnjoy":IsEnjoy}
		,function(msg){
			if(msg>0){ alert("谢谢您的投票。");UserPollABGet(pid);}
			else {alert("您已投过票，不需要重复投票。");jQuery("#span_form_poll").html("");}
		});
	return false;
}

function UserPollABGet(pid)
{
	var url = "/CommonTools/Update.aspx?IsAdd=1002";
	
	Common.Ajax("GET",url,{"pid":pid}
		,function(msg){
			if(msg!=null){
				if(msg.IsPolled>0) {
					//jQuery("#span_form_poll").html("您投了喜欢一票");
						jQuery("#span_form_poll").html("");
				}
				else 
				{
					var s = '<input type="radio" id="span_pollA" name="UserPollAB" >喜欢<input type="radio" id="span_pollB" name="UserPollAB" >不喜欢'
						+'<input type="button" id="UserPollAB_Submit" onclick="return UserPollABClick('+ pid+');" value="投票">';
					jQuery("#span_form_poll").html(s);
				}
				jQuery("#Span_PollA").html(msg.PollA+"/"+msg.PollB);
			}
			//else alert("数据为空。");
			
		},null,"json");
}
function UserPollABClick(pid)
{
	// mb_id,islogin
	var Uid=Common.getCookie("islogin",0);
	if(Uid<1){	alert("请登陆.");	return false;}
	
	var IsEnjoy = -1;
	if(jQuery("#span_pollA").attr("checked")){IsEnjoy=1;}
	if(jQuery("#span_pollB").attr("checked")){IsEnjoy=0;}
	if(IsEnjoy==-1){alert("请选择您的喜好.");}
	else{UserPollABAdd(pid,IsEnjoy);}
	return false;
	
}
/************************************** 17:03 2011-07-04 *****************************************/
function CheckIsLogin(){
	var islogin = Common.getCookie("islogin");
	//alert(islogin);
	if(islogin && islogin==1) {return true;}
	else{AjaxLoginBox();return false;}
}
//0:42 2011-12-02 ajax获取UID
function GetUid(){var islogin = 0;jQuery.ajax({async:false,cache: false,type: "POST",url: "/User/AjaxUid.aspx",data:{"id":0},success: function(msg){islogin=msg;}});return islogin;}
/************************************** 17:03 2011-07-06 *****************************************/
/*
jQuery(ducument).ready(function(){
	jQuery("img").error(function(){
			
		var IsErrorCount = Common.setCookie
		Common.setCookie("");
	
	});
});
*/


/************************************** 10:51 2011-07-20 *****************************************/

//检查待跳转的网址是否有效。
function CheckUrlExisted(url)
{
	if(url.length<3)
	{
		alert("地址无效.");return false;
	}
	else
	return true;
}


function CheckIsLoginForLogin()
{
	var islogin = Common.getCookie("islogin");
	//alert(islogin);
	if(islogin && islogin==1) {return true;}
	else{AjaxLoginBox();return false;}
}


/************************************** 15:50 2011-07-21 *****************************************/
//会员晒图处理
//id:竞拍信息编号
function UserPicNoteShow(id,gametype,OrderFormType)
{
	var _url ="/UserInfo/UserPicNote/UPDATE.ASPX?IsAdd=0";
	var _data = null;//{"infoId":id,"GameType":_gameType,"UserId":UserId,"OrderFormType":OrderFormType,"PageUrlType":1};
	_data =	{"InfoId":id,"GameType":gametype,"OrderFormType":OrderFormType},
	Common.EditFunction("POST",_url,_data,"work_order_ui_list","编辑晒图信息",'SaveInfoSub')		
	
	
//	AddDialogbox("#Div_AdminEdit","编辑晒图信息",10001,660);
	//quitScreenMask();
	/*
	$.ajax({
		type: "POST",
		url: "/UserInfo/UserPicNote/UPDATE.ASPX?IsAdd=0",
		data:{"InfoId":id,"GameType":gametype,"OrderFormType":OrderFormType},
		cache: false,
		success: function(msg){
			//$("#Div_AdminEdit .dialogboxContent").html(msg);
			//$("#Div_AdminEdit .dialogboxContent").addClass("regWrap");
			AddDialogbox("Div_UserPicNote_A_Edit","",100001,625,"Ajax_Err_screenMask_UserPicNote",100000,true,msg,"编辑晒图信息");			
		}
	});*/
	//将本行设置为选中颜色
	SetActive(id);
}


function UserPicNoteShow_PicManage(id,GameType,OrderFormType)
{
	
	var UserId = 0;
	if(id<1)
	{
		alert("暂无晒图信息，请先保存晒图信息后再管理晒图图片。");
		return false;
	}
	SetActive(id);
	
	//quitScreenMask();
	var fileId = "";
	switch(OrderFormType)
	{
		//case 0:fileId = 0;break;//
		//case 0:fileId = 0;break;//
		//case 0:fileId = 0;break;//
		case 1:fileId = "_4";break;//Vendue=1,
		case 3:fileId = "_5";break;//SafeBuy=3,
		case 5:fileId = "_6";break;//SecondGame = 5,
		case 6:fileId = "_7";break;//SecondGameSafeBuy = 6,
		case 7:fileId = "_8";break;//Game3 = 7,
		case 8:fileId = "_9";break;//Game3SafeBuy = 8,
		case 9:fileId = "_10";break;//Game4 = 9,
		case 10:fileId = "_11";break;//Game4SafeBuy = 10,
		default:fileId = "-1";break;//
	}
	
	if(fileId=="-1")
	{
		alert("订单类型无效.");
		return false;
	}
	else
	{
		
		var _url =WebSiteAdminDir+"/PicManage/List"+ fileId +".aspx";
		var _data ={"infoId":id,"GameType":GameType,"UserId":UserId,"OrderFormType":OrderFormType,"PageUrlType":1};
		Common.EditFunction("POST",_url,_data,"Div_PicManage","编辑晒图信息",'');		
		/*
		jQuery.ajax({
			type: "POST",
			//url: APP+"/Admin/Product_Pic_UI_List&PhotoType=2&PhotoUserType=2",
			url: "/ADMIN/PicManage/List"+ fileId +".aspx",
			data:{"InfoId":id},//2产品编号,3广告类,4晒图类
			cache: false,
			success: function(msg){
				AddDialogbox("Div_AdminEdit","",100003,625,"Ajax_Err_screenMask",100002,true,msg,"晒图图片管理");
			}
		});
		*/
	}
	return false;
}

/************************************** 12:12 2011-08-31 *****************************************/
function CheckExisted(type,strValue,funSuccess)
{
	var _typeData = { "CheckType": type, "Value": strValue};
	var _typetTitle = "用户名";
	var _typeUrl = "/UserInfo/UserInfo_Update.aspx?IsAdd=201";
	if(type=="UserNickName"){
		_typeUrl = "/UserInfo/UserInfo_Update.aspx?IsAdd=201";_typetTitle="用户名";
		 _typeData = { "CheckType": type, "UserNickName": strValue};
	}
	else if(type=="UserMobile"){
		_typeUrl = "/UserInfo/UserInfo_Update.aspx?IsAdd=203";_typetTitle="手机号";
		 _typeData = { "CheckType": type, "UserMobile": strValue};
	}
	else if(type=="UserEmail"){
		_typeUrl = "/UserInfo/UserInfo_Update.aspx?IsAdd=202";_typetTitle="邮箱";
		 _typeData = { "CheckType": type, "UserEmail": strValue};
	}
		
	//alert(type + "/" + _typeUrl);	
    jQuery.ajax({
        type: "POST",
        async:false,//本处采用同步请求。	
        url: _typeUrl,
        data:_typeData,
        cache: false,
        success:funSuccess
    });		
	/*用例:
	
			CheckExisted("UserMobile",value,function(msg){
				if(msg>0)spanObj.html("手机号已存在");
				else spanObj.html("");
			});	
	*/
}

/************************************** 0:52 2011-10-07 *****************************************/
//QQ绑定提示及操作
function CheckUserLoginAndQQBind(isReg,UserQQOpenId){
	if(!isReg) isReg=0;
	var msg = "您好，您的本站帐户已登陆成功,现在是否要与当前登陆的QQ进行绑定?\r\n(QQ绑定后可通过QQ完成本站的会员登陆)";
	if(isReg==1) msg = "您好，您的本站帐户已注册成功,现在是否要与当前登陆的QQ进行绑定?\r\n(QQ绑定后可通过QQ完成本站的会员登陆)"
		
	if(confirm(msg)){
		//Ajax调用绑定
		var _typeUrl = "/UserInfo/UserInfo_Update.aspx?IsAdd=301";
		var _typeData = { "CheckType": 0,"isReg":isReg,"UserQQOpenId": UserQQOpenId};
	    jQuery.ajax({
	        type: "POST",
	        async:false,//本处采用同步请求。	
	        url: _typeUrl,
	        data:_typeData,
	        cache: false,
	        success:function(msg){
	        	//
	        	if(msg>0) alert("QQ帐户绑定成功，您以后可以通过QQ快捷登陆本站了。");
	        	else if(msg==-1) alert("您本地帐户登陆标识信息失败（未登陆或已退出或其他原因），请您先用本地帐户登陆后再试。");
	        	else alert("不好意思，QQ帐户绑定失败，可能是QQ登陆时间过久了，您可以重新进行QQ登陆再试。");
	        
	        }
	    });
	}
	else{
		//取消，关闭本页
		//如果QQ登陆发现本地帐户已登陆，则直接提示绑定
	}
}