			//initial the style from cookie
			//
			// by zyq
		try{
	  		window.onload=iniColor();
	  	}catch(e){}
	  		function iniColor(){
	  			
	  		
	  			var color=getColorfromcookie();	//read user's style from cookie
	  			
	  			var tag=false;
	  			
	  			var allcolors=Array("gray","blue","purple","red","orange");
	  		
	  			for(var i=0;i<allcolors.length;i++){
	  				if(color==allcolors[i]){		//is exist
	  					tag=true;
	  					break;		//exist
	  				}
	  			}
	  			
	  			
	  			
	  			if(!tag){	//has saved
	  				return;
	  			}
				
				changestyle(color,false);
				
	  		}
	  		
	  		//tag whether save cookies
	  		function changestyle(color,tag){ 
	  		
				links=document.getElementsByTagName("link");
				
				for(var i=0;i<links.length;i++){
					
					var href=links[i].href;
					
					if(href.indexOf("font")!=-1){
						links[i].href=changeStylefile(href,"font",color)
					}
					
					if(href.indexOf("block")!=-1){
						links[i].href=changeStylefile(href,"block",color)
					}
					
					if(href.indexOf("body")!=-1){
						links[i].href=changeStylefile(href,"body",color)
					}
					
					if(href.indexOf("nav")!=-1){
						links[i].href=changeStylefile(href,"nav",color)
					}
				
				 }
				 
				 if(tag){
				 	savetoCookies(color);	//lasts for a week
				 	savetoServ(color);
				 }
			}
			
			function changeStylefile(href,attr,color){
			
				var args=href.split("/");		//split the path name
				
				var stylename=args[args.length-1].split(".")[0];//get the css file name
			
				if(color=='blue'){//default style
					    attr=attr.split("_")[0];  //remove '_'
				}else{
					if(attr.indexOf("_")!=-1){	//file name '_'
						var arg1=attr.split["_"];
						arg1[2]=color;
						for(var i=0,attr="";i<arg1.length;i++){
							attr+=arg1[i];
						}
					}else{
						attr=attr+"_"+color;
					}
				}
				
				attr+=".css";
				
				args[args.length-1]=attr;
				
				for(var i=0,href="";i<args.length;i++){
					if(i!=args.length-1){
						href+=args[i]+"/";
					}else{
						href+=args[i];
					}
				}
				
				return href;
			}

			function savetoCookies(color){
			
			//	var date=new Date();
				
            //	date.setTime(date.getTime()+expireday*24*3600*1000);
				
			//	alert(date.toGMTString());
			
			//	document.cookie="jiaoyincolor="+color+";expire="+date.toGMTString()+";path=/";		//cookie path
				
				Cookie.Set("jiaoyincolor",color);
				
			}
			
			
			
			function getColorfromcookie(){	//read from cookie
				var allcookies = document.cookie;
			//	alert(allcookies);
				var cookiesarray = allcookies.split(";");
				
				for(var i=0;i<cookiesarray.length;i++){
					if(cookiesarray[i].indexOf("jiaoyincolor")!=-1){
						var color=cookiesarray[i].split("=")[1];
						return color;
					}
				}	
				return "";
			}
			
			
			//////////////////////////////////////
			
			var colorxmlHttp;
			
			var requestType;
			
			function createXMLHttpRequest(){
			    if (window.ActiveXObject) {
			        colorxmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			    }
			    else  if (window.XMLHttpRequest) {
			        colorxmlHttp = new XMLHttpRequest();
			    }
			}
		
			function savetoServ(color){
				createXMLHttpRequest();
		   	    colorxmlHttp.open("POST", "/configcolor.ha?colorconfig="+color);
		        colorxmlHttp.send(null);	
			}
			
			
			
			var Cookie= {
			        Set : function (){
			                var name = arguments[0], value = escape(arguments[1]),
			                days = (arguments.length > 2)?arguments[2]:365,
			                path = (arguments.length > 3)?arguments[3]:"/";
			                with(new Date()){
			                        setDate(getDate()+days);
			                        days=toUTCString();
			                }
			                document.cookie = "{0}={1};expires={2};path={3}".format(name, value, days, path);
			        },
			        Get : function (){
			                var returnValue=document.cookie.match(new RegExp("[\b\^;]?" + arguments[0] + "=([^;]*)(?=;|\b|$)","i"));
			                return returnValue?unescape(returnValue[1]):returnValue;
			        },
			        Delete : function (){
			                var name=arguments[0];
			                document.cookie = name + "=1 ; expires=Fri, 31 Dec 1900 23:59:59 GMT;";
			        }
			}
			
			
			String.prototype.format = function(){ 
			        var s = this; 
			        for (var i=0,j=arguments.length; i<j; i++)
			                s = s.replace("{" + (i) + "}", arguments[i]);
			        return(s);
			}