$.LOGID='';

function getHrefArgs() {
	return location.search.substring(1).toJson('&', '=',function(v) {return decodeURIComponent(v)});
}

(function($) {
$.extend(String.prototype, {
	trim: function(r) {r = r || /(^\s+)|(\s+$)/g;return this.replace(r, "");},
	empty: function() {return this.trim() == '';},
	isqq: function() {return /^[1-9]\d{4,10}$/.test(this);},
	lenW: function() {return this.replace(/[^\x00-\xff]/g, "**").length;},
	padDate: function(s) {return this.replace(/(\D)(\d)(?=\D|$)/g, "$10$2");},
	format: function() {
		var a = arguments;
		var data = (a.length == 1 && typeof(a[0]) == 'object') ? a[0] : a;
		return this.replace(/\{([\d\w]+)\}/g,function(m, n) {return data[n] != undefined ? data[n].toString() : m;});
	},
	html: function(isdecode) {
		var ar = ['&', '&amp;', '<', '&lt;', '>', '&gt;', ' ', '&nbsp;', '"', '&quot;', "'", '&#39;', '\\r', '<br>', '\\n', '<br>'];
		if (isdecode) ar.reverse();
		for (var i = 0,r = this; i < ar.length; i += 2) r = r.replace(new RegExp(ar[i], 'g'), ar[1 + i]);
		return r;
	},
	toJson: function(lvl_1, lvl_2, fn) {
		fn = $.isFunction(fn) ? fn: (function(v) {return v});
		var ar = $.grep(this.split(lvl_1),function(v) {return v.trim() != ''});
		var r = {};
		$.each(ar,function(i, v) {var a = v.split(lvl_2);if (a[1] != undefined) r[a[0]] = fn(a[1]);});
		return r;
	},
	toArray: function(a) {
		switch (a.length) {
		case 0:
			return [this];
		case 1:
			var ar = this.split(a[0]);
			if (ar.length && ar[ar.length - 1].empty()) ar.pop();
			return ar;
		case 2:
			return this.toJson(a[0], a[1]);
		default:
			var arRslt = [];
			var tmp = this.split(a[0]);
			if (tmp[tmp.length - 1].empty()) tmp.pop();
			$.each(tmp,function(i, n) {arRslt.push(n.toArray(a.slice(1)));});
			break;
		}
		return arRslt;
	},
	toCodeArray: function() {
		var ar = this.replace(/(\d\d)(?!(\d$|$))/g, '$1,').split(',');
		$.each(ar,function(i, n) {ar[i] = +n;});
		return ar;
	},
	templateReplace:function (data) {
		var html = [];
		var t = this;
		$.each(data, function (i, n) {
			html.push(t.format(n));
		});
		return html.join('');
	},
	formatEval:function () {
		var t = this;
		var reg = /<%\=(.*?)%>/g;
		return this.replace(reg, function (_1, _2) {return eval(_2)});
	}
});
}) (jQuery);

(function($) {
$.extend(Date.prototype, {
	format : function () {
		var arg = arguments;
		if (arg.length == 1 && typeof arg[0] == 'string') {
			var str = arg[0];
			var reg = /(yyyy|yy|mm|m|dd|d|hh|h|MM|M|ss|s)/gi;
			var d = {
				yyyy:this.getFullYear(), 
				yy:this.getFullYear().toString().match(/\d{2}$/),
				mm:(this.getMonth() + 1)<10?('0'+(this.getMonth() + 1)) : (this.getMonth() + 1),
				m:(this.getMonth() + 1),
				dd:this.getDate()<10?('0'+this.getDate()):this.getDate(), 
				d:this.getDate(),
				hh:this.getHours()<10?('0'+this.getHours()):this.getHours(), 
				h:this.getHours(),
				MM:this.getMinutes()<10?('0'+this.getMinutes()):this.getMinutes(), 
				M:this.getMinutes(),
				ss:this.getSeconds()<10?('0'+this.getSeconds()):this.getSeconds(), 
				s:this.getSeconds()
			};
			str = str.replace(reg, function() {
				return d[arguments[1]];
			});
			return str;
		}
	}
});
}) (jQuery);

var cookie = $.cookie = function(name, value, options) {
	if (typeof value != 'undefined') {
		options = options || {path: '/',domain: 'qq.com'};
		if (value === null) {
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString();
		}
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure': '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
	} else {
		var cookieValue = '';
		if (document.cookie && document.cookie != '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};
(function() {
	var $$ = jQuery.fn.flash = function(htmlOptions, pluginOptions, replace, update) {
		var block = replace || $$.replace;
		pluginOptions = $.extend(true, $$.pluginOptions, pluginOptions);
		if (!$$.hasFlash(pluginOptions.version)) {
			if (pluginOptions.expressInstall && $$.hasFlash(6, 0, 65)) {
				var expressInstallOptions = {
					src: pluginOptions.xiSWFPath,
					flashvars: {
						MMredirectURL: location,
						MMplayerType: 'PlugIn',
						MMdoctitle: jQuery('title').text()
					}
				};
			} else if (pluginOptions.update) {
				block = update || $$.update;
			} else {
				return this;
			}
		}
		htmlOptions = $.extend(true, $$.htmlOptions, htmlOptions, expressInstallOptions);
		return this.each(function() {
			block.call(this, $.extend({},
			htmlOptions));
		});
	};
	$$.hasFlash = function() {
		if (/hasFlash\=true/.test(location)) return true;
		if (/hasFlash\=false/.test(location)) return false;
		var pv = $$.hasFlash.playerVersion().match(/\d+/g);
		var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($$.pluginOptions.version).match(/\d+/g);
		for (var i = 0; i < 3; i++) {
			pv[i] = parseInt(pv[i] || 0);
			rv[i] = parseInt(rv[i] || 0);
			if (pv[i] < rv[i]) return false;
			if (pv[i] > rv[i]) return true;
		}
		return true;
	};
	$$.hasFlash.playerVersion = function() {
		try {
			try {
				var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
				try {
					axo.AllowScriptAccess = 'always';
				} catch(e) {
					return '6,0,0';
				}
			} catch(e) {}
			return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
		} catch(e) {
			try {
				if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
					return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
				}
			} catch(e) {}
		}
		return '0,0,0';
	};
	$$.htmlOptions = {
		flashvars: {},
		width: '100%',
		height: '100%',
		pluginspage: 'http://www.adobe.com/go/getflashplayer',
		src: '#',
		type: 'application/x-shockwave-flash',
		wmode: 'transparent',
		AllowScriptAccess: 'always'
	};
	$$.pluginOptions = {
		expressInstall: true,
		update: true,
		xiSWFPath: 'http://8.qq.com/flash/playerInstall.swf',
		version: '8.0.0'
	};
	$$.replace = function(htmlOptions) {
		if (this.innerHTML != "") this.innerHTML = '<div class="alt">' + this.innerHTML + '</div>';
		jQuery(this).addClass('flash-replaced').prepend($$.transform(htmlOptions));
	};
	$$.update = function(htmlOptions) {
		var url = String(location).split('?');
		url.splice(1, 0, '?hasFlash=true&');
		url = url.join('');
		var msg = '<p>浏览此处内容需要<a href="http://www.adobe.com/go/getflashplayer">安装最新版本的Macromedia Flash 播放器</a><br/>使用已有播放器播放请：<a href="' + url + '">点击这里.</a><br/>太低版本的播放器存在安全隐患，建议您<a href="http://www.adobe.com/go/getflashplayer">安装最新版本的Macromedia Flash 播放器</a></p>';
		this.innerHTML = '<span class="alt">' + this.innerHTML + '</span>';
		jQuery(this).addClass('flash-update').prepend(msg);
	};
	function toAttributeString() {
		var ar = [];
		$.each(this,function(k, v) {if (!$.isFunction(v)) ar.push(k + '="' + v + '" ');});
		return ar.join('');
	};
	function toFlashvarsString() {
		var ar = [];
		$.each(this,function(k, v) {if (!$.isFunction(v)) ar.push(k + '=' + encodeURIComponent(v));});
		return ar.join('&');
	};
	$$.transform = function(htmlOptions) {
		htmlOptions.toString = toAttributeString;
		if (htmlOptions.flashvars) htmlOptions.flashvars.toString = toFlashvarsString;
		return '<embed ' + String(htmlOptions) + '/>';
	};
	if (window.attachEvent) {
		window.attachEvent("onbeforeunload",
		function() {
			__flash_unloadHandler = function() {};
			__flash_savedUnloadHandler = function() {};
		});
	}
})();

(function($){
	$.fn.visible = function () {
		return this.get(0).style.display.toUpperCase()!='NONE' 
			&& this.get(0).style.visibility.toUpperCase()!='HIDDEN'
			&& parseInt(this.get(0).style.width)>0
			&& parseInt(this.get(0).style.height)>0
	};

	$.fn.blink = function () {
		return this.each(function (i, n) {
			(function() {
				var num=0;
				$(n).attr('timer',setInterval(function () {
					$(n).css({opacity:num++%2?1:.6});
				},400));
			})();
		});
	};

	$.fn.stopBlink = function () {
		return this.each(function (i, n) {
			if (!$(n).attr('timer')) {return;}
			clearInterval($(n).attr('timer'));
		});
	};

	$.fn.getCheckeds = function () {
		var ar = [];
		$.each(this, function (i, n) {
			if (n.checked) ar.push(n);
		});
		return ar;
	};

	$.fn.appFilters = function () {
		return this.each(function (i, n) {
			if (n.nodeName != 'IMG') return;
			var hload = (function (obj) {
				return function () {
					obj.onload = null;
					obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "', sizingMethod='scale')";
					obj.src = 'http://imgcache.qq.com/ac/b.gif';
				}
			}) (n);
			n.onload = hload;
		});
	};

	$.fn.center = function () {
		return this.each(function (i, n) {
			function set() {
				$(n).css({
					left:($(window).width() - $(n).width())/2 + $(window).scrollLeft(),
					top:($(window).height() - $(n).height())/2 + (($.browser.msie&&$.browser.version<7)?$(window).scrollTop():0),
					position:($.browser.msie&&$.browser.version<7)?'absolute':'fixed'
				});
			}
			set();
			if($.browser.msie&&$.browser.version<7) $(window).scroll(set).resize(set);
		});
	};
	$.fn.caret = function(begin, end) {
		if (this.length == 0) return;
		if (typeof begin == 'number') {
			end = (typeof end == 'number') ? end: begin;
			return this.each(function() {
				if (this.setSelectionRange) {
					this.focus();
					this.setSelectionRange(begin, end);
				} else if (this.createTextRange) {
					var range = this.createTextRange();
					range.collapse(true);
					range.moveEnd('character', end);
					range.moveStart('character', begin);
					range.select();
				}
			});
		} else {
			if (this[0].setSelectionRange) {
				begin = this[0].selectionStart;
				end = this[0].selectionEnd;
			} else if (document.selection && document.selection.createRange) {
				var range = document.selection.createRange();
				begin = 0 - range.duplicate().moveStart('character', -100000);
				end = begin + range.text.length;
			}
			return {
				begin: begin,
				end: end
			};
		}
	};

	$.userinfo =function(options){
		$.userinfo.impl.open(options);
	}
	$.fn.userinfo =function (options,$hide){
		$.userinfo($.extend(true,options,{parentNode:this.eq(0)}));
	}
	$.userinfo.close = function(fn){
		$.userinfo.impl.close(fn);
	}
	$.userinfo.impl = {
		opts:{
			//选项参数
			parentNode:null,
			hidden:null,
			callback:null,
			idcard:!true,
			title:'填 写 个 人 信 息',
			subtitle:'请留下您的联系方式，以便我们的工作人员及时将奖品发送给您。',
			message:'请再次检查您输入的联系方式，以确保正确！',
			submitSrc:'http://imgcache.qq.com/ACT/dial_20070723/img/submit.gif',
			confirmSrc:'http://imgcache.qq.com/ACT/dial_20070723/img/affirm_yes.gif',
			modifySrc:'http://imgcache.qq.com/ACT/dial_20070723/img/affirm_no.gif',
			qrycgi_true:'http://qdou.qq.com/cgi-bin/qbean?configid=q&cmd=comm_getuseraddr',
			addcgi_true:'http://qdou.qq.com/cgi-bin/qbean?configid=q&cmd=comm_adduseraddr',
			modcgi_true:'http://qdou.qq.com/cgi-bin/qbean?configid=q&cmd=comm_moduseraddr',
			qrycgi_false:'http://qdou.qq.com/cgi-bin/qbean?configid=q&cmd=comm_getuseraddr',
			addcgi_false:'http://qdou.qq.com/cgi-bin/qbean?configid=q&cmd=comm_adduseraddr',
			modcgi_false:'http://qdou.qq.com/cgi-bin/qbean?configid=q&cmd=comm_moduseraddr',
			loginopts:{},
			logincss:{},
			//样式参数
			outer:{width:'100%',textAlign:'center',fontSize:'12px',color:'#330033'},
			head:{fontSize:'16px',fontWeight:'bold'},
			clear:{border:'0px',width:'400px',height:'0px',fontSize:'1px',backgroundColor:''},
			body:{},
			input:{backgroundColor:'#fef7db',color:'black',border:'1px solid #98988c',padding:'2px',width:'236px',marginTop:'15px'},
			locked:{backgroundColor:'#D5D5D5',color:'#808080'},
			warn:{visibility:'hidden',color:'red'},
			foot:{textAlign:'',width:'380px',paddingLeft:'80px'},
			button:{border:'0px',margin:'0px 5px',width:'auto'},
			div:{margin:'10px auto'}
		},
		open:function(options){
			var opts=this.opts = $.extend(true,this.opts,options);
			if(!$.userinfo.impl.data){
				$.get(opts['qrycgi_'+!!opts.idcard],{},function(res) {
					var callback = function (rc,ui){
						switch(rc){
							case '0':$.userinfo.impl.data = ui;$.userinfo(options); break;
							case '30003':$.userinfo.impl.data = {};$.userinfo(options); break;
							case '20012':
								alert('对不起，您还没有登录，或者登录已超时！\n登录后可以查看您曾经填写的个人信息！');
								login($.extend(opts.loginopts,{callback:function(){	$.userinfo(options); } } ),opts.logincss);
								break;
							default:alert('对不起，获取您的个人信息时发生未知错误！\n错误码:'+rc);break;
						}
					}
					eval(res);
				});
				return false;
			}
			if(!this.outer){
				var outer = this.outer = $('<div>'.concat(
					'<div>',opts.title,'</div>',
					'<div></div>',
					'<div>',opts.subtitle,'<br/>',
					'真实姓名(*)：<input maxlength="32"/><br/>',
					'联系电话(*)：<input maxlength="32"/><br/>',
					'证件号码(*)：<input maxlength="32"/><br/>',
					'收货地址(*)：<input maxlength="100"/><br/>',
					'邮政编码(*)：<input maxlength="32"/><br/>',
					'</div>',
					'<div>',opts.message,'</div>',
					'<div><input type="image" src="',opts.submitSrc,'"/>',
					'<input type="image" src="',opts.confirmSrc,'"/>',
					'<input type="image" src="',opts.modifySrc,'"/>',
					'</div></div>')).appendTo(opts.parentNode).css(opts.outer)
					.find('div').css(opts.div).each(function(i){$(this).css(opts[['head','clear','body','warn','foot'][i]])})
					.find('input:text').css(opts.input).end()
					.find('input:image').css(opts.button).slice(1).css({display:'none'}).end().end().end();
				outer.find('input:image').eq(0).click(
						function(){
							var arMsg = [];
							var ar = '真实姓名,联系电话,'.concat((opts.idcard?'证件号码,':''),'收货地址,邮政编码').split(',');
							var arReg = [/^.*$/, opts.idcard];
							var txts = outer.find('input:text');
							txts.each(function(i){
								var ipt = $(this);
								if(ipt.val().empty()) arMsg.push(ar[i]);
								else ipt.attr({title:ipt.val()})
							});
							var msg = '';
							if(arMsg.length==0){
								txts.css(opts.locked).attr({readOnly:true}).end().find('input:image').slice(0,1).hide().end().slice(1).show();
								msg = opts.message;
							}
							$.userinfo.impl.msg(msg||'<span style="color:red">'+'您还没有填写您的 '+arMsg+'</span>');
						}
					).end().eq(2).click(
						function(){
							outer.find('input:text').css(opts.input).attr({readOnly:false}).each(function(i){$(this).attr({title:''})}).end()
								.find('input:image').slice(0,1).show().end().slice(1).hide();
							outer.find('div:eq(3)').css({visibility:'hidden'});
						}
					).end().eq(1).click(
						function(){
							var cgi = opts[($.userinfo.impl.data.name==undefined?'add':'mod')+'cgi_'+!!opts.idcard];
							var getparam = (cgi.split('?')[1]||'').toJson('&','=',function(v){return decodeURIComponent(v)});
							var key = ('name,phone,id,addr,postno').split(','),data={};
							outer.find('input:text').each(function(i){data[key[i]] = this.value.trim();});
							$.extend(data,getparam);
							$.post(cgi.split('?')[0],data,function(res){
								var callback = function(rc){
									var nick = getNick();
									switch(rc){
										case '0': $.userinfo.impl.msg('亲爱的'+nick.html()+'：您的个人信息保存成功了，恭喜您！'); $.extend($.userinfo.impl.data,data); break;
										case '20012': $.userinfo.impl.msg('亲爱的'+nick.html()+'：您的登录已经超时了，请重新登录！'); login($.extend(opts.loginopts,{callback:function(){
											outer.find('input:image')[2].click();
										}}),opts.logincss); break;
										default: $.userinfo.impl.msg('亲爱的'+nick.html()+'：对不起，保存您的个人信息时发生未知错误！错误码:'+rc);break;
									}
									setTimeout(function() {outer.slideUp('fast');(opts['callback']||function() {})();},2000);
								}
								eval(res.replace(/<script>(.*?)<\/script>/gi, '$1').replace(/frameElement\./g, ''));
							});
							outer.find('input:image').attr({disabled:true});
							setTimeout(function(){outer.find('input:image').attr({disabled:false})},1500);
						}
					)
			}
			this.outer.fadeIn();
			if(opts.hidden && opts.hidden.hide) opts.hidden.hide();
			this.outer.find('input:text').each(function(i){$(this).val($.userinfo.impl.data[('name,phone,idcard,addr,postno').split(',')[i]]) });
		},
		msg:function(html){
			var div = this.outer.find('div:eq(3)').css({visibility:'visible'});
			div.html(html).fadeIn('fast',function(){div.fadeOut('fast',function(){div.fadeIn('fast',function(){div.fadeOut('fast',function(){div.fadeIn('fast')})})})});
		},
		close:function(fn){
			if($.isFunction(fn)) fn.call(this.outer,this.data);
			this.outer.fadeOut('fast',(function(impl){ return function(){if(impl.opts.hidden && impl.opts.hidden.hide) impl.opts.hidden.fadeIn('fast');}})(this));
			//if(this.opts.hidden && this.opts.hidden.hide) this.opts.hidden.show();
		}
	};
})(jQuery);

//kunerzhang:改进的修改用户信息

var popUserInfo = {
		version :'1.0',
		author :'kunerzhnag',
		config : {
			postUrl : 'http://qdou.qq.com/cgi-bin/qbean',
			isAdd:false,
			baseURL : 'http://qdou.qq.com/',
			hasContainer : 0,
			container : (function() {
				if (arguments.callee.container) return arguments.callee.container;
				var div = document.createElement('div');
				div.id = 'alert_container';
				with(div.style) {
					position = 'absolute';
				}
				arguments.callee.container = $(div);
				return $(div);
			}) (),
			html : '',
			htmlLoaded : 0
		},	
		init: function() {
			var t = this;
			if(t.config.htmlLoaded ==0)
			{
				t.getHTML();
			}
		},

		getAttrs : function(_str) {
			var o = {};
			var aratt = _str.replace(/^\s+|\s+$/).split(/\s+/g);
			for (var i=0; i<aratt.length; i++) {
				o[aratt[i].split('=')[0]] = aratt[i].split('=').slice(1).join('=').replace(/["']/g, '');//"
			}
			return o;
		},
		getHTML : function () {
			var t = this, url = t.config.baseURL + '/user.html'
			$.ajax.charset = 'gb2312';
			$.get(url, {}, function (res) {
				t.config.html = res.replace(/[\r\n\t]/g, '');
				t.config.htmlLoaded = 1;
			});
		},
		
		reSize:function () {
			var t = this, c = t.config;
			parent.$('#alert_container');
			var ifr = parent.$('#alert_container').find('ifr');

		},
		append : function () {
			if (arguments.callee.dom) arguments.callee.dom.remove();
			var t = this, c = t.config;
			arguments.callee.dom = c.container;
			c.container.appendTo('body');
			if (parent.third_resize) {

				setTimeout(function() {
				parent.third_resize({
					width:c.container.width(),
					height:c.container.height()
				});
				}, 100);
			}
		},

		userInfo:function(settings){
			var t = this, c = t.config, html;

				//校验普通电话、传真号码：可以“+”开头，除数字外，可含有“-”   
  			var isTel=function (s)   
 			 {   
  				var   patrn=/^[+]{0,1}(\d){1,3}[   ]?([-]?((\d)|[   ]){1,12})+$/;   
  				if   (!patrn.exec(s))   return   false   
  				return   true   
 			}   
    
 				 //校验手机号码：必须以数字开头，除数字外，可含有“-”   
  			var isMobil=function (s)   
  			{   
  				var   patrn=/^[+]{0,1}(\d){1,3}[   ]?([-]?((\d)|[   ]){1,12})+$/;   
 				 if   (!patrn.exec(s))   return   false   
 				 return   true   
 			 }   
    
  				//校验邮政编码   
  			var isPostal=function (s)   
			 {   
			 
 	 			var   patrn=/^[0-9   ]{6}$/;   
  				if   (!patrn.exec(s))   return   false;
  				return   true;
  			}   

			//获取字符串的真实长度
			var strGetLen=function (str) {
				var len = 0;
				for (var i=0; i<str.length; i++) {
				  if (str.charCodeAt(i) > 127)
				   len += 3; //utf8格式下中文占3位，gb2312请修改位2位
				  else 
				   len++;
				}
				return len;
			} 

			//提交用户信息数据
			var postData=function(data)
			{
				if(data.length<1)
					return;
				$.post(c.postUrl,data,function(res){
	 				 var callback = function(rc){
	 					switch(rc)
				  		{
				  			case '20012':alert("对不起，您登录超时或者尚未登录，请您先登录！");
								login.quit();c.container.find('a,button[cmd="close"]').click();
								showLogin({auto:true});break;
							case '0':
								$("#alertinfo").html('您的个人信息保存成功了，恭喜您！');
								//提示信息闪烁2秒钟后对话框消失
        							var succ=function(){
        									var num=0;
       									 $("#alertinfo").attr('timer',setInterval(function () {
											$("#alertinfo").css({opacity:num++%2?1:.4});
											},400));

       										setTimeout(function(){if (!$('#alertinfo').attr('timer')) {return;}clearInterval($('#alertinfo').attr('timer'));c.container.find('a[cmd="close"]').click()},2000);
      											 }();
											break;
							default:alert('对不起，保存您的个人信息时发生未知错误！错误码:'+rc);break;
				  		 	
				  		}
			     					
		        
			}
			    	eval(res.replace(/<script>(.*?)<\/script>/gi, '$1').replace(/frameElement\./g, ''));
			  });
			};

			//检查用户输入
			var checkInput=function()
			{
				var alertMsg=[];
				var errMsg=['真实姓名','证件号码','联系电话','收货地址','邮政编码'];
				var strlen=[20,32,32,100,32];
				var str="";
				$("#input_table input").each(function(i){
					if($(this).val()<1)
						alertMsg.push(errMsg[i]);				
				})
				if(alertMsg.length>0)
				{
					$("#alertinfo").html("您还没有填写您的： "+alertMsg.join('、'));
					return ;
				}

				/*alertMsg=[];
				$("#input_table input").each(function(i){
					str=$(this).val().trim();
					if(strGetLen(str)>strlen[i])
						alertMsg.push(errMsg[i]);				
				})*/

				
					
				
			/*	if(alertMsg.length>0)
				{
					$("#alertinfo").html("您的： "+alertMsg.join('、')+"  字符过长。");
					return ;
				}*/
					
				
				var postMsg={};
				var strid;
				$("#input_table input").each(function(i){
					       strid=$(this).attr('id');
						if(strid=='idcard') strid='id';
						postMsg[strid]=$(this).val();
				})

				if(strGetLen(postMsg['name'])>20)
				{
					$("#alertinfo").html("真实姓名 最长可填写6个中文汉字，或者20个英文字母/数字");
					return;
				}

				if(strGetLen(postMsg['addr'])>100)
				{
					$("#alertinfo").html("收货地址 最长可填写33个中文汉字，或者50个英文字母/数字");
					return;
				}
	
				
				if(!isTel(postMsg['phone']) || !isMobil(postMsg['phone']))
				{
					alert("对不起，您的联系电话填写不正确！");
					return;
				}
				if(!isPostal(postMsg['postno']))
				{
					alert("对不起，您的邮政编码填写不正确！");
					return;
						
				}
				
				if(c.isAdd)
						postMsg['cmd']='comm_adduseraddr';
					else
						postMsg['cmd']='comm_moduseraddr';
				
				postMsg['configid']='q';

				postData(postMsg);
				
			};
		
			//获得用户信息
			var getUserInfo=function()
			{
				var o={configid:'q',cmd:'comm_getuseraddr','_':Math.random()};
				 c.isAdd=false;
				$.get(c.postUrl,o,function(res){
					var callback=function(rc, userinfo){
						switch(rc){
							case '0':
								      c.isAdd=false;
								      $.each(userinfo,function(p,v){
									 	$("#"+p).val(v);;
								      });
								      $("#alertinfo").html('您已成功保存了您的个人信息！');
								       break;
							case '20012':
								      alert('对不起，您还没有登录，或者登录已超时！');
									  login.quit();c.container.find('a,button[cmd="close"]').click();
									 showLogin({auto:true});
								      return;
							case '30003':
								     c.isAdd=true;
								      $("#name").val('');
								      $("#postno").val('');
							             $("#phone").val('');
								      $("#addr").val('');
								      $("#cardid").val('');
								      $("#alertinfo").html('您还没有填写过您的个人信息！');
								    	break;
							case '20015':
								    alert("对不起，该活动已结束，感谢您的参与，敬请关注腾讯更多精彩活动！");
								    return;
							default:alert('对不起，获取您的个人信息时发生未知错误！\n错误码:'+rc);
							            return;				 
		                		 }
			

		 		}
				eval(res);
			     });
			};

			var regHandler=function()
			{		
				c.container.find('a,button[cmd="close"]').click(function () {
					mask.hide();
					if(settings)
					if ($.isFunction(settings['onClose']))
						settings['onClose'].call(this);
					c.container.find('div[container="6"]').remove();
					if (parent.third_close) {parent.third_close();}
					return false;
				});
				getUserInfo();
				
				c.container.find('button[cmd="submit"]').click(checkInput)
			};
			(function () {
				if(!login.is())
				{	
					alert('对不起，您还没有登录，或者登录已超时，请重新登录！');
					showLogin({auto:true});return;
				}
				t.init();
				if (!t.config.htmlLoaded) {setTimeout(arguments.callee, 10);return;}  
					var reg = /<\!\-\-userinfo\-\->.*<\!\-\-enduserinfo\-\->/g;
				
				html = t.config.html.match(reg).join('');
				c.container.html(html);
				t.append();
				c.container.center();
				mask.show();
				regHandler();
			}) ();
		}
}

var awardInfo = $.extend(true, {}, {
	'LTMCLUB_31':{desc:'会员一个月体验',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_01.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'XXJZGW_31':{desc:'黄钻一个月体验',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_02.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'XXQQF_31':{desc:'红钻一个月体验',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_08.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'XXZXYY_31':{desc:'绿钻一个月体验',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_07.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'1':{desc:'16cmQQ公仔一对',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/pic_03.jpg', sometxt:'<a href="http://qdou.qq.com/prize.html?add=">查询</a>',tips:'您所获得的实物奖品，将会在兑奖后60个工作日内寄出。寄出前腾讯客服工作人员将对您进行电话回访，确认收件地址。请您现在就填写<a href="prize.html?addr=1">个人详细信息</a>，以便我们为您及时寄送奖品。'},
	'2':{desc:'抱枕一个',pic:'', sometxt:'<a href="http://qdou.qq.com/prize.html?add=">查询</a>',tips:'您所获得的实物奖品，将会在兑奖后60个工作日内寄出。寄出前腾讯客服工作人员将对您进行电话回访，确认收件地址。请您现在就填写<a href="prize.html?addr=1">个人详细信息</a>，以便我们为您及时寄送奖品。'},
	'3':{desc:'200 Q币',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/pic_04.jpg', sometxt:'<a href="http://my.qq.com/" target="_blank"></a>',tips:'您所获得的Q币奖品，将会在兑奖后30个工作日内发放至您的中奖QQ号码个人账户。届时请登陆您的个人账户查收。'},
	'4':{desc:'50 Q币',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/pic_04.jpg', sometxt:'<a href="http://my.qq.com/" target="_blank"></a>',tips:'您所获得的Q币奖品，将会在兑奖后30个工作日内发放至您的中奖QQ号码个人账户。届时请登陆您的个人账户查收。'},
	'5':{desc:'会员、黄钻、红钻、绿钻各一个月',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/pic_05.jpg',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com" target="_blank">"“我的QQ>个人增值业务”</a>查询。'},
	'6goodsset090413152407877':{desc:'1个月会员',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_01.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'6goodsset090413152503502':{desc:'1个月黄钻',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_02.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'6goodsset090413152528987':{desc:'1个月红钻',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_08.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'6goodsset090413152637565':{desc:'1个月绿钻',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_07.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank">查询</a>',tips:'您所获得腾讯产品包月体验，将会在24小时内发放至您的中奖QQ号码。请登陆<a href="http://my.qq.com/my_service.html" target="_blank">"“我的QQ&gt;个人增值业务”</a>查询。'},
	'7goodsset090416100431549':{desc:'会员5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_01.gif', sometxt:'<a href=" http://paycenter.qq.com/club/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'7goodsset090416100535331':{desc:'黄钻5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_02.gif', sometxt:'<a href="http://paycenter.qq.com/home/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'7goodsset090416100600143':{desc:'红钻5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_08.gif', sometxt:'<a href="http://paycenter.qq.com/qqshow/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'7goodsset090416100630737':{desc:'绿钻5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_07.gif', sometxt:'<a href=" http://paycenter.qq.com/music2/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'20090416093239424':{desc:'会员5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_01.gif', sometxt:'<a href="http://paycenter.qq.com/club/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'20090416093434081':{desc:'黄钻5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_02.gif', sometxt:'<a href="http://paycenter.qq.com/home/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'20090416093515502':{desc:'红钻5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_08.gif', sometxt:'<a href="http://paycenter.qq.com/qqshow/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'20090416093545831':{desc:'绿钻5元抵用券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_07.gif', sometxt:'<a href=" http://paycenter.qq.com/music2/" target="_blank">使用</a>',tips:'您所获得的腾讯产品抵扣券，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>中查询使用。'},
	'20090408095926775':{desc:'16cmQQ公仔一对',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_05.gif', sometxt:'<a href="http://qdou.qq.com/prize.html?add=">查询</a>',tips:'您所获得的实物奖品，将会在兑奖后60个工作日内寄出。寄出前腾讯客服工作人员将对您进行电话回访，确认收件地址。请您现在就填写<a href="prize.html?addr=1">个人详细信息</a>，以便我们为您及时寄送奖品。'},
	'20090408100010781':{desc:'抱枕',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_06.gif', sometxt:'<a href="http://qdou.qq.com/prize.html?add=">查询</a>',tips:'您所获得的实物奖品，将会在兑奖后60个工作日内寄出。寄出前腾讯客服工作人员将对您进行电话回访，确认收件地址。请您现在就填写<a href="prize.html?addr=1">个人详细信息</a>，以便我们为您及时寄送奖品。'},
	'20090408100052645':{desc:'200元Q币',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_04.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank"></a>',tips:'您所获得的Q币奖品，将会在兑奖后30个工作日内发放至您的中奖QQ号码个人账户。届时请登陆您的个人账户查收。'},
	'20090408100132666':{desc:'50元Q币',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_04.gif', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank"></a>',tips:'您所获得的Q币奖品，将会在兑奖后30个工作日内发放至您的中奖QQ号码个人账户。届时请登陆您的个人账户查收。'},
	'20090422145619293':{desc:'Q豆',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_09.gif',tips:'您所获得的Q豆，已经发放至您的中奖QQ号码，请注意查询您当前的Q豆数。如因网络原因发放失败，将会在24小时内补发。您可以在<a href="prize.html">“我的奖品”</a>中查询获得的Q豆总数。'},
	'20090515105745697':{desc:'Q豆乐园2009Q币',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/pic_04.jpg', sometxt:'<a href="http://my.qq.com/my_service.html" target="_blank"></a>',tips:'恭喜您获得 2009个Q币！您所获得的Q币奖品，将会在兑奖后30个工作日内发放至您的中奖QQ号码个人账户。届时请登陆您的个人账户查收。'},
	'8':{desc:'QQ优惠兑换码1个',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_03.gif',tips:'您所获得的QQ优惠兑换码，将会在24小时内发放至您的中奖QQ号码。您可以在<a href="prize.html">“我的奖品”</a>查询使用。使用QQ优惠兑换码可以在QQ兑奖乐园领取腾讯服务优惠购买资格，享受更优惠的价格，同样获得等量Q豆。<a href="http://free.qq.com" target="_blank">去QQ兑奖乐园&gt;&gt;</a>'},
	'9':{desc:'Q豆',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_09.gif',tips:'您所获得的Q豆，已经发放至您的中奖QQ号码，请注意查询您当前的Q豆数。如因网络原因发放失败，将会在24小时内补发。您可以在<a href="prize.html">“我的奖品”</a>中查询获得的Q豆总数。'},
	'10':{desc:'20元拍拍红包', pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_paipai.jpg',tips:'您所获得拍拍网20元红包，将会在10个工作日内发放至您的中奖QQ号码拍拍账户。届时请登陆您的<a href="http://my.paipai.com/hongbao.shtml?PTAG=10012.35.2" target="_blank">我的拍拍>我的红包/现金券</a>中查询并使用。拍拍红包自发放日起15天内有效，详见<a href="http://www.paipai.com/hongbao/help.shtml#1?PTAG=10012.35.2" target="_blank">拍拍网红包使用规则</a>。',sometxt:'<a href="http://qdou.qq.com/help.html?t=9" target="_blank">了解详情</a>'},
	'20090826104550013':{desc:'20元拍拍红包', pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_paipai.jpg',tips:'您所获得拍拍网20元红包，将会在10个工作日内发放至您的中奖QQ号码拍拍账户。届时请登陆您的<a href="http://my.paipai.com/hongbao.shtml?PTAG=10012.35.2" target="_blank">我的拍拍>我的红包/现金券</a>中查询并使用。拍拍红包自发放日起15天内有效，详见<a href="http://www.paipai.com/hongbao/help.shtml#1?PTAG=10012.35.2" target="_blank">拍拍网红包使用规则</a>。',sometxt:'<a href="http://qdou.qq.com/help.html?t=9" target="_blank">了解详情</a>'},
	'20090826104457054':{desc:'10元拍拍红包', pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_paipai.jpg',tips:'您所获得拍拍网10元红包，将会在10个工作日内发放至您的中奖QQ号码拍拍账户。届时请登陆您的<a href="http://my.paipai.com/hongbao.shtml?PTAG=10012.35.2" target="_blank">我的拍拍>我的红包/现金券</a>中查询并使用。拍拍红包自发放日起15天内有效，详见<a href="http://www.paipai.com/hongbao/help.shtml#1?PTAG=10012.35.2" target="_blank">拍拍网红包使用规则</a>。',sometxt:'<a href="http://qdou.qq.com/help.html?t=9" target="_blank">了解详情</a>'},
	'11':{desc:'3元手机充值券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_chong3.jpg',tips:'活动中所获得的手机充值券，将会在5个工作日内发放至您中奖QQ号码的财付通账户中，直接抵用手机话费。届时请登陆您的<a href="https://www.tenpay.com/pay_ten.shtml" target="_blank">财付通>优惠>我的优惠券</a>中查询并使用，并确保已<a href="https://www.tenpay.com/zft/register_1.shtml?tag=qq" target="_blank">开通财付通账户</a>。手机充值券自发放之日起10天内有效，请及时查询使用。'},
	'20091116163919875':{desc:'3元手机充值券',pic:'http://imgcache.qq.com/qdou/portal_qdou_v1/img/prize_chong3.jpg',sometxt:'<a href="http://qdou.qq.com/help.html?t=9" target="_blank">了解详情</a>'}
});


(function($) { 
window.mask = $.extend(true, {}, {
	has : false,
	show : function () {
		if ($('#pagemask').size()==0) {
			$('<div id="pagemask" style="width:'+$(document.documentElement).get(0).scrollWidth+'px; height:'+$(document.documentElement).get(0).scrollHeight+'px;left:0px; top:0px;z-index:100; background-color:#000;position:absolute;"></div>').css({opacity:.4}).appendTo('body');
		}
		else {$('#pagemask').css({width:$(document.documentElement).get(0).scrollWidth, height:$(document.documentElement).get(0).scrollHeight}).show();}
		if ($.browser.msie&&$.browser.version<7) $('select').hide();
		$(window).resize(function () {
			if (mask.has) {
				$('#pagemask').css({width:$(document.documentElement).get(0).scrollWidth, height:$(document.documentElement).get(0).scrollHeight}).show();
			}
		});
		this.has = true;
	},

	hide : function () {
		$('#pagemask').hide();
		if ($.browser.msie&&$.browser.version<7)$('select').show();
		mask.has = false;
	}
});
}) (jQuery);


function getNick(fmt){
	var qq = login.is();
	if(!qq) return false;
	var nick = unescape(cookie("actnick")).trim();
	if(nick.empty())
		fmt='[%qq%]';
	else
		fmt = fmt || '[%nick%]([%qq%])';
	return fmt.replace(/\[%nick%\]/g,nick).replace(/\[%qq%\]/g,qq);
}

function copyToClipboard(txt,cbf){
	if(window.clipboardData && window.clipboardData.setData){
		if(!window.clipboardData.setData("Text",txt)){
			alert("复制文本内容失败!"); return false;}
	}else if($.browser.opera && navigator.mimeTypes["application/x-shockwave-flash"]){
		var d = document.createElement("div");
		document.getElementsByTagName("body")[0].appendChild(d);
		d.innerHTML="<embed src='/common/flash/clipboard.swf' FlashVars='clipboard="+escape(txt)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
	}else if(window.netscape){
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
		}catch(e){
			alert('您的firefox安全限制限制您进行剪贴板操作!\n您可以在地址栏中输入"about:config"将"signed.applets.codebase_principal_support"设置为"true"来开启此功能!');
			return false;
		}
		try {
			clip=Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard)
			trans=Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable)
		}catch(e){return false;}
		trans.addDataFlavor("text/unicode");
		var oStr=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		oStr.data=txt;
		trans.setTransferData("text/unicode",oStr,txt.length*2);
		try{clipid=Components.interfaces.nsIClipboard}catch(e){return false;}
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}else{
		alert("该功能只支持MSIE，firefox和opera浏览器！");
		return false;
	}
	if(cbf instanceof Function) cbf();
}

function showLogin(arg) {
	var user=login.is();
	var callback =function() {showLogin();showQdouInfo();if(arg&&arg['callback']) arg['callback']();};
	if (user) {
		$('#loginInfo').html('亲爱的QQ用户，<span>' +(($.cookie('actnick').html())||user)+'</span> 您好！ <a href="" onclick="login.quit();">[退出]</a>');
		showQdouInfo();
	}
	else {
		$('#loginInfo').html('尊敬的QQ用户，请您先  <a href="#" id="toLogin">登录</a>');
		if (arg&&arg['auto']) {login({callback:callback,qlogin_redirect_url:(arg['qlogin_redirect_url']||location.href)});}
		$('#toLogin').login({callback:callback,qlogin_redirect_url:(arg && arg['qlogin_redirect_url']||location.href)});
	}
	if (!$.cookie('actnick')) 
		$.get('/cgi-bin/qbean?configid=q&cmd=comm_getnick', function(res) {
			var callback = function (rc, nick) {
				$.cookie('actnick', nick);
				//$.cookie('actnick', nick,{path: '/',domain: 'qdou.qq.com'});
				$('#loginInfo').find('span').html(nick.html()||login.is());
			}
			eval (res);
		});

}

function showQdouInfo(fn) {
	if (!login.is()) {$('#qdouInfo').html('您还没有登录');return false;}
	var url = '/cgi-bin/qbean?configid=q&cmd=qbean_get';
	$.get(url, {}, function (res) {
		var callback = function (rc1, rc2) {
			switch(rc1) {
				case '0':
					$('#qdouInfo').html('您当前的Q豆数： <span>'+rc2['qdou']+'</span> 豆<span class="icon">&#9654;</span><a href="http://qdou.qq.com/qdou.html">领取当月Q豆</a>');
					if ($.isFunction(fn)) {fn(rc2['qdou'])}
					$("#myqdou").html(rc2['qdou']);
					$("#qdouunit1").html('个');
					break;
				default:
					$('#qdouInfo').html('');
					$("#myqdou").html('');
					$("#qdouunit1").html('');
					break;
			}
		}
		eval(res);
	});
}

/*@ 描述：购买公用展示层
 *@ 参数：cfn-回调函数；opt-来源，从哪个页面过来，默认为all；alt-游戏中购买true，主动购买false
 */
function showExchange(cfn, opt, alt) {
	var kind = {star:'light,li_ta,magic', tarot:'tarot', all:'light,tarot,li_ta,magic,leisu',leisure:'leisu'};
	var itemlist = {
		'light':{price:20,name:'星座馆点亮游戏券',units:'张'},
		'magic':{price:100,name:'星座馆魔法棒',units:'个'},
		'star+tarot':{price:60,name:'点亮游戏券+竞猜游戏券',units:'张'},
		'tarot':{price:50,name:'竞猜游戏筹码',units:'个'},
		'leisu':{price:20,name:'休闲游戏券',units:'张'},
		'leisu+tarot':{price:60,name:'休闲游戏券+竞猜游戏券',units:'张'}
	};
	opt = opt||'all';
	var ckind = kind[opt];
	var all_tmp = '';
	if (!login.is()) {login({callback:function(){showLogin();showExchange(cfn, opt, alt)},qlogin_redirect_url:location.href});return;}
	mask.show();
	var initNum = 0, maxNum = 10000,price = 50;
	var C = function () {$('#exchange').hide();mask.hide();return false;}
	
	var filterInput = function (evt) {
		evt = evt||event;
		var code = evt.keyCode||evt.charcode;
		if (evt.ctrlKey) return false;
		if ((code>57 || code<48) && (code>105 || code<96) && code!=8 && code!=46 && code!=37&&code!=39) return false;
		setTimeout(calculate,0);
	};
	var calculate = function () {
		var total = 0;
		var ar = [], showextinfo = $('#showextinfo');
		$('#exchange').find(':text').each(function (i, n) {
			if (!/^\d+$/.test(n.value)) return;
			total += (parseInt(n.value.replace(/^0+/g,''))||0) * (+ n.getAttribute('k'));
			if (n.value != '0') ar.push('<span class="em">' + n.value.replace(/^0+/g, '') + '</span>' + (itemlist[n.getAttribute('kind')]['units']||'张') + itemlist[n.getAttribute('kind')]['name']);
		});
		showextinfo.html('您将兑换：' + ar.join('，')).attr('title', '您将兑换：' + ar.join('，').replace(/<.*?>|<\/.*?>/g, ''));
		$('#totalqdounum').html(total||'0');
		return total;
	}
	var common = function () {
		$('#totalqdounum').html('0');
		$('#showextinfo').html('');
		$('#exchange :text').val(initNum);
		if (opt != 'all') {
			$('#exchange div[cmd="btntab"]').remove();
		}
		else {
			$('#exchange div[cmd*="+"]').hide();
			$('#exchange div[cmd="btntab"] button').unbind('click').click(function (evt) {
				$('#exchange div[cmd="btntab"] button').addClass('sel');
				this.className = '';
				var dis = {
					single:function() {$('#exchange div[cmd][cmd!="btntab"]').show();$('#exchange div[cmd*="+"]').hide();},
					multi:function() {$('#exchange div[cmd][cmd!="btntab"]').hide();$('#exchange div[cmd*="+"]').show();}
				};
				dis[this.getAttribute('cmd')]();
				this.blur();
			});
			$('#exchange div[cmd="btntab"] button').eq(0).click();
		}
		if (alt) 
			$('#exchange .my_ticket').css({'visibility':'visible'}).css({'color':'red'}); 
		else $('#exchange .my_ticket').css({'visibility':'hidden'});
		$('#exchange').find(':text').unbind('keydown keypress keyup').keydown(filterInput).bind('contextmenu', function() {return false;}).focus(function() {
			if (this.value == '' || this.value == '0') this.value = '1';
			$(this).caret(0, this.value.length);
			calculate();
		});
		$('#exchange').find('img').unbind('click').click(function() {var chk = $(this).parent().next().find(':text').focus();});
		$('#exchange').find('.ticket_item').each(function (i, n) {
			$(n).find(':text').attr('k', itemlist[(n.getAttribute('cmd')||n.parentNode.getAttribute('cmd'))]['price'])
				.attr('kind', (n.getAttribute('cmd')||n.parentNode.getAttribute('cmd')));
			$(n).attr('kind', itemlist[(n.getAttribute('cmd')||n.parentNode.getAttribute('cmd'))]['kind']);
			$(n).attr('units', itemlist[(n.getAttribute('cmd')||n.parentNode.getAttribute('cmd'))]['units']);
			$(n).attr('kindname', itemlist[(n.getAttribute('cmd')||n.parentNode.getAttribute('cmd'))]['name']);
		//	if (n.parentNode.getAttribute('cmd').indexOf(opt)<0) $(n).remove();
		}).end()
		.find('.close a').unbind('click').click(C).end()
		.find('button[cmd="op"]:eq(1)').unbind('click').click(C).end()
		.find('button[cmd="op"]:eq(0)').unbind('click').click(function () {
			var num = calculate.call(null);
			if (+$('#qdouInfo span').html()>0 && +$('#qdouInfo span').html()<num) {if(confirm('您没有足够的余额进行支付，现在就去领取！')) window.open('http://my.qq.com');return false;}
			if (!num) {alert('请您选择需要兑换的游戏机会！');return false;}
			var url = '/cgi-bin/qbean';
			var items = [];
			var outer = {};
			var _fortxt = [];
			var postmap = {'star+tarot':'li_ta', 'leisu+tarot':'ta_le'}
			$('#exchange').find('.ticket_item').each(function (i, n) {
				if ($(n).find(':text').val().trim() == '') return;
				if ($(n).find(':text').val().trim() == '0') return;
				if ($(n).find(':text').attr('kind').indexOf('+')) {
					var s = $(n).find(':text').attr('kind').split('+');
					for (var i=0; i<s.length; i++) {
						if (!outer[s[i]]) {
							outer[s[i]] = +$(n).find(':text').val();
						}
						else {
							outer[s[i]] += +$(n).find(':text').val();
						}
					}
				}
				//outer[$(n).find(':text').attr('kind').split('+')[1]] = +$(n).find(':text').val();
				var pk = $(n).find(':text').attr('kind');
				items.push((postmap[pk]||pk)+'*'+$(n).find(':text').val());
				var _o = {};
				_o['xx'] = $(n).attr('kindname');
				_o['nn'] = parseInt($(n).find(':text').val().replace(/^0+/g,''));
				_o['pp'] = $(n).attr('units');
				_fortxt.push(_o);
			});
			var buybtn = this;
			this.disabled = true;
			$.post(url, {configid:'q', cmd:'shop_buy', item:items.join(',')}, function (res) {
				var callback = function (rc1, rc2) {
					buybtn.disabled = false;
					switch(rc1) {
						case '10608': alert('您提交的商品出错，请核对！');break;
						case '10611': if(confirm('您没有足够的余额进行支付，现在就去领取！')) window.open('http://qdou.qq.com/qdou.html');;break;
						case '0':
							var fn = '__close' + new Date().getTime() + Math.ceil(Math.random() * 100);
							var succhtml = '<div class="dialog"><div class="change_succ my_info">'
							+'	<div class="my_ticket_left"></div>'
							+'	<div class="my_ticket_con" style="position:static">'
							+'		<div class="title_bg"></div>'
							+'		<h2>兑换游戏券</h2>'
							+'		<div class="succ_info">兑换成功!快去体验精彩游戏吧!</div>'
							+'		<div class="btn">'
							+'			  <button class="btn_ok" onclick="'+fn+'()">确  定</button>'
							+'		</div>'
							+'		<div class="auto_close">本窗口 <span id="closetips' + fn + '" style="color:red;">3</span> 秒后自动关闭</div>'
							+'		<div class="close"><a href="#" title="关闭" onclick="'+fn+'();return false;">&#215;</a></div>'
							+'	</div>'
							+'	<div class="my_ticket_right"></div>'
							+'</div></div>';

							var ss = $(succhtml).appendTo('body');							
							setTimeout(function() {mask.show();ss.css('z-index', 110).center();},100);

							window[fn] = function () {
								ss.remove();
								mask.hide();
							}
							var second = 3;
							(function() {
								if (second == 0) {window[fn]();clearTimeout('timers' + fn);}
								$('#closetips' + fn).html(second--);
								window['timers' + fn] = setTimeout(arguments.callee, 1000);
							}) ();
							
							$('#qdouInfo').html('您当前的Q豆数： <span>'+rc2['qdou']+'</span> 豆<span class="icon">&#9654;</span><a href="http://qdou.qq.com/qdou.html">领取当月Q豆</a>');
							if ($.isFunction(cfn)) setTimeout(function() {cfn($.extend(true, outer, {qdou:rc2['qdou']}));},0);
							break;
						default:alert('系统繁忙，请稍候再试！');break;
					}
					C();
				}
				eval(res.replace(/<script>(.*?)<\/script>/gi, '$1').replace(/frameElement\./g, ''));
			});
		}).end()
		.find('>div>div:last a').click(C);
	}
	if (!$('#exchange').size()) {
		$.get('dialog.html', {}, function (res) { 
			var dia = $(res).appendTo('body').hide();
			dia.css({'z-index':110})
			dia.find('>div:first').get(0).className = 'alert_ticket ' + ('alert_ticket_'+{star:2,tarot:3,leisu:4,all:'v2'}[opt]);
			dia.center().show();
			
			setTimeout(function() {common();},0);
		});
	}
	else {
		var dia = $('#exchange').find('>div:first');
		dia.get(0).className = 'alert_ticket ' + ('alert_ticket_'+{star:2,tarot:3,leisu:4,all:'v2'}[opt]);
		dia.end().show().center();
		common();
	}
}

function debug() {
	if (!arguments.callee.fn) arguments.callee.fn = '__' + new Date().getTime();
	var arg = arguments;
	function encode(str) {
		if (typeof str != 'string') return str;
		return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
	}
	var fn = arguments.callee.fn, win, doc;
	window[fn] = function(o, key, index) {
		key = key || '';
		var str = '<ul style="padding:0px; margin:0px 10px; list-style:none;font-size:12px;">';
		if ({_string:1,_number:1,_boolean:1,_function:1}['_'+typeof o]) {
		//	for (var i=0; i<arg.length; i++) {
				str += '<li><b>'+typeof o+'</b>:<span style="color:gray; font-style:italic; font-family:Courier, "Courier New", monospace;">' + encode(o)+'</span></li>'; 
		//	}
		}
		else for (var i in o) {
			var s = '';
			try {s = encode(o[i]);}catch (e) {s=''};
		//	if (i == fn || i == fn + '__click') continue;
			if (typeof o[i] == 'string' || typeof o[i] == 'number' || o[i] === null) str+='<li><b>'+i+'</b>:<span style="color:gray; font-style:italic;font-family:Courier, "Courier New", monospace;">' + s +'</span></li>';
			else if ( typeof o[i] == 'function' ) str+='<li><b>'+i+'</b>:function() {...}</li>';
			else if (o[i] instanceof Array) str += '<li><span style="cursor:pointer;font-size:10px; padding:2px;margin:1px;" onclick="'+fn+'__click(this, \''+ (key?key + ',':'') + i +'\', ' + index + ');return false;">+</span><b>'+i+'</b>:[...]</li>';
			else {
				str += '<li><span style="cursor:pointer;font-size:10px; padding:2px;margin:1px;" onclick="'+fn+'__click(this, \''+ (key?key + ',':'') + i +'\', ' + index + ');return false;">+</span><b>'+i+'</b>:{...}</li>';
			}
		}
		str+='</ul>';
		return str;
	}
	window[fn + '__click'] = function (obj, key, index) {
		obj.innerHTML = obj.innerHTML.replace(/(\+|\-)/g, function(_1) {return _1=='+'?' -':'+';});
		var ul = obj.parentNode.getElementsByTagName('ul');
		if (ul.length>0) {ul[0].style.display = ul[0].style.display == ''?'none':'';return false;}
	    var ks = key.replace(/,$/, '').split(','), _o = arg[index];
	    for (var i=0; i<ks.length; i++) _o = _o[ks[i]];
		try{obj.parentNode.innerHTML += window[fn](_o, key, index)||'';}catch(e){};
	}
	function __typeof__(obj) {
		return obj.constructor ? (obj.constructor.toString().replace(/function\s*([^\(]+)?\((?:.|\n)*/g, '$1')||typeof obj) : typeof obj;
	}

	var str = '<div style="position:absolute;left:100px; top:100px; z-index:10000; width:425px; text-align:left;">'
	+'<div style="background-color:#000000; text-align:right; height:20px;font-size:14px; color:white; font-weight:700; padding:5px;"><span style="float:left;">JavaScript - RunTime查看工具1.0</span><a href="javascript:;" style="color:red; margin:0px 5px; text-decoration:none;" onclick="this.parentNode.nextSibling.style.display=this.innerHTML==\'＋\'?\'\':\'none\';this.parentNode.parentNode.nextSibling.style.height=this.innerHTML==\'＋\'?\'530px\':\'30px\';this.innerHTML = this.innerHTML==\'＋\'?\'－\':\'＋\';this.blur();">－</a><a href="javascript:;" onclick="document.body.removeChild(this.parentNode.parentNode.nextSibling);document.body.removeChild(this.parentNode.parentNode);" style="color:red;margin:0px 5px; text-decoration:none;">×</a></div>'
	+'<div style="overflow:auto; background-color:lightgreen; height:500px;width:425px;border-left:1px solid gray;border-bottom:1px solid gray;">'
	for (var i=0, len = arg.length; i<len; i++) {
		str += '<div style="cursor:hand;" onclick="var ul = this.nextSibling;ul.style.display=ul.style.display==\'\'?\'none\':\'\';">argument '+ (i+1) + ' of ' + len + '(type:'+(__typeof__(arg[i]))+')</div><div style=" overflow:auto;">' + window[fn](arg[i], '', i) + '</div>';
	}
	str += '</div></div><div style="position:absolute;left:107px; top:107px; background-color:#666666; z-index:9999; width:425px; height:530px;"></div>';
	if (document.body) {
		document.body.insertAdjacentHTML('beforeEnd', str);
	}
	else document.write(str);
}
