var isIE  = false;
if (document.all) {
	 isIE = true;
}
// Added by Phrodo
var agt = navigator.userAgent.toLowerCase();
var isMac = (agt.indexOf("mac") != -1);
// END

// preload rollover img for meta navigation
if (document.images) { 
	var meta_home = new Image(); meta_home.src = "img/meta_home.gif";
	var meta_home_hi = new Image(); meta_home_hi.src = "img/meta_home_hi.gif";
	var meta_home_text = new Image(); meta_home_text.src = "img/meta_home_text.gif";
	var meta_tell_friend = new Image(); meta_tell_friend.src = "img/meta_tell_friend.gif";
	var meta_tell_friend_hi = new Image(); meta_tell_friend_hi.src = "img/meta_tell_friend_hi.gif";
	var meta_tell_friend_text = new Image(); meta_tell_friend_text.src = "img/meta_tell_friend_text.gif";
	var meta_sound = new Image(); meta_sound.src = "img/meta_sound.gif";
	var meta_sound_hi = new Image(); meta_sound_hi.src = "img/meta_sound_hi.gif";
	var meta_sound_text = new Image(); meta_sound_text.src = "img/meta_sound_text.gif";
	var meta_contact = new Image(); meta_contact.src = "img/meta_contact.gif";
	var meta_contact_hi = new Image(); meta_contact_hi.src = "img/meta_contact_hi.gif";
	var meta_contact_text = new Image(); meta_contact_text.src = "img/meta_contact_text.gif";
	var meta_about = new Image(); meta_about.src = "img/meta_about.gif";
	var meta_about_hi = new Image(); meta_about_hi.src = "img/meta_about_hi.gif";
	var meta_about_text = new Image(); meta_about_text.src = "img/meta_about_text.gif";
	var meta_text_off =  new Image(); meta_text_off.src = "/s.gif"
}

function hiMeta ( picName ) {
// show rollover and text
	picSrc = "meta_" + picName + "_hi";
	textSrc = "meta_" + picName + "_text";
	imgSwap(picName, picSrc); 
	imgSwap("metaText", textSrc); 
}

function loMeta ( picName ) {
// hide rollover and text
	picSrc = "meta_" + picName;
	textSrc = "meta_text_off";
	imgSwap(picName, picSrc); 
	imgSwap("metaText", textSrc); 
}

function imgSwap(picName, picSrc) {
  if (document.images)  {
		document.images[picName].src = eval(picSrc + ".src");
  }
}

function getUrlMainFrame ( url, setTopnaviFlag ) {
// load content into frame "main"
// this function is called from the flashnavigation
// url: targeturl relative to the root directory
// setTopNaviFlag: 1 if topNavi has to be reset
// extensions are added automatically
	var extension = ".html";
	if (url != "") {
	
		// check if devserver or filesystem-testversion
		if (location.href.indexOf("dev.argonauten")==-1 && location.href.indexOf("file")==-1) {
			// set suitable extension for dynamic pages
			if (url.indexOf("01_drinks") != -1 || (url.indexOf("03_products") != -1 && url.indexOf("03_products/products") == -1)) extension = ".php";
		}
		parent.frames["main"].location.href="/" + url + extension;
		top.setTopnavi = ( setTopnaviFlag == 1);
	}
}

function setFlashTopnavi ( id ) {
// select item id in the topnavigation flash movie (works only with IE)
	if (isIE && window.topnavi) {
		// topnavi is the id of the flashmovie
		window.topnavi.SetVariable("newItem", id);
	}
	else {
		// wait until flashnavi available
	 	setTimeout("parent.topnavi.setFlashTopnavi('" + id + "')", 1000);
	}
}

function toggleSound ( ) {
	// set value of global sound flag
	if (typeof top.soundOn != 'undefined') {
		top.soundOn = !top.soundOn;

		// set variable for ebentsounds within the flashmovies (works only in IE)
		if (isIE && !isMac) {	// && !isMac added by Phrodo
			value = (top.soundOn) ? 1 : 0;
			parent.main.setFlashVariable("soundOn", value);
			if (window.topnavi) {
				window.topnavi.SetVariable("soundOn", value);
			}
		}
		else {
			// netscape: reload content frame (exception: homepage)
			if (location.href.indexOf("home.php")==-1)	parent.main.location.href = parent.main.location.href;
		}
		
		// start and stop soundloops
		if (top.soundOn) {
			// play
			if (top.soundUrl != "") {
				// load soundfile
				parent.main.loadSoundLoop( );
			}
		}
		else {
			// sound off
			parent.left.location.href = "/00_home/grey.html";
			// right frame is only used by ritmo / cds
			parent.right.location.href = "/00_home/grey.html";
		}
	}
}

function checkMain( ) {
	// sets homepage in frame "main", if not already loaded 
	if (top.frames.length > 1 && top.frames[2].name == "main") {
		if (parent.frames["main"].location.href.indexOf("home.php")==-1) {
			parent.frames["main"].location.href= "/00_home/home.php";
		}
	}
}

function openBatshop( ) {
	// open BATshop popup
	if (top.batshopWin && !top.batshopWin.closed) {
		top.batshopWin.focus( );
	}
	else top.batshopWin=window.open("https://secure.bacardi.de/shop/shop.html","BATshop","toolbar=no,location=no,directories=no,status=yes,resizable=0,scrollbars=1,width=790,height=520");

	// zentrieren
	//var x = Math.round((screen.availWidth - 790) / 2);
	//var y = Math.round((screen.availHeight - 520) / 2);
	//top.batshopWin.moveTo(x, y);
}

function openBatclub( ) {
	// open BATclub popup
	if (top.batclubWin && !top.batclubWin.closed) {
		top.batclubWin.focus( );
	}
	else top.batclubWin=window.open("http://www.batclub.de/frameset_login.html","BATclub","toolbar=no,location=no,directories=no,status=no,resizable=0,scrollbars=1,width=800,height=520");
}

function openMetaPopup( url, width, height, scrollbars ) {
	// open popup for impressum, tell@friend, contact or terms and conditions
	if (!scrollbars) scrollbars = 0;
	
	if (top.popupWin && !top.popupWin.closed && top.popupWin.location.href.indexOf(url)!=-1) {
		top.popupWin.focus( );
	}
	else {
		if (top.popupWin && !top.popupWin.closed) top.popupWin.close( );
		top.popupWin=window.open(url,"popup","toolbar=no,location=no,directories=no,status=no,resizable=0,scrollbars=" + scrollbars + ",width=" + width + ",height=" + height);
	}
}

