function jsTrim(s) {return s.replace(/(^\s+)|(\s+$)/g, "");}

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 chkNumber(obj)
{
    if(isNaN(obj.value))
    {
        alert("请输入数字！");
		obj.focus();
		return false;
    }
}

function RefreshParent()
{
	window.opener.location.reload();
}

function RefreshSelf()
{
	window.location.reload();
}

function load()
{
	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 SetFrame()
{
    //alert(parent.MainContent.children[1].src);
    if (parent.MainContent.children[1].height == 0)
    {
        parent.MainContent.frameSpacing = "6";
        parent.MainContent.frameBorder = "1";
        parent.MainContent.borderColor = "#606060";
        parent.MainContent.rows = "50%,*";
        //parent.MainContent.children[1].src = "";
        SetCookie("Frame", true);
    }
    else
    {
        parent.MainContent.frameSpacing = "0";
        parent.MainContent.frameBorder = "0";
        parent.MainContent.borderColor = "";
        parent.MainContent.rows = "100%,*";
        SetCookie("Frame", false);
    }
    
    //alert(parent.MainContent.children[1].height);
}

function SetAnchor(number)
{
    var strLocation = parent.MainRight.document.location + "#anchor0";
    if (strLocation.indexOf("#anchor") > 0)
    {
        strLocation = strLocation.substring(0, strLocation.indexOf("#anchor"));
    }
    strLocation = strLocation + "#anchor" + number;  
    parent.MainRight.document.location = strLocation;  
}

function SetAnchor2(number)
{
    var strLocation = window.opener.location + "#anchor0";
    if (strLocation.indexOf("#anchor") > 0)
    {
        strLocation = strLocation.substring(0, strLocation.indexOf("#anchor"));
    }
    strLocation = strLocation + "#anchor" + number;  
    window.opener.location.location = strLocation;  
}

///////////////////////////////////////////////////////

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 Showitem(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
		event.srcElement.src="/App/Images/admin/hideitem.gif";
	}
	else
	{
		obj.style.display ="none";
		event.srcElement.src="/App/Images/admin/showitem.gif";
	}
}



function SetCookie(sName, sValue)
{
  //document.cookie = sName + "=" + escape(sValue) + "; domain=" + document.domain;
  parent.document.cookie = sName + "=" + escape(sValue);
  //alert(parent.frames["MainRight"].document.cookie);
//alert(self.parent.frames["MainTop"]);

  //alert(document.domain);
}

function GetCookie(sName)
{
    //var aCookie = document.cookie.split("; ");
    var aCookie = parent.document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0]) 
        return unescape(aCrumb[1]);
    }
  // a cookie with the requested name does not exist
  return null;
}


function showitem2(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
		event.srcElement.src="/App/Images/treeimg/tree_Tminus.gif";
	}
	else
	{
		obj.style.display ="none";
		event.srcElement.src="/App/Images/treeimg/tree_Tplus.gif";
	}
}

function showitem3(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
		event.srcElement.src="/App/Images/treeimg/tree_Lminus.gif";
	}
	else
	{
		obj.style.display ="none";
		event.srcElement.src="/App/Images/treeimg/tree_Lplus.gif";
	}
}

function showreply(obj)
{
	if (obj.style.display == "none") 
	{
		obj.style.display ="";
	}
	else
	{
		obj.style.display ="none";
	}
}


//设为默认页
function default_home()
{
	this.home.style.behavior='url(#default#homepage)';
	this.home.setHomePage('http://www.fudaoyuan.com');
}


//被选中
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 SetValue(obj)
{
	var value = "";
	value = showModalDialog("/App/HtmlEdit/upload_j2.aspx", window, "font-family:Verdana;font-size:12;dialogWidth:40em;dialogHeight:5em;status:off");
	//imgArr =showModalDialog("/sensor/fbt/upload_j.aspx",window,'dialogWidth:450px; dialogHeight:100px;help:0;status:0;resizeable:1;');
	obj.value = value;

	if (typeof(obj.value) == "undefined")
	{
		obj.value = "";
	}
}	


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;
}	

