netscapeflashRedirect="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";

flashVersion_DONTKNOW = -1;
var flashVersion = 0;
var OptimalWidth=-1;
var OptimalHeight=-1;
var OptimalDimensionsWin="";
var OptimalDimensionsStart=false;
var minTBLHeight=500;
var minTBLWidth=700;
var Browser="";


function getFlashVersion() {
        var agent = navigator.userAgent.toLowerCase(); 
        
   // NS3 needs flashVersion to be a local variable

  // if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
     // flashVersion = 0;
   //}

        // NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
        if (navigator.plugins && navigator.plugins.length) {
                var flashPlugin = navigator.plugins["Shockwave Flash"];
          
               // if (typeof flashPlugin == 'object') { 
                 
                    if (flashPlugin){
                    var desc = flashPlugin.description;
                    
                    flashVersion = desc.charAt(desc.indexOf('.')-1);

                       // if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
                       // else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
                       // else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
                       // else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
                       // else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;
                }
        }

        // IE4+ Win32:  attempt to create an ActiveX object using VBScript
        else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
           document.write('<scr' + 'ipt language="VBScript"\> \n');
                document.write('on error resume next \n');
                document.write('dim obFlash \n');
                document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
                document.write('if IsObject(obFlash) then \n');
                document.write('flashVersion = 7 \n');
                document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
                document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
                document.write('flashVersion = 6 \n');
                document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
                document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
                document.write('flashVersion = 5 \n');
                document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
                document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
                document.write('flashVersion = 4 \n');
                document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
                document.write('if flashVersion < 4 and IsObject(obFlash) then \n');
                document.write('flashVersion = 3 \n');
                document.write('end if');
                document.write('</scr' + 'ipt\> \n');
  }
                
        // WebTV 2.5 supports flash 3
        else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

        // older WebTV supports flash 2
        else if (agent.indexOf("webtv") != -1) flashVersion = 2;

        // Can't detect in all other cases
        else {
                flashVersion = flashVersion_DONTKNOW;
        }

        return flashVersion;
}



function getInnerWidth(win) {
  var winWidth;
  if (document.compatMode == "CSS2Compat" || navigator.userAgent.indexOf('Gecko') != -1) {
    winWidth = parseInt(win.document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue("width"));
  }
  else if (document.compatMode == "CSS1Compat") {
    winWidth = win.document.documentElement.clientWidth;
  }
  else if (navigator.appName == 'Netscape') {
    winWidth = win.innerWidth;
  }
  else {
    winWidth = win.document.body.clientWidth;
  }
  return winWidth;
}

function getInnerHeight(win) {
  var winHeight;
  if (document.compatMode == "CSS2Compat" || navigator.userAgent.indexOf('Gecko') != -1) {
    winHeight = parseInt(win.document.defaultView.getComputedStyle(document.documentElement, null).getPropertyValue("height"));
  }
  else if (document.compatMode == "CSS1Compat") {
    winHeight = win.document.documentElement.clientHeight;
  }
  else if (navigator.appName == 'Netscape') {
    winHeight = win.innerHeight;
  }
  else {
    winHeight = win.document.body.clientHeight;
  }
  return winHeight;
}



        function getBrowser()
        {


                browsername=navigator.appName;
                if (browsername.indexOf("Netscape")!=-1) 
                        {browser="NS";}
                else
                        {if (browsername.indexOf("Microsoft")!=-1) 
                                {browser="IE";}
                        else {browser="";}}

                return browser;

        }


		function getOptimalDimensions()
		{		

			window.resizeTo(minTBLWidth,minTBLHeight);	
			outerW=minTBLWidth;
			outerH=minTBLHeight;

			innerW=getInnerWidth(window);
			innerH=getInnerHeight(window);
			deltaW=outerW-innerW;
			deltaH=outerH-innerH;
			
			OptimalHeight=minTBLHeight + deltaH;
            OptimalWidth=minTBLWidth + deltaW;
			//alert(OptimalWidth + " x " + OptimalHeight);
			//alert(deltaW + " x " + deltaH);
			
		}


        function WriteMovieTable()
        {

                var height=0, width=0;
                var xy=0.0;
                var yx=0.0;

                height=getInnerHeight(window);
                width=getInnerWidth(window);

				//alert(width + "x" + height);

                if (height<minTBLHeight || width<minTBLWidth)
                {

                        if(screen.availWidth>799 )
                        {
							getOptimalDimensions();
							window.resizeTo(OptimalWidth,OptimalHeight);
                            window.moveTo((screen.availWidth-(OptimalWidth))/2,(screen.availHeight-(OptimalHeight))/2);
                        }
                        else
                        {
							OptimalWidth=screen.availWidth;
							OptimalHeight=screen.availHeight;
							window.resizeTo(OptimalWidth,OptimalHeight);
                            window.moveTo(0,0);
                        }
                }
				else
				{
							if(Browser=="NS")
							{
								OptimalWidth=window.outerWidth;
								OptimalHeight=window.outerHeight;					
							}
							else
								if(document.documentElement)
								{
									//OptimalWidth=document.documentElement.offsetWidth;
									//OptimalHeight=document.documentElement.offsetHeight;
									OptimalWidth=document.body.offsetWidth;
									OptimalHeight=document.body.offsetHeight;

								}
				}

                height=getInnerHeight(window);
                width=getInnerWidth(window);


                if (width<800)
                        tbl="<table width=\"" + minTBLWidth + "\" height=\"" + minTBLHeight + "\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr valign='top'><td width=\"" + minTBLWidth + "\" align='center'>\n";
                else
                        if(width>900)
                                tbl="<table width=\"900\" height=\"643\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr valign='top'><td width=\"900\" height=\"643\" align='center'>\n";
                        else
                        {

                                done=false;

                                xy=width;
                                yx=height;
                                slp=minTBLHeight/minTBLWidth;
                                while(!done)
                                {
                                        xy-=1;        
                                        yx=xy*slp;        
                                        if(xy<width && yx<height)
                                                done=true;
                                }
                        
                                        xy-=5;        
                                        yx-=5;        
                        

                                tbl="<table width=\"" + xy + "\" height=\""+ yx +"\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr valign='top'><td width=\"" + xy + "\" height=\""+ yx +"\" align='center'>\n";
                        }

                //alert(tbl);
                document.write(tbl);

        }


        function renderPage()
        {

                flashVer=getFlashVersion();
                Browser=getBrowser();


                if(flashVer<6)
                        if(Browser=="NS")
                        {
                                window.open(netscapeflashRedirect,"flash");
				document.write("<p>&nbsp</p><p align='center'><font size='2' face='verdana'><b>In order to view this website, you will need the latest Flash player.<br><br><a href='" + netscapeflashRedirect + "'>click here to download the latest Flash player</a></b></font></p><br><p align='center'><img src=\"../eco_solutionq_logo.jpg\"></p>");
                                return;
                        }


                if(Browser!="IE")
                {
                        tbl="<table width=\"" + minTBLWidth + "\" height=\"" + minTBLHeight + "\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr valign='top'><td width=\"" + minTBLWidth + "\" align='center'>\n";
                        document.write(tbl);
                        return;
                }        

                WriteMovieTable();
                
        }
