/*
 * Copyright 2006 Servelots Infotech Pvt. Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You may
 * obtain a copy of the License at:
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */


/** Returns the URL with which the current community is being accessed */
function getCustomPanelURL()
{
  var url = new String(document.location);
  var customPanelFile = document.CustomPanel.panel.value + ".wm";
  var currentDomainId = document.CustomPanel.urlid.value ; 
  url = url.substring(0, url.indexOf("servlet"));
  url += "domain/" + currentDomainId + "/" + customPanelFile;
  return url;
}

function hideEditor()
{
    document.getElementById("editorPanel").style.display = "none";
}


function toggleEditor(panel)
{

  document.CustomPanel.panel.value = panel;

  //  alert("inside toggleEditor");

  if (document.getElementById("edp").style.display == "inline")
  {
    document.getElementById("edp").style.display = "none";
  }
  else if (document.getElementById("edp").style.display == "none")
  {
    var panelURL = getCustomPanelURL();
    readContent(panelURL);
    document.getElementById("edp").style.display = "inline";
  }
  
  tinyMCE.execCommand('mceResetDesignMode');

}

function submit(formname)
{
  formname.submit();
}

function submitClose(formname)
{
  formname.submit();
  window.opener.parent.location.reload();
  window.close();
}


function closeChildWindow()
{
  window.close();
}

function show_login()
{
  var obj = document.getElementById("login");
  obj.style.display="block";
}

function hide_login()
{
  var obj = document.getElementById("login");
  obj.style.display="none";
}

function openInMain(o)
{
document.getElementById("mainContent").innerHTML = "<Object data=" + o.href + " width='600px' height='2000px' type='text/html'>";
return false;
}										

function addSearchWordAndOpenInMain(o)
{
var ID="searchword";
var temp = document.getElementById(ID);
temp.style.display="none";
o.href = o.href + "&keyword=" + document.getElementById("searchword").value;
openInMain(o);
return false;



}
