jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        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 { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

//网站换肤
$(function(){
	  var cookie_skin = $.cookie("MyCssSkin");
	  switchSkin(cookie_skin);
	  addEvent();
});

function switchSkin(skinName){
		$("#"+skinName).addClass("selected")  //当前<li>元素选中
		.siblings().removeClass("selected");  //去掉其他同辈<li>元素的选中
	  $("#cssfile").attr("href","/css/"+ skinName +".css"); //设置不同皮肤
		$.cookie( "MyCssSkin",skinName, {path: '/', expires: 10 });
}

function addEvent(){
		var $li =$("#skins li");
		$li.click(function(){
			switchSkin(this.id );
		});
		var cookie_skin = $.cookie("MyCssSkin");
		if (cookie_skin) {
			switchSkin(cookie_skin);
		}
}
//搜索
var Search=getObject=function(element){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i<length;i++){elements.push(Search(arguments[i]));}return elements;}if(typeof element=='string'){return document.getElementById(element);}return element;};var createScript=function(cid,url,f,arg){try{var _f="function"==typeof f?f:false;if(url.indexOf(".js")>=0){url=url.indexOf("?")==-1?url+"?t="+new Date().getTime():url+"&t="+new Date().getTime();};var v=document.createElement("script");v.setAttribute('type','text/javascript');v.setAttribute('id',""!=cid?cid:"createScript"+new Date().getTime());v.setAttribute('src',url);document.getElementsByTagName("head")[0].appendChild(v);if(document.all){v.onreadystatechange=function(){var state=v.readyState;if(state=="loaded"||state=="interactive"||state=="complete"){this.parentNode.removeChild(this);if(_f){return _f.apply(this,(arg||[]))}}else{v.src=url;}};}else{v.onload=function(){this.parentNode.removeChild(this);if(_f){return _f.apply(this,(arg||[]))}};}}catch(e){}return createScript;};
if (!globalsearchformaction) {
				var globalsearchformaction = "";
			}
			var manulQuery = "";
			var tabIdx = 2;
			function showTag(n) {
				tabIdx = n;
				for (var i = 1; i <= 5; i++) {
					if (i == n) {
						getObject("tag" + i).className = "tagThis hand";
						if(getObject("scontent" + i))getObject("scontent" + i).style.display="";
	else getObject("scontent2").style.display="";			switchSearch(n);
						globalsearchformaction = document.searchform.action;
					} else {
						getObject("tag" + i).className = "tagOut hand";
						if(getObject("scontent" + i))getObject("scontent" + i).style.display="none";
         else if(n==1)getObject("scontent2").style.display="";
         					}
				}
			}
			function transTag(n) {
				if(getObject("tag" + n).className != "tagThis hand"){
					getObject("tag" + n).className = "tagTrans hand";
				}
			}
			function transTagOut(n) {
				if(getObject("tag" + n).className != "tagThis hand"){
					getObject("tag" + n).className = "tagOut hand";
				}
			}
			function s(o){
				var w=getObject("searchform").query;
				if(w.value.length>0 && w.value!=manulQuery && w.value!=manulQuery){var h=o.href;var q=encodeURIComponent(w.value);if(h.indexOf("kw=")>0){o.href=h.replace(new RegExp("kw=[^&$]*"),"kw="+q)}else{o.href+="&kw="+q}}};
			function switchSearch(n){
				if(n){
					var sf = getObject("searchform");
					var pid = getObject("pid");
					var po = getObject("po");
					switch(n){
						case 1:
							sf.action = "/plus/search/"
							pid.value = "0"
							with(sf.query){if(value==""||value==manulQuery){value=manulQuery;style.color="#666";}}
							break;
						case 2:
							sf.action = "/plus/search/"
							pid.value = "1"
							with(sf.query){if(value==""||value==manulQuery){value=manulQuery;style.color="#666";}}
							break;
						case 3:
							sf.action = "/plus/search/"
							pid.value = "5"
							with(sf.query){if(value==""||value==manulQuery){value=manulQuery;style.color="#666";}}
							break;
						case 4:
							sf.action = "/plus/search/"
							pid.value = "111"
							with(sf.query){if(value==""||value==manulQuery){value=manulQuery;style.color="#666";}}
							break;
						case 5:
							sf.action = "/plus/search/"
							pid.value = "3"
							with(sf.query){if(value==""||value==manulQuery){value=manulQuery;style.color="#666";}}
							break;
					}
				}
			}
	var dhsubmit = false;
	var remQuery = "";
	getObject("searchform").query.value = manulQuery;	
	function erase(q){
	if(q.value==manulQuery||q.value==manulQuery)q.value='';q.style.color='#000';
	}

