﻿function OpenWindow(URL, Name, Width, Height)
{
	var PositionX = 200;
	var PositionY = 200;
	var DefaultWidth = 600;
	var DefaultHeight = 400;
	var WinObject, Params = 'scrollbars=1, resizable=1, left=' + PositionX + ', top=' + PositionY;
	Params += ', width=' + ((isNaN(parseInt(Width))) ? DefaultWidth : Width);
	Params += ', height=' + ((isNaN(parseInt(Height))) ? DefaultHeight : Height);
	WinObject = window.open(URL, Name, Params)
	if (!WinObject) return true;
	if (WinObject.focus) WinObject.focus();
	return false;
}


function InsertFlash(Target, ID, Version, File, Width, Height, Parameters)
{
	var ParametersObjectStr = ''
	var ParametersEmbedStr = ''
	var s, v
	for (s in Parameters)
	{
		v = Parameters[s]
		ParametersObjectStr += '<param name="' + s + '" value="' + v + '" />'
		ParametersEmbedStr += ' ' + s + '="' + v + '" '
	}
	var FlashHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' +
			'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + Version + ',0,0,0" ' +
			'width="' + Width + '" height="' + Height + '" id="' + ID + '">' +
			'<param name="movie" value="' + File + '" />' +
			ParametersObjectStr +
			'<embed src="' + File + '" ' +
				'pluginspage="http://www.macromedia.com/go/getflashplayer"  ' +
				'type="application/x-shockwave-flash" width="' + Width + '" height="' + Height + '" name="' + ID + '" ' + ParametersEmbedStr + ' />' +
		'</object>'
	document.getElementById(Target).innerHTML = FlashHTML
}

function VerifyBrowserFlashSupport(FlashVersion)
{
	var flashinstalled = 0;
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length)
	{
		var x = navigator.plugins["Shockwave Flash"];
		if (x)
		{
			flashinstalled = 2;
			if (x.description)
			{
				var y = x.description;
				if (parseFloat(y.substring(y.lastIndexOf(' ', y.indexOf('.')))) >= FlashVersion) return true;
			}
		}
		if ((FlashVersion == 2) && (navigator.plugins["Shockwave Flash 2.0"]))
		{
			return true;
		}
	} else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
	} else
	{
		try
		{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + FlashVersion);
			return true;
		}
		catch (e)
		{
		}
	}
	return false;
}

function InsertFlashOrHTML(Target, ID, Version, File, Width, Height, Parameters, NoFlashHTML)
{
	if (VerifyBrowserFlashSupport(Version))
	{
		InsertFlash(Target, ID, Version, File, Width, Height, Parameters)
	} else
	{
		document.getElementById(Target).innerHTML = NoFlashHTML
	}
}

function InsertFlashIfSupported(Target, ID, Version, File, Width, Height, Parameters)
{
	if (VerifyBrowserFlashSupport(Version))
	{
		InsertFlash(Target, ID, Version, File, Width, Height, Parameters)
	}
}

function TogglePanel(panelId)
{
	var blockObj = document.getElementById("CollapsiblePanel" + panelId);
	var blockImageObj = document.getElementById("CollapsiblePanelImage" + panelId);
	
	if (blockObj && blockImageObj)
	{
		if (blockObj.style.display == "none")
		{
			blockObj.style.display = "block";
			blockImageObj.src = "images/button/panel-collapse.gif";
		}
		else
		{
			blockObj.style.display = "none";
			blockImageObj.src = "images/button/panel-expand.gif";
		}
	}
}