function popup (url,name,properties)
{ 

  openedwindow=window.open(url,name,properties);
  if(openedwindow){
	  openedwindow.focus();
  }
  
}
function windowspopup (url,name,properties)
{ 
  openedwindow=window.open(url,name,properties);
  if(openedwindow){
	  openedwindow.focus();
  }
}
function doConfirm(){
		if (confirm ("You are about to delete this record. Are you sure?"))
			return true;
		else
			return false;
		}
function doConfirmAction(msg){
		if (confirm (msg))
			return true;
		else
			return false;
}	
function refresh(){
	window.location.href=window.location.href;
}	
function chkRetun()
	{
	if (event.keyCode==13)
		{
		if (event.shiftKey==false)
			{
			var thisSel = 
			document.selection.createRange();
			thisSel.pasteHTML('<br>')
			event.cancelBubble = true; 
			event.returnValue = false; 
			thisSel.select();
			thisSel.moveEnd("character", 1);
			thisSel.moveStart("character", 1);
			thisSel.collapse(false);
			return false;
			idContent.focus();
			}
		else
			{
			return event.keyCode=13
			}
		}
	}

function postForm(frmName,fldName){
        var Search="http://"+ servername + "/admin/";
        var content = idContent.document.body.innerHTML;
        content = SearchAndReplace(content,Search,"");
        content = SearchAndReplace(content,'<LI>','<LI class="normallist">');
        content = SearchAndReplace(content,'<TABLE borderColor=#001970','<TABLE class="tables" borderColor=#001970');
        document.forms[frmName].elements[fldName].value=content;
        if(document.forms[frmName].RawHtml){
		    if(document.forms[frmName].RawHtml.checked){
			    document.forms[frmName].elements[fldName].value=document.forms[frmName].txtCONTENTRAW.value;
		    }
        }
		document.forms[frmName].submit();
		}	


function SearchAndReplace(Content, SearchFor, ReplaceWith) {

   var tmpContent = Content;
   var tmpBefore = new String();   
   var tmpAfter = new String();
   var tmpOutput = new String();
   var intBefore = 0;
   var intAfter = 0;

   if (SearchFor.length == 0)
      return;


   while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) {
   
      // Get all content before the match
      intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase());
      tmpBefore = tmpContent.substring(0, intBefore);
      tmpOutput = tmpOutput + tmpBefore;

      // Get the string to replace
      tmpOutput = tmpOutput + ReplaceWith;


      // Get the rest of the content after the match until
      // the next match or the end of the content
      intAfter = tmpContent.length - SearchFor.length + 1;
      tmpContent = tmpContent.substring(intBefore + SearchFor.length);

   }

   return tmpOutput + tmpContent;

}

function validate(frmName){

	for (i=0;i<document.forms[frmName].length;++i)
		if (!document.forms[frmName].elements[i].value)
			{
			alert ("Please fill all fields ..");
			return false;
			}

	if (isEmailAddr(document.forms[frmName].elements["Email"].value) == false)
		{
		alert ("Invalid Email Id");
		return false;
		}
	return true;
	}

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}


var element;var docevent;

function captureme(elementobject,pdocevent,pageid){element = elementobject;docevent = pdocevent;
    if(event.button == 2 || event.button == 3) {
        sortPageId=pageid;
        dropdownmenu(element, event, rightmenu1, '150px');
        return false;
    }    
}

function sortorder(pageid,sorttype){
    popup('sortpageorder.php?sortpageid='+pageid+'&sortmode='+sorttype,'sort','width=50,height=50,scrollbars=yes');
}

function delpage(pageid){
    popup('delete_page.php?delpageid='+pageid+'&action=del&pageid=1','del','width=50,height=50,scrollbars=yes');
}


function change(id, newClass,oldClass) {
    var bodyelement=document.getElementById("thebody");
    var arrElements = new Array(6);
    arrElements[0]='column01';
    arrElements[1]='column02';
    arrElements[2]='column03';
    arrElements[3]='column04';
    arrElements[4]='column05';
    arrElements[5]='column06';
    arrElements[6]='column07';

    for(var i=0; i<=arrElements.length;i++){
        identity=document.getElementById(arrElements[i]);
        if(identity){
            if(identity.style.display=='none'){
                identity.style.display='';
                bodyelement.className="bodypanelopen";
            }else{
                identity.style.display='none';
                bodyelement.className="bodypanelclosed";
            }
        }        
    }
    identity=document.getElementById(id);
    if(identity){
        if (identity.className==oldClass){
	        identity.className=newClass;
        }else{
	        identity.className=oldClass;
        }
    }

}

	function DelEvent(){
	    var objfrm = document.form1;
		if(isChecked(objfrm)){
			if(doConfirm()){
				objfrm.pageaction.value ="DEL";
				objfrm.submit();
			}
		}else{
			alert("Please select a record to delete");
		}
	}
    function isChecked(objfrm){
	    if(objfrm){
    	    for(i=0;i< objfrm.elements.length;i++){
    		    if(objfrm.elements[i].checked)
    			    return true;
    	    }
    	}
    	return false;
	
    }

    function changeColor(blnOver, rowTarget) {
        var cells = rowTarget.cells;
        for (var i = 0; i < cells.length; i++) {
            cells[i].className = (blnOver) ? "cellOver" : ("c" + (i + 1))
    }
    
    }
    function changeColor1(blnOver, rowTarget) {
        var cells = rowTarget.cells;
        rowTarget.className = (blnOver) ? "cellOver" : ("dots")
    }
    function clicked(paraid,pageid){
        parent.location.href="admin/para-edit.php?paraid=" + paraid + "&pageid=" + pageid + "&module=para";

    }
    var selectallvariable=true;
    function selectall(){
	     var objfrm = document.form1;
	      if(objfrm){
    	    for(i=0;i< objfrm.elements.length;i++){
	    	    if(objfrm.elements[i].type=="checkbox"){
		    	    if(selectallvariable){
		    	    	objfrm.elements[i].checked=true;
	    	    	}else{
		    	    	objfrm.elements[i].checked=false;
	    	    	}
	    	    }
    	    }
    	    if(selectallvariable){
	    	    selectallvariable=false;
    	    }else{
	    	    selectallvariable=true;
    	    }
    	}
    }
