function jsTrim(s) {return s.replace(/(^\s+)|(\s+$)/g, "");}

function RefreshParent()
{
	window.opener.location.reload();
}

function RefreshSelf()
{
	window.location.reload();
}

function LinkUrl(url)
{
    url = encodeURI(url);
    window.parent.frames(1).location.replace(url);
}

///////////////////////////////////////////////////////
function SetColor(objectName)
{
	script = '/HtmlEdit/colorpicker.htm';
    color = showModalDialog(script, window, 'dialogWidth:210px;dialogHeight:170px;status:0;scroll:0;help:0;');
    var obj = document.getElementById(objectName);
    if (typeof(color) != "undefined")
    {
        obj.value = color;
        obj.style.backgroundColor = color;
    }
}

function SetDefaultColor(objectName)
{
	var obj = document.getElementById(objectName)
	obj.value = "";
	obj.style.backgroundColor = "#ffffff";
	
}

function SetImageFile(objectName)
{
	var obj = document.getElementById(objectName);
	
	var path = showModalDialog("/HtmlEdit/upload_j2.aspx",window,'dialogWidth:450px; dialogHeight:100px;help:0;status:0;resizeable:1;');

	if (typeof(path) != "undefined")
	{
		obj.value = path;
	}    
}
///////////////////////////////////////////////////////

function ExecUrl(url)	
{
    http_request = false;

    if (window.XMLHttpRequest) 
    { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) 
        {
            http_request.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) 
    { // IE
        try 
        {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) 
        {
            try 
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
                catch (e) {}
        }
    }

    if (!http_request) 
    {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    //http_request.onreadystatechange = alertContents;
    http_request.open('GET', url, true);
    http_request.send(null);
}

/////////////////////////////////////////////////////////////////////////////////
function Calendar1_DblClick()
{
	var objCalendar = document.getElementById("Calendar1");
	
	objTemp.value = objCalendar.Year + "-" + objCalendar.Month + "-" + objCalendar.Day;
	objCalendar.style.visibility = "hidden";
	//alert(objTemp.value);
	//objTemp.focus();
}

function SetDateTime2(obj)
{
	objTemp = obj;
	
	var t = obj.offsetTop;
	var l = obj.offsetLeft;
	
	while(obj = obj.offsetParent)
	{
		t += obj.offsetTop;
		l += obj.offsetLeft;
	}
	
	var objCalendar = document.getElementById("Calendar1");
	
	objCalendar.style.visibility = "visible";
	objCalendar.style.top = t;
	objCalendar.style.left = l;
	
	if (objTemp.value != "")
	{
		var strValue = objTemp.value;
		strValue = strValue.split("-");
		objCalendar.Year = strValue[0];
		objCalendar.Month = strValue[1];
		objCalendar.Day = strValue[2];
	}
}
/////////////////////////////////////////////////////////////////////////////////    

function ResizeWindow()
{
    if (document.body.clientWidth==0) return;
    var header = document.all.item("header");
    var mainSection = document.all.item("mainSection");
    
    if (mainSection == null) return;
    
    document.body.scroll = "no"
    mainSection.style.overflow= "auto";
    header.style.width= document.body.offsetWidth - 2;
    //mainSection.style.paddingRight = "20px"; // Width issue code
    mainSection.style.width= document.body.offsetWidth - 4;
    mainSection.style.top=0;  
    if (document.body.offsetHeight > header.offsetHeight + 10)
    {
        //mainSection.style.height= document.body.offsetHeight - (header.offsetHeight + 10);
        mainSection.style.height= document.body.offsetHeight - (header.offsetHeight);
    }   
    else
    {
        mainSection.style.height=0;
    }
    
    try
    {
        mainSection.setActive();
    }
    catch(e)
    {
    
    }
}

var CurrentTR;
var TempTR;
function SetBG(obj)
{
	obj.bgColor = "#f0f0f0";
	CurrentTR = obj;
	//alert(CurrentTR);
}

function ReSetBG(obj)
{
	obj.bgColor = "";
}


function SetBGColor(obj, color)
{
	obj.bgColor = color;
}

function ReSetBGColor(obj, color)
{
	obj.bgColor = color;
}


function IsDate(dateValue)
{ 
	var s = dateValue.replace(/-/g,"/");
	var newdate = new Date(s); 
	var s = newdate.getYear();
	
	if (isNaN(newdate) == false)
	{
	    return true;
	}
	else
	{
	    return false;
	}
} 	



function Showitem(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
		event.srcElement.src="/images/admin/hideitem.gif";
	}
	else
	{
		obj.style.display ="none";
		event.srcElement.src="/images/admin/showitem.gif";
	}
}

function showitem2(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
		event.srcElement.src="/images/treeimg/tree_Tminus.gif";
	}
	else
	{
		obj.style.display ="none";
		event.srcElement.src="/images/treeimg/tree_Tplus.gif";
	}
}

function showitem3(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
		event.srcElement.src="/images/treeimg/tree_Lminus.gif";
	}
	else
	{
		obj.style.display ="none";
		event.srcElement.src="/images/treeimg/tree_Lplus.gif";
	}
}

function showreply(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
	}
	else
	{
		obj.style.display ="none";
	}
}


//去空格
//function TrimSpaces( str ) 
//{
//	var start;
//	var end;
//
//	str = str.toString();
//
//	var len = str.length;
//
//	for (start = 0; start < len; start ++)
//	{
//		if (str.charAt(start) != ' ')
//			break;
//	}
//	if (start == len)
//		return "";
//
//	for (end = len - 1; end > start; end --)
//	{
//		if (str.charAt(end) != ' ')
//			break;
//	}
//	end ++;
//
//	return str.substring(start, end);
//}


//设为默认页
function default_home()
{
	this.home.style.behavior='url(#default#homepage)';
	this.home.setHomePage('http://www.deyan.com.cn');
}

//跳到第几页
function checkRecordCount(num)
{
	var tempvalue;
	tempvalue = parseInt(goform.pageNumber.value)
	if (isNaN(tempvalue))
	{
		alert("请输入数字！");
		return false;
	}
	
	if ( tempvalue > num )
	{
		goform.pageNumber.value = num;
	}
	else if ( parseInt(goform.pageNumber.value) < 1 )
	{
		goform.pageNumber.value = 1;
	}
	goform.submit();
}

//跳到第几页
function checkRecordCount1(num)
{
	
	var tempvalue;
	tempvalue = parseInt(goform1.pageNumber.value)
	if (isNaN(tempvalue))
	{
		alert("请输入数字！");
		return false;
	}
	if ( tempvalue > num )
	{
		goform1.pageNumber.value = num;
	}
	else if ( parseInt(goform1.pageNumber.value) < 1 )
	{
		goform1.pageNumber.value = 1;
	}
	goform1.submit();
}

//被选中
var temp="";
function Clicked(obj)
{
	if ( temp == obj)
	{
		obj.runtimeStyle.backgroundColor = "HIGHLIGHT";
		obj.runtimeStyle.color = "HIGHLIGHTTEXT";
	}
	else
	{
		if ( temp == "" )
		{
			temp=obj;
		}
		temp.runtimeStyle.backgroundColor = "";
		temp.runtimeStyle.color = "";
		obj.runtimeStyle.backgroundColor = "HIGHLIGHT";
		obj.runtimeStyle.color = "HIGHLIGHTTEXT";
	}	
	temp=obj;
}

//推荐文章
function commend(subject)
{
	commendform.linkstr.value=document.location;
	commendform.target="_blank";
	commendform.submit();
}

//收藏文章
function collection(subject)
{
	collectionform.linkstr.value=document.location;
	collectionform.target="_blank";
	collectionform.submit();
}


//改变字体
function changefont()
{
	
}

function doprint()
{
	var strHtml;
	strHtml = "<center><table width='100%' bgcolor='#ffffff'><tr><td align=center>" ;
	strHtml = strHtml + printarea.innerHTML + "<table cellspacing=0 cellpadding=0><td nowrap>【字体：<a style='cursor:hand' onclick='changefontsize(16)'>大</a> <a style='cursor:hand' onclick='changefontsize(14)'>中</a> <a style='cursor:hand' onclick='changefontsize(12)'>小</a>】</td>";
	strHtml = strHtml + "<td nowrap><a style='cursor:hand' onclick='javascript:print();'>【打印】</a></td></table>";
	strHtml = strHtml + "</td></tr></table>";
	document.body.innerHTML = strHtml;
}

function pallette(obj)
{
	var value = "";
	value = showModalDialog("/public/color.htm", "", "font-family:Verdana;font-size:12;dialogWidth:50em;dialogHeight:35em;status:off");
	obj.value = value;
	obj.style.backgroundColor = value;
}	

function load()
{
	var name=navigator.appName
	var vers=navigator.appVersion
	if(name=='Netscape')
	{
		window.location.reload(true)
	}
	else
	{
		history.go(0)
	}
}
