function goWindow(strURL,strName,strWidth,strHeight,strOthers)
{
	var strFeatures = "width=" + strWidth + ",height=" + strHeight;
	if (strOthers.length != 0)
		strFeatures += "," + strOthers;
			
	var newWindow = window.open(strURL,strName,strFeatures);
	newWindow.focus();
	
//_blank The sURL is loaded into a new, unnamed window. 
//_media   The sURL is loaded into the HTML content area of the Media Bar. Available in Internet Explorer 6 or later. 
//_parent The sURL is loaded into the current frame's parent. If the frame has no parent, this value acts as the value _self. 
//_search Available in Internet Explorer 5 and later. The sURL is opened in the browser's search pane. 
//_self The current document is replaced with the specified sURL . 
//_top sURL replaces any framesets that may be loaded. If there are no framesets defined, this value acts as the value _self. 

// window attributes
// url - the variable for the url of the page in the new window that is passed by placing it single-quoted in either the link or form
// window_name - the name of the new window being opened
// width - width of the new window in pixels
// height - height of the new window in pixels
// top - the new widow top will appear xx number of pixels from the top of the screen
// left - the new widow left margin will appear xx number of pixels from the left of the screen

// The following attributes will suppress the respective window elements
// when the value is set to zero or if omitted. When listed or equal to one
// the window attribute will appear
// toolbar,menubar,resizable,dependent,status
//
}

function goAction(strAction) 
{
	if (strAction == 'delete') 
	{
		var intConfirm = confirm("Are you sure you want to delete this record?")
		if (intConfirm)
		{
			document.forms.update.hiddenaction.value = strAction;
		}
		else
		{
			return false;
		}
	}
	else
	{
		if (strAction == 'deletesublist') 
		{
			var intConfirm = confirm("Are you sure you want to delete this sublist?")
			if (intConfirm)
			{
				document.forms.update.hiddenaction.value = strAction;
			}
			else
			{
				return false;
			}
		}
		else
		{
			if (strAction == 'deleteitem') 
			{
				var intConfirm = confirm("Are you sure you want to delete this item?")
				if (intConfirm)
				{
					document.forms.update.hiddenaction.value = strAction;
				}
				else
				{
					return false;
				}
			}
			else
				document.forms.update.hiddenaction.value = strAction;
		}
	}	
	
	// submit the form 
	document.forms.update.submit();
}

function goSpecialAction(strAction,intItem)
{
	var strError = "";
	
	// they must enter a numeric code
	if ((intItem == 0) || (isNaN(intItem)))
		strError += ' - You must enter a numeric sequence number.\n';
	else	
		document.forms.update.hiddenitem.value = intItem;
		
	if (strError)
	{
		alert('The following errors occurred:\n' + strError);
		return false;	
	}
	else
		goAction(strAction);
}

function goSpecialUpdateAction(strAction,intItem,intID,intAid)
{
	var strError = "";
	
	// they must enter a numeric code
	if ((intItem == 0) || (isNaN(intItem)))
		strError += ' - You must enter a numeric sequence number.\n';
	else
	{	
		document.forms.update.hiddenitem.value = intItem;
		document.forms.update.hiddenID.value = intID;
		document.forms.update.hiddenAID.value = intAid;
	}	
	
	if (strError)
	{
		alert('The following errors occurred:\n' + strError);
		return false;	
	}
	else
		goAction(strAction);
}

function goLayoutAction(strAction)
{
	var intSequence = "";
	var strError = "";
	
	if (strAction == 'addparagraph') 
	{
		// they must enter a numeric code
		if ((document.forms.update.txtSequence.value == 0) || (isNaN(document.forms.update.txtSequence.value)))
			strError += ' - You must enter a numeric sequence number.\n';
		else
			intSequence = document.forms.update.txtSequence.value;
	}
	else
	{
		if (strAction == 'addlist') 
		{
			// they must enter a numeric code
			if ((document.forms.update.txtSequence2.value == 0) || (isNaN(document.forms.update.txtSequence2.value)))
				strError += ' - You must enter a numeric sequence number.\n';
			else
				intSequence = document.forms.update.txtSequence2.value;
		}
		else
		{
			// add link
			// they must enter a numeric code
			if ((document.forms.update.txtSequence3.value == 0) || (isNaN(document.forms.update.txtSequence3.value)))
				strError += ' - You must enter a numeric sequence number.\n';
			else
				intSequence = document.forms.update.txtSequence3.value;
		}
	}
		
	if (strError)
	{
		alert('The following errors occurred:\n' + strError);
		return false;	
	}
	else
	{
		// set the sequence
		document.forms.update.hiddenitem.value = intSequence;
	
		// set the action
		document.forms.update.hiddenaction.value = strAction;
		
		// submit the form 
		document.forms.update.submit();	
	}
}

function goImage(imgTemp)
{
	if (imgTemp.border == 0)
	{
		imgTemp.border = 1;
		imgTemp.width = 2.5 * imgTemp.width;
		imgTemp.height = 2.5 * imgTemp.height;
	}
	else if (imgTemp.border == 1)
	{
		if (imgTemp.width < 350)
		{		
			imgTemp.border = 2;
			imgTemp.width = 2 * imgTemp.width;
			imgTemp.height = 2 * imgTemp.height;
		}
		else
		{
			imgTemp.border = 0;
			imgTemp.width = imgTemp.width / 2;
			imgTemp.height = imgTemp.height / 2;
		}
	}	
	else
	{
		imgTemp.border = 0;
		/* Math.pow - 2^3
		imgTemp.width = imgTemp.width / Math.pow(2,2);
		imgTemp.height = imgTemp.height / Math.pow(2,2);*/
		imgTemp.width = imgTemp.width / 4.5;
		imgTemp.height = imgTemp.height / 4.5;		
	}
}

function addBold() 
{
   var objRange = document.selection.createRange();

   if (objRange.text == "")  
		return false; 
   else
		objRange.text = '<b>' + objRange.text + '</b>';
}

function addItalics() 
{
   var objRange = document.selection.createRange();

   if (objRange.text == "")  
		return false; 
   else
		objRange.text = '<i>' + objRange.text + '</i>';
}

function addUnderline() 
{
   var objRange = document.selection.createRange();

   if (objRange.text == "")  
		return false; 
   else
		objRange.text = '<u>' + objRange.text + '</u>';
		// can also be done with document.execCommand("underline");
		
}

function addLink() 
{
   var objRange = document.selection.createRange();

   if (objRange.text == "")  
		return false; 
   else
   {
		if (document.forms.update.txtLink.value == "")
		{
			alert('You must enter a link');
			return false;	
		}
		else
		{
			objRange.text = '<a class=""reglink"" href=""' + document.forms.update.txtLink.value + '"" target=""_blank"">' + objRange.text + '</a>';
		}
	}
}

function addscalelink()
{
   var objRange = document.selection.createRange();

   if (objRange.text == "")  
		return false; 
   else
   {
		objRange.text = '<a class=""reglink"" href=""home.asp?page=' + document.forms.update.scalelink[document.forms.update.scalelink.selectedIndex].value + '"">' + objRange.text + '</a>';
	}
}

function show(id){						
	alert('You requested action no. '+ id);
}

function toggle(id,closed,opened,pre){				
	var myChild = el(id);
	var myPIcon = el("picon" + id);						
	var myIcon = el("icon" + id);																			
	if(myChild.style.display=="none"){
		myChild.style.display="block";
		myIcon.src=opened;
		myPIcon.src="images/"+ pre + "minus.gif";
	}else{
		myChild.style.display="none";
		myIcon.src=closed;
		myPIcon.src="images/"+ pre +"plus.gif";
	}					
}

function el(id){
	if(document.all){
		return document.all[id];
	}else{
		return document.getElementById(id);
	}
}

function showImage(strPic) { 
     window.open( "image.htm?"+strPic, "scale_image", "resizable=1,HEIGHT=100,WIDTH=100,top=100,left=150,menubar=no,toolbar=no,alwaysraised"); 
} 

function goDiv(strDivName)
{
	var strDiv = eval("document.all." + strDivName + ".style.display");
		
	if (strDiv=="none")
		eval("document.all." + strDivName + ".style.display = ''");
	else
		eval("document.all." + strDivName + ".style.display = 'none'");
}