/**
 * Variablen
 */
var FlashHeight = 1440;
var ObjFlash;
   
/**
 * wird von Flash aufgerufen bei Ã¯Â¿Â½nderung der Hoehe des Flash Objektes
 * speichert die aktuelle Flash Hoehe in Pixel
 */
function setFlashHeight(value)
{
  if(useragent.match("Macintosh") && useragent.match("AppleWebKit/"))
  {
    FlashHeight = "2000";
    if(typeof(console) != "undefined" && console) console.debug("setFlashHeight() has not been executed due to mac and safari usage");
    return;
  }
  
  yHeight = (typeof(document.body.clientHeight)            !== "undefined" ? document.body.clientHeight            : 0); 
  yHeight = (typeof(document.documentElement.clientHeight) !== "undefined" ? document.documentElement.clientHeight : yHeight); 
  yHeight = (typeof(window.innerHeight)                    !== "undefined" ? window.innerHeight                    : yHeight); 
  
  if(parseInt(yHeight) > parseInt(value))
  {
    document.getElementById('main').style.height = yHeight + 'px';
  }
   else
   {
    document.getElementById('main').style.height = value + 'px';
   }
  
  if(typeof(console) != "undefined" && console) console.debug("setFlashHeight(): " + value);
}

/**
 * setzt die Hoehe des Flashelementes
 */
function SetFlashHeighElement()
{
  if (typeof document.body.scrollHeight != "undefined" && document.body.scrollHeight > FlashHeight)
    document.getElementById("main").style.height = "100%";
  else
    document.getElementById("main").style.height = FlashHeight + "px";
  if(typeof(console) != "undefined" && console) console.debug("setFlashHeightElement()");
}

/**
 * Aendert die Hoehe des Flash Objektes
 */ 
function WindowResize()
{
  SetFlashHeighElement();
  if(typeof(console) != "undefined" && console) console.debug("WindowResize()");
}


function Scroll()
{
  var pos1 = 0, pos2 = 0;
  
  if (typeof document.body.scrollTop != "undefined")
    pos1 = document.body.scrollTop;
  else if (typeof document.documentElement.scrollTop != "undefined")
    pos1 = document.documentElement.scrollTop;
  else if (typeof window.pageYOffset != "undefined")
    pos1 = window.pageYOffset;
  
  if (typeof document.body.clientHeight != "undefined")
    pos2 = document.body.clientHeight;
  else if (typeof document.documentElement.clientHeight != "undefined")
    pos2 = document.documentElement.clientHeight;
  else if (typeof window.innerHeight != "undefined")
    pos2 = window.innerHeight;
    
  if (ObjFlash && typeof ObjFlash.setDisplay != "undefined")
  {                                   
    ObjFlash.setDisplay(pos1, pos2);
  }
  
  if(typeof(console) != "undefined" && console) console.debug("Scroll()");
}

function NachOben () {
  var y = 0;
  if (window.pageYOffset) {
    y = window.pageYOffset;
  } else if (document.body && document.body.scrollTop) {
    y = document.body.scrollTop;
  }
  if (y > 0) {
    window.scrollBy(0, -10);
    setTimeout("NachOben()", 10);
  }
  if(typeof(console) != "undefined" && console) console.debug("NachOben()");
}



function ScrollTop()
{
  NachOben();
  if(typeof(console) != "undefined" && console) console.debug("ScrollTop()");
}

/**
 * Aendert die Hoehe des Flash Objektes
 */ 
function LoadingDone()
{
  ObjFlash = swfobject.getObjectById("main");
  if(typeof(console) != "undefined" && console) console.debug("LoadingDone()");
}

function setDisplay()
{
  yScroll = (typeof(document.documentElement.scrollTop)    !== "undefined" ? document.documentElement.scrollTop    : 0);
  yScroll = (typeof(document.body.scrollTop)               !== "undefined" ? document.body.scrollTop               : yScroll);
  yScroll = (typeof(window.pageYOffset)                    !== "undefined" ? window.pageYOffset                    : yScroll);
  yHeight = (typeof(document.body.clientHeight)            !== "undefined" ? document.body.clientHeight            : 0); 
  yHeight = (typeof(document.documentElement.clientHeight) !== "undefined" ? document.documentElement.clientHeight : yHeight); 
  yHeight = (typeof(window.innerHeight)                    !== "undefined" ? window.innerHeight                    : yHeight); 

  if(typeof(ObjFlash) == "object" || typeof(ObjFlash) == "function")
  {
    ObjFlash.setDisplay(yScroll,yHeight);
  }
  if(typeof(console) != "undefined" && console) console.debug("setDisplay()");
}

/* window.onresize = WindowResize; */
window.onscroll = setDisplay;

function CampaignIFA2010(client_id)
{
  var f1 = window.open("/campaign/ifa2010/?client_id=" + client_id,"IFA2010","width=710,height=630,statusbar=no,toolbar=no,menubar=no,personalbar=no");
  f1.focus();
  if(typeof(console) != "undefined" && console) console.debug("CampaignIFA2010()");
}

function openCampaign(client_id)
{
  var f1 = window.open("/campaign/laufspiel/?client_id=" + client_id,"EP:Laufspiel","width=1000,height=550,statusbar=no,toolbar=no,menubar=no,personalbar=no");
  f1.focus();
  if(typeof(console) != "undefined" && console) console.debug("openCampaignLaufspiel()");
}

function facebook(isHome)
{
	if(document.location.href.match("language=fr"))
		languagestring = "?language=fr";
	else if(document.location.href.match("language=de"))
		languagestring = "?language=de";
	else if(document.location.href.match("language=it"))
		languagestring = "?language=it";
	else languagestring = "";

	url = document.location.href;
	
	if(typeof(isHome) == "number" && isHome == 1)
	{
		url = url.substring(0,url.search("/#") + 1) + "sharer.php?q=startseite";
		url = encodeURIComponent(url.replace(languagestring,"") + languagestring);
	}
	 else
	 {
	 	url = encodeURIComponent(url.replace("#/","sharer.php?q=").replace(languagestring,"") + languagestring);
	 }
	
	window.open("http://www.facebook.com/sharer.php?t=" + clientname.replace(/ /g,"+") + "&u=" + url, "Facebook", "width=800, height=410, location, status, scrollbars, resizable");
}

function openWindowAsPopup(windowWidth, windowHeight, windowURL)
{
	//alert(windowWidth + " " + windowHeight + " " + windowURL);
	fenster = window.open(windowURL, "EP", "width=" + windowWidth + ",height=" + windowHeight + ",status=no,scrollbars=no,resizable=no");
	fenster.focus();
}
