
/*ÐìÎÀ¶«Ôö¼Ó*/
function SwitchDiv(div)
{
		if(div!=null)
		{
			if(div.style.display=="none")
			{
				div.style.display = "";
			}
			else
			{
				div.style.display = "none";
			}
		}
}
/* end */
function SwitchVisibleState(element)
{
	var div = element;
	while(div!=null && div.tagName!="DIV")
	{
		div = div.parentElement.parentElement;
	}
	
	if(div!=null)
	{
		div = div.nextSibling;
		
		if(div!=null)
		{
			if(div.style.display=="none")
			{
				div.style.display = "";
			}
			else
			{
				div.style.display = "none";
			}
		}
	}
}

function InsertFileToMyWebEditor(path, file_name, content_type)
{
  var editor = null;
  
  if(editor_focused != null)
  {
    editor = document.frames(editor_focused.id);
  }
  
  if(editor!=null)
  {
    var html = "";
    
	if(content_type.toLowerCase().indexOf("image/")>=0)
	{
		// Paste Image 
		if(editor.Mode=="Design")
		{
			html = "<img border=0 src='" + path + "'>";
		}
		else if(editor.Mode=="Html")
		{
			html = "&lt;img border=0 src='" + path + "'&gt;";
		}
	}
	else
	{
		// Paste Link
		if(editor.Mode=="Design")
		{
			html = "<a href='" + path + "'>" + file_name + "</a>";
		}
		else if(editor.Mode=="Html")
		{
			html = "&lt;a href='" + path + "'&gt;" + file_name + "&lt;/a&gt;";
		}
	}
		
	if(html!="" && MyWebEditor_PasteHtml!=null)
	{
		MyWebEditor_PasteHtml(editor, html);
	}
  }
}

var Try = {
  these: function() {
    var returnValue;

    for (var i = 0, length = arguments.length; i < length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) {}
    }

    return returnValue;
  }
}

var Ajax = function() {
    return Try.these(
      function() {return new XMLHttpRequest()},
      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
      function() {return new ActiveXObject('Microsoft.XMLHTTP')}
    ) || false;
}