var codetries; var webkinzLocaleCookie; var wide_layout=true;document.domain="webkinz.com"; function getBrowserCookie(){ dc=document.cookie.split(";"); //dc[0] is codetries //alert(dc[0]); //ct is codetries value ct = dc[0].split("="); //alert("cookie = "+ct[1]); codetries = ct[1]; //alert("getBrowserCookie: codetries = "+codetries); //cookie fix code starts 20080229 by KW if (!((codetries>=0) && (codetries<=5))){ //alert("before: codetries = "+codetries); codetries = 0; //alert("after: codetries = "+codetries); }else{ //alert("cannot get it"); } //cookie fix code ends //webkinzLocaleCookie = readCookie("webkinzLocaleCookie"); //alert("webkinzLocaleCookie = "+webkinzLocaleCookie); } function getSecretCodeCookie(area){ getBrowserCookie(); //alert("getSecretCodeCookie("+area+"), codetries = "+codetries); if (area=="main"){ //alert("window.document.main = "+window.document.main); //window.document.main.SetVariable("mycodetries",ct[1]); //window.document.main.SetVariable("mycodetries",codetries); }else{ //alert("window.document.adoptionCenter = "+window.document.adoptionCenter); //alert("window.document['adoptionCenter'] = "+window.document['adoptionCenter'] ); //window.document.adoptionCenter.SetVariable("mycodetries",ct[1]); //alert("adoptionCenter codetries = "+codetries); //window.document.adoptionCenter.SetVariable("mycodetries",codetries); } } //This JavaScript function sets the number of tries the user enters the pet code. function setSecretCodeCookie(tries) { var futdate = new Date(); //Get the current time and date var expdate = futdate.getTime(); //Get the milliseconds since Jan 1, 1970 var expdate = expdate+3600*1000*24; //expires in 1 day(milliseconds) futdate.setTime(expdate); var cookieString ="codetries="+tries+";expires=" + futdate.toGMTString(); //alert("cookieString = "+cookieString); document.cookie = cookieString; } function readCookie(name){ var nameEQ=name+"="; var value; var ca=document.cookie.split(';'); for(var i=0;i0) { var w = 536; var h = 402; } else { var w = 1000; var h = 680; } var WAPIserver = new Array(); WAPIserver[1]= 'wapi1.webkinz.com'; WAPIserver[2]= 'wapi2.webkinz.com'; WAPIserver[3]= 'wapi3.webkinz.com'; WAPIserver[4]= 'wapi4.webkinz.com'; WAPIserver[5]= 'wapi5.webkinz.com'; WAPIserver[6]= 'wapi6.webkinz.com'; WAPIserver[7]= 'wapi7.webkinz.com'; WAPIserver[8]= 'wapi8.webkinz.com'; WAPIserver[9]= 'wapi9.webkinz.com'; WAPIserver[10]= 'wapi10.webkinz.com'; WAPIserver[11]= 'wapi11.webkinz.com'; WAPIserver[12]= 'wapi12.webkinz.com'; WAPIserver[13]= 'wapi13.webkinz.com'; WAPIserver[14]= 'wapi14.webkinz.com'; WAPIserver[15]= 'wapi15.webkinz.com'; WAPIserver[16]= 'wapi16.webkinz.com'; WAPIserver[17]= 'wapi17.webkinz.com'; WAPIserver[18]= 'wapi18.webkinz.com'; WAPIserver[19]= 'wapi19.webkinz.com'; // BT: if the country argument is set to "free" // then this code is running on a tier0 site // so there should be a geoIPCountry variable // defined in the window scope by loader4.php if (screen.width > 1024 && this.wide_layout===true){ var isWide = 1; var fW = 1140; if(parent.location.href.match(/webkinz.html/)){ parent.moveWiderAds(); } } else{ var isWide=0; var fW = 1000; if(parent.location.href.match(/webkinz_s.html/)){ parent.slimAd(); } } //alert("webkinzLocaleCookie = "+readCookie('webkinzLocaleCookie')); main = 'main2.v172_0.swf'; WAPIdomain = WAPIserver[world_DbId]; aol = (navigator.userAgent.toLowerCase().indexOf('aol')>0 && navigator.userAgent.toLowerCase().indexOf('netscape')<0 ? 1 : 0); html = ''; html = html + ' '; html = html + ' '; html = html + ' '; html = html + ' '; html = html + ' '; html = html + ' '; //html = html + ' '; html = html + ' '; html = html + ''; html = html + ' '; html = html + ' '; html = html + ''; // alert(html); // added for the bridge - PhilS document.getElementById('api').innerHTML = '
'; document.getElementById('divMain').innerHTML = html; createAS3Div(); addDiv(); if(screen.width <= 1024 || !isWide){ document.getElementById('divMain').style.width="1000px"; document.getElementById('rightAd').style.display="none"; } else{ $('#api').css('width','1140px'); document.getElementById('divMain').style.width="1140px"; $('#rightAd').css('display','block'); } } // added to load the AS3 ElectroServer4.0.n Client function loadES4() { html2 = ''; html2 = html2 + ' '; html2 = html2 + ' '; html2 = html2 + ' '; html2 = html2 + ' '; html2 = html2 + ' '; html2 = html2 + ' '; html2 = html2 + ' '; html2 = html2 + ''; // alert(html2); document.getElementById('divES4').innerHTML = html2; } /////////////////////////////////////////////////////////////////////////////////////////////////////// //CHANGES MADE FOR UNITY/FLASH CONNECTION /////////////////////////////////////////////////////////////////////////////////////////////////////// //Path to the hamster files var hamsterPath = "http://www.webkinz.com/SWF/VIEWS/Hamsters/Unity_Files/"; //Webkinz User Info var userName = ""; var userId = ""; var userDeluxe = ""; var token = ""; var key = ""; var worldId = ""; var languageCode = ""; var friendList = ""; var serverTime = ""; //Version number of the Unity3d file var vnum = "v0_0"; //Hamsters API Info var API_IP = ""; var API_PORT = ""; //Used to check that Unity can only load once var unityFinishedLoading = false; var delayedLoad = null; var delayedHide = null; //Adds the Unity divTag to the page function addDiv() { if (unityExists() == true) { removeDiv(); } //Create the divTag var divTag = document.createElement("div"); divTag.id = "unityDiv"; divTag.style.position = "absolute"; divTag.style.left = "3000px"; divTag.style.top = "3000px"; divTag.style.zIndex = 11; // Do not modify visibility, it causes JS to stop working in IE, which breaks ExternalInterface in Flash //divTag.style.visibility = "hidden"; //Write the new divTag to the page document.body.appendChild(divTag); } //Removes the Unity divTag from the page function removeDiv() { //Get the unity divTag var removeTag = document.getElementById('unityDiv'); //Remove the divtag from its parent removeTag.parentNode.removeChild(removeTag); } //Removes the AS3 divTag from the page function removeAS3Div() { //Get the unity divTag var removeTag = document.getElementById('as3coreDiv'); //Remove the divtag from its parent removeTag.parentNode.removeChild(removeTag); } function createAS3Div() { //Create the divTag var divTag = document.createElement("div"); divTag.id = "as3coreDiv"; divTag.style.position = "absolute"; divTag.style.left = "3000px"; divTag.style.top = "3000px"; divTag.style.zIndex = 10; // Do not modify visibility, it causes JS to stop working in IE, which breaks ExternalInterface in Flash //divTag.style.visibility = "hidden"; // Only add innerHTML content if not in IE, if content exists in IE it will break, // if content does not exist in other browsers it will also break if (navigator.appName.indexOf("Microsoft") == -1) { divTag.innerHTML = '
'; } document.getElementById('api').style.position = "absolute"; //Write the new divTag to the page //var mainTag = document.getElementById('divMain'); document.body.appendChild(divTag); } // Added 27/04/2011 to allow the as3 div to resize and reposition itself // Reposisioning code is in the Content/asbridge.js file var previousXPos = 0; var previousYPos = 0; function showAS3Div() { // Do not modify visibility, it causes JS to stop working in IE, which breaks ExternalInterface in Flash //document.getElementById('as3coreDiv').style.visibility = "visible"; // Reposition the AS3 div document.getElementById('as3coreDiv').style.left = "0px"; document.getElementById('as3coreDiv').style.top = "0px"; document.getElementById('api').style.left = "3000px"; document.getElementById('api').style.top = "3000px"; // Regenerate the AS3 tag (this is being done for now to alleviate AS3 memory leak issues showAS3Content('CoreLoader.swf'); } function hideAS3Div() { /** Do not modify visibility, it causes JS to stop working in IE, which breaks ExternalInterface in Flash */ //document.getElementById('as3coreDiv').style.visibility = "hidden"; // Reposition the AS3 div document.getElementById('as3coreDiv').style.left = "3000px"; document.getElementById('as3coreDiv').style.top = "3000px"; document.getElementById('api').style.left = "0px"; document.getElementById('api').style.top = "0px"; // Wipe out the AS3 div tags content (note: IE blows up if there is no innerHTML, all other browsers blow up if there is innerHTML) var divTag = document.getElementById('as3coreDiv'); if (navigator.appName.indexOf("Microsoft") != -1) { divTag.innerHTML = '
'; } else { divTag.innerHTML = ''; } toggleAS2CSSClass(); } function as3Logout() { thisMovie('as3core').DoAS3Logout(); } // Display AS3 content in the AS3
function showAS3Content(swfName) { var objectHeight = "715"; if (navigator.appName.indexOf("Microsoft") == -1) { objectHeight = "660"; } // Set all values to wider Webkinz by default var isWide = 1; var logout_x = 1091; var as3DivWidth = 1140; var logout_y = 8; var as3BG = "default_w.png"; if (screen.width <= 1024 && this.wide_layout === false){ isWide = 0; logout_x = 951; as3DivWidth = 1000; as3BG = "default.png"; } document.getElementById('as3coreDiv').style.width = as3DivWidth; document.getElementById('as3coreDiv').style.height = 680; var deluxeImagePath = 'http://www.webkinz.com/SWF/Deluxe/webkinzLogo.swf'; var deluxeImageX = 825; var deluxeImageY = 10; if (isWide) { deluxeImageX = 962; } if (isDeluxe == true) { deluxeImagePath = 'http://www.webkinz.com/SWF/Deluxe/' + languageCode.toLowerCase() + '.swf'; deluxeImageX = 820; if (isWide) { deluxeImageX = 957; } deluxeImageY = 0; } var deluxeImage=""; deluxeImage+=""; outputHTML+=""; outputHTML+=""; deluxeImage+=""; deluxeImage+=""; deluxeImage+=""; var logoutObject=""; logoutObject+=""; logoutObject+=""; logoutObject+=""; logoutObject+=""; logoutObject+="" logoutObject+=""; logoutObject+=""; logoutObject+=""; // Build the AS3 content html for the var outputHTML=""; outputHTML+=""; outputHTML+=""; outputHTML+=""; outputHTML+=""; outputHTML+="" outputHTML+=""; outputHTML+=""; outputHTML+=""; var carnivalAdsContainer = "
"; // Add the swf tag to the html in the AS3
document.getElementById('as3coreDiv').innerHTML = deluxeImage + logoutObject + outputHTML + carnivalAdsContainer; document.getElementById('as3core').style.position = "absolute"; // Set the background image in the AS3 div changeAS3BG(as3BG); // Set the flag that the page is ready, which we know is the case since AS3 is only shown after you log in pageInit(); //Only invoke this when the core has ACTUALLY been loaded thisMovie('mainSite').CoreLoaded(); } function changeAS3BG(filename) { document.getElementById('as3coreDiv').style.backgroundImage = "url('http://www.webkinz.com/AS3/services/assets/viewService/" + filename + "')"; } // This function is called by the AS3 core once it loads, it sets a CSS class on the which will // force IE to re-render the page, without this the swf will load but not display in IE, unless loaded from cache function addCSSClassToObject() { document.getElementById('as3core').setAttribute("className", "pageRenderClass"); toggleAS2CSSClass(); } // This function is called once AS2 is hidden or shown, it sets a CSS class on the which will // force IE to re-render the page, without this AS2 will not be moved off screen function toggleAS2CSSClass() { if (document.getElementById('api').className == "pageRenderClass") { document.getElementById('api').setAttribute("className", ""); } else { document.getElementById('api').setAttribute("className", "pageRenderClass"); } } //Used to Load Hamster Content and Show the divTag function showUnity() { //Create the HTML Content for the Hamsters unity3d file var unityHTML = ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; unityHTML += ''; //Move the divTag into view document.getElementById('unityDiv').style.left = "13px"; document.getElementById('unityDiv').style.top = "70px"; //Write the HTML Content to the divTag document.getElementById('unityDiv').innerHTML = unityHTML; //Show the divTag document.getElementById('unityDiv').style.visibility = "visible"; //Add Unity Events for mouse click and focus - not fully tested //addUnityEvents(); } function loadView(viewId) { trace("loadView("+viewId+")"); var intViewId = parseInt(viewId); //If we are not trying to load AS3Core from AS3Core if (intViewId != 4156 && intViewId != 4157 && intViewId != 4160) { hideUnity(); //Load the view thisMovie('mainSite').loadView(viewId); unityFinishedLoading = false; } else if (viewId != 4154 && viewId != "4154") { //Destroy Unity //hideUnity(); unityCommitSuicide(); document.getElementById('unityDiv').style.left = "750px"; document.getElementById('unityDiv').style.top = "750px"; document.getElementById('unityDiv').style.visibility = "hidden"; //Delay the loading of the view //delayedLoad = setTimeout("delayedLoadView("+viewId+")", 5000); delayedHide = setTimeout("hideUnity()", 1000); unityFinishedLoading = false; //Load the view thisMovie('mainSite').loadView(viewId); return; } else { trace("loadView(): Hamsters is trying to load itself"); } } function delayedLoadView(viewId) { trace("delayedLoadView("+viewId+")"); //Load the view thisMovie('mainSite').loadView(viewId); } function unityCommitSuicide() { trace("unityCommitSuicide()"); //tell Unity to sendCallToUnity("QuitApplication", "null"); } function hideUnity() { trace("hideUnity()"); //Remove Unity Events - not fully tested //removeUnityEvents(); /*if (navigator.appName.indexOf("Microsoft") != -1) { var regExpression = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); var browserVersion = 8.0; if (regExpression.exec(navigator.userAgent) != null) { browserVersion = parseFloat(RegExp.$1); } if (browserVersion < 8.0) { //Not sure if this will fix Unity crashing or cause more problems document.getElementById('unityDiv').innerHTML = ' '; //document.getElementById('unityDiv').innerHTML = '

hello

'; } }*/ //Readd the Unity divTag //This should remove the old one first addDiv(); } function showFlashMessage(message) { trace("showFlashMessage("+message+")"); if(message != "") { //Show a webkinz system message thisMovie('mainSite').FlashAlert(message); } } //All calls from Flash should come here function FlashCall(parameters) { trace("FlashCall("+parameters.method+")"); //If parameters has a method if (parameters.method != null && parameters.method != "") { //Check if it's a method we know switch(parameters.method) { case "showUnity": //Grab the users webkinz info from the parameters object userName = parameters.userName; friendList = parameters.friendList; serverTime = parameters.serverTime ; userId = parameters.userId; token = parameters.token; key = parameters.key; languageCode = parameters.languageCode; worldId = parameters.worldId; vnum = parameters.vnum; API_IP = parameters.HamstersIP; API_PORT = parameters.HamstersPort; if (vnum != "v0_0") { showUnity(); } break; case "showAS3Content": //Grab the users webkinz info from the parameters object userName = parameters.userName; userId = parameters.userId; token = parameters.token; key = parameters.key; languageCode = parameters.languageCode; worldId = parameters.worldId; isDeluxe = parameters.userDeluxe; trace("Showing AS3 Content"); showAS3Content("CoreLoader.swf"); break; case "showAS3DTS": //Grab the users webkinz info from the parameters object userName = parameters.userName; userId = parameters.userId; token = parameters.token; key = parameters.key; languageCode = parameters.languageCode; worldId = parameters.worldId; trace("Showing AS3 Content"); showAS3Content("DynamicTestingApplication.swf"); break; case "hideAS3Div": hideAS3Div(); break; case "showAS3Div": showAS3Div(); break; case "createAS3Div": //createAS3Div(); showAS3Div(); break; case "checkUnity": //Check if we have Unity DetectUnityWebPlayer(); break; case "getUnity": //Send the user to Unity's webpage GetInstallerPath(); break; case "setFilePath": //Define the path to the Hamster Unity files - Not really needed anymore //Please don't use //hamsterPath = parameters.path; break; case "checkLogout": //Pass the logout call from Flash to Unity sendCallToUnity("Logout", "null"); break; case "timeOut": //Pass the timeout call from Flash to Unity sendCallToUnity("Timeout", "null"); break; default: break; } } } //All calls from Unity should come here function UnityCall(method) { trace("UnityCall("+method+")"); //If the method exists and Unity is sending the call (avoids phantom Unity calls from after Unity closes) if (method != null && method != "" && unityExists()) { //Check if it's a method we know switch(method) { case "OpenNews": //Link straight to Untiy page loadURL = "http://www.webkinznewz.com/wp-mu/category/mazin-hamsters-announcements/"; //Popup a new window to the URL var popupWindow = window.open(loadURL, "OpenNews"); break; case "SurveyYes": //store a cookie alert(userName); loadURL = "http://192.168.51.228/wp-mu284/blog/2010/06/take-our-hamsters-survey/"; var popupWindow = window.open(loadURL, "Survey"); createCookie('surveyDone',true,30); break; case "SurveyNo": //store a cookie createCookie('surveyWaiver',true,30); break; case "openEStore": //Link straight to Unity page loadURL = "http://www.ganzestore.com"; //Popup a new window to the URL var popupWindow = window.open(loadURL, "EStore"); break; case "openStoreLocator": //Link straight to Unity page loadURL = "http://66.48.69.113/index.php"; //Popup a new window to the URL var popupWindow = window.open(loadURL, "StoreLocator"); break; case "unityLoaded": //Unity is loaded, send Unity the users webkinz info sendLoginInfo(); break; case "gotoNewspaper": //Load Newspaper loadView(12); break; case "loadCodeShop": //Load Code Shop loadView(4011); break; case "keepPlayingHamsters": //Pass along the keep alive call thisMovie('mainSite').keepPlayingHamsters(); break; case "logout": //Pass along a logout call thisMovie('mainSite').logout(); break; case "showHamsterTutorial": //New window position var xPos = 0; var yPos = 0; //Check for IE if (navigator.appName.indexOf("Microsoft") != -1) { //Define new window position xPos = window.screenLeft + 50; yPos = window.screenTop; } else { //Define new window position xPos = window.screenX + 150; yPos = window.screenY + 100; } //Popup a new window with the tutorial video var tutorialPopup = window.open(hamsterPath+"Tutorial_Videos/Hamster_Tutorial.html", "Tutorial", "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,height=486,width=720,top="+yPos+",left="+xPos); break; case "showBuilderTutorial": //New window position var xPos = 0; var yPos = 0; //Check for IE if (navigator.appName.indexOf("Microsoft") != -1) { //Define new window position xPos = window.screenLeft + 50; yPos = window.screenTop; } else { //Define new window position xPos = window.screenX + 150; yPos = window.screenY + 100; } //Popup a new window with the tutorial video var tutorialPopup = window.open(hamsterPath+"Tutorial_Videos/Builder_Tutorial.html", "Tutorial", "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,height=486,width=720,top="+yPos+",left="+xPos); break; default: break; } } } function loadSurvey() { var showSurvey = true; if( readCookie('surveyDone') == 'true' || readCookie('surveyWaiver') == 'true'){ showSurvey = false; } return showSurvey; } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; //alert(name+" : "+value); } //Sends the users webkinz info to Unity function sendLoginInfo() { var survey = loadSurvey(); trace("sendLoginInfo(userName = "+ userName + ", userId = " + userId + ", token = " + token + ", key = " + key + ", languageCode = " + languageCode + ", worldId = " + worldId+", API_IP = " + API_IP + ", API_PORT = "+ API_PORT +", survey = "+survey+")"); //If we haven't run this function yet if (unityFinishedLoading == false) { //Only let this function run once unityFinishedLoading = true; //Token, userName, and userId are the three required properties for login if (token != "" && userName != "" && userId != "") { //Send Unity the users webkinz info sendCallToUnity("SetLoginInfo", userName + ";" + userId + ";" + token + ";" + key + ";" + languageCode + ";" + worldId + ";" + API_IP + ";" + API_PORT + ";" + survey + ";" +friendList + ";" + serverTime + ";"); //Empty out the users info userName = ""; userId = ""; token = ""; key = ""; languageCode = ""; worldId = ""; API_IP = ""; API_PORT = ""; survey = ""; friendList = ""; serverTime = ""; } else { //This means that either the connection to Flash id broken or Flash didn't send us what we wanted. trace("sendLoginInfo(): Either: token = "+token+", userName = "+userName+" or userId = "+userId+" are blank."); //Show a message showFlashMessage("You cannot login into Mazin' Hamsters."); //Load the Newspaper loadView(12); } } } //Trace something out in Flash function trace(message) { //Trace causes IE to break if (navigator.appName.indexOf("Microsoft") == -1) { //Removed since its not needed at this point //thisMovie('mainSite').FlashTrace("Browser: " + message); } } //Make a call to Unity function sendCallToUnity(functionName, parameters) { if (unityMovie() != null) { try { //Send the call to Unity unityMovie().SendMessage("Main Camera", functionName, parameters); } catch(javascriptError) { //"Main Camera" is the name of the object everything is attached to in Unity trace("The Unity call to " + functionName + " failed probably because 'Main Camera' doesn't exist in the Unity project. javascriptError = " + javascriptError); } } else { //Unity doesn't exist trace("The Unity call to " + functionName + " failed because unityMovie() = "+unityMovie()+", is not vaild."); } } //Used to grab an object from the page in any browser function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { //Return the IE object return window[movieName]; } else { //Return the object for every other browser return document[movieName]; } } //Used to grab the Unity object from the page in any browser function unityMovie() { var unityObject; if (navigator.appName.indexOf("Microsoft") != -1) { //Return the IE object unityObject = window['Unity_object']; } else { //Return the object for every other browser unityObject = document['Unity_embed']; } if (unityObject != null) { return unityObject; } else { return null; } } //Check if Unity exists function unityExists() { if (unityMovie() != null && unityMovie() != undefined) { return true; } else { return false; } } //////////////////////////////////////////////// //CODE IS BASED OFF HTML FILE GENERATED BY UNITY //////////////////////////////////////////////// //Check and see if the user has Unity installed in IE function DetectUnityWebPlayerActiveX() { //This function was written in VB in Unity's HTML //Everthing is a converted from VB var axObject; var unityInstalled = false; try { //Grab the Unity Plugin axObject = new ActiveXObject("UnityWebPlayer.UnityWebPlayer.1"); } catch(javascriptError) { //Unity is not installed or the browser doesn't know it exists //trace("DetectUnityWebPlayerActiveX(): This is Normal: Error on ActiveXObject: javascriptError = " + javascriptError); return unityInstalled; } try { //If you have version 2.5.0f5 of Unity it has other issues if(axObject.GetPluginVersion() == "2.5.0f5") { var ua; var re; var matches; var major; //Comments from Unity HTML // 2.5.0f5 on Vista && later has an auto-update issue; // on Internet Explorer. Detect Vista (6.0 || later); // && in that case treat it as ! installed; ua = navigator.userAgent; re = new RegExp("Windows NT (\d+)\."); matches = re.exec(ua); //trace("DetectUnityWebPlayerActiveX(): axObject Plugin version = 2.5.0f5"); //This has never been fully tested, and i'm not sure if it would work /*if(matches.Count == 1) { major = CInt(matches[0].SubMatches[0]); if(major < 6) { unityInstalled = true; } }*/ } else { //trace("DetectUnityWebPlayerActiveX(): Unity Exists."); unityInstalled = true; } } catch(javascriptError) { //Something was wrong with the axObject, Unity must not be installed //trace("DetectUnityWebPlayerActiveX(): This is Normal: Error on axObject: javascriptError = " + javascriptError); return unityInstalled; } return unityInstalled; } //Check and see if the user has Unity installed function DetectUnityWebPlayer() { trace("DetectUnityWebPlayer()"); var unityInstalled = false; //IE has its own special check for Unity if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.toLowerCase().indexOf("win") != -1) { //trace("DetectUnityWebPlayer(): Doing IE Check."); unityInstalled = DetectUnityWebPlayerActiveX(); } else { //trace("DetectUnityWebPlayer(): Doing not IE Check."); //Find the plugin if (navigator.mimeTypes && navigator.mimeTypes["application/vnd.unity"]) { //trace("DetectUnityWebPlayer(): Vaild mimeTypes."); //Check if the plugin is running and functional if (navigator.mimeTypes["application/vnd.unity"].enabledPlugin && navigator.plugins && navigator.plugins["Unity Player"]) { //trace("DetectUnityWebPlayer(): Unity Installed."); unityInstalled = true; } } } // These two checks always seem to tell us Unity is not Installed on a Mac in Safari // Not sure what their purpose was in the unity html so they have been removed for now if (navigator.appVersion.indexOf("Safari") != -1 && navigator.appVersion.indexOf("Mac OS X 10_6") != -1) { trace("DetectUnityWebPlayer(): Index of 'Safari' = "+navigator.appVersion.indexOf("Safari")+", Index of 'Mac OS X 10_6' = " + navigator.appVersion.indexOf("Mac OS X 10_6")); //unityInstalled = false; } else if (navigator.platform == "MacPPC") { trace("DetectUnityWebPlayer(): navigator.platform = "+navigator.platform); //unityInstalled = false; } //Send the results back to Flash thisMovie('mainSite').UnityCheck(unityInstalled); } function GetInstallerPath() { trace("GetInstallerPath()"); //Old code that was suppose to download the unity install file /*var downloadURL = ""; var hasXpi = navigator.userAgent.toLowerCase().indexOf( "firefox" ) != -1; if (navigator.platform == "MacIntel") { downloadURL s= "http://webplayer.unity3d.com/download_webplayer-2.x/webplayer-i386.dmg"; } else if (navigator.platform == "MacPPC") { downloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/webplayer-ppc.dmg"; } else if (navigator.platform.toLowerCase().indexOf("win") != -1) { downloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/UnityWebPlayer.exe"; }*/ //Link straight to Unity page downloadURL = "http://unity3d.com/webplayer/"; //Popup a new window to the URL var popupWindow = window.open(downloadURL, "Download"); } //////////////////////////////////////////////// //END CODE IS BASED OFF HTML FILE GENERATED BY UNITY //////////////////////////////////////////////// //Pass mouse and focus events to Unity function addUnityEvents() { if (unityMovie() != null) { //Check for Internet Explorer if (navigator.appName.indexOf("Microsoft") != -1) { //Internet Explorer unityMovie().attachEvent('onmouseover', focus, true); unityMovie().attachEvent('onmouseout', blur, true); } else { //Netscape, Firefox, Mozilla, Chrome and Safari. unityMovie().addEventListener('mouseover', focus, true); unityMovie().addEventListener('mouseout', blur, true); unityMovie().addEventListener('focus', focus, true); unityMovie().addEventListener('blur', blur, true); } } } //Remove mouse and focus events to Unity function removeUnityEvents() { if (unityMovie() != null) { //Check for Internet Explorer if (navigator.appName.indexOf("Microsoft") != -1) { //Internet Explorer unityMovie().detachEvent('onmouseover', focus, true); unityMovie().detachEvent('onmouseout', blur, true); } else { //Netscape, Firefox, Mozilla, Chrome and Safari. unityMovie().removeEventListener('mouseover', focus, true); unityMovie().removeEventListener('mouseout', blur, true); unityMovie().removeEventListener('focus', focus, true); unityMovie().removeEventListener('blur', blur, true); } } } //Functions for sending mouse clicks and focus to Unity function focus() { sendCallToUnity("OnFocus", "null"); } function blur() { sendCallToUnity("OnBlur", "null"); } //End focus functions /////////////////////////////////////////////////////////////////////////////////////////////////////// //END CHANGES MADE FOR UNITY/FLASH CONNECTION ///////////////////////////////////////////////////////////////////////////////////////////////////////