function $id(id){return typeof(id)=="string"?document.getElementById(id):id;};
(function(){
	$loader={
		onLoad:function(name){},
		onReady:function(){},
		init:function(container){},
		handlerError:function(e){alert(e);},
		on:function(evt,handler){switch(evt.toLowerCase()){case'load':this.onLoad=handler;break;case'ready':this.onReady=handler;break;default:break;}return true;},
		_load:function(path,callback){
			try{
			var script=document.createElement('script');script.src=path;script.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(script);
			if(script.addEventListener){script.addEventListener("load",callback,false);}else if(script.attachEvent){
				script.attachEvent("onreadystatechange",function(){if(script.readyState==4||script.readyState=='complete'||script.readyState=='loaded'){callback();}});
			}
			}catch(e){this.handlerError(e);callback();}
		},
		load:function(scripts){
			var total=scripts.length;var _self=this;var indicator=arguments[1]||0;if(indicator>=total){_self.onReady();return true;}
			var callee=arguments.callee;var script=scripts[indicator];
			this._load(script,function(){_self.onLoad(script);callee.apply(_self,[scripts,++indicator]);});return true;
		}
	}
})();
function $xss(str,type){
	if(!str){return str===0?0:"";}
	switch(type){
		case"none":return str+"";break;
		case"html":return str.replace(/[&'"<>\/\\\-\x00-\x09\x0b-\x0c\x1f\x80-\xff]/g,function(r){return"&#"+r.charCodeAt(0)+";"}).replace(/ /g,"&nbsp;").replace(/\r\n/g,"<br />").replace(/\n/g,"<br />").replace(/\r/g,"<br />");break;
		case"htmlEp":return str.replace(/[&'"<>\/\\\-\x00-\x1f\x80-\xff]/g,function(r){return"&#"+r.charCodeAt(0)+";"});break;
		case"url":return escape(str).replace(/\+/g,"%2B");break;
		case"miniUrl":return str.replace(/%/g,"%25");break;
		case"script":return str.replace(/[\\"']/g,function(r){return"\\"+r;}).replace(/%/g,"\\x25").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\x01/g,"\\x01");break;case"reg":return str.replace(/[\\\^\$\*\+\?\{\}\.\(\)\[\]]/g,function(a){return"\\"+a;});break;
		default:return escape(str).replace(/[&'"<>\/\\\-\x00-\x09\x0b-\x0c\x1f\x80-\xff]/g,function(r){return"&#"+r.charCodeAt(0)+";"}).replace(/ /g,"&nbsp;").replace(/\r\n/g,"<br />").replace(/\n/g,"<br />").replace(/\r/g,"<br />");break;
	}
};
var PP=PP||{};
PP.shopNoticeBoard={
	noticeBoard:"msgBoard",
	showNoticeBoard:function(){
		var oBoard=$id(this.noticeBoard);
		if(oBoard){
			var date=new Date();
			window.showGonggao=function(o){
				var opt={noticeId:"",noticeType:"1",template:"<p attr='{#id#}'>{#content#}</p>",starTime:"",endTime:"",nowTime:(new Date()).getTime(),domain:"",level:"0",content:""};
				var noticeList=[],curNotice,listLen,tempRe;
				var curUrl=window.location.href,strArr=[],tempHtml="";
				var cancleNotice=function(){$id(oBoard).style.display="none";};
				for(var i=0;i<o.length;i++){
					noticeList[i]=opt;for(var n in o[i]){noticeList[i][n]=o[i][n]}
					if(noticeList[i]["domain"].length>0){
						tempRe=new RegExp(noticeList[i]["domain"],"i");
						if(tempRe.test(curUrl)){
							if(noticeList[i]["nowTime"]>noticeList[i]["starTime"]&&noticeList[i]["nowTime"]<noticeList[i]["endTime"]){if(!curNotice){curNotice={};for(var m in noticeList[i]){curNotice[m]=noticeList[i][m];}}else{if(parseInt(noticeList[i]["level"],10)<parseInt(curNotice["level"],10)){for(var m in noticeList[i]){curNotice[m]=noticeList[i][m];}}}}
						}
					}
				}
				showGonggao["noticeList"]=noticeList;
				if(curNotice){if(curNotice["noticeType"]=="1"){strArr.push("<div class='pp-topnotice'><div class='pp-topnotice-bd'>");strArr.push(curNotice["template"].replace("{#id#}",curNotice["noticeId"]).replace("{#content#}",curNotice["content2"]));}else{strArr.push("<div class='pp-topbanner'><div class='pp-topbanner-bd'>");strArr.push(curNotice["content2"]);}
				strArr.push("<a href='#h' class='pp-topmessage-close' id='cancleBtn' attr='"+curNotice["noticeId"]+"' title='关闭'>关闭</a>");
				strArr.push("</div></div>");tempHtml=strArr.join("");}
				if(tempHtml.length>0){
					oBoard.innerHTML=$xss(tempHtml,"none");
					oBoard.className=oBoard.className.replace(/ hide/gi,"");
					$id("cancleBtn").onclick=cancleNotice;
				}else{
					if(oBoard.className.indexOf(" hide")==-1){oBoard.className+=" hide";}
				}
			};
			$loader.load(["/static/js/pp.noticeBoard.js?t="+date.getMonth()+date.getDate()+date.getHours()]);

		}
	}
};
PP.shopNoticeBoard.init=function(){PP.shopNoticeBoard.showNoticeBoard();};




function gotoSearchByCombine( classId, key, obj, ptag )
{
    var tag = '';
    if ( ptag )
    {
        tag = ptag;
    }
    if ( classId == 0 )
    {
        obj.href = 'http://shop.qq.com/search/index.html?q='+encodeURIComponent( encodeURIComponent(key) )+'&PTAG='+tag;
    }
    else
    {
        obj.href = 'http://shop.qq.com/search/index.html?q='+encodeURIComponent( encodeURIComponent(key) )+'&classId='+classId+'&PTAG='+tag;
    }
}
function gotoBabySearchByCombine( classId, key, obj, ptag )
{
    var tag = '';
    if ( ptag )
    {
        tag = ptag;
    }
    if ( classId == 0 )
    {
        obj.href = 'http://shop.qq.com/baby/search.html?q='+encodeURIComponent( encodeURIComponent(key) )+'&PTAG='+tag;
    }
    else
    {
        obj.href = 'http://shop.qq.com/baby/search.html?q='+encodeURIComponent( encodeURIComponent(key) )+'&classId='+classId+'&PTAG='+tag;
    }
}
function gotoShoeSearchByCombine( classId, key, obj, ptag )
{
    var tag = '';
    if ( ptag )
    {
        tag = ptag;
    }
    if ( classId == 0 )
    {
        obj.href = 'http://shop.qq.com/shoe/search.html?q='+encodeURIComponent( encodeURIComponent(key) )+'&PTAG='+tag;
    }
    else
    {
        obj.href = 'http://shop.qq.com/shoe/search.html?q='+encodeURIComponent( encodeURIComponent(key) )+'&classId='+classId+'&PTAG='+tag;
    }
}
