// The following Function allows a user to click on a thumbnail and have a flash animation popup with the desired size and elements
function flash_popup_window(url, width, height, text2write)
{
	var win, Left, Top, Name, Settings, Width, Height;
	Name = "FlashViewer";

	Width = width + 20;//sets the width and the height of the image popup
	Height = height + 110;
	Left = (screen.width)?(screen.width-Width)/2:100;
	Top = (screen.height)?(screen.height-Height)/2:100;

	Settings = 'width='+Width+',height='+Height+',top='+Top+',left='+Left+',menubar=no,scrollbars=no,resizable=no';

	win = window.open("",Name,Settings);
	win.document.writeln("<html><head><title>Flash Viewer</title></head><body>");
	win.document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
	win.document.writeln('	<param name="movie" value="' + url + '">');
	win.document.writeln('	<param name="quality" value="high">');
	win.document.writeln('	<embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
	win.document.writeln('</object>');
	win.document.writeln("<br><br>" + text2write);
	win.document.writeln("<br><a href=\"#\" onClick=\"window.close()\">Close Window</a>");
	win.document.writeln("</body></html>");
	win.document.close();
	win.focus();

	return true;
}

// This function opens a browser window with sizes and
// scrollbar properties available when called

function MM_openBrWindow(theURL,winName,features)
	{ //v2.0
	  window.open(theURL,winName,features);
	}

// This function auto tabs the input text boxes for things like phone numbers etc..
//just put onKeyUp="return autoTab(this, 1, event); within the input tag. 1 = length...

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e)
{
	var keyCode = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		if(input.value.length >= len && !containsElement(filter,keyCode))
		{
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}
		function containsElement(arr, ele)
		{
			var found = false, index = 0;
			while(!found && index < arr.length)
				if(arr[index] == ele)
				found = true;
					else
					index++;
			return found;
		}
		function getIndex(input)
		{
			var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
				if (input.form[i] == input)index = i;
				else i++;
				return index;
		}
	return true;
}
		// Set the horizontal and vertical position for the popup:
		PositionX = 100;
		PositionY = 100;

		// Set these value approximately 20 pixels greater than the
		// size of the largest image to be used (needed for Netscape):
		defaultWidth  = 550;
		defaultHeight = 550;

		// Set autoclose true to have the window close automatically
		// Set autoclose false to allow multiple popup windows:
		var AutoClose = true;

		if (parseInt(navigator.appVersion.charAt(0))>=4){var isNN=(navigator.appName=="Netscape")?1:0;var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
		function pop_up(imageURL,imageTitle,text){if (isNN){imgWin=window.open('about:blank','',optNN);}if (isIE){imgWin=window.open('about:blank','',optIE);}with (imgWin.document){
				writeln('<html><head><title>Loading...</title><style>body{color:#FF9900;margin:0px;font:11px Verdana, Arial, Helvetica, sans-serif;}u{color:#00A0C6;}</style>');writeln('<sc'+'ript>');
				writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
				writeln('isNN=(navigator.appName=="Netscape")?1:0;');
				writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');writeln('function reSizeToImage(){');
				writeln('if (isIE){');writeln('window.resizeTo(100,100);');
				writeln('width=100-(document.body.clientWidth-document.images[0].width);');
				writeln('height=100-(document.body.clientHeight-document.images[0].height);');
				
				writeln('window.resizeTo(width,height+60);}');writeln('if (isNN){');writeln('window.innerWidth=document.images["foo"].width;');
				
				writeln('window.innerHeight=document.images["foo"].height+60;}}');writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
				if (!AutoClose)writeln('</head><body bgcolor=#ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
				else writeln('</head><body bgcolor=#ffffff scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');writeln('<img name="foo" src='+imageURL+' style="display:block">'+text+'</body></html>');
				close();
				}}
