// JavaScript Document

function displayDS(n){
	obj=document.getElementById('clonedDS_'+n);
	if (obj.style.visibility=='hidden'){
		obj.style.visibility='visible';
		obj.style.height=document.getElementById('contentTable_'+n).style.height;
		document.getElementById('displayTag_'+n).innerHTML = "Hide Edited Page";
	}else{
		obj.style.visibility='hidden';
		document.getElementById('adminMenu_'+n).innerHTML = "";
		document.getElementById('adminMenu_'+n).style.visibility='hidden';
		obj.style.height=0;
		document.getElementById('displayTag_'+n).innerHTML = "Display Edited Page";
	}

}

function editContent(name,content, col, rows, id){
	var obj = document.getElementById(name);
	obj.innerHTML='<form name="kw"><textarea name="'+name+'" cols="'+col+'" rows="'+rows+'">'+content+'</textarea></form>';
	document.getElementById('WordsDiv').style.visibility = 'visible';
	document.getElementById('WordsDiv').style.height = '45px';
}
function submitKeywords(id,name){
	window.location = 'index.php?command=editorPage&operation=saveCategoryKeywords&catid='+ id +'&words='+escape(document.kw.keywords_field.value);
}


function alertBeforeDelete(num,linkToPublish){
	if (num==0){
		var answer = confirm("WARNING\nThis action will remove any references to this page from this Category . \nThis action will not delete the page from other categories\nAre you sure you want to perform this action?")

	}else if (num==1){
		var answer = confirm("WARNING\nThis action will Permanently delete all instances of this page in all categories \nAre you sure you want to perform this action?")
	}
	if (answer){
		window.location = linkToPublish;
	}
	//window.location=linkToPublish
}

function alertBeforePerformAction(linkToPublish){

	var answer = confirm("WARNING\nChanges made to the description, comments, and title will not be saved automatically. \nDo you still want to perform this action and lose any unsaved changes?")
	if (answer){
		window.open(linkToPublish);
	}
	//window.location=linkToPublish
}

// JavaScript Document
var url2 = "getCategoriesData.php?id="; // The server-side script
var whichElement=''



function getHTTPObject() {
  var xmlhttp;
  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }

  @else

  xmlhttp = false;

  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}




function showCategoryContent(elementID,id,dsid,currCatID){
	//if (document.getElementById(elementID).style.visibility=='hidden'){
		document.getElementById(elementID).style.visibility='visible';
		 document.getElementById(elementID).innerHTML = "Loading ...";
		whichElement=	elementID;
		  http.open("GET", url2+id+'&dsid='+dsid+'&currCatID='+currCatID , true);
		  http.onreadystatechange = handleHttpResponse;

		  http.send(null);


}
function handleHttpResponse(elementID) {
  if (http.readyState == 4) {
     document.getElementById(whichElement).innerHTML = http.responseText;
	 //whichElement='';
  }
}
var http = getHTTPObject();
