/*
 This function opens a horizontally centered window, 10 pixels from the top of the 
 screen. A supplied URL is opened for the document. The window's name width and 
 heigth are all specified in the call
 
 @param url - url to open in the popup window
 @param name - name of the popup window, must be unique
 @param width - width of the popup window
 @param height - height of the popup window
*/
function openWindow(url, name, width, height)
{
	winwidth = width;
	winheight = height;
	var winl = (screen.width - winwidth) / 2;
	var wint = 10;
	var regexp = /-/g;
	name = name.replace(regexp, "_");
	
	win  = window.open(url, name, 'width=' + winwidth + ',height=' + winheight + ',top=' +wint+ ',left=' +winl+ ',resizable,scrollbars,status');
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/*
 This function strips HTML tags from an input field
  
 Example of use:
 <input type="text" onBlur="stripHTML(this)">
 
 @param formElement - the form element object that is being formatted
*/
function stripHTML(formElement) 
{
	var elementValue =  formElement.value;
	var a, b, c, d;
	var error = true;
	a = elementValue.indexOf("<");
	b = elementValue.indexOf(">");
	while(a != -1)
	{
		len = elementValue.length;
		c = elementValue.substring(0, a);
		if(b == -1)b = a;
		d = elementValue.substring((b + 1), len);
		elementValue = c + d;
		a = elementValue.indexOf("<");
		b = elementValue.indexOf(">");
	}
	formElement.value = elementValue;
}


/*
 This function opens a centered window. Supplied code is written to the 
 document body. The window's name, width, and height are all specified 
 in the call.
 
 @param textToWrite - text or HTML to write into the new window document
 @param name - name of the popup window, must be unique
 @param width - width of the popup window
 @param height - height of the popup window
*/
function writeToNewWindow(textToWrite, name, width, height)
{
	var leftalign = (screen.width - width) / 2;
	var topalign = (screen.height - height) / 2;
	writeWindow = open("", name, "width="+width+",height="+height+",top="+topalign+",left="+leftalign+",status=no,toolbar=no,menubar=no,resizable,scrollbars");

	// open document for further output
	writeWindow.document.open();
  
	// create document
	writeWindow.document.write("<html><head><title></title>");
	writeWindow.document.write('</head><body bgcolor="white">');
	writeWindow.document.write(textToWrite);
	writeWindow.document.write("</body></html>");
  	
	// align window for Netscape
	writeWindow.screenX = leftalign;
	writeWindow.screenY = topalign;
	
	// bring window to front
	writeWindow.focus();
}

function RunFlash(path, nameFlash, w, h)
{
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="');
   document.write(w);
   document.write('" height="');
   document.write(h);
   document.write('">\n');
   document.write('<param name="movie" value="');
   document.write(path);
   document.write(nameFlash);
   document.write('">\n');
   document.write('<param name="play" value="true">\n');
   document.write('<param name="quality" value="high">\n');
   document.write('<embed src="');
   document.write(path);
   document.write(nameFlash);
   document.write('" play="true" quality="high" width="');
   document.write(w);
   document.write('" height="');
   document.write(h);
   document.write('"'); 
   document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
   document.write(' </embed>\n');
   document.write('</object>\n');
}

function RunQuickTime(path, fileName, w, h)
{
   document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" id="Player" width="');
   document.write(w);
   document.write('" height="');
   document.write(h);
   document.write('">\n');
   document.write('<param name="autoplay" value="true"/>\n');
   document.write('<param name="controller" value="true"/>\n');
   document.write('<param name="src" value="');
   document.write(path);
   document.write(fileName);
   document.write('">\n');
   document.write('<embed name="QuickPlayer1" src="');
   document.write(path);
   document.write(fileName);
   document.write('" autoplay="true" controller="true" width="');
   document.write(w);
   document.write('" height="');
   document.write(h);
   document.write('"'); 
   document.write(' pluginspage="http://www.apple.com/quicktime/download/">');
   document.write(' </embed>\n');
   document.write('</object>\n');
}