﻿function $(id,tag){if(!tag){return document.getElementById(id);}else if(typeof id=='string'){return document.getElementById(id).getElementsByTagName(tag);}else{return id.getElementsByTagName(tag);}}//$(id,tag):返回容器下某标签的集合,id可为obj,如TAG为空返回容器
YK=window.YK||{};
YK.IE=function(){return navigator.userAgent.search('MSIE')>0;}//是否为IE浏览器

//窗体属性
YK.W=function(id){if(!id){return document.body.offsetWidth;}else if(typeof id=='string'){return $(id).offsetWidth;}else{return id.offsetWidth;}} //容器宽,[id可为string或obj],id为空,返回body宽
YK.H=function(id){if(!id){return Math.max(document.body.clientHeight,document.body.offsetHeight);}else if(typeof id=='string'){return $(id).offsetHeight;}else{return id.offsetHeight;}}//容器高，[id可为string或obj]id为空,返回body高
YK.T=function(){return (document.documentElement.scrollTop||document.body.scrollTop);}//返回竖滚动条现在位置与页顶的距离
YK.Hs=function(){return Math.min(document.documentElement.clientHeight,document.body.clientHeight);} //返回网页可用区域的高


//鼠标坐标
YK.mouseX=function(event){return (event.pageX || (event.clientX +(document.documentElement.scrollLeft || document.body.scrollLeft)));}//返回鼠标的X座标
YK.mouseY=function(event){return (event.pageY || (event.clientY +(YK.T() || document.body.scrollTop)));}//返回鼠标的Y座标


//创建容器[要添加到的父容器，要创建的标签，是否在容器头部插入(true=在头部插入，false＝在尾部插入)，标签的ID(可选)，标签的样式名(可选)]
YK.HtmCreate=function(obj,tag,where,id,cname){var o=document.createElement(tag);if(id){o.id=id;}if(cname){o.className=cname;}if(where){obj.parentNode.insertBefore(o,obj);}else{obj.appendChild(o);}return o;}
YK.HtmDel=function(obj){obj.parentNode.removeChild(obj);} //删除容器
YK.HtmWH=function(obj,w,h){if(w){obj.style.width=obj.style.minWidth=w+"px";}if(h){obj.style.height=obj.style.minHeight=h+"px";}}//设置容器的width与height
YK.HtmLT=function(obj,lf,to){if(lf){obj.style.left=lf+"px";}if(to){obj.style.top=to+"px";}}//设计容器的left与top
YK.HtmOP=function(obj,op){if(YK.IE()){obj.filters.alpha.opacity=op;}else{obj.style.opacity=(op/100);}}//设置层的透明度


//显示隐藏(用className来实现)[第一个列的集合，要变化第几个，第二可列的集合（可选）]
YK.ShowHide=function(obj,now,obj1)
{
	if(obj1){for(var i=0;i<obj.length;i++){obj[i].className="";obj1[i].className="";}if(now!=-1){obj[now].className="show";obj1[now].className="show";}}
	else{for(var i=0;i<obj.length;i++){obj[i].className="";}if(now!=-1){obj[now].className="show";}}
}

