﻿function clickTrap(e) {
    var isNS = (document.layers) ? true : false;
    var isIE = (document.all) ? true : false;
    if (isNS && (e.which == 3)) {
        alert("[Creative Commons License | Attribution-NonCommercial-ShareAlike 2.5] \n\n Protected Transliteration Page\n\u00A9 {Khapre.org} | Transliteral");
        return false;
    }
    else if (isIE && (window.event.button == 2)) {
        alert("[Creative Commons License | Attribution-NonCommercial-ShareAlike 2.5] \n\n Protected Transliteration Page\n\u00A9 {Khapre.org} | Transliteral");
        return false;
    }
    else
        return false;
}
function ShowLinksFromList(divNameToShow, xmlString) {
    var RsltElem = document.getElementById(divNameToShow);
    RsltElem.innerHTML = xmlString;
}

function showHideContent(id, image)
  {
    var cDiv = document.getElementById(id);
    var cImage = document.getElementById(image);
    
    if (cDiv) 
    {
      if(cDiv.style.visibility == 'hidden') 
      {
        cDiv.style.display = 'block';
        cDiv.style.visibility = 'visible';
        cImage.src ='http://images.khapre.org/portal/service/themes/red/images/minus.gif';
      } 
      else
      {
        cDiv.style.display = 'none';
        cDiv.style.visibility = 'hidden';
        cImage.src = 'http://images.khapre.org/portal/service/themes/red/images/plus.gif';
        
      }
    }
  }  
  function PageUnload(strText,url)
  {
      var mainBody = document.getElementById('main-wrapper');
      mainBody.innerHTML = '<div><br><img src="http://images.khapre.org/portal/service/themes/red/images/progressbar.small.gif"><span class=\"bTitle\"> Loading page .. <br><br>' + (strText == null ? '' : strText) + '....</span><br><br><div>';
      mainBody.style.textAlign = 'center';
      window.location =url;
   }
   function DoPageUnload(href)
   {
        PageUnload(href.innerHTML,href.href);
   }
   function DoMouseOver(ctl)
   {
        window.status='Click to VIEW ' + ctl.innerHTML;
        return true;
   }
   function DoMouseOut(ctl)
   {
        window.status='';
        return true;
   }
  
  function NavOptionChanged(id,label)
  {
    var cList = document.getElementById(id);
    PageUnload(cList[cList.options.selectedIndex].text,cList[cList.options.selectedIndex].value);
  }   
  function bookmarkUrl(){
    var title=document.title.replace('|',' - ');
    var url=location.href;
    if (window.sidebar) // firefox
	    window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){ // opera
	    var elem = document.createElement('a');
	    elem.setAttribute('href',url);
	    elem.setAttribute('title',title);
	    elem.setAttribute('rel','sidebar');
	    elem.click();
    } 
    else if(document.all)// ie
	    window.external.AddFavorite(url, title);
    }

function copyUrl()
{
    var title=document.title;
    var url=location.pathname;
    
    var str="&nbsp;<a href=\"" + url + "\">"+ title + "</a>&nbsp;";
    copyTextToClipboard(str,"Text");
}
function printPage()
{
    if(confirm("Use your browsers back button to return to this page."))
        location.href=location.href+"?switch=print";
}
function copyTextToClipboard(s,type)
{
   
   if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData(type, s);
	}
	else
	{
		user_pref("signed.applets.codebase_principal_support", true);
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		var clip =Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;
		var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=meintext;
		str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]);
		var clipid=Components.interfaces.nsIClipboard;
		if (!clip) return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);	   
	}
}
function ClientActiveItemChanged(sender, e) {
    var result =
        confirm("You are about to switch to the tab with ID " +
        e.get_id() + ".\nAre you sure?");
    if (!result)
        e.set_cancel(true);
}







