var newwin;

function openWindow(Link, Width, Height, Name, Slides){
	
	if (Width == null)
		Width = 770;
		
	if (Height == null)
		Height = 560;
	
	if (Name == null)
		Name = "WindowName";
		
		Resize = "yes";
		Scroll = "yes";
	
	winfeatures = "width=" + Width;
	winfeatures += ",height=" + Height;
	winfeatures += ",scrollbars=" + Scroll;
	winfeatures += ",resizable=" + Resize;
//	winfeatures += ",location=yes"; //use for adding the address bar for testing

	//Check to see if link is swf or flv
	linkType = Link.substring(Link.length - 3);

	if (linkType == 'swf' || linkType == 'flv')
	{
		if(linkType == 'swf') //If link IS swf, then check to see if it's the correct version
		{
			folderLink = findFolder();
			newwin = window.open("/embed_swf?link="+folderLink+Link,Name,winfeatures);
			newwin.focus();
		}
		else if(linkType =='flv') //If link is an FLV, then we'll use a little different link
		{
			folderLink = findFolder();
			newwin = window.open("/embed_flv?link=http://static.dna.gov/flash/videos.swf&flvLink="+Link+"&slides="+Slides,Name,"width=430,height=450" + winfeatures);
			newwin.focus();
		}
	} // close swf OR flv if statement
	else if(Link == 'http://www.nfstc.org/review/review_form.php')
	{
		location = window.location; // find location of referring page
		Link = Link + '?referer=' + location; // used for finding referring page on review form
		newwin = window.open(Link,Name,winfeatures);
		newwin.focus();
	}
	else 
	{
		newwin = window.open(Link,Name,winfeatures);
		newwin.focus();
	}
} // close openWindow

function findFolder()
{
	var locate = window.location;
	var text = new String(locate);

	function delineate(str)
	{
		theleft = 0;
		theright = str.lastIndexOf("/") - 1;
		
		for (i=0; str.charAt(theright - i) != "/" && str.charAt(theright - i) != "\\"; i++)
			theleft = theright -i;
		
		theright += 2;
		return(str.substring(theleft, theright));
	}

	return(delineate(text));
}// close findFolder

function openVideo(Link, Slides, Width, Height, Name) {
	if (Width == null)
		Width = 430;
		
	if (Height == null)
		Height = 450;
		
	if (Name == null)
		Name = 'video';

	if (Slides == null)
		Slides = 0;

	openWindow(Link, Width, Height, Name, Slides);
}// close openVideo

function openGlossary(Link) {

	fullLink = "../glossary.htm#" + Link;

	Width = 790;
	Height = 150;
	
	openWindow(fullLink, Width, Height, "glossaryName");
}// close openGlossary
