//控制左边导航菜单的显示和隐藏
function showMenu(menuID,obj)
{
	var menu =	document.getElementById(menuID);
	var target = obj;
	target.blur();
	if (menu.style.display != "block")
	{
		menu.style.display = "block";
		target.style.backgroundImage = "url(../images/min.gif)";

	}
	else
	{
		menu.style.display = "none";
		target.style.backgroundImage = "url(../images/max.gif)";
	}
}

//控制对象显示和隐藏
function showObj(objID, action)
{
	var obj = document.getElementById(objID);
	action = (action == "show") ? "block" : "none";
	obj.style.display = action;
}
//设置表单中GD选项的状态
function setGDState(bool)
{
	var obj = document.getElementById("noGD");
	if (bool == true)
	{
		obj.checked = false;
	}
	obj.disabled = bool;
}
//设置单选的check值
function setRadioCheck(name, checkValue)
{
	var radio = document.getElementsByName(name);
	for(i=0; i<radio.length; i++)
	{
		if(radio[i].value == checkValue)
		{
			radio[i].checked = true;
			return;
		}
	}
}
//图片显示
function showImage(id)
{
	var feature = "dialogWidth:750px;dialogHeight:500px;help:no;status:no;"
	window.showModalDialog("showImage.php?id="+id, null, feature);
}
//图片选择
function selectPic(path)
{
	var Composition = opener.document.getElementById("Composition");
	if(typeof(path) != "undefined")
		Composition.document.execCommand("InsertImage",false,path);
	else
		Composition.focus();
	window.close();
}
//缩略图选择
function selectThumb(path)
{
	//更改文章缩略图的图片
	var selectedThumb = opener.document.getElementById("selectedThumb");
	var imgName		  = opener.document.getElementById("imgName");
	selectedThumb.src = path;
	imgName.value	  = path;
	window.close();
}
function ShowHelp(div, title, desc)
	{
		div.style.display = 'inline';
		div.style.position = 'absolute';
		div.style.width = '170';
		div.style.backgroundColor = 'lightyellow';
		div.style.border = 'dashed 1px black';
		div.style.padding = '10px';
		div.innerHTML = '<b>' + title + '</b><br><img src=images/blank.gif width=1 height=5><br><div style="padding-left:10; padding-right:5">' + desc + '</div>';
	}

function HideHelp(div)
{
	div.style.display = 'none';
}

/* orering of things */
function listItemTask( id, task ) {
	var f = document.adminform;
	cb = eval( 'f.' + id );
	if (cb) {
		cb.checked = true;
		submitbutton(task);                  
	}
	return false;
}

function listItemCheck( id ) {
	var f = document.adminform;
	cb = eval( 'f.' + id );
	if (cb) {
		cb.checked = true;
		Highlight(cb);    
		document.adminform.boxchecked.value++;         
	}
	return false;
}

function Toggle(e)
{
if (e.checked) {
Highlight(e);
}
else {
Unhighlight(e);
}
}

    function ToggleAll(e)
    {
	if (e.checked) {
	    CheckAll();
	}
	else {
	    ClearAll();
	}
    }
//全选checkbox和全不选
function checkAll(obj)
{
	var check =	document.getElementsByName("idList[]");
	for(i=0; i<check.length; i++)
	{
		check[i].checked = obj.checked;
	}
}

    function Check(e)
    {
	e.checked = true;
	isChecked(e.checked);
    }

    function Clear(e)
    {
	e.checked = false;
	isChecked(e.checked);
    }

    function ClearAll()
    {
	var ml = document.adminform;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.name == "cid[]" ) {
		Clear(e);
		Unhighlight(e);
	    }
	}
    }
	
	function Highlight(e)
    {
	var r = null;
	if (e.parentNode && e.parentNode.parentNode) {
	    r = e.parentNode.parentNode;
	}
	else if (e.parentElement && e.parentElement.parentElement) {
	    r = e.parentElement.parentElement;
	}
	if (r) {
	    if (r.className == "wbg") {
		r.className = "wbgs";
	    }
		if (r.className == "gbg") {
		r.className = "wgbg";
	    }
	}
    }

    function Unhighlight(e)
    {
	var r = null;
	if (e.parentNode && e.parentNode.parentNode) {
	    r = e.parentNode.parentNode;
	}
	else if (e.parentElement && e.parentElement.parentElement) {
	    r = e.parentElement.parentElement;
	}
	if (r) {
	    if (r.className == "wbgs") {
		r.className = "wbg";
	    }
		if (r.className == "wgbg") {
		r.className = "gbg";
	    }
	}
    }

//图片按比例缩放
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){  
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){  
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;        
        }else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    }
} 
//调用：<img src="images/toplogo.gif" onload="javascript:DrawImage(this,100,100)">


//var scrollNewsCt=1;
//var pauseTime=15*1000;
//var timer1;

function hideAllClips() {
	for (i=1; i<3; i++){
		var allClips="topNews_"+i;
		var clipNum="clipNum"+i;
		document.getElementById(allClips).style.display="none";
		document.getElementById(clipNum).className="topNewsClip_OFF";
		}
	}
	
function clip_Switch(n) {
	var curClip="topNews_"+n;
	var curClipNum="clipNum"+n;
	hideAllClips();
	document.getElementById(curClip).style.display="block";
	document.getElementById(curClipNum).className="topNewsClip_ON";
	//scrollNewsCt=n; 
	}	