﻿TempCode 			= 548;
ActiveXVersion		= "1,0,2,19";
ext					= "219";
PluginDownloadURL	= "http://c212729.r29.cf1.rackcdn.com/";

//firefox plugin:   
PluginFFShaHash		= "sha1:7282009c49cccaf31262fc3e90168752b3d1fb84";
XPIFile = PluginDownloadURL+"CamSpaceFFPlugin"+ext+".xpi";


PluginImagesURL		= "http://c212729.r29.cf1.rackcdn.com/";
//PluginImageIE		= PluginImagesURL+"InstallPluginZooli.jpg"; //for IE 9, need to fix...
//defaultPreroll		= PluginImagesURL+"WelcomeEnglish.html";
defaultLang			= 'en';
Installation_ID		= 0;
camspacePublisherID = 1;



camspaceThemeID = 0;
doFlashIntro = true;
CSFeedback = false;
CSSharing = true
CSEmbed = true;
CSSkipLandingPage = false;
//CSInstallPageOverride = null;
//CSIncludeInstallInstructions = true;
CSInstallPageOverride = "http://c212729.r29.cf1.rackcdn.com/motion_install_screen-3.jpg";
CSIncludeInstallInstructions = false;
CSCreateDesktopLinkSelf = true;
CSCreateDesktopLinkCamSpace = true;

ThemeOverride = null;
FullMenuFilename = null;
AdultMode = false;
InstructionsTimeout = 8500;
var d = new Date();
PageLoadeTime =  d.getTime();
InstructionsLoaded = false;
CamSpaceSupportedOnSystem = true;
if (navigator.language != null)
	defaultLang = navigator.language;
if (navigator.browserLanguage != null)
	defaultLang = navigator.browserLanguage;
var CamSpaceVersion = "uninstalled";


CSDone = false;
function doit()
{
	if (CSDone==true) return;
	CSDone=true;
	document.getElementById("before_user_confirms").innerHTML =  CamSpaceCode2(__width, __height, __gameurl, __themeurl,__prerollurl,__socket,__camspacevars);
}

function setInstallationID(instid)
{
	Installation_ID = instid;
	


	//
	var html = 	'';
	if (CSFeedback)
	html=	'<form id="userstats" accept-charset="utf-8" action="http://www.camspace.com/stats/codyfeedback" method="post" enctype="multipart/form-data">'+	
	//var html = 	'<form id="userstats" action="http://127.0.0.1/stats/codyfeedback/user/'+Installation_ID+'" method="post" enctype="multipart/form-data">'+	

		'<input type="hidden" name="version" value="'+CamSpaceVersion+'">'+
		'<input type="hidden" name="url" value="'+window.location+'">'+
		'<input type="hidden" name="theme_id" value="'+0+'">'+
		'<input type="hidden" name="theme_url" value="'+defaultTheme+'">'+
		'<input type="hidden" name="publisher_id" value="'+0+'">'+
		'<input type="hidden" name="installation_id" value="'+Installation_ID+'">'+
	CamSpaceFeedbackText+'	</form>';

	
	 
	 
	if (CSEmbed)
		html = html+'<INPUT TYPE="button" NAME="button" Value="Embed" onClick="DoEmbed();">';

	if (CSSharing)
		html = html+CamSpaceLikeButton;

	if (CSEmbed)
		html = html+'<div id="embed_div"> </div>';
//	html = "<a href = \"https://spreadsheets.google.com/spreadsheet/viewform?formkey=dHhsUDJkdWVvd3o3ai1MMEU0aE9wbEE6MQ\" target=\"_blank\">"+CamSpaceReportABugText+"</href> "+CamSpaceLikeButton;
	document.getElementById("CamSpaceFeedbackDiv").innerHTML = html;	
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
   po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
}
	if (window.attachEvent) {
window.attachEvent("onload", setupSound);
}
else {
window.addEventListener("load", setupSound, false);
}

function setupSound()
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var snd = document.createElement("bgsound");
		document.getElementsByTagName("body")[0].appendChild(snd);
		playSound = function(url)
		{
			snd.src = url;
		}
	}
	else
	{ //not IE
		playSound = function(url)
		{
			var obj = document.createElement("object");
			obj.width="1x";
			obj.height="0px";
			obj.type = "audio/mp3";
			obj.data = url;
			var body = document.getElementsByTagName("body")[0];
			body.appendChild(obj);
		}
	}
}


function getDocumentTitle ()
{
	var title = document.title;
	return title;
}

function SetCamSpaceLanguage(language,width)
{

	var googlep1code = "<g:plusone></g:plusone>";
	var fblike = "<iframe src=\"http://www.facebook.com/plugins/like.php?app_id=257931230884246&amp;href=http%3A%2F%2Fwww.facebook.com%2FCamSpace&amp;send=false&amp;layout=standard&amp;width="+width/2+"'&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=35\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:500px; height:35px;\" allowTransparency=\"true\"></iframe>";
	var tweet = '<a href="http://twitter.com/CamspaceLive" target="_blank"><img src="http://c190547.r47.cf1.rackcdn.com/twitter_icon.png" border="0"/></a>';

	

	CamSpaceLikeButton = /*googlep1code+tweet+*/fblike;
	CodyPointLeft = PluginImagesURL+"kody_point_left.swf"
	CodySayHello = PluginImagesURL+"kody_happy.swf"
	
				

	if (AdultMode) 
	{
		InstructionsTimeout = 0;
		doFlashIntro = false;
	}

	if (language.toLowerCase()=="he") 
	{
		if (AdultMode) 
		{
			FullMenuFilename = "BlueConsole_FULL6.camspace";
			defaultPreroll = PluginImagesURL+'Black1_WelcomeHeb1.html';
			defaultTheme   = PluginImagesURL+'Blue1Theme6.zip';
			PluginImageBackground = PluginImagesURL+"Black1_BGHeb.jpg";
		}
		else
		{
			FullMenuFilename = "CodyMenu_FULL2.camspace";
			defaultPreroll = PluginImagesURL+'WelcomeHebrew.html';
			defaultTheme   = PluginImagesURL+'CodyThemeHeb31.zip';
			PluginImageBackground = PluginImagesURL+"Cody_BGHeb.jpg";
		}
		
		PluginImageIE		= PluginImagesURL+"IEHeb2.jpg";
		PluginImageFF		= PluginImagesURL+"FFHeb2.jpg";
		PluginImageChrome	= PluginImagesURL+"ChromeHeb2.jpg";
		PluginImageIE7		= PluginImagesURL+"IEHeb2.jpg";
		PluginImageIE9		= PluginImagesURL+"Arrow.png";
		PluginAnimation		= PluginImagesURL+"ShortAnim2.swf";
		PluginAnimation		= PluginImagesURL+"kodyspeak.swf";
		PluginImageIELayer = PluginImagesURL+"LayerIEHeb.png";
		PluginImageFFLayer = PluginImagesURL+"LayerFFHeb.png";
		PluginImageChromeLayer = PluginImagesURL+"LayerChromeHeb.png";
		IntroSound = PluginImagesURL+"InstallHeb.mp3";

		LeaveTextBeforeInstall = 'האם אתם בטוחים שאתם רוצים לעזוב את קודי?\nההתקנה פשוטה ומהירה מאוד, רק עקבו אחר ההוראות על המסך.\n\nנסו את חווית המשחק בתנועה החדשנית שלנו!';
		LeaveTextAfterInstall = 'האם אתם בטוחים שאתם רוצים לעזוב את קודי?\nלוקח לו כמה דקות להיטען בפעם הראשונה, אבל הוא שווה את זה!!!\n\nאנא המתינו עד שקודי יסיים להיטען...';
		CodyNotSupportedByBrowser = 'קודי משחקים בתנועה עדיין לא נתמך בדפדפן זה.<br>אנא נסו לפתוח את העמוד בדפדפן שונה';
		CodySupportedOnWindows = 'קודי נתמך כרגע רק במערכת הפעלה חלונות.';
		CamSpaceFeedbackText = '<p dir="RTL"><font color="black">דווח על בעייה:<textarea name="feedback" id="feedback" class="textarea" rows="1" cols="20"></textarea> \
		<input type="submit" value="שלח" class="button" /></font></p>';
		CamSpaceReportABugText = "דווח על בעיה";
		return;
	}

	//default: english
	//if (language.toLowerCase()=="en") 
	{


		if (AdultMode) 
		{
			FullMenuFilename = "BlueConsole_FULL6.camspace";
			defaultPreroll = PluginImagesURL+'BlueEngPreroll.html';
			defaultTheme   = PluginImagesURL+'Blue1Theme6.zip';
			PluginImageBackground = PluginImagesURL+"Black1_BGEng.jpg";
		}
		else
		{
			FullMenuFilename = "CodyMenu_FULL2.camspace";
			defaultPreroll = PluginImagesURL+'WelcomeEnglish.html';
			defaultTheme   = PluginImagesURL+'CodyThemeEng31.zip';
			PluginImageBackground = PluginImagesURL+"Cody_BGEng.jpg";
		}

		
		PluginImageIE		= PluginImagesURL+"IEEng2.jpg";
		PluginImageFF		= PluginImagesURL+"FFEng2_.jpg";
		PluginImageChrome	= PluginImagesURL+"ChromeEng2.jpg";
		PluginImageIE7		= PluginImagesURL+"IEEng2.jpg";
		PluginImageIE9		= PluginImagesURL+"Arrow.png";
		PluginAnimation		= PluginImagesURL+"ShortAnim2.swf";
		PluginAnimation		= PluginImagesURL+"kodyspeak.swf";
		PluginImageIELayer = PluginImagesURL+"LayerIEEng.png";
		PluginImageFFLayer = PluginImagesURL+"LayerFFEng.png";
		PluginImageChromeLayer = PluginImagesURL+"LayerChromeEng.png";
		IntroSound = PluginImagesURL+"InstallEng.mp3";

		LeaveTextBeforeInstall = 'Are you sure you want to quit Cody?\nStarting is very simple, just follow the on-screen instructions.\n\nTry our new Motion Gaming Experience!';
		LeaveTextAfterInstall = "Are you sure you want to quit Cody?\nIt takes some time to load, but you'll love it!!!\n\nPlease wait until cody is finished downloading...";
		CodyNotSupportedByBrowser = 'Cody motion games is still not supported by this browser.<br>Please open this page in a different browser';
		CodySupportedOnWindows = 'Cody is currently only supported on Windows platform.';
		CamSpaceFeedbackText = 'Feedback: <textarea name="feedback" id="feedback" class="textarea" rows="1" cols="20"></textarea> \
		<input type="submit" value="Send" class="button" />';
		CamSpaceReportABugText = "Report a Bug";
		return;
	}
	
}





//     <!--Google Analitics--> 
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4070405-6']);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

  

/*
  (function() {
  	var s = document.getElementsByTagName('script')[0];
      var jq = document.createElement('script'); jq.type = 'text/javascript';jq.async = false;
    jq.src = PluginImagesURL+'jquery-1.6.2.min.js';
     s.parentNode.insertBefore(jq, s);
  
   
	 jq = document.createElement('script'); jq.type = 'text/javascript';jq.async = false;
    jq.src = PluginImagesURL+'jquery.effects.core.js';
     s.parentNode.insertBefore(jq, s);
	
	jq = document.createElement('script'); jq.type = 'text/javascript';jq.async = false;
    jq.src = PluginImagesURL+'jquery.effects.bounce.js';
     s.parentNode.insertBefore(jq, s);
  })();
*/
	
	
function leaveconfirm()
{
	if (AdultMode) return; //don't annoy adults
	if (CamSpaceSupportedOnSystem == false) return; //we are not supported here, don't harrass the user..
	if (Installation_ID>0) return; //CamSpace is running, don't harrass the user..

	if (detectCamSpacePresence()==true)
		return LeaveTextAfterInstall; //user is donwloading the game  /theme
//	else
	//	return LeaveTextBeforeInstall; //user did not install yet... 
}


function detectActiveXCTL()
{
  if (window.ActiveXObject) 
  {  
      var control = null;  
     try {  
          control = new ActiveXObject('ScriptableActiveX.CamSpaceActiveX.5');
      } catch (e) {  
	 //alert("nope, catch... ");
          return false;  
      }  
      if (control) {  
	 //alert("it exists");
          isInstalled = true;

		  control.FakeSocket="hello";
		  if (control.FakeSocket!="Hello to you too")
		  {
			return false;
		  }

		  
		  control.FakeSocket="getver";
		  ver = control.FakeSocket;
		  CamSpaceVersion = ver;
		  //alert(ver);
		  if (ver != ActiveXVersion)
		  {
			return false;
		  }
		  
		  
	//	  alert(b);
	//alert("CamSpaceActiveX latest version is now installed, refreshing page...");
		  return true;
      }  
  } else {  
  return false;
      // Check navigator.plugins for "Shockwave for Director"  
  }
}


function install(aEvent)
{
	var params;
	if (aEvent==null)
	{
//	alert("1");
		params = {
		"Camspace": { URL: XPIFile,
				 IconURL: "http://www.camspace.com/public/images/Application.png",
				 Hash: PluginFFShaHash,
				 toString: function () { return this.URL; }
					}
			}
	} 
	else
	{
	//alert("2");
		params = {
		"Camspace": { URL: aEvent.currentTarget.href,
				 IconURL: aEvent.currentTarget.getAttribute("iconURL"),
				 Hash: aEvent.currentTarget.getAttribute("hash"),
				 toString: function () { return this.URL; }
					}
			}
	};
	InstallTrigger.install(params);
	return false;
}

function SetCamSpaceObjectSize(Width,Height)
{
	var obj = document.getElementById('CamSpaceOBJ');
	if (obj)
	{
		obj.width = Width;
		obj.height = Height;
		return true;
	}
	return false;
};

function SetCamSpaceExtComponentSize(Width,Height)
{
	document.getElementById('CamSpaceOBJ').HaveExtComponent = 1;
	document.getElementById('CamSpaceOBJ').ExtComponentWidth = Width;
	document.getElementById('CamSpaceOBJ').ExtComponentHeight = Height;
	document.getElementById('CamSpaceFlash').width = Width;
	document.getElementById('CamSpaceFlash').height = Height;

}

function CSGetInstallationId()
{
	return MessageCamSpaceActiveX("getver");
//	return MessageCamSpaceActiveX("getInstId");
}

function MessageCamSpaceActiveX(s)
{
	document.getElementById('CamSpaceOBJ').FakeSocket = s;
	return document.getElementById('CamSpaceOBJ').FakeSocket;
};

function SetCamSpaceGame(Game)
{
	return MessageCamSpaceActiveX("game:"+Game);
};


function is_ie() 
{ 
	var ua = navigator.userAgent.toLowerCase();
	if ( ua.indexOf( "msie" ) != -1 )
		return true;
	return false;
}
	
function detectCamSpacePresence()
{
	if (is_ie())
	{
		var detected = detectActiveXCTL();
		return detected;
	}
	var mime = navigator.mimeTypes["application/x-camspace-file"];
//	alert(mime);
	//alert(navigator.mimeTypes["application/x-shockwave-flash"]);
//	return true;
	if (mime) 
	{
		var plugin = mime.enabledPlugin;
		if (plugin)
		{
		//alert(plugin);

	//			alert(plugin.description);
		CamSpaceVersion = plugin.description;
			if (plugin.description == "CamSpace plugin "+ActiveXVersion) //is correct plugin and version?
			{
				return true;
			}
//			alert("CamSpace Plugin is outdated. Please install the new one");
				
//				alert(plugin.description);
		}
	//	else
		//	alert("CamSpace Plugin is not enabled");

	}
	return false;
}


function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}


function StartDownload ( )
{
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	if (is_chrome) 
	{
		var m = document.readyState; 
		window.onbeforeunload = null;
		if (m=='complete')
		{
			setTimeout ( "SetOnbeforeunload()", 500 );
			window.location = PluginDownloadURL+"ChromePlugin"+ext+".crx";
		}
		else
		{
			setTimeout ( "StartDownload()", 500 );
		}
	}
	else
		window.location = XPIFile;
}



function SetOnbeforeunload()
{
//		alert ("SetOnbeforeunload");
	window.onbeforeunload = leaveconfirm;
	if (Installation_ID==0)
		setInstallationID(0);
}


function CheckInstructions()
{
	if (!detectCamSpacePresence())
	{
		var d = new Date();
		if ((d-PageLoadeTime>InstructionsTimeout) && (InstructionsLoaded==false))
		{
			InstructionsLoaded = true;
			if (CSIncludeInstallInstructions==true)
				document.getElementById("CamSpaceOverlayInstructions").innerHTML = InstallInstuctionsCode;

			if (is_ie())
			{
				$(".installation-arrow").
			  delay(1000).fadeIn(1000).
			  delay(2500).
			  effect("bounce", { times:4, direction:"down", distance:40 }, 600);
			}
			else
			{
				$(".installation-arrow").
			  delay(1000).fadeIn(1000).
			  delay(2500).
			  effect("bounce", { times:4, distance:40 }, 600);
			}
			 if (AdultMode == false)
			{			 
				$(".installation-cody").
				delay(1000).fadeIn(500);
			}

		}
		else
			setTimeout ( "CheckInstructions()", 500 );
	}
}

function CheckChromeInstalled ( )
{
  	if (detectCamSpacePresence())
	{
		window.onbeforeunload = null;
		history.go();
	}
	else
	{
		setTimeout ( "CheckChromeInstalled()", 500 );
	}
}
function CheckFFInstalled()
{
/*alert("dffdg");
	var pos=getScrollXY();
	var size=getWindowSize();
	document.getElementById("CamSpaceOverlay").style.left=(size[0]-800)/2;
	document.getElementById("CamSpaceOverlay").style.top=(size[1]-600)/2+pos[1];
	if (!detectCamSpacePresence())
		setTimeout ( "CheckFFInstalled()", 500 );*/

}

function CheckIEInstalled ( )
{
  // (do something here)
	//alertSize();
/*	if ( navigator.userAgent.toLowerCase().indexOf( "msie 9" ) != -1 )
	{
	var pos=getScrollXY();
	var size=getWindowSize();
	document.getElementById("CamSpaceOverlay").style.left=(size[0]-800)/2+"px";
	document.getElementById("CamSpaceOverlay").style.top=(size[1]-600)/2+pos[1]+"px";
	
//	document.getElementById("CamSpaceOverlayArrow").style.left=50+"px";
	//document.getElementById("CamSpaceOverlayArrow").style.top=size[1]-148+pos[1]+"px";
	
	}*/
	
//	document.getElementById("CamSpaceOverlay").style.left=(size[0]-800)/2+"px";
	//document.getElementById("CamSpaceOverlay").style.top=(size[1]-600)/2+pos[1]+"px";
//	alert(navigator.userAgent);
//	alert((size[1]-600)/2+pos[1]);
	//document.getElementById("CamSpaceOverlay").style.position="absolute";
	//alert();
//	alert(document.getElementById("CamSpaceOverlay").style.top);
	//alert(pos[1]);
//	  objDiv = document.getElementById("CamSpaceDiv");
  //          objDiv = objDiv.style;
    //        alert(window.innerHeight);
			
  if (detectCamSpacePresence())
	{
//	alert(document.getElementById("CamSpaceOBJ").top);
		document.getElementById("CamSpaceOverlay").innerHTML = "";
		$(".installation-arrow").fadeOut(1000);
		$(".installation-cody").fadeOut(500);
	}
	else
		setTimeout ( "CheckIEInstalled()", 500 );
}

function logPageview(url,camspace_version,theme_url, game_url,publisher_id)
{
	var completeurl = "http://developers.camspace.com/pageview/log?browser="
	+escape(navigator.platform.toLowerCase())+"&url="+escape(url)+"&camspace_version="
	+escape(camspace_version)+"&theme_url="+escape(theme_url)
	+"&game_url="+escape(game_url)+"&referrer="+escape(document.referrer)
	+"&publisher_id="+escape(publisher_id);
//	alert(completeurl);
	return completeurl;
}

function includejQuery()
{
  	var s = document.getElementsByTagName('script')[0];
      var jq = document.createElement('script'); jq.type = 'text/javascript';jq.async = false;
    jq.src = PluginImagesURL+'jquery-1.6.2.min.js';
     s.parentNode.insertBefore(jq, s);
  
   
	 jq = document.createElement('script'); jq.type = 'text/javascript';jq.async = false;
    jq.src = PluginImagesURL+'jquery.effects.core.js';
     s.parentNode.insertBefore(jq, s);
	
	jq = document.createElement('script'); jq.type = 'text/javascript';jq.async = false;
    jq.src = PluginImagesURL+'jquery.effects.bounce.js';
     s.parentNode.insertBefore(jq, s);
}

function createSWFCode(movie,width,height) 
{
return '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'"> \
              <param name="movie" value="'+movie+'"/> \
              <param name="quality" value="high"/> \
			  <param name="allowScriptAccess" value="always" />\
			  <param name="allowNetworking" value="all" />\
              <param name="wmode" value="transparent"/> \
              <embed src="'+movie+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"/> 			  \
            </object> ';
}


function get_embed_html()
{
var code = 
	'<script language="JavaScript" src="http://www.camspace.com/public/js/1embed_camspace.js">'
	+'<'+'/script>'
		+'<div id="CamSpaceDiv"></div>'
	+'<script language="JavaScript">';
	if (AdultMode == true)
		code = code+'AdultMode = true;'
	else
		code = code+'AdultMode = false;';
	
		code = code+'	camspaceThemeID = '+camspaceThemeID+';camspacePublisherID = '+camspacePublisherID
		+';document.getElementById("CamSpaceDiv").innerHTML = CamSpaceCode('+CamSpaceWidth+', '+CamSpaceHeight+', "'
		+ CamSpaceGameURL +'", "' + defaultTheme +'","");'
	+'<'+'/script>';

	return code;
}
embedShown  = false;
function DoEmbed()
{
if (embedShown==true)
{
	document.getElementById("embed_div").innerHTML = '';
	embedShown = false;
}
else
{
	embedShown = true;
	document.getElementById("embed_div").innerHTML = 
	'<h3>Copy Code & Embed in your website!</h3><br><textarea id="htmlcode" rows="5" cols="70" style="font-size:70%;width:520px;height:50px" onclick="this.select()" ></textarea>';
	document.getElementById("htmlcode").value = get_embed_html();
	}
	
}

var inanim=false;
var over = false;
function on_no_hover()
{
if (over == false) return;
if (inanim==true) return;
inanim=true;
over=false;
	$(".play_button2").
animate({
    opacity: 1.00,
    left: '+=10',
   // top: '+=10',
	height: '-=20',
	width: '-=20'
    //height: 'toggle'
  }, 200, function() {
    // Animation complete.
	inanim=false;
  });
}
function on_hover()
{
if (over == true) return;
if (inanim==true) return;
inanim=true;
over=true;
				$(".play_button2").
animate({
    opacity: 1.0,
    left: '-=10',
   // top: '-=10',
	height: '+=20',
	width: '+=20'
    //height: 'toggle'
  }, 200, function() {
    // Animation complete.
	inanim=false;
  });
	//		 effect("bounce", { times:50, direction:"down", distance:10 }, 300);
}

function CamSpaceCode(width,height,gameurl,themeurl,prerollurl,socket,camspacevars)
{

__width = width;
__height = height;
__gameurl = gameurl;
__themeurl = themeurl;
__prerollurl = prerollurl;
__socket = socket;
__camspacevars = camspacevars;

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4070405-7']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

	 
	 
	 
	 if (detectCamSpacePresence() || CSSkipLandingPage)
		return CamSpaceCode2(__width, __height, __gameurl, __themeurl,__prerollurl,__socket,__camspacevars);
	 
	 
setTimeout ( "doit()", 22000 );


	 var s = '<div onclick="doit()" style="width: '+width+'px;	height:'+height+'px;'+
'	margin: 0px 0px;	position:relative; '+
//'background-image:url('+PluginImagesURL+'blue_bg2.png);'+
//'	background-repeat:no-repeat;background-size:100% 100%;'+

'" id="before_user_confirms">'+
'<img  onclick="doit()" style="width:'+width+'px;	height:'+height+'px;	" src="'+PluginImagesURL+'blue_bg2.png"/>' + 
'<div onclick="doit()" style="z-index:4; position:absolute;	top:'+width*0.03+'px;	left:'+width*0.15+'px;" >'+createSWFCode(PluginImagesURL+'ConsolePics.swf',width*0.7,2*width/4)+'</div>'+

'<div onclick="doit()" style="z-index:5; position:absolute; width:'+width*0.6+'px;	height:'+width*0.2+'px;		top:'+0.003*width+'px;	left:'+0.003*width+'px;" ><img style="width:'+width*0.6+'px;	height:'+width*0.2+'px;	" src="'+PluginImagesURL+'nowebcam_strip.png"/></div>';



if (is_ie())
{
includejQuery();
s+='<div class="play_button2"  onmouseover="on_hover()" onmouseout="on_no_hover()" onclick="doit()" style="z-index:4; position:absolute;	top:'+0.7*height+'px;	left:'+width*0.36+'px; width:'+0.28*width+'px;	height:'+0.25*height+'px;	" >'+'<img width=100% src="'+PluginImagesURL+'install_plugin5.png"/>'+'</div>';
}
//s+='<div id="play_button2"  onclick="alert(222);doit()" style="z-index:4; position:absolute;	top:'+0.7*height+'px;	left:'+width*0.36+'px;" >'+createSWFCode(PluginImagesURL+'play_button2.swf',width*0.28,width/4)+'</div>';
else
{
s+='<div id="play_button2"  onmouseover="enlarge()" onclick="alert(222);doit()" style="z-index:4; position:absolute;	top:'+0.7*height+'px;	left:'+width*0.36+'px;" >'+createSWFCode(PluginImagesURL+'play_button2.swf',width*0.28,width/4)+'</div>'
+'<div onclick="doit()" style="z-index:6; position:absolute;	width:800px; height:600px; top:0px;	left:0px;" ></div>';
}
			  

s+=

'<div onclick="doit()" style="z-index:1; position:absolute;	width:800px; height:600px; top:0px;	left:0px;" ></div>'+
'</div>';
return s;
}
function CamSpaceCode2(width, height, gameurl, themeurl,prerollurl,socket,camspacevars) 
{
  
 SetCamSpaceLanguage(defaultLang,width); 

 CamSpaceWidth = width;
 CamSpaceHeight = height;
 CamSpaceGameURL = gameurl;
 
 
 if (camspacePublisherID==2 || camspacePublisherID==7)
 {
           camspaceThemeID = 5;
 }
 
  			
 var themeurl = defaultTheme;
 var prerollurl = defaultPreroll;
var PublisherID = camspacePublisherID;
var ThemeID = camspaceThemeID;

	if (ThemeID==0)
	{
		if (AdultMode==true)
			ThemeID = 5;
		else
			ThemeID = 3;
	}

if (ThemeOverride!=null) 
	themeurl = ThemeOverride;
if (CSInstallPageOverride!=null)
	PluginImageBackground=CSInstallPageOverride;
	



	var AnimationHeight = height * 0.5;
	AnimationCode = createSWFCode(PluginAnimation,width,AnimationHeight);
	var codypointing = createSWFCode(CodyPointLeft,250,300);
	var codyhello = createSWFCode(CodySayHello,250,300);



 OptionalHTML = "";
	var TableStart = 
			'<table cellpadding="0" cellspacing="0" border="0">\
		<tr valign="top">\
		<td>';

	var TableEnd = 
		'</td>\
		</tr>\
		<tr>\
		<td><div id="CamSpaceFeedbackDiv" ></div>\
		</td>\
		</tr>\
		</table>';
		


var DesktopShortcutFlags=0;
if (CSCreateDesktopLinkSelf==true) DesktopShortcutFlags+=1;
if (CSCreateDesktopLinkCamSpace==true) DesktopShortcutFlags+=2;		
		
				
		
if (!socket)
	socket = "CreateDesktopShortcuts:"+DesktopShortcutFlags;

if (!camspacevars)
	camspacevars = "EmptyCamSpaceVars";

	if (FullMenuFilename)
		camspacevars = camspacevars+";menu_url:"+PluginImagesURL+FullMenuFilename;
	
	var s = '';
	var platform = navigator.platform.toLowerCase();
	if (platform.indexOf('win32')<0)
	{
		s = '<font size="3" color="red">'+CodySupportedOnWindows+'</font>';
		CamSpaceSupportedOnSystem = false;
	}
	else
	{
		if (is_ie())
		{//if ie, no version check / installation check. just run activeX. will install automatically once user approves.
			InstallInstuctionsCode = "<img style=\"width: "+width+"px; height: "+AnimationHeight+"px; border:none\" src=\""+PluginImageIELayer+"\" />";

			s = 
			'<div id="CamSpaceDivObj" style="position:relative;z-index:4;   left: 0px;    width: '+width+'px;height: '+height+'px;background-color: #999;color: inherit;margin-left: 0px;margin-top: 0px;"> <OBJECT style="position:relative;z-index:4;" ID="CamSpaceOBJ" CLASSID="CLSID:79DA2FED-7618-4a84-8E79-35FDC3CA61B5" CODEBASE="'+PluginDownloadURL+'CamSpaceActiveX'+ext+'.cab#version='+ActiveXVersion+'"\
			 WIDTH="'+width+'" HEIGHT="'+height+'">\
			<PARAM NAME="TempCode" Value="'+TempCode+'">\
			 <PARAM NAME="DispMode" Value="0">\
			 <PARAM NAME="GameURL" Value="'+gameurl+'">\
			 <PARAM NAME="ThemeURL" Value="'+themeurl+'">\
			 <PARAM NAME="FakeSocket" Value="'+socket+'">\
			 <PARAM NAME="PrerollURL" Value="'+prerollurl+'">\
			 <PARAM NAME="CamSpaceVars" Value="'+camspacevars+'">\
			 <PARAM NAME="PublisherID" Value="'+PublisherID+'">\
			 <PARAM NAME="ThemeID" Value="'+ThemeID+'">\
			</OBJECT> </div>';
			if (!detectCamSpacePresence())
			{
				includejQuery();
				if (AdultMode == false)
				{
					setupSound();
					playSound(IntroSound);
				}
				var offsetY = -height;
				if (( navigator.userAgent.toLowerCase().indexOf( "msie 6" ) != -1 ) || ( navigator.userAgent.toLowerCase().indexOf( "msie 7" ) != -1 ) || ( navigator.userAgent.toLowerCase().indexOf( "msie 8" ) != -1 ))
				{
					PluginImageIE = PluginImageIE7;
				}
				PluginImageIE = PluginImageBackground;
		//		else
					//offsetY = 0;
				s = s+'<div id="CamSpaceOverlay" style="position:relative;z-index:4;   left: 0px;    top: '+offsetY+'px;height: '+0+'px;background-color: #999;color: inherit;margin-left: 0px;margin-top: 0px;">'
				+'<img style="border:none;" width="'+width+'" height="'+height+'" src="'+PluginImageIE+'"/>'
			+'</div>';
									s = s+'<div id="CamSpaceOverlayInstructions" style="position:relative;z-index:4;   left: 0px;    top: -'+AnimationHeight+'px;height: '+0+'px;background-color: #999;color: inherit;margin-left: 0px;margin-top: 0px;">';
				if (doFlashIntro) 
				{
					s=s+AnimationCode;
				}
				s=s+'</div>';
/*				if ( navigator.userAgent.toLowerCase().indexOf( "msie 9" ) == -1 )
				{//not IE9
					OptionalHTML ='<img id="BouncingArrow" alt="Arrow" class="installation-arrow" style="opacity: 0.75;position: fixed; top: 0px; '+'left'+': 120px; display: none;z-index:10000;" src="'+PluginImagesURL+'UpArrowBlue.png" />'+
					'<div class="installation-cody" style="position: fixed; top: -60px; '+'left'+': 240px; display: none;z-index:10000;" >'+codypointing+'</div>';
				}*/

						
				//	alert(s);
				
/*				//finish this!
				if ( navigator.userAgent.toLowerCase().indexOf( "msie 9" ) != -1 )
				s = s+'<div id="CamSpaceOverlayArrow" style="position:absolute;z-index:2;   left: 0px;    top: '+0+'px;height: "+0+"px;background-color: #999;color: inherit;margin-left: 0px;margin-top: 0px;\">\
				<img style="border:none" width="'+40+'" height="'+148+'" src="'+PluginImageIE9+'"/>\
				</div>';*/

				setTimeout ( "CheckIEInstalled()", 1000 );
				CamSpaceVersion = CamSpaceVersion + " no go";
			}
			else
				CamSpaceVersion = CamSpaceVersion + " running";


		}//IE
		else
		{
			if (navigator.appName == "Netscape")
			{
				// detection for Netscape
				if (detectCamSpacePresence())
				{
//							PLUGINSPAGE="XPI_Install.htm"
							s = '<embed \
							id="CamSpaceOBJ"\
							TYPE="application/x-camspace-file"\
							ALIGN="baseline" BORDER="0"\
							WIDTH="'+width+'" HEIGHT="'+height+'" \
							ThemeURL="'+themeurl+'"\
							FakeSocket="'+socket+'"\
							GameURL="'+gameurl+'"\
							PrerollURL="'+prerollurl+'"\
							PublisherID="'+PublisherID+'"\
							ThemeID="'+ThemeID+'"\
							DispMode="0"\
							TempCode="'+TempCode+'"\
							CamSpaceVars="'+camspacevars+'"\
					</embed>';
					CamSpaceVersion = CamSpaceVersion + " running";
				}
				else
				{
					includejQuery();
					if (AdultMode == false)
					{
						setupSound();
						playSound(IntroSound);
					}
		//			alert("1");

					var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
					if (is_chrome) 
					{//chrome
					InstallInstuctionsCode = "<img style=\"width: "+width+"px; height: "+AnimationHeight+"px; border:none\" src=\""+PluginImageChromeLayer+"\" />";

					//s = "<META HTTP-EQUIV="Refresh" CONTENT=\"3;URL="+PluginDownloadURL+"ChromePlugin.crx\">";
						s = "<a style=\"font-size:10pt;font-weight:bold;\"\
						href=\""+PluginDownloadURL+"ChromePlugin"+ext+".crx\"\
						iconURL=\"http://www.camspace.com/public/images/Application.png\"\
						type= \"application/x-crxinstall\"\
						onclick=\"return install(event);\">\
						<img style=\"width: "+width+"px; height: "+height+"px; border:none\" src=\""+PluginImageBackground+"\" />\
						</a>";
						//PluginImageChrome
						s = s+'<div id="CamSpaceOverlayInstructions" style="position:relative;z-index:4;   left: 0px;    top: -'+AnimationHeight+'px;height: '+0+'px;background-color: #999;color: inherit;margin-left: 0px;margin-top: 0px;">';
						if (doFlashIntro) 
						{
							s=s+AnimationCode;
						}
						s=s+'</div>';

//				s=s+'<br><br>';

						var lang = navigator.language;
						if (lang==null) lang = navigator.browserLanguage;
						if (lang==null) lang = defaultLang;
						var dir='left';
						var codyPos = 240;
						if (lang=='he') 
						{
							dir = 'right';
							codyPos = 0;
						}
						

						OptionalHTML ='<a href="'+PluginDownloadURL+'ChromePlugin'+ext+'.crx"><img alt="Arrow" class="installation-arrow" style="opacity: 0.75;position: fixed; bottom: 0px; '+dir+': 120px; display: none;z-index:10000;" src="'+PluginImagesURL+'DownArrowBlue.png" /></a>'+
						'<div class="installation-cody" style="position: fixed; bottom: -60px; '+dir+': '+codyPos+'px; display: none;z-index:10000;" ><a href="'+PluginDownloadURL+'ChromePlugin'+ext+'.crx">'+codypointing+'</a></div>';
						
						//<br><form><input type=button value=\" Refresh after installing \" onClick=\"history.go()\"></form></div></div><br><br><br><br>";
						setTimeout ( "StartDownload()", 2000 );
						setTimeout ( "CheckChromeInstalled()", 3000 );
					}//chrome
					else
					{ //firefox

						{
							InstallInstuctionsCode = "<img style=\"width: "+width+"px; height: "+AnimationHeight+"px; border:none\" src=\""+PluginImageFFLayer+"\" />";

							s = "<a style=\"font-size:10pt;font-weight:bold;\"\
							href=\""+XPIFile+"\"\
							iconURL=\"http://www.camspace.com/public/images/Application.png\"\
							hash=\""+PluginFFShaHash+"\"\
							type= \"application/x-xpinstall\"\
							onclick=\"return install(event);\">\
							<img style=\"width: "+width+"px; height: "+height+"px; border:none\" src=\""+
							PluginImageBackground
							//PluginImageFF
							+"\" />\
							</a>";
							if (CSIncludeInstallInstructions==true)
							{
								s = s+'<div id="CamSpaceOverlayInstructions" style="position:relative;z-index:4;   left: 0px;    top: -'+AnimationHeight+'px;height: '+0+'px;background-color: #999;color: inherit;margin-left: 0px;margin-top: 0px;">';
								s = s+InstallInstuctionsCode;
//						if (doFlashIntro) 
	//					{
		//					s=s+AnimationCode;
			//			}
							s=s+'</div>';
						}
						
							if (AdultMode == false)
								OptionalHTML =	'<div class="hello-cody" style="position: fixed; bottom: -60px; right: 240px; ;z-index:10000;" >'+codyhello+'</div>';


							//setTimeout ( "StartDownload()", 1000 );
							setTimeout("install(null)",1000);
							setTimeout ( "CheckFFInstalled()", 3000 );
						}
					}//firefox
					CamSpaceVersion = CamSpaceVersion + " no go";
				}
			}//netscape
		}//not ie
	}//windows
	setTimeout ( "SetOnbeforeunload()", 3000 );
	setTimeout ( "CheckInstructions()",1000);

	var url='<img width="1px" height="1px" src="'+logPageview(window.location,CamSpaceVersion,themeurl, gameurl,PublisherID)+'" />';
	return url+TableStart+s+TableEnd+OptionalHTML;
}
	
function CamSpaceFlashCode(flashwidth, flashheight, flashurl, csw, csh, camspaceurl, themeurl,prerollurl) 
{ 
		if (is_ie())
	{
var s = 
		'<table cellpadding="0" cellspacing="0" border="0">\
		<tr valign="top">\
		<td>\
		<embed id="CamSpaceFlash"\
			src="'+flashurl+'"\
			width="'+flashwidth+'"\
			height="'+flashheight+'"\
			allowscriptaccess="always"\
			allowfullscreen="false"\
			flashvars="quality=high"/>\
		</td>\
		<td>\
		<OBJECT ID="CamSpaceOBJ" CLASSID="CLSID:79DA2FED-7618-4a84-8E79-35FDC3CA61B5" CODEBASE="http://www.camspace.com/public/CamSpaceActiveX.cab#version='+ActiveXVersion+'"\
		WIDTH="'+csw+'" HEIGHT="'+csh+'">\
		<PARAM NAME="TempCode" Value="'+TempCode+'">\
		<PARAM NAME="DispMode" Value="0">\
		<PARAM NAME="GameURL" Value="'+camspaceurl+'">\
		<PARAM NAME="ThemeURL" Value="'+themeurl+'">\
		<PARAM NAME="PrerollURL" Value="'+prerollurl+'">\
		<PARAM NAME="HaveExtComponent" value="1">\
		<PARAM NAME="ExtComponentWidth" value="'+flashwidth+'">\
		<PARAM NAME="ExtComponentHeight" value="'+flashheight+'">\
		</OBJECT>\
		</td>\
		</tr>\
		</table>';
		return s;
		}
				var s = 
				'<table cellpadding="0" cellspacing="0" border="0">\
				<tr valign="top">\
				<td>\
				<object \
                id="CamSpaceOBJ"\
                TYPE="application/x-camspace-file"\
                ALIGN="baseline" BORDER="0"\
				WIDTH="'+csw+'" HEIGHT="'+csh+'" \
				ThemeURL="'+themeurl+'"\
				GameURL="'+camspaceurl+'"\
				PrerollURL="'+prerollurl+'"\
				DispMode="0"\
				TempCode="'+TempCode+'"\
				HaveExtComponent" value="1"\
				ExtComponentWidth" value="'+flashwidth+'"\
				ExtComponentHeight" value="'+flashheight+'"\
        </object>';
		return s;
};
