$(document).ready(function(){
	var minFlashVersion = 9;
	var contentBox = document.getElementById("flashContent");
	var flashVersion = swfobject.getFlashPlayerVersion();
	var req = location.href.split("#");
   var $winMinHeight = '750';
   var $winHeight = '';
	if( parseInt($(window).height()) < $winMinHeight ) {
        $winHeight = $winMinHeight;
   } else {
        $winHeight = $(window).height();
   }
   
	// check for browser and correct flash width to avoid a horizontal scrollbar
	// to be done for mac, linux and for cases when no scroll bar is shown at all on large screens
	var horizontalCorrection = 16;
	if( $winHeight <= 750 ) {
		horizontalCorrection = 16;
	} else {
		horizontalCorrection = 0;
	}
	
	// show intro?
	var visited = readCookies('Concord');
	var showIntro = "?";
	//if( document.location.href.indexOf("?intro=1") > 0 ) {
	if( visited != "visited" || document.location.href.indexOf("?intro=1") > 0 ) {
		showIntro = "?intro=1&";
		var expiryDate = new Date();
		var inFiveDays = expiryDate.getTime() + (1 * 24 * 60 * 60 * 1000);
		expiryDate.setTime( inFiveDays );
		document.cookie = "Concord=visited; expires=" + expiryDate.toGMTString();
	}
	
   
   // Flash?
   if (flashVersion.major >= minFlashVersion )
   { 	
      var r = Array();
      var lang = '';
      var htmlLink = false;
      if( location.href.indexOf('#') == -1 ) {
         lang = location.href.match("\/[a-z].\/");
         r = location.href.split(lang);
         if( r[1].length > 0 ) {
            htmlLink = true;
         }
      } 
      // else {
      // 			if( location.href.match("id=([0-9]+)") > 0 ) {
      // 				r = location.href.match("id=([0-9]+)");
      // 			}
      // 		}
      
      if( htmlLink == true ) // html link?
      {
         // change this line in live version
         location.href = "http://www.concord.de"+lang+"#/"+r[1];
         //location.href = "/c6d3e1eba587564cf34aedad965a9016"+lang+"#/"+r[1];					
         return;
      }
      else
      {
         var baseUrlAr = location.href.split('#');
         
         // change this lines in live version
         var pagetreeUri = baseUrlAr[0] + 'xml/pagetree.xml';

         // change this line in live version
//			swfobject.embedSWF("/flash/main.swf?pageID=" + location.href.split("/")[4], "flashContent", "100%", "100%", "9.0.0");
         //swfobject.embedSWF("/c6d3e1eba587564cf34aedad965a9016/flash/main.swf"+showIntro+"tree="+pagetreeUri+"&pageID=" + location.href.split("/")[4], "flashContent", "100%", "100%", "9.0.0", '', '', {wmode:'opaque'});
         swfobject.embedSWF("/flash/main.swf"+showIntro+"tree="+pagetreeUri+"&pageID=" + location.href.split("/")[4], "flashContent", "100%", "100%", "9.0.0", '', '', {wmode:'opaque'});
         //swfobject.embedSWF("/flash/main.swf?tree="+pagetreeUri+"&pageID=" + location.href.split("/")[4], "flashContent", "100%", "100%", "9.0.0", '', '', {wmode:'opaque'});
         //swfobject.embedSWF("/c6d3e1eba587564cf34aedad965a9016/flash/main.swf?tree=http://www.concord.de/c6d3e1eba587564cf34aedad965a9016/fileadmin/xml/pagetree_de.xml&pageID=" + location.href.split("/")[4], "flashContent", "100%", "100%", "9.0.0", '', '', {wmode:'opaque'});
//			document.getElementById("flashContent").style.display = "";
         document.getElementById("flashContent").style.display = "block";
         document.getElementById("header").style.display = "none";
         document.getElementById("navigator").style.display = "none";
         document.getElementById("main").style.display = "none";
         document.getElementById("player").style.display = "none";
         document.getElementById("footer").style.display = "none";	
         // added mkeck; 25-5-2009
         $('#flashContent').attr('width', $(window).width()-horizontalCorrection).attr('height', $winHeight).css('display', 'block');
       //$('#flashContent').attr('width', $(window).width()).attr('height', $(window).height()).css('display', 'block');
      }
   }
   // HTML?
   else {
      
   }
   
});

function readCookies(n)
{
 a = document.cookie;
 res = '';
 while(a != '')
 {
  cookiename = a.substring(0,a.search('='));
  cookiewert = a.substring(a.search('=')+1,a.search(';'));
  
  if(cookiewert == '')
  {cookiewert = a.substring(a.search('=')+1,a.length);}

  if(n == cookiename){res = cookiewert; return (res);}

  i = a.search(';')+1;
  if(i == 0){i = a.length}
  a = a.substring(i,a.length);
 }
 return(res)
}