DocumentRoot = (typeof(DocumentRoot)=="undefined" || DocumentRoot == "/") ? "" : DocumentRoot; //Base for paths

/*----------------------------------
STORE CHOOSER OVERLAY. 
Handles overlay, cookies and redirect
-----------------------------------*/

var ThisStore= "us";

var Stores = [
{store: "eu", url: "http://eu.eroscillator.com"}, 
{store: "de", url: "http://de.eroscillator.com"}, 
{store: "us", url: "http://www.eroscillator.com"}
];

var OverlayHTML = "\
<h1>Please Choose your store</h1>\
<div class='Left'>\
	<p><a href=javascript:SetStore('us')><img src='" + DocumentRoot + "/images/global/store_chooser/north_america_lg.gif'></a></p>\
	<p><strong><a href=javascript:SetStore('us')>North American store</a></strong><br />\
	For users with 110v Electricity<br />\
	<span class='Small'>(USA, Canada, Japan, Columbia, Mexico and Puerto Rico)</span>\
	</p>\
</div>\
<div class='Right'>\
	<p><a href=javascript:SetStore('eu')><img src='" + DocumentRoot + "/images/global/store_chooser/europe_lg.gif'></a></p>\
	<p><strong><a href=javascript:SetStore('eu')>European store</a></strong><br />\
		For users with 220v Electricity <br />\
		<span class='Small'>\
		(everyone else)<br />\
		<img src='" + DocumentRoot + "/images/global/store_chooser/germany_sm.gif' style='margin: 3px 3px -3px 0;'>\
		<a href=javascript:SetStore('de')>Auch verf&uuml;gbar auf Deutsch</a></span>\
	</p>\
</div>\
<div class='Clear'>\
";

function StoreChooser (){
	if (ShowStoreChooserOverlay == true) { //ShowStoreChooserOverlay is set by the server
		DisplayOverlay ();	
	}
}

function Redirect (theStore){
	for (var i=0;i< Stores.length; i++) {
		if (Stores[i].store == theStore){
			location.href= Stores[i].url + location.pathname + "?st=" + theStore;
		}
	}	
}


function SetStore (theStore){
	SetStoreCookie(theStore);
	if (ThisStore == theStore) {
		HideOverlay ();
	}
	else {
		Redirect (theStore);
	}
}

function SetStoreCookie(theStore) {
	var date = new Date();
	date.setTime(date.getTime()+(365*24*60*60*1000));
	document.cookie = "st=" + theStore + "; expires=" + date.toGMTString() + "; path=/";
}

function DisplayOverlay (){
	document.getElementById("StoreOverlayBg").style.display = "block";
	document.getElementById("StoreOverlay").innerHTML = OverlayHTML;
	document.getElementById("StoreOverlay").style.display = "block";
	PositionLayer ()
	document.documentElement.style.overflow = "hidden";
	window.onresize = PositionLayer;
}

function PositionLayer (){
	theOverlay = document.getElementById("StoreOverlay");
	theOverlay.style.left = (document.body.clientWidth / 2) - (theOverlay.clientWidth / 2) + 'px';
}

function HideOverlay (){
	document.getElementById("StoreOverlay").style.display = "none";
	document.getElementById("StoreOverlayBg").style.display = "none";
	document.documentElement.style.overflow = "auto";
	window.onresize = "";
}

/*----------------------------------
Science of pleasure. 
Avoid the dreaded 'click to activate'
-----------------------------------*/

function ScienceOfPleasureFlash (){
document.write ('\
<OBJECT id="science_of_pleasure" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"\
height="315" width="491" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" VIEWASTEXT>\
<PARAM NAME="_cx" VALUE="12991">\
<PARAM NAME="_cy" VALUE="8334">\
<PARAM NAME="FlashVars" VALUE="">\
<PARAM NAME="Movie" VALUE="' + DocumentRoot + '/images/science_of_pleasure/science_of_pleasure.swf?NoTracking=true">\
<PARAM NAME="Src" VALUE="' + DocumentRoot + '/images/science_of_pleasure/science_of_pleasure.swf?NoTracking=true">\
<PARAM NAME="WMode" VALUE="opaque">\
<PARAM NAME="Play" VALUE="-1">\
<PARAM NAME="Loop" VALUE="-1">\
<PARAM NAME="Quality" VALUE="High">\
<PARAM NAME="SAlign" VALUE="">\
<PARAM NAME="Menu" VALUE="-1">\
<PARAM NAME="Base" VALUE=".">\
<PARAM NAME="AllowScriptAccess" VALUE="sameDomain">\
<PARAM NAME="Scale" VALUE="ShowAll">\
<PARAM NAME="DeviceFont" VALUE="0">\
<PARAM NAME="EmbedMovie" VALUE="0">\
<PARAM NAME="BGColor" VALUE="FFFFFF">\
<PARAM NAME="SWRemote" VALUE="">\
<PARAM NAME="MovieData" VALUE="">\
<PARAM NAME="SeamlessTabbing" VALUE="1">\
<PARAM NAME="Profile" VALUE="0">\
<PARAM NAME="ProfileAddress" VALUE="">\
<PARAM NAME="ProfilePort" VALUE="0">\
<embed src="' + DocumentRoot + '/images/science_of_pleasure/science_of_pleasure.swf?NoTracking=true" quality="high" bgcolor="#ffffff" \
	base="." width="491" height="315" name="science_of_pleasure" align="middle" allowScriptAccess="sameDomain"\
	type="application/x-shockwave-flash" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" />\
</OBJECT>\
');
}