// =========================== POP Dialog===========================

var isIe = ( navigator.appName == "Microsoft Internet Explorer" );//alert( navigator.appName + " - " + navigator.appVersion );
//��IE������select�Ŀɼ�״̬,��ֹ��ס��������
function setSelectState(state)
{
	var selectList = document.getElementsByTagName('select');
	for (var i = 0; i < selectList.length; i++)
	{
		selectList[i].style.visibility = state;
	}
}
function popDialog(popId,marginTop){
	var iWidth = parseInt(document.documentElement.scrollWidth);
	var iHeight = parseInt(document.documentElement.scrollHeight);
	var divShadow;
	//���õ����
	if(document.getElementById("backShadow")){
		divShadow = document.getElementById("backShadow");
	}else{
		divShadow = document.createElement("div");
		divShadow.id = "backShadow";
		document.body.appendChild(divShadow);
	}
	divShadow.zIndex = 9998;
	divShadow.style.cssText = "position:absolute; top:0; left:0; background:#000; width:" + iWidth + "px;height:" + iHeight + "px;" + ( isIe ? "filter:alpha(opacity=50);" : "opacity:0.5;");
	divShadow.onclick = function(){
		this.style.display="none";
		document.getElementById(popId).style.display = "none";
		if (isIe) setSelectState('visible');
	};
	//���õ�������
	var divPopContent = document.getElementById(popId);
	divPopContent.style.zIndex = "9999";
	if( divPopContent.parentNode != document.body ){//���popId��δ�ƶ���#PopWrapper����
		divPopContent.style.display = "block";//divҪ��ʾ֮����ܻ����clientWidth��
		var cWidth = divPopContent.clientWidth;
		divPopContent = divPopContent.parentNode.removeChild(divPopContent);//todo:�ƺ��Ƴ���Ч
		divPopContent.style.cssText = "margin:0;position:absolute; top:" + marginTop + "; left:" + ((iWidth - cWidth)/2) +  "px;";
		document.body.appendChild(divPopContent);
	}
	//��ʾ�����͵����
	if (isIe) setSelectState('hidden');
	divShadow.style.display = "block";
	divPopContent.style.display = "block";
}

// =========================== Element Highlight===========================

function eHL(jQueryId,colorA,colorB){//Element Highlight,�ڵ����Ч��
	$(jQueryId).css("background-color",colorA).animate( { backgroundColor: colorB }, 1000);
}

// ===========================          ===========================

var slt ={
    check:function(id, obj)
    {
        var state = obj.checked;
        var more = document.getElementById(id).getElementsByTagName("input");
        for (i = 0; i < more.length; i++) {
            more[i].checked = state;
        }
    },
    all:function(id){
        var more = document.getElementById(id).getElementsByTagName("input");
        for (i = 0; i < more.length; i++) {
            more[i].checked = true;
        }
    },
    none:function(id){
        var more = document.getElementById(id).getElementsByTagName("input");
        for (i = 0; i < more.length; i++) {
            more[i].checked = false;
        }
    }
}

function resizeImg(which,w) {

    var block = document.getElementById(which);
    var imgs = block.getElementsByTagName("img");
    for(var i = 0; i<imgs.length;i++){
        var ow = imgs[i].width;
        var oh = imgs[i].height;
        var hw = oh/ow;
        if(ow>w){
            imgs[i].width = w;
            imgs[i].height = w*hw;
        }
    }
}
function menuFocus(which){
	$("#"+which).attr("class","current");
}