var isIE = (document.all) ? true : false;

var $ = function (id) {
	return "string" == typeof id ? document.getElementById(id) : id;
};
var $$ = function (id) {
	return "string" == typeof id ? document.getElementById(id) : id;
};

//********** 用来控制菜单和显示和隐藏

function ShowSub(sid)
{
	var obj = $$(sid);
	var parentUL = obj.parentNode.parentNode;
	var oldstatus = obj.style.display;
//		 trace(parentUL.childNodes[0].childNodes[0].innerHTML);
//		 trace(parentUL.childNodes[0].childNodes[1].innerHTML);
//		 trace(parentUL.childNodes[0].childNodes[2].innerHTML);
		// alert(parentUL.childNodes[0].childNodes[i].style.display = 'none');
	//return ;
	for(var i = 0; i < parentUL.childNodes.length; i ++)
	{	
		if("UL" == parentUL.childNodes[i].tagName){
			 parentUL.childNodes[i].style.display = 'none';
		}	

		for(var j = 0 ; j < parentUL.childNodes[i].childNodes.length; j ++)
		{
			//trace();
			if("UL" == parentUL.childNodes[i].childNodes[j].tagName){
				 parentUL.childNodes[i].childNodes[j].style.display = 'none';
			}
		}
			
		 //alert(parentUL.childNodes[i].childNodes[i].style.display = 'none');
		// parentUL.childNodes[i].childNodes[i].style.display = 'none';
	}
	if(oldstatus == 'none')
	{
		obj.style.display='';
	}
	else
	{
		obj.style.display='none';
	}
};


if(!isIE){
	HTMLElement.prototype.__defineGetter__("currentStyle", function () {
		return this.ownerDocument.defaultView.getComputedStyle(this, null);
	});
}

function getStyleWidth(obj)
{
	if(!obj) return;
	var w =obj.currentStyle.width? obj.currentStyle.width:null;
	w = obj.style.width ? obj.style.width : w;
	if(!w || w == 'auto'){
		w = obj.offsetWidth ? obj.offsetWidth : null;
	}
	w = parseInt(w);
	return w;
}
function getStyleHeight(obj)
{
	if(!obj) return;
	var h =obj.currentStyle.height? obj.currentStyle.height:null;
	h = obj.style.height ? obj.style.height : h;
	if(!h || h == 'auto'){
		h = obj.offsetHeight ? obj.offsetHeight : null;
	}
	w = parseInt(h);
	return h;
}
function getStyleMarginWidth(obj)
{
	if(!obj) return;
	var w =obj.currentStyle.marginLeft? obj.currentStyle.marginLeft:null;
	w = obj.style.marginLeft ? obj.style.marginLeft : w;
	w = obj.currentStyle.marginLeft ? w + obj.currentStyle.marginLeft : w ;
	w = obj.currentStyle.marginRight ? w + obj.currentStyle.marginRight : w ;
	w = parseInt(w);
	return w;
}

function trace(str)
{
	if(! document.getElementById('DebugBox')) return;
	document.getElementById('DebugBox').value += str + '\n';	
}
/******************************************************************
* URI 管理类。
* 一个URI分成两部分：URL和QueryString，这里主要是对后者进行管理。
* 默认以?打头，但是可以修改Url变量组成完成的URI
* .Url变量：设置跳转地址。
* .Add(name,key)  添加变量
* 主要的方法是getURI()，g()是前一个方法的简洁写法，另外重写了toString()(继承自Object）
******************************************************************/
function URI(){
	var _this = this;		//防止类成员的this和类本身的this混淆，所以在类成员的代码段里有_this来引用。
	var str = '?';			//var打头，可以当作private用
	this.Url = '';			//this打头，可以当作public用
	this.Add = function(str1,str2)
	{
		if(str == '?')
		{
			str += str1 + '=' + str2;
		}
		else
		{
			str += '&' + str1 + '=' + str2;
		}
	}
	this.toString = function()
	{
		return _this.getURI();
	}
	this.getURI = function(){
		return _this.Url + str;
	}
	//------------  下面这种不行！
	//this.g = this.getURI();
	this.g = function(){ //getURI()简写作g()
		return _this.getURI();
	}
}


