
///// START: ADOBE FLASH SCRIPT

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var isSafari = (navigator.userAgent.toLowerCase().indexOf('safari') != -1) ? true : false;

function ControlVersion() {
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
		
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}


// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {

	versionStr = GetSwfVer();
	

	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


///// END: ADOBE FLASH SCRIPT




///// START: MICHAEL SCRIPT: INDEX.PHP
			
			
			//window.onbeforeunload = function () {");
			//	var warning = getFlashApp('main').sendToActionScript('browser window closed');");
    		//	if (warning != '')");
        	//		return warning;");
    		//	else");
    		//	return;");
			//}");
			
			

			window.onbeforeunload = function () {
				
				// CANCELING THIS CALL. PERFORMING THIS FUNCTION OF KNOWING WHEN A MEMBER HAS KILLED THE REZMAY APP
				// BY USING A BEACON IN THE MAIN.SWF BECAUSE THE AJAX CALL xmlHttp.open() DOESN'T SEEM TO WORK IN SAFARI ON WINDOWS
				// AND USING THIS MEANS THAT A MEMBER WON'T BE ABLE TO RELOAD AND AUTO LOG IN SINCE THE RELOAD WILL KILL THE SESSION ID
				// AND THE APP ON RELOAD WILL NOT KNOW THE MEMBER IS RELOADING
			
				//ajaxFunction();
				
				closeChildWindowOnMainClose();

			}
			



			//var jsReady = false;
			var jsReady = true;
			
     		function isReady() {
         		return jsReady;
     		}


			var curUser = '';


     		function initUser(usr) {
         		curUser = usr;
     		}




			function ajaxFunction() {
			var xmlHttp;
			try {
  			// Firefox, Opera 8.0+, Safari
  			xmlHttp=new XMLHttpRequest();
  			}
			catch (e)
  			{
  				// Internet Explorer
  			try {
   				xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
    			}
  			catch (e)
    			{
    			try {
      			xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
      			}
    			catch (e) {
      			alert('Your browser does not support AJAX!');
      			return false;
      			}
    			}
  			}
  			xmlHttp.onreadystatechange=function() {
    			if(xmlHttp.readyState==4) {
     			document.myForm.time.value=xmlHttp.responseText;
      			}
    			}
  			var url='kill_member_session_id.php?un=' + curUser;
  			xmlHttp.open('GET', url, true);
  			xmlHttp.send(null);
  			}



			//function pageClose() {
				//ajaxFunction();
     		//}




			function getFlashApp(appName) {
				if (navigator.appName.indexOf ('Microsoft') !=-1) {
    				return window[appName];
    				alert(appName);
  				}
 				else {
    				return document[appName];
				}
			}



			// open window for engine.swf (not main.swf)
			var newWindow_engine;
 	       	function openWindow_engine(url, name, options) { 	       	
    	      	if (newWindow_engine = window.open(url, name, options)) {
    	        	 if (window.focus) { newWindow_engine.focus(); }
        	    	return true;
            	}
            	
     	  		return false;
			}






			var newWindow;
 	       	function openWindow(type, url, name, options, _datasource, _username, _app, _sl, _pos, _label, _data, _datac, _uprefs, _jobdata, _jobsort, _usernodepos, _usernodelabel, _usernodedata, _usertype, _lang, _key, _key_sid) {
     			
     			// translate the apostrophe character to it's code equivalent or this process will break since the apostrophe will be seen as an end of line for the string
    	       	var _username = _username.replace(/'/g, "&#39;");
    	       	var _label = _label.replace(/'/g, "&#39;");
     	        var _data = _data.replace(/'/g, "&#39;");
   		       	var _datac = _datac.replace(/'/g, "&#39;");
    	       	var _jobdata = _jobdata.replace(/'/g, "&#39;");
    	       	var _usernodelabel = _usernodelabel.replace(/'/g, "&#39;");
    	       	var _usernodedata = _usernodedata.replace(/'/g, "&#39;");
    	        //var _data2 = _data.split("'").join("\\\'"); // using array to do the same thing
    	        
    	        if( newWindow = window.open(url, name, options) ) {
    	        
    	        //var keys = 'testdata';
    	        //var values = 'testdata';
    	        
    	        if (type == 'test') {
					var html = '';
					html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
				
						html += "<input type='hidden' name='datasource' value='" + _datasource + "' />";
						html += "<input type='hidden' name='username' value='" + _username + "' />";
						html += "<input type='hidden' name='app' value='" + _app + "' />";
						html += "<input type='hidden' name='sl' value='" + _sl + "' />";
						html += "<input type='hidden' name='pos' value='" + _pos + "' />";
						html += "<input type='hidden' name='label' value='" + _label + "' />";
						html += "<input type='hidden' name='data' value='" + _data + "' />";
						html += "<input type='hidden' name='datac' value='" + _datac + "' />";
						html += "<input type='hidden' name='uprefs' value='" + _uprefs + "' />";
						html += "<input type='hidden' name='jobdata' value='" + _jobdata + "' />";
						html += "<input type='hidden' name='jobsort' value='" + _jobsort + "' />";
						html += "<input type='hidden' name='usernodepos' value='" + _usernodepos + "' />";
						html += "<input type='hidden' name='usernodelabel' value='" + _usernodelabel + "' />";
						html += "<input type='hidden' name='usernodedata' value='" + _usernodedata + "' />";
						html += "<input type='hidden' name='usertype' value='" + _usertype + "' />";
						html += "<input type='hidden' name='lang' value='" + _lang + "' />";
						html += "<input type='hidden' name='key' value='" + _key + "' />";
						html += "<input type='hidden' name='key_sid' value='" + _key_sid + "' />";

						//if (keys && values && (keys.length == values.length))
	
						//for (var i=0; i < keys.length; i++) {
						//	html += \"<input type='hidden' name='' + keys[i] + '' value='' + values[i] + ''/>\";
						//}
				
						html += "</form><script type='text/javascript'>document.getElementById('formid').submit()</script></body></html>";
				
						newWindow.document.write(html);
    	        
    	        }

    	        	 if (window.focus) { newWindow.focus(); }
    	        	 
        	    	return true;
            	}
					//var warning = getFlashApp('main').openWindowFromSwf();");
					
					// this currently is not used.  not needed since a javascript call to flash is not needed
					// to know that safari popup failed, just use the result from the main popup attempt
					//getSwf('main').openWindowFromSwf();"); // open window failed so call openWindowFromSwf() in flash
     	       
     	       return false;
			}
		


			// ENGINE.SWF ONLY, NOT MAIN.SWF.  only focuses window. used if browser is safari and platform is mac.
 	       	function openWindow_safari_mac_engine(url, name, options) {
    	      	if( newWindow_engine = window.open(url, name, options) ) {
    	        	if (window.focus) { newWindow_engine.focus(); }
        	   		return true;
            	} else {
     	       		return false;
				}
			}



		
			// only focuses window. used if browser is safari and platform is mac.
 	       	function openWindow_safari_mac(url, name, options) {
    	      	if( newWindow = window.open(url, name, options) ) {
    	        	if (window.focus) { newWindow.focus(); }
        	   		return true;
            	} else {
     	       		return false;
				}
			}



			/* this was needed by openWindow_safari_windows() which is no longer used
    		function getSwf(id) {
        		if (navigator.appName.indexOf('Microsoft') != -1) {
            		return window[id];
        		}
        		else {
            		return document[id];
        		}
    		}
            */
            
            


			// if not, safari/windows will spawn new windows when user clicks either "visit your site"
			// or "see my site" and not close past window making the user experience very messy with many open windows
			// only if browser=safari and plaform=windows will this window be closed if focused is returned to this parent window
			function closeWindow() {
  	      		if (safariWin && isWin && isSafari) {
   	      			safariWin.close();
   	      		}

  			}
			
			window.onfocus=closeWindow;


			function closeChildWindowOnMainClose() {
  	      		if (safariWin && isWin && isSafari) {
   	      			safariWin.close();
   	      		} else {
  	      			if (newWindow) {
   	      				newWindow.close();
   	      			}
  	      			if (newWindow_engine) {
   	      				newWindow_engine.close();
   	      			}
   	      		}
  			}




			// only focuses window. used if browser is safari and platform is windows.
			// THE ONLY ROUTINE USED HERE IS THE CALL BACK TO openWindowFromSwf().  Safari/windows doesn't call window.open() or windowObj.focus().
			// i'm leaving the code in in case Safari/windows changes and the (supposed) bug is fixed.

			// this works but Safari/windows can't call window.open() or windowObj.focus() so javascript is never called
			// so the call always comes back to openWindowSafari() from javascript so just call it here rather than making the round trip.
			/*
			var winNew;
 	       	function openWindow_safari_windows(url, winName, options, _datasource, _username, _app, _sl, _pos, _label, _data, _datac, _uprefs, _jobdata, _jobsort, _usernodepos, _usernodelabel, _usernodedata, _usertype, _lang, _key, _key_sid) {

        		var winName = Math.round(9999*Math.random()) + new Date().getTime();
        		winNew = window.open(url,winName,options);
   	      		
					
					var html = '';
					html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
					html += "<input type='hidden' name='datasource' value='" + _datasource + "' />";
					html += "<input type='hidden' name='username' value='" + _username + "' />";
					html += "<input type='hidden' name='app' value='" + _app + "' />";
					html += "<input type='hidden' name='sl' value='" + _sl + "' />";
					html += "<input type='hidden' name='pos' value='" + _pos + "' />";
					html += "<input type='hidden' name='label' value='" + _label + "' />";
					html += "<input type='hidden' name='data' value='" + _data + "' />";
					html += "<input type='hidden' name='datac' value='" + _datac + "' />";
					html += "<input type='hidden' name='uprefs' value='" + _uprefs + "' />";
					html += "<input type='hidden' name='jobdata' value='" + _jobdata + "' />";
					html += "<input type='hidden' name='jobsort' value='" + _jobsort + "' />";
					html += "<input type='hidden' name='usernodepos' value='" + _usernodepos + "' />";
					html += "<input type='hidden' name='usernodelabel' value='" + _usernodelabel + "' />";
					html += "<input type='hidden' name='usernodedata' value='" + _usernodedata + "' />";
					html += "<input type='hidden' name='usertype' value='" + _usertype + "' />";
					html += "<input type='hidden' name='lang' value='" + _lang + "' />";
					html += "<input type='hidden' name='key' value='" + _key + "' />";
					html += "<input type='hidden' name='key_sid' value='" + _key_sid + "' />";

					html += "</form><script type='text/javascript'>document.getElementById('formid').submit()</script></body></html>";
					//winNew.document.write(html);
					


        		if(!winNew) {
        			getSwf('main').openWindowFromSwf(url, _datasource, _username, _app, _sl, _pos, _label, _data, _datac, _uprefs, _jobdata, _jobsort, _usernodepos, _usernodelabel, _usernodedata, _usertype, _lang, _key, _key_sid);
       		 	}
       		 	else {
      				winNew.focus();
       		 	}
			}
			*/



			// this is needed for the test_engine.php and member.php to return back the this parent window a reference
			// to it's window object so it can close it when focus returns to this parent window
			// if not, safari/windows will spawn new windows when user clicks either "visit your site"
			// or "see my site" and not close past window making the user experience very messy with many open windows
			// only if browser=safari and plaform=windows will this window be closed if focused is returned to this parent window
			var safariWin;
 	       	function initSafariWindowObject(winObj) {
				safariWin = winObj;
			}

///// END: MICHAEL SCRIPT: INDEX.PHP





///// START: MICHAEL SCRIPT: MEMBER.PHP AND TEST_ENGINE.PHP

	window.opener.initSafariWindowObject(this);

///// END: MICHAEL SCRIPT: MEMBER.PHP AND TEST_ENGINE.PHP





