function InitFlash(maxFlash)
{
	actualVersion = 0;	
		for(x = 2;x <= maxFlash;x++)
	{
		eval("flash" +x+ "Installed = false;");
		eval("foo"+x+"=false;");
	}
}
function DetectFlash(maxFlash, requiredFlash) {
	var rightVersion = false
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	if(isIE && isWin){
	  document.write('<scr' + 'ipt type="text/vbscript"\> \n');
	  document.write('On Error Resume Next \n');	  
	  for(x = 2; x <= maxFlash; x++)
	  {
		 	document.write('flash' +x+ 'Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' +x+ '"))) \n')
	  }
	  document.write('</scr' + 'ipt\> \n');
	}
	if (navigator.plugins) {
	  if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
	    var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
	    var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
	    var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));	    
	    for(x = 2;x <= maxFlash; x++)
	    {
	    	if(x != maxFlash)
	    	{
	    		eval("flash" +x+ "Installed = flashVersion == " +x+ ";");
	    	}
	    	else
	    	{
	    		eval("flash" +x+ "Installed = flashVersion >= " +x+ ";");
	    	}
	    }
	  }
	}
	for (var i = 2; i <= maxVersion; i++) { if (eval("flash" + i + "Installed") == true) actualVersion = i }
	actualVersion >= requiredFlash ? rightVersion = true : rightVersion = false;
	return (rightVersion);
}
function BuildFlash (width,height,url,wmode,vars){
	var html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n'
	    + 'width="' +width+ '" height="' +height+ '"\n'
	    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">\n'
	    + '<param name="movie" value="' +url+ '" />\n'
	    + '<param name="play" value="true" />\n'
	    + '<param name="loop" value="false" />\n'
	    + '<param name="quality" value="high" />\n'
	    + '<param name="menu" value="false" />\n'
	    + '<param name="wmode" value="' +wmode+ '" />'
	    + '<param name="flashvars" value="' +vars+ '" />\n'
	    + '<embed src="' +url+ '" \n'
	    + 'width="' +width+'" height="' +height+ '" \n'
	    + 'play="true" \n'
	    + 'loop="false" \n'
	    + 'quality="high" \n'
	    + 'menu="false" \n'
	    + 'wmode="' +wmode+ '" \n'
	    +	'flashvars="' +vars+ '" \n'
	    + 'type="application/x-shockwave-flash" \n'
	    + 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> \n'
	    + '</embed> \n'
	    + '</object>\n';
    return (html);
}
function DisplayFlash(redirect,detect)
{
 	if(detect && DetectFlash(maxVersion, requiredVersion))
	{
	  document.write(BuildFlash(width, height, url, wmode, flashVars));
	}
	else
	{
		redirect ? document.location.replace(noFlash) : document.write(noFlash);
	}
}


// This code opens external links in new window
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
window.onload = externalLinks;


//for pop up windows

function OpenWindow( url, width, height, options, name )

{

if ( ! width ) width = 640;

if ( ! height ) height = 420;

if ( ! options ) options = "scrollbars=yes,menubar=no,toolbar=no,location=no,status=no,resizable=yes";

if ( ! name ) name = "outsideSiteWindow";

var newWin = window.open( url, name, "width=" + width + ",height=" + height + "," + options );

}
