
function SetCwinHeight(o){
  var bobo=document.getElementById(o); //iframe id
  if (document.getElementById){
   if (bobo && !window.opera){
    if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){
     bobo.height = bobo.contentDocument.body.offsetHeight;
    }else if(bobo.Document && bobo.Document.body.scrollHeight){
     bobo.height = bobo.Document.body.scrollHeight;
    }
   }
  }
 }


function skin(){	
	var p = document.getElementById("skin_control");	
	var c = p.getElementsByTagName("span");
	for(var i = 0 ; i < c.length ; i++){
		c[i].onclick = function(){
			changeSkin(this.getElementsByTagName("input")[0].value);
			SetCookie("skin",this.getElementsByTagName("input")[0].value,15552000);
		}
	}
}

function changeSkin(cssUrl){
	
	var link = document.getElementsByTagName("link");
	link[0].href = "css/" + cssUrl + ".css";
}

function loadSkin(){
	if(GetCookie("skin")!=null){
		changeSkin(GetCookie("skin"));
	}
}

function menu01(o){	
	for(var i = 0 ; i < o.length ; i++){		
		o[i].value = i;			
		o[i].onmouseover = function(e){		
			clearBubble(e);
			for(var j = 0 ; j < o.length ; j++){				
				o[j].getElementsByTagName("ul")[0].style.display = "none";
			}			
			this.getElementsByTagName("ul")[0].style.display = "block";
			this.getElementsByTagName("ul")[0].onclick = function(){this.style.display = "none";};
			//this.getElementsByTagName("ul")[0].onmouseout = function(){this.style.display = "none";};				
		}
	}	
}

function addEvent(type,o,fn){
	var ieType = "on" + type;
	if(window.attachEvent){
		 o.attachEvent(ieType,fn);
	}else{
		 o.addEventListener(type,fn,false);
	}
}

function delEvent(type,o,fn){
	var ieType = "on" + type;
	if(window.attachEvent){
		 o.detachEvent(ieType,fn);
	}else{
		 o.addEventListener(type,fn,false);
		 o.removeEventListener (type,fn,false);
	}
}

function clearBubble(e){
	if(e){			
		e.stopPropagation();
	}else{
		window.event.cancelBubble = true;
	}	
}


function scrollDoor(){
}

scrollDoor.prototype = {
	onlyMenu : function(menus,openClass,closeClass){ // only menu no have content
			var _this = this;
			for(var i = 0 ; i < menus.length ; i++)
			{	
				_this.$(menus[i]).flag = ++this.value;
				_this.$(menus[i]).value = i;
				_this.$(menus[i]).onclick = function(){										
					for(var j = 0 ; j < menus.length ; j++)
					{						
						_this.$(menus[j]).className = closeClass;
						//_this.$(divs[j]).style.display = "none";					
					}				
					_this.$(menus[this.value]).className = openClass;	
					//_this.$(divs[this.value]).style.display = "block";				
				}
			}
			
		},
	sd : function(menus,divs,openClass,closeClass){
		var _this = this;
		if(menus.length != divs.length)
		{
			alert("菜单层数量和内容层数量不一样!");
			return false;
		}				
		for(var i = 0 ; i < menus.length ; i++)
		{	
			_this.$(menus[i]).value = i;				
			_this.$(menus[i]).onmouseover = function(){
						
				for(var j = 0 ; j < menus.length ; j++)
				{						
					_this.$(menus[j]).className = closeClass;
					_this.$(divs[j]).style.display = "none";
				}
				_this.$(menus[this.value]).className = openClass;	
				_this.$(divs[this.value]).style.display = "block";				
			}
		}
	 },
	$ : function(oid){
		if(typeof(oid) == "string")
		return document.getElementById(oid);
		return oid;
	}
}




function GetCookieVal(offset) 
//获得Cookie解码后的值 
{ 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
	endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr)); 
} 


function SetCookie(name, value) 
//设定Cookie值 
{ 
	var expdate = new Date(); 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 )); 
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString())) 
	+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain)) 
	+((secure == true) ? "; secure" : ""); 
} 


function DelCookie(name) 
//删除Cookie 
{ 
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1); 
	var cval = GetCookie (name); 
	document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString(); 
} 


function GetCookie(name) 
//获得Cookie的原始值 
{ 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) 
	{ 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
		return GetCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
	} 
	return null; 
}



function focusText(o,orginText){
	if(o.value.substring(0,orginText.length)==orginText){
		if(o.value.length==orginText.length)
			o.value=o.value.substring(orginText.length,o.value.length);	
		else
			o.value=o.value.substring(orginText.length,o.value.length);
	}
}

function blurText(o,orginText,objText){
	if(orginText!=""){
		o.value=orginText+o.value;
	}else if(o.value==""){
		o.value=objText;
	}
}

function focusMenu(id){
	var num = parseInt(id.substring(1));
	var n = document.getElementById("nav").getElementsByTagName("li");
	var fos = document.getElementById(id);
	for(var i = 1 , j = n.length ; i < j ; i=i+2){
		if(i==num)
			n[i].className = "m hover";
		else
			n[i].className = "m";
	}
}














