var initialImages
global_reload = false
source = new Array();
function loading()
{
	foo.location.href=document.all("pageurl").value;
	foo.document.designMode = 'On';
	if(global_reload == true) {
		global_reload=false;
	}
	foo.location.reload();
	window.setTimeout("loadAfter()",200);
}

function loadAfter() {
	if(foo.document.readyState != "complete") {
		window.setTimeout("loadAfter()",200);
		return;
	}
	foo.focus();
	initialImages = foo.document.images;
	var initCount=initialImages.length;
	for(i=0;i<initCount;i++) {
		source.push(initialImages[i].src);	
	}
}
function changeFont(tFont) {
	foo.document.execCommand(tFont);
	foo.focus();	
}
function doFont(t) {
	foo.document.execCommand('FontName',false,t[t.selectedIndex].value);
	foo.focus();
	t.selectedIndex=0;
}
	//size changing
	function doSize(t) {
		foo.document.execCommand('FontSize',true,t[t.selectedIndex].value);
		foo.focus();
		t.selectedIndex=0;
	}
	//end size changing
	
	
	/*function fooLoad()
	{
		//alert('');
		return true;
	}*/
	
	var Mode = "1";
	function setHeight() {
		//height = 119
		height = 5
		
		if (Mode == 2)
		{ 
			height = 87
		}
		return (document.body.clientHeight-height)
	}
	
	function button_down(eButton){
		eButton.style.borderBottom = "buttonhighlight solid 1px";
		eButton.style.borderLeft = "buttonshadow solid 1px";
		eButton.style.borderRight = "buttonhighlight solid 1px";
		eButton.style.borderTop = "buttonshadow solid 1px";
	}
	
	function button_over(eButton){
		if (eButton.style.borderBottom != "buttonhighlight 1px solid")
		{
		eButton.style.borderBottom = "buttonshadow solid 1px";
		eButton.style.borderLeft = "buttonhighlight solid 1px";
		eButton.style.borderRight = "buttonshadow solid 1px";
		eButton.style.borderTop = "buttonhighlight solid 1px";
		}
	}
	function button_out2(eButton){
		if (eButton.style.borderBottom != "buttonhighlight 1px solid")
		{
		eButton.style.borderColor = "threedface";
		}
		eButton.style.borderColor = "threedface";
	}

	function button_out(eButton){
		eButton.style.borderColor = "threedface";
	}
	var SlectedColor = null;
	function changefontcolor(colorType){
		          if(colorType == 1){
		   			SeletedRange = foo.document.selection.createRange();
					
				   if(SeletedRange.queryCommandValue('ForeColor')){
				   		 SlectedColor = foo.queryCommandValue('ForeColor').toString(16);
						    while(SlectedColor.length < 6)
						     SlectedColor = '0' + SlectedColor;
						    SlectedColor = SlectedColor.substr(4) + SlectedColor.substr(2, 2) + SlectedColor.substr(0, 2);
						   }
		           }

				  if(SlectedColor == null)
				   var Callcolordialog = colordialog.ChooseColorDlg();
				  else
				   var Callcolordialog = colordialog.ChooseColorDlg(SlectedColor);

  				  Callcolordialog = Callcolordialog.toString(16);
				  if (Callcolordialog.length < 6) {
				   var Temp = "000000".substring(0,6-Callcolordialog.length);
				   Callcolordialog = Temp.concat(Callcolordialog);
				  }
 
				  Command = (colorType == 2) ? 'BackColor' : 'ForeColor';
				  foo.document.execCommand(Command, false, Callcolordialog);
				  SlectedColor = Callcolordialog;
  
 	}
	
function isImageSelected() {
  foo.focus()
  if (foo.document.selection.type == "Control") {
   var oControlRange = foo.document.selection.createRange();
   if (oControlRange(0).tagName.toUpperCase() == "IMG") {
    selectedImage = foo.document.selection.createRange()(0);
    return true;
   }	
  }
 }	
//Image Insertion	
function sImgDlg(){
  res = showModalDialog('includes/tImage.php', null, 'dialogWidth: 330px; dialogHeight: 225px; center: yes; resizable: no; scroll: no; status: no;');
  if(res == 'lib')
   res = showModalDialog('lib/lib.php', null, 'dialogWidth: 770px; dialogHeight: 450px; center: yes; resizable: no; scroll: no; status: no;');
  if(res)
   return res;
 }
 
function sNewImg(){
  if(isImageSelected())
   temp = selectedImage;
  else
   temp = 0;
  
  res = sImgDlg();
  if(res){
   document.forms.imgUpl.nSel.outerHTML = '<select name=nSel>' + document.forms.imgUpl.nSel.innerHTML + '<option value=images/' + res.replace(/^.*\//ig, '') + '">' + res.replace(/^.*\//ig, '') + '</option></select>';
   uplTd.style.display = 'block';
//   document.forms.fileUpl.nSel.outerHTML = '<select name=nSel>' + document.forms.fileUpl.nSel.innerHTML + '<option value="images/' + res.replace(/^.*\//ig, '') + '">' + res.replace(/^.*\//ig, '') + '</option></select>';
//   upfTd.style.display = "block";

   foo.focus();
   foo.document.execCommand("InsertImage", false, res);
  
   if(isImageSelected() && temp){
    selectedImage.style.position = temp.style.position;
    selectedImage.style.zIndex = temp.style.zIndex;
    selectedImage.style.top = temp.style.top;
    selectedImage.style.left = temp.style.left;
    selectedImage.style.borderColor = temp.style.borderColor;
    selectedImage.border = temp.border;
    selectedImage.style.alt = temp.alt;
    selectedImage.hspace = temp.hspace;
    selectedImage.vspace = temp.vspace;
    selectedImage.align = temp.align;
   }
  }
 }
 //end Image Insertion
 
 //Table Insertion
 function ShowInsertTable() {
try{
  sFakedObj = new Object();
  sFakedObj.cellPadding = 1;
  sFakedObj.cellSpacing = 2;
  res = showModalDialog('includes/tprop.php', sFakedObj, 'dialogWidth: 375px; dialogHeight: 260px; center: yes; resizable: no; scroll: no; status: no;');
  if(res){
   foo.focus();
   sParent = foo.document.selection.createRange().parentElement();
   sNewTable = foo.document.createElement('<table>');
   sParent.appendChild(sNewTable);

   HTMLTable = "<table" + (res.width ? ' width=' + res.width : '') + " border=" + res.border + " cellpadding=" + res.cellPadding + " cellspacing=" + res.cellSpacing + (res.bgColor ? ' bgcolor = ' + res.bgColor : '') + (res.background ? ' background=' + res.background : '') + ">";        
   for(i=0; i<res.rows; i++){
    HTMLTable = HTMLTable + "<tr>";
    for(j=0; j<res.columns; j++)
     HTMLTable = HTMLTable + "<td>&nbsp</td>"
    HTMLTable = HTMLTable + "</tr>"
   }       			
   HTMLTable = HTMLTable + "</table>"
   sNewTable.outerHTML = HTMLTable;

	try{
		if(borderShown){
			sNewTable.runtimeStyle.borderTop = sNewTable.runtimeStyle.borderLeft = "1px dotted #BFBFBF";
			allRows = sNewTable.rows;
			for(y=0; y < allRows.length; y++){
			 allCells = allRows[y].cells;
			 for(x=0; x < allCells.length; x++)
			   allCells[x].runtimeStyle.borderRight = allCells[x].runtimeStyle.borderBottom = "1px dotted #BFBFBF";
			}
	   }
	}catch(e){}
  }
  }catch(e)
  {
  }
 }
 //New
 function Createtable(){
	 TbObj = new Object();
	  TbObj.cellPadding = 1;
	  TbObj.cellSpacing = 2;
		 res = showModalDialog('tblpro.php', TbObj, 'dialogWidth: 360px; dialogHeight: 328px; center: yes; resizable: no; scroll: no; status: no;');
		 if(res){
		   foo.focus();
		   SelParent = foo.document.selection.createRange().parentElement();
		   NewTable = foo.document.createElement('<table>');
		   SelParent.appendChild(NewTable);
		   if(res.width=="" && res.width <10)
		     res.width=100;
		   //HTMLTable = "<table" + (res.width ? ' width=' + res.width : '') + " border=" + res.border + " cellpadding=" + res.cellPadding + " cellspacing=" + res.cellSpacing + (res.bgColor ? ' bgcolor = ' + res.bgColor : '') + (res.background ? ' background=' + res.background : '') + ">";        
		   StrNewTable = "<table width=" + res.width + "  border=" + res.border + " cellpadding=" + res.cellPadding + " cellspacing=" + res.cellSpacing + ' bgcolor = ' + res.bgColor + ">";        
		   for(i=0; i<res.rows; i++){
		    StrNewTable = StrNewTable + "<tr>";
		    for(j=0; j<res.columns; j++)
		     StrNewTable = StrNewTable + "<td>&nbsp;</td>"
		    StrNewTable = StrNewTable + "</tr>"
		   }       			
		   StrNewTable = StrNewTable + "</table>"
		   NewTable.outerHTML = StrNewTable;
		 }  
 }
 
 function CheckcursorIsinTableCell(){
     foo.focus();

	if(document.selection.type != "Control"){
	  
	           var pointedElem = document.selection.createRange().parentElement();
			   while(pointedElem.tagName.toUpperCase() != "TD" && pointedElem.tagName.toUpperCase() != "TH"){
			    pointedElem = pointedElem.parentElement
			    if(pointedElem == null)
			     break
			   }
			   
			   if(pointedElem){
					    PointedTD = pointedElem
					    PointedTR = PointedTD.parentElement
					    PointedTBODY =  PointedTR.parentElement
					    PointedTable = PointedTBODY.parentElement
					    return true
			   }else{
			    alert("Please Place the cursor inside the table cell");
			   }	
	  }
	  
 }

 function InsertColumbefore(){
   
		 if (CheckcursorIsinTableCell()){
		   Movecolumn = (PointedTR.cells.length-1) - (PointedTD.cellIndex)
		   TotalRows = PointedTable.rows
		   for(i=0;i<TotalRows.length;i++){
		    rowCount = TotalRows[i].cells.length - 1
		    WheretoInsert = rowCount - Movecolumn
		    if(WheretoInsert < 0)
		     WheretoInsert = 0
		    newCell = TotalRows[i].insertCell(WheretoInsert)
		    newCell.innerHTML = " "
		   }	
		  }
 }
 function InsertColumafter(){
   
		 if (CheckcursorIsinTableCell()){
		   Movecolumn = (PointedTR.cells.length-1) - (PointedTD.cellIndex + 1)
		   TotalRows = PointedTable.rows
		   for(i=0;i<TotalRows.length;i++){
		    rowCount = TotalRows[i].cells.length - 1
		    WheretoInsert = rowCount - Movecolumn 
		    if(WheretoInsert < 0)
		     WheretoInsert = 0
		    newCell = TotalRows[i].insertCell(WheretoInsert)
		    newCell.innerHTML = " "
		   }	
		  }
 }
 function InsertRowbefore(){
  if(CheckcursorIsinTableCell()){
   var TotCols = 0
   TotRows = PointedTR.cells
   for(var i=0;i<TotRows.length;i++) 
    TotCols = TotCols + TotRows[i].getAttribute('colSpan')
   var Newtablerow = PointedTable.insertRow(PointedTR.rowIndex)
   for(i = 0; i < TotCols; i++){
    Newtablecolumn = Newtablerow.insertCell()
    Newtablecolumn.innerHTML = " "
   }
  }	
 }
 function InsertRowafter(){
  if(CheckcursorIsinTableCell()){
   var TotCols = 0
   TotRows = PointedTR.cells
   for(var i=0;i<TotRows.length;i++) 
    TotCols = TotCols + TotRows[i].getAttribute('colSpan')
   var Newtablerow = PointedTable.insertRow(PointedTR.rowIndex + 1)
   for(i = 0; i < TotCols; i++){
    Newtablecolumn = Newtablerow.insertCell()
    Newtablecolumn.innerHTML = " "
   }
  }	
 }

 function DeleteRow(){
  if(CheckcursorIsinTableCell())
   PointedTable.deleteRow(PointedTR.rowIndex)
 }
 function DeleteColumn(){
  if(CheckcursorIsinTableCell()){
   Movecolumn = (PointedTR.cells.length-1) - (PointedTD.cellIndex)
   TotalRows = PointedTable.rows
   for(var i=0;i<TotalRows.length;i++){
    LastRow = TotalRows[i].cells.length - 1
    DeleteR = LastRow - Movecolumn
    if(DeleteR < 0)
     DeleteR = 0
    Totalcells = TotalRows[i].cells
    if(Totalcells[DeleteR].colSpan > 1)
     Totalcells[DeleteR].colSpan = Totalcells[DeleteR].colSpan - 1
    else
     TotalRows[i].deleteCell(DeleteR)
   }
  }
 }
 
 function ModifyTable(){
	  TbObj = new Object();
	  TbObj.cellPadding = 1;
	  TbObj.cellSpacing = 2;
	  if(CheckcursorIsinTableCell()){
	 // alert(PointedTable.rows.length);
        res = showModalDialog('includes/tblpromodi.php', PointedTable, 'dialogWidth: 360px; dialogHeight: 400px; center: yes; resizable: no; scroll: no; status: no;');
 
			 if(res){
					    if(res.width)
					     PointedTable.width = res.width;
					    else
					     PointedTable.removeAttribute('width',0);
					
					    if(res.cellPadding)
					     PointedTable.cellPadding = res.cellPadding;
					    else
					     PointedTable.removeAttribute('cellPadding',0);
					    
					    if(res.bgColor)
					     PointedTable.bgColor = res.bgColor;
					    else
					     PointedTable.removeAttribute('bgColor',0);
					
					    if(res.background)
					     PointedTable.background = res.background;
					    else
					     PointedTable.removeAttribute('background',0);
					
							  if(res.cellSpacing)
					     PointedTable.cellSpacing = res.cellSpacing;
					    else
					     PointedTable.removeAttribute('cellSpacing',0);
					
						if(res.border)
					     PointedTable.border = res.border;
					    else
					     PointedTable.removeAttribute('border',0);
					    if(res.borderColor)
					     PointedTable.borderColor = res.borderColor;
					    else
					     PointedTable.removeAttribute('borderColor',0);
					    if(res.align)
					     PointedTable.align = res.align;
					    else
					     PointedTable.removeAttribute('align',0);
						 
					}
	}		   
 }
 
 function ModifyCell(){
  if(CheckcursorIsinTableCell()){
   res = showModalDialog('includes/cellprop.php', PointedTD, 'dialogWidth: 370px; dialogHeight: 425px; center: yes; resizable: no; scroll: no; status: no;');
   if(res){
    PointedTD.colSpan = res.colSpan;
    PointedTD.rowSpan = res.rowSpan;
    if(res.width)
     PointedTD.width = res.width;
    else
     PointedTD.removeAttribute('width',0);

    if(res.height)
     PointedTD.height = res.height;
    else
     PointedTD.removeAttribute('height',0);
    
    if(res.bgColor)
     PointedTD.bgColor = res.bgColor;
    else
     PointedTD.removeAttribute('bgColor',0);

    if(res.background)
     PointedTD.background = res.background;
    else
     PointedTD.removeAttribute('background',0);

		  if(res.align && !res.align.match(/^None$/i))
     PointedTD.align = res.align;
    else
     PointedTD.removeAttribute('align',0);

	  	if(res.vAlign && !res.vAlign.match(/^None$/i))
     PointedTD.vAlign = res.vAlign;
    else
     PointedTD.removeAttribute('vAlign',0);
   }
  }else{
   alert('Please put the curcor in the cell you want to edit first.');
  }
 } 
 
 function ChangeCellBg(){
    if(CheckcursorIsinTableCell()){
	       
				   var Callcolordialog = colordialog.ChooseColorDlg();
				   Callcolordialog = Callcolordialog.toString(16);
				  if (Callcolordialog.length < 6) {
				   var Temp = "000000".substring(0,6-Callcolordialog.length);
				   Callcolordialog = Temp.concat(Callcolordialog);
				  }
          PointedTD.bgColor = Callcolordialog;
    	
	}
 }
 function ChangeColsize(){
   if(CheckcursorIsinTableCell()){
     var colwidth = prompt("Enter a Image URL:", "100%");
    PointedTD.width = colwidth;
   }
 
 }
 
//End Table Insertion 

//showhtml
var SelMode=1;
 function ShowHtml() {
  if (SelMode == 1) {
   selctedrange = foo.document.selection.createRange();
   Htmltext = selctedrange.htmlText;

   foo.document.body.innerText = foo.document.documentElement.outerHTML.replace(/&amp;/g, '&');
   code = foo.document.body.innerHTML;
   code = code.replace(/(&lt;([\s\S]*?)&gt;)/gi, "<font color=#000080>$1</font>")
   code = code.replace(/(&lt;(table|tbody|th|tr|td|\/table|\/tbody|\/th|\/tr|\/td)([\s\S]*?)&gt;)/gi, "<font color=#008080>$1</font>")
   code = code.replace(/(&lt;!--([\s\S]*?)&gt;)/gi, "<font color=#808080>$1</font>")
   code = code.replace(/(&lt;img([\s\S]*?)&gt;)/gi, "<font color=#800080>$1</font>")
   code = code.replace(/(&lt;(a|\/a)([\s\S]*?)&gt;)/gi, "<font color=#008000>$1</font>")
   code = code.replace(/(&lt;(script|\/script)([\s\S]*?)&gt;)/gi,"<font color=#800000>$1</font>")
   foo.document.body.innerHTML = code;
   foo.document.body.runtimeStyle.fontFamily = "Verdana"
   foo.document.body.runtimeStyle.fontSize = "10pt"
   foo.document.body.runtimeStyle.bgColor = '#FFFFFF';
   foo.document.body.runtimeStyle.color = '#000000';
   foo.document.body.runtimeStyle.text = '#000000';
   foo.document.body.runtimeStyle.background = '';
   foo.document.body.runtimeStyle.marginTop = '10px';
   foo.document.body.runtimeStyle.marginLeft = '10px';

   Selectednewrange = foo.document.selection.createRange();
   r = foo.document.body.createTextRange();
   if(Htmltext && r.findText(Htmltext)){
    r.select();
    r.scrollIntoView();
   }

   foo.document.onkeypress = function(){
    if(foo.event.shiftKey && foo.event.keyCode == 13){
     sRange = foo.document.selection.createRange();
     sRange.text = '<BR>';
    }
   }

   SelMode = 2;
  }else{
   foo.document.body.innerHTML = foo.document.body.innerText;
   foo.document.body.runtimeStyle.cssText = "";
   foo.document.onkeypress = '';
   SelMode = 1;
  }
 }

//end showhtml

//Form Show

function isAllowed() {
		var sel
		var obj
		// if (editDefault != 1) {
		//	return true
		// } else {
			
			sel = foo.document.selection
			
			if (sel.type != "Control")
			{
				obj = sel.createRange().parentElement()
			} else {
				obj = sel.createRange()(0)
			}
			
			if (obj.isContentEditable) {
				return true
			} else {
				return false
			}

		return true
			
		//}
	}
function isCursorInForm() {
		if (document.selection.type != "Control") {
                          var elem = document.selection.createRange().parentElement()
                          while (elem.tagName != "FORM")
                          {
                            elem = elem.parentElement
                            if (elem == null)
                              break
                          }
				if (elem) {
					selectedForm = elem
					return true
				}
		}
	}

function insertForm() {
		if (isAllowed())
		{
			var leftPos = (screen.availWidth-500) / 2
			var topPos = (screen.availHeight-400) / 2 
	 		insertFormWin = window.open('insertform.php','','width=500,height=440,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}
	}

function modifyForm() {
		if (isAllowed)
		{

		if (isCursorInForm()) {
			var leftPos = (screen.availWidth-500) / 2
			var topPos = (screen.availHeight-400) / 2 
	 		modifyFormWin = window.open('modifyform.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}

		}
	}
function doTextField() {
		if (isAllowed())
		{

		var leftPos = (screen.availWidth-500) / 2
		var topPos = (screen.availHeight-400) / 2 

		if (foo.document.selection.type == "Control") {
			var oControlRange = foo.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "INPUT") {
				if ((oControlRange(0).type.toUpperCase() == "TEXT") || (oControlRange(0).type.toUpperCase() == "PASSWORD")) {
					selectedTextField = foo.document.selection.createRange()(0);
					textFieldWin = window.open('modifytextfield.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
				}
				return true;
			}	
		} else {
			textFieldWin = window.open('inserttextfield.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}

		}
	}

function doTextArea() {
		if (isAllowed())
		{

		var leftPos = (screen.availWidth-500) / 2
		var topPos = (screen.availHeight-400) / 2 

		if (foo.document.selection.type == "Control") {
			var oControlRange = foo.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "TEXTAREA") {
					selectedTextArea = foo.document.selection.createRange()(0);
					textFieldWin = window.open('modifytextarea.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
				return true;
			}	
		} else {
			textFieldWin = window.open('inserttextarea.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}

		}
	}
function doHidden() {
		if (isAllowed())
		{

		var leftPos = (screen.availWidth-500) / 2
		var topPos = (screen.availHeight-400) / 2 

		if (foo.document.selection.type == "Control") {
			var oControlRange = foo.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "INPUT") {
				if (oControlRange(0).type.toUpperCase() == "HIDDEN") {
					selectedHidden = foo.document.selection.createRange()(0);
					hiddenWin = window.open('modifyhidden.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
				}
				return true;
			}	
		} else {
			hiddenWin = window.open('inserthidden.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}

		}
	}	
function doButton() {
		if (isAllowed())
		{

		var leftPos = (screen.availWidth-500) / 2
		var topPos = (screen.availHeight-400) / 2 

		if (foo.document.selection.type == "Control") {
			var oControlRange = foo.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "INPUT") {
				if ((oControlRange(0).type.toUpperCase() == "RESET") || (oControlRange(0).type.toUpperCase() == "SUBMIT") || (oControlRange(0).type.toUpperCase() == "BUTTON")) {
					selectedButton = foo.document.selection.createRange()(0);
					buttonWin = window.open('modifybutton.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
				}
				return true;
			}	
		} else {
			buttonWin = window.open('insertbutton.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}

		}
	}	
function doCheckbox() {
		if (isAllowed())
		{

		var leftPos = (screen.availWidth-500) / 2
		var topPos = (screen.availHeight-400) / 2 

		if (foo.document.selection.type == "Control") {
			var oControlRange = foo.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "INPUT") {
				if (oControlRange(0).type.toUpperCase() == "CHECKBOX") {
					selectedCheckbox = foo.document.selection.createRange()(0);
					checkboxWin = window.open('modifycheckbox.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
				}
				return true;
			}	
		} else {
			checkboxWin = window.open('insertcheckbox.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}

		}
	}

function doRadio() {
		if (isAllowed()) {

		var leftPos = (screen.availWidth-500) / 2
		var topPos = (screen.availHeight-400) / 2 

		if (foo.document.selection.type == "Control") {
			var oControlRange = foo.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "INPUT") {
				if (oControlRange(0).type.toUpperCase() == "RADIO") {
					selectedRadio = foo.document.selection.createRange()(0);
					radioWin = window.open('modifyradio.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
				}
				return true;
			}	
		} else {
			radioWin = window.open('insertradio.php','','width=500,height=400,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
		}

		}
	}	
//End Form Show

//Insert Link
var sUploadsList = new Array();
var sPages = new Array("index.html","search.html");
onload = function(){
		try{
		for(i in sPages){
			sPageSwitch.options[sPageSwitch.length] = new Option(sPages[i], sPages[i]);
			if(sPages[i] == location.href.replace(/^(.)*=/ig, ''))
				sPageSwitch.options[sPageSwitch.length-1].selected = true;
		}
		}catch(e){ }
		loading();
	}
	
/*function sHyperlink(){

  if(foo.document.selection.type == 'None'){
   alert('Please select text or image first.');
  }else{
   sSel = new Object();
   sSel.defLinkColor = foo.document.body.link ? foo.document.body.link : '#0000ff';

   if(foo.document.selection.type == "Control"){
    var oControlRange = foo.document.selection.createRange();
    if(oControlRange(0).tagName.toUpperCase() == "IMG")
     oSel = oControlRange(0).parentNode;
   }else{
    oSel = foo.document.selection.createRange().parentElement();
   }

   sRange = foo.document.selection.createRange();

   if(sRange.queryCommandValue('ForeColor')){
    sSel.linkcolor = sRange.queryCommandValue('ForeColor').toString(16);
    while(sSel.linkcolor.length < 6)
     sSel.linkcolor = '0' + sSel.linkcolor;
    sSel.linkcolor = sSel.linkcolor.substr(4) + sSel.linkcolor.substr(2, 2) + sSel.linkcolor.substr(0, 2);
   }
   if(sRange.queryCommandState('Underline', false, null))
    sSel.linkDec = 'underline';

   if(oSel.tagName != 'A'){
    firedObj = oSel;
    while(firedObj.tagName != "BODY" && firedObj.tagName != "A")
     firedObj = firedObj.parentElement;
    if(firedObj.tagName == 'A')
     oSel = firedObj;
   }

   if(oSel.tagName == "A"){
    if(oSel.childNodes[0] && oSel.childNodes[0].tagName){
     tmpObj = oSel.childNodes[0];
     while(!tmpObj.tagName == 'FONT' && typeof(tmpObj.childNodes[0]) != 'undefined')
      tmpObj = tmpObj.childNodes[0];
     
     if(tmpObj.tagName == 'FONT' && tmpObj.outerHTML && tmpObj.outerHTML.match(/<font[^>]*onmouseover/i)){
      if(temp = tmpObj.outerHTML.match(/this\.color='#([0-9a-fA-F]*)/i))
       sSel.hovercolor = temp[0].replace(/.*'#/, '');
      if(temp = tmpObj.outerHTML.match(/textDecoration='([^']*)/i))
       sSel.hoverDec = temp[0].replace(/.*'/, '');
     }
    }

    sSel.popup = oSel.target == '_blank' ? true : false;

    if(oSel.outerHTML.match(/onclick=/ig) && oSel.onclick.match(/^open\(/)){
      sHref = oSel.onclick.replace(/^.*\/|['|"].*$/g, '');
      sSel.popup = true;
      sSel.res = oSel.onclick.replace(/^.*resizable=|;.*$/g, '');
      sSel.status = oSel.onclick.replace(/^.*status=|;.*$/g, '');
      sSel.tool = oSel.onclick.replace(/^.*toolbar=|;.*$/g, '');
      sSel.width = oSel.onclick.replace(/^.*width=|;.*$/g, '');
      sSel.height = oSel.onclick.replace(/^.*height=|;.*$/g, '');
    }else{
     sHref = unescape(oSel.href);
    }

    if(sHref.match(/@/)){
     sSel.type = 3;*/
//     sSel.url = sHref.replace(/^mailto:( )*/ig, '');
/*    }else if(sHref.match(/^http:\/\/guestbook/i)){
     sSel.type = 1;
     sSel.url = sHref;
    }else if(sHref.match(/usr/ig) || !sHref.match(/http:/ig)){
     sHref = sHref.replace(/(.)*\//ig, '');
     match = false;
     for(key in sUploadsList)
      match = sUploadsList[key] == sHref;
     if(match){
      sSel.type = 4;
      sSel.url = sHref;
     }else{
      sSel.type = 1;
      sSel.url = sHref ? sHref : 'index.html';
     }
    }else{
     sSel.type = 2;
     sSel.url = sHref;
    }   
   }

   sSel.self = location.href.replace(/.*file=/ig, '');
   sSel.pages = sPageSwitch.options;
	
	//window.open('http://www.site2you.com/builder/inc/sHyperlink.php');
   res = showModalDialog('insertlink.php', sSel, 'dialogWidth: 280px; dialogHeight: 535px; center: yes; resizable: no; scroll: no; status: no;');

   if(res && res.url){
    oNewSelection = foo.document.selection.createRange();
    if(foo.document.selection.type == "Control"){
     selectedImage = foo.document.selection.createRange()(0);
     selectedImage.border = selectedImage.border ? selectedImage.border : 0;
    }

    oNewSelection.execCommand("CreateLink",false,res.url);
    
    if(res.linkcolor)
     oNewSelection.execCommand('ForeColor', false, res.linkcolor);
    if(res.linkDec && ((res.linkDec.match(/underline/i) && !oNewSelection.queryCommandState('Underline', false, null)) || (res.linkDec.match(/none/i) && oNewSelection.queryCommandState('Underline', false, null))))
     oNewSelection.execCommand('Underline', false, null);

    if(foo.document.selection.type == "Control")
     oLink = oNewSelection(0).parentNode;
    else
     oLink = oNewSelection.parentElement();

    if(oLink.tagName != 'A')
     while(oLink.tagName != "BODY" && oLink.tagName != "A")
      oLink = oLink.parentElement;

    if(oLink.tagName.match(/^A$/i)){
     oLink.removeAttribute('onclick');
     oLink.removeAttribute('target');

     if(oNewSelection.htmlText){
      if(res.hovercolor){
       sOverText = "this.tempColor=this.color; this.color='" + res.hovercolor + "';";
       sOutText = "this.color=this.tempColor;";
       if(res.hoverDec != res.linkDec){
        sOnState = res.linkDec.match(/underline/i) ? 'none' : 'underline';
        sOverText += "this.style.textDecoration='" + sOnState + "';";
        sOutText += "this.style.textDecoration='" + res.linkDec + "';";
       }      
      }     

      sOterLink = oNewSelection.htmlText.replace(/<A[^>]*>|<\/A>/ig, '');
      if(res.hovercolor){*/
//       sOterLink = sOterLink.replace(/\sonmouseover=[^\s]*|\sonmouseout=[^\s]*/ig, '');
/*       sOterLink = sOterLink.replace(/<FONT/i, '<FONT onmouseover="' + sOverText + '" onmouseout="' + sOutText + '"');
      }
      sOterLink = '<a ' + (res.params ? 'style="cursor:hand;" onclick="open(\'' + foo.document.location.href.replace(/\/[^\/]*$/ig, '/') + res.url + '\', \'_blank\', \'' + res.params + '\')"' : 'href=' + res.url + (res.popup ? ' target=_blank' : '')) + '>' + sOterLink + '</a>';
      oNewSelection.pasteHTML(sOterLink);
     }
    }

    foo.focus();
    if(res.url == 'the_s2u_new_page.html')
     sNewPage();
   }
  }
 }*/

function insertInternalLink(chk) {
	if(foo.document.selection.type == 'None'){
   alert('Please select text or image first.');
  }else{
   sSel = new Object();
   sSel.defLinkColor = foo.document.body.link ? foo.document.body.link : '#0000ff';

   if(foo.document.selection.type == "Control"){
    var oControlRange = foo.document.selection.createRange();
    if(oControlRange(0).tagName.toUpperCase() == "IMG")
     oSel = oControlRange(0).parentNode;
   }else{
    oSel = foo.document.selection.createRange().parentElement();
   }

   sRange = foo.document.selection.createRange();

   if(sRange.queryCommandValue('ForeColor')){
    sSel.linkcolor = sRange.queryCommandValue('ForeColor').toString(16);
    while(sSel.linkcolor.length < 6)
     sSel.linkcolor = '0' + sSel.linkcolor;
    sSel.linkcolor = sSel.linkcolor.substr(4) + sSel.linkcolor.substr(2, 2) + sSel.linkcolor.substr(0, 2);
   }
   if(sRange.queryCommandState('Underline', false, null))
    sSel.linkDec = 'underline';

   if(oSel.tagName != 'A'){
    firedObj = oSel;
    while(firedObj.tagName != "BODY" && firedObj.tagName != "A")
     firedObj = firedObj.parentElement;
    if(firedObj.tagName == 'A')
     oSel = firedObj;
   }

   if(oSel.tagName == "A"){
    if(oSel.childNodes[0] && oSel.childNodes[0].tagName){
     tmpObj = oSel.childNodes[0];
     while(!tmpObj.tagName == 'FONT' && typeof(tmpObj.childNodes[0]) != 'undefined')
      tmpObj = tmpObj.childNodes[0];
     
     if(tmpObj.tagName == 'FONT' && tmpObj.outerHTML && tmpObj.outerHTML.match(/<font[^>]*onmouseover/i)){
      if(temp = tmpObj.outerHTML.match(/this\.color='#([0-9a-fA-F]*)/i))
       sSel.hovercolor = temp[0].replace(/.*'#/, '');
      if(temp = tmpObj.outerHTML.match(/textDecoration='([^']*)/i))
       sSel.hoverDec = temp[0].replace(/.*'/, '');
     }
    }

    sSel.popup = oSel.target == '_blank' ? true : false;

    if(oSel.outerHTML.match(/onclick=/ig) && oSel.onclick.match(/^open\(/)){
      sHref = oSel.onclick.replace(/^.*\/|['|"].*$/g, '');
      sSel.popup = true;
      sSel.res = oSel.onclick.replace(/^.*resizable=|;.*$/g, '');
      sSel.status = oSel.onclick.replace(/^.*status=|;.*$/g, '');
      sSel.tool = oSel.onclick.replace(/^.*toolbar=|;.*$/g, '');
      sSel.width = oSel.onclick.replace(/^.*width=|;.*$/g, '');
      sSel.height = oSel.onclick.replace(/^.*height=|;.*$/g, '');
    }else{
     sHref = unescape(oSel.href);
    }

    if(sHref.match(/@/)){
     sSel.type = 3;
     sSel.url = sHref.replace(/^mailto:( )*/ig, '');
    }else if(sHref.match(/^http:\/\/guestbook/i)){
     sSel.type = 1;
     sSel.url = sHref;
    }else if(sHref.match(/usr/ig) || !sHref.match(/http:/ig)){
     sHref = sHref.replace(/(.)*\//ig, '');
     match = false;
     for(key in sUploadsList)
      match = sUploadsList[key] == sHref;
     if(match){
      sSel.type = 4;
      sSel.url = sHref;
     }else{
      sSel.type = 1;
      sSel.url = sHref ? sHref : 'index.html';
     }
    }else{
     sSel.type = 2;
     sSel.url = sHref;
    }   
   }

   sSel.self = location.href.replace(/.*file=/ig, '');
   sSel.pages = sPageSwitch.options;
   strUrlParam="?type=" + document.all("type").value;
	if(chk == 1)
	{
	res=showModalDialog('insertinternal.php' + strUrlParam, sSel, 'dialogWidth: 280px; dialogHeight: 235px; center: yes; resizable: no; scroll: no; status: no;');
	}
	else if(chk == 2)
	{
	res=showModalDialog('insertmail.php', sSel, 'dialogWidth: 280px; dialogHeight: 235px; center: yes; resizable: no; scroll: no; status: no;');
	}
	else if(chk == 3)
	{
	res=showModalDialog('insertanchor.php', sSel, 'dialogWidth: 280px; dialogHeight: 235px; center: yes; resizable: no; scroll: no; status: no;');
	}
	if(res && res.url){
    oNewSelection = foo.document.selection.createRange();
    if(foo.document.selection.type == "Control"){
     selectedImage = foo.document.selection.createRange()(0);
     selectedImage.border = selectedImage.border ? selectedImage.border : 0;
    }

    oNewSelection.execCommand("CreateLink",false,res.url);
	}
  }

}
//End Insert Link

//insert br
function inserttag(sTag){
  foo.focus();
  foo.document.selection.createRange().pasteHTML("<br>");
}
//end insert br

//Special characters
var cPopup = window.createPopup();
	
 function showMenu(menu, width, height){
  var lefter = event.clientX;
  var leftoff = event.offsetX
  var topper = event.clientY;
  var topoff = event.offsetY;
  var cPopBody = cPopup.document.body;
  
  var HTMLContent = eval(menu).innerHTML
  cPopBody.innerHTML = HTMLContent
  cPopup.show(lefter - leftoff - 2, topper - topoff + 22, width, height, document.body);
  
  return false;
 }
function insertChar(oChar) {
  foo.focus();
  var sel = foo.document.selection;
  var rng = sel.createRange();
  rng.pasteHTML(oChar.innerHTML)
  cPopup.hide()
 }
//End special Characters

//Page Properties
 function ModifyProperties(){
  open('pageprop.php','','width=740,height=340,scrollbars=no,toolbar=0');
 }
//End PageProperties

//Insert image
 function insertImage() {
	 var strUrl="type=" + document.all("type").value;
	 res = showModalDialog('insertimage.php', null, 'dialogWidth: 300px; dialogHeight: 190px; center: yes; resizable: no; scroll: no; status: no;');	 
	if(res != null && res.url != "") {
		winHeight=0;
		winWidth=0;
		if(res.url != "uploadimage.php") {
			winHeight=500;
			winWidth=360;
		}
		else {
			winHeight=140;
			winWidth=300;
		}
		res = showModalDialog(res.url + "?" + strUrl, null, 'dialogWidth: ' + winWidth + 'px; dialogHeight: ' + winHeight + 'px; center: yes; resizable: no; scroll: auto; status: no;');	 
		if(res != null && res.url != "") {
			imagePath=res.url;
			document.getElementById('foo').contentWindow.document.execCommand('InsertImage', false, imagePath);
		}
	}
 }
//End Insert Image

//Insert flash
function insertFlash() {
	imagePath="";
	var strUrl="type=" + document.all("type").value;
	res = showModalDialog('insertflash.php?' + strUrl, null, 'dialogWidth: 300px; dialogHeight: 180px; center: yes; resizable: no; scroll: no; status: no;');	 
	if(res != null && res.type == 1) {
		res = showModalDialog('uploadflash.php?' + strUrl, null, 'dialogWidth: 260px; dialogHeight: 190px; center: yes; resizable: no; scroll: no; status: no;');	 
	}
	if(res != null && res.url != "") {
		imagePath=res.url;
		SelectFlash(imagePath);	
	}		
/*		SelParent = foo.document.selection.createRange().parentElement();
	   NewTable = foo.document.createElement('<Object>');
	   SelParent.appendChild(NewTable);
	   //StrNewTable = "<embed pluginspage=http://www.macromedia.com/go/getflashplayer align=top src=\"" + imagePath +  "\" width=\"150\" height=\"150\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" bgcolor=\"_______\" salign=\"CT\" quality=\"high\" menu=\"true\" loop=\"true\"></embed>";
	   StrNewTable = "<Object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\">";
	   StrNewTable = StrNewTable + "<param name=\"movie\" value=\"" + imagePath +  "\">";
	   StrNewTable = StrNewTable + "<param name=\"quality\" value=\"high\">";
	   StrNewTable = StrNewTable + "<embed src=\""+ imagePath + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>";
	   StrNewTable = StrNewTable + "</Object>";
	   NewTable.outerHTML = StrNewTable;*/
	}
function SelectFlash(FlashName)
	{
		var sel = foo.document.selection;

		if (sel != null)
		{
			var rng = sel.createRange();
			
			if (rng != null)
			{
				/*FlashObject = 
				'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0">' +
				'<param name=movie value="' + FlashName + '">' +
				'<embed src="' + FlashName +
				'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed></object>';
				*/	
				FlashObject = '<embed src="' + FlashName +
				'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>';
				rng.pasteHTML(FlashObject);
				//self.close();
			}
		}
	}
//End Insert Flash

//Save File Section
function SaveHTMLPage(saveType) {
		try{
			if (SelMode == 2) {
				ShowHtml()
			}
		}catch(e){}
 		document.all("EditorHTM").value = foo.document.body.innerHTML
		re = /&amp;/g
		document.all("EditorHTM").value = document.all("EditorHTM").value.replace(re,'&')
		
		htmlLength = document.all("EditorHTM").value.length

		myHTML = document.all("EditorHTM").value
		mcLength = myHTML.length / 5;

		document.all("EditorHTM").value = myHTML.substring(0, mcLength);
		document.all("EditorHTM2").value = myHTML.substring(mcLength, mcLength*2 + 1);
		document.all("EditorHTM3").value = myHTML.substring(mcLength*2+1, mcLength*3 + 1);
		document.all("EditorHTM4").value = myHTML.substring(mcLength*3+1, mcLength*4 + 1);
		document.all("EditorHTM5").value = myHTML.substring(mcLength*4+1, myHTML.length);

		document.all("SaveTpe").value = saveType;
		document.all("EditorFrm").submit(); 
	}
//End Save File Section

//Add/Edit/Remove Page
	// Add a page 
	// Before adding a page we ask the  user whether to save the present page before proceeding to add 
	// a new page	
	function addPage() {
			var saveAndProceed=confirm("Do you want to save your current page before creating a new one?");
			res = showModalDialog('insertpage.php', null, 'dialogWidth: 360px; dialogHeight: 400px; center: yes; resizable: no; scroll: no; status: no;');	
			if(res.type == "" || res.name == "") {
				return;	
			}
			else if(ifPagePresent(res.name)) {
				alert("Duplicate page name. Try another name for the page.");
				return;
			}
			document.all("pagetype").value=res.type;
			document.all("editpage").value=res.name;

			if(saveAndProceed != true) {
				document.all("actiontype").value="newpage";
				document.all("PageDetails").submit();
			}
			else{
				savePage(2);
			}
		}
    function editPage() {
			if(document.all("cmbPages").value == "") {
				return;
			}
			else if(document.all("cmbPages").options[document.all("cmbPages").selectedIndex].text == document.all("presentpage").value) {
				alert('You are in the same page you are trying to edit.');
				return;
			}

			document.all("editpage").value=document.all("cmbPages").value;

			var saveAndProceed=confirm("Do you want to save your current page before editing the next page?");
			if(saveAndProceed != true) {
				document.all("actiontype").value="edit";
				document.all("PageDetails").submit();
			}
			else{
				savePage(3);
			}
		}
	function removePage() {
			if(foo.document.readyState != "complete") {
				alert('Please wait till the page gets loaded completely before performing any operation.');	
				return;
			}
			if(confirm("Are you sure you want to delete " + document.all("presentpage").value)) {
			if(document.all("cmbPages").options[document.all("cmbPages").selectedIndex].text != document.all("presentpage").value) {
				alert("Page Mismatch!");
				return;
			}
			document.all("deletedimages").value = checkForActual();
			document.all("editpage").value=document.all("cmbPages").value;
			if(isNaN(document.all("checkid").value) || document.all("checkid").value.length <= 0 || (parseInt(document.all("checkid").value) <= 0)) {
				document.all("checkid").value=1;
			}
			else {
				document.all("checkid").value = parseInt(document.all("checkid").value) + 1;
			}
			document.all("actiontype").value="delete";
			document.all("PageDetails").submit();
			}
		}
	function savePage(a) {
		if(foo.document.readyState != "complete") {
			alert('The page you are trying to save has not yet loaded completely. Please wait for the page to load completely.');	
			return;
		}
		try{
			if (SelMode == 2) {
				ShowHtml()
			}
		}catch(e){}
 		//document.all("EditorHTM").value = foo.document.body.innerHTML
		document.all("EditorHTM").value = foo.document.documentElement.outerHTML
		re = /&amp;/g
		document.all("EditorHTM").value = document.all("EditorHTM").value.replace(re,'&')
		
		htmlLength = document.all("EditorHTM").value.length

		myHTML = document.all("EditorHTM").value
		mcLength = myHTML.length / 5;

		document.all("EditorHTM").value = myHTML.substring(0, mcLength);
		document.all("EditorHTM2").value = myHTML.substring(mcLength, mcLength*2 + 1);
		document.all("EditorHTM3").value = myHTML.substring(mcLength*2+1, mcLength*3 + 1);
		document.all("EditorHTM4").value = myHTML.substring(mcLength*3+1, mcLength*4 + 1);
		document.all("EditorHTM5").value = myHTML.substring(mcLength*4+1, myHTML.length);

		if(a != 4) {
		document.all("deletedimages").value = checkForDeleted();
		document.all("newimages").value = checkForNew();
		}
		else {
			document.all("deletedimages").value = "";
			document.all("newimages").value = checkForFinal();
		}
		switch(a) {
			case 1:	
					document.all("actiontype").value = "save";
					break;
			case 2:		
				document.all("actiontype").value = "saveandcreate";
				break;
			case 3:		
				document.all("actiontype").value = "saveandedit";
				break;
			case 4:		
				document.all("actiontype").value = "saveas";
				break;
			case 5:		
				document.all("actiontype").value = "saveandexit";
				break;
			default:
					alert("Invalid function call.");
					return;
		}
		if(isNaN(document.all("checkid").value) || document.all("checkid").value.length <= 0 || (parseInt(document.all("checkid").value) <= 0)) {
			document.all("checkid").value=1;
		}
		else {
			document.all("checkid").value = parseInt(document.all("checkid").value) + 1;
		}
		//return;
		document.all("PageDetails").submit();
		}
function savePageAs() {
		res = showModalDialog('saveas.php', null, 'dialogWidth: 340px; dialogHeight: 150px; center: yes; resizable: no; scroll: no; status: no;');	
		if(res.name == "") {
			return;	
		}
		else if(ifPagePresent(res.name)) {
			alert("Duplicate page name. Try another name for the page.");
			return;
		}
		document.all("editpage").value=res.name;
		savePage(4);
	}
function saveAndExit() {
		savePage(5);
	}	

function fooLoad() {
//foo.document.onkeydown = test;
}
function test() {
		//alert(foo.event.keyCode);	//del key = 46; x=88
/*		if(foo.event.control && foo.event.keyCode == 88) {
				alert("ss");
			}
		if(foo.event.keyCode == 46)	{
			if(foo.document.selection.type == "Control") {
				var r1 = foo.document.selection.createRange(); 
					if(r1(0).tagName.match(/^IMG$/i)) {
						alert("array to be modified");	
					}
			}
		}
*/		
//		return false;
	}
//function that gives the list of images deleted from the page	
processFlag=false;
function process() {
	if(processFlag == false) {
		processFlag=true;
			finalImages = foo.document.images;
			i=0;
			var sourceCount=source.length;
			var finalCount=finalImages.length;
			while(i < sourceCount) {
				if(source[i] != "") {
					var strTemp=source[i];
					strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
					if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
						j=0;
						while(j < finalCount) {
							if(finalImages[j].src != "") {
								var strTemp2 = finalImages[j].src;
								if(strTemp == strTemp2.substring((strTemp2.lastIndexOf("/") + 1),(strTemp2.length))) {
									source[i]="";
									finalImages[j].src="";
									break;
								}
							}
							j++;
						}
					}
					else {
						source[i] == "";
					}
				}
				i++;
			}
	}
}
function checkForDeleted() {
	var strDeleted = "";
	process();
	var sourceCount=source.length;
	for(i=0;i<sourceCount;i++) {
		if(source[i] != "") {
			var strTemp=source[i];
			strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
			if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
				strDeleted = strDeleted + strTemp + "|";
			}
		}
	} 
	if(strDeleted.length > 0) {
		strDeleted = strDeleted.substring(0,strDeleted.length-1);
	}
	//alert(strDeleted);
	return strDeleted;
}
function checkForNew() {
	var strNew = "";
	process();
	var finalCount=finalImages.length;
	for(i=0;i<finalCount;i++) {
		if(finalImages[i].src != "") {
			var strTemp=finalImages[i].src;
			strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
			if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
				strNew = strNew + strTemp + "|";
			}
		}
	} 
	if(strNew.length > 0) {
		strNew = strNew.substring(0,strNew.length-1);
	}
	//alert(strNew);
	return strNew;
}
/*
function checkForDeleted_orig() {
	var strDeleted = "";
	finalImages = foo.document.images;
	i=0;
	var sourceCount=source.length;
	while(i < sourceCount) {
		var strTemp=source[i];
		strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
		j=0;
		var finalCount=finalImages.length;
		while(j < finalCount) {
			var strTemp2 = finalImages[j].src;
			if(strTemp == strTemp2.substring((strTemp2.lastIndexOf("/") + 1),(strTemp2.length))) {
				break;
			}
			j++;
		}
		if(j == finalCount && (strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl")) {
			strDeleted = strDeleted + strTemp + "|";
		}
		i++;
	}
	if(strDeleted.length > 0) {
		strDeleted = strDeleted.substring(0,strDeleted.length-1);
	}
	return strDeleted;
}   
function checkForNew_orig() {
	var strNew= "";
	finalImages = foo.document.images;
	i=0;
	var finalCount=finalImages.length;
	while(i < finalCount) {
		var strTemp=finalImages[i].src;
		strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
		j=0;
		var sourceCount=source.length;
		while(j < sourceCount) {
			var strTemp2 = source[j];
			if(strTemp == strTemp2.substring((strTemp2.lastIndexOf("/") + 1),(strTemp2.length))) {
				break;
			}
			j++;
		}
		if(j == sourceCount  && (strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl")) {
			strNew = strNew + strTemp + "|";
		}
		i++;
	}
	if(strNew.length > 0) {
		strNew = strNew.substring(0,strNew.length-1);
	}
	return strNew;
} */ 	
function checkForActual() {
	var strActual = "";
	i=0;
	var sourceCount=source.length;
	while(i < sourceCount) {
		var strTemp=source[i];
		strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
		if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
				strActual = strActual + strTemp + "|";
			}
		i++;
	}
	if(strActual.length > 0) {
		strActual = strActual.substring(0,strActual.length-1);
	}
	//alert(strActual);
	return strActual;
}
function checkForFinal() {
	var strActual = "";
	i=0;
	finalImages = foo.document.images;
	var finalCount=finalImages.length;
	while(i < finalCount) {
		var strTemp=finalImages[i].src;
		strTemp=strTemp.substring((strTemp.lastIndexOf("/") + 1),(strTemp.length));
		if(strTemp.substring(0,2) == "ug" || strTemp.substring(0,2) == "sg" || strTemp.substring(0,2) == "sl") {
				strActual = strActual + strTemp + "|";
			}
		i++;
	}
	if(strActual.length > 0) {
		strActual = strActual.substring(0,strActual.length-1);
	}
	return strActual;
}
function ifPagePresent(strName) {
	var flag=false;
	var tempCount=document.all("cmbPages").options.length;
	for(i=0;i<tempCount;i++) {
		if(document.all("cmbPages").options[i].text == strName) {
				flag=true;
				break;
			}	
	}
	return flag;
}
//Add/Edit/Remove Page

//Preview Site
	function previewSite(loc,id,pageName) {
		var leftPos = (screen.availWidth-500) / 2;
		var topPos = (screen.availHeight-400) / 2 ;
		var strUrl = "../workarea/" + loc + "/" + id + "/" + pageName;
		insertFormWin = window.open(strUrl,'','width=' + screen.availWidth + ',height=' + screen.availHeight + ',scrollbars=yes,resizable=yes,titlebar=0,top=' + topPos + ',left=' + leftPos);
	}
//End Preview Site

//Publish Site
	function publishSite() {
		if(document.all("type").value == "new") {
				document.all("publishPage").method="post";
				document.all("publishPage").action="../publishpage.php";
				document.all("publishPage").submit();
		}
	}
	function printDocument() {
			foo.print();
		}
	function  exitDocument() {
			if(confirm("Are you sure you want to exit this document?")) {
				location.href="../usermain.php";
			}
		}	
//End Publish Site
