// JavaScript Document
// Version 27. Mai 2009

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
} 

//------------------------------
//-->LAYER FUNCTIONS
//------------------------------

function sidebarHeight() {
	var minHeight = 550;
	if( document.getElementById('mainContent') ) {
		nObj = document.getElementById('mainContent');
		defaultHeight = nObj.offsetHeight;
		if(document.defaultView) {
			//alert(document.defaultView.getComputedStyle(nObj,'').getPropertyValue('height'));
			defaultHeight = document.defaultView.getComputedStyle(nObj,'').getPropertyValue('height');
		}
		
		if (minHeight < parseInt(defaultHeight)) {
	
			document.getElementById('sidebar1').style.height = parseInt(defaultHeight) +40 +"px";
		}
		
		//Refresh
		document.getElementById('sidebar1').style.display = "block";
	} 	// end if (element exists?)
	
}
//------------------------------
//--> OPEN WINDOWS
//------------------------------
function openNews(url) {
	F = open("../includes/news/"+url,"News","width=520, height=450, left=20,top=20, toolbar=no, directories=no, status=no, menubar=0, scrollbars=yes,resizable=yes");
	F.focus();
}
function openFlyer(url) {
	F = open("/upload/flyer/"+url,"News","width=800, height=550, left=20,top=20, toolbar=no, directories=no, status=no, menubar=0, scrollbars=yes,resizable=yes");
	F.focus();
}  

function openGabenProfil(url) {
	window.open(url,"Gabenprofil","width=820, height=830, screenX=50,screenY=50, toolbar=no, directories=no, status=no, menubar=0, scrollbars=auto,resizable=yes");	
}


//------------------------------
//--> INSERT FLASH Movie
//------------------------------
function insertIframe(name, width, height) {
	var insertString = "<iframe src='"+ name +"' width='"+ width +"px' height='"+ height +"px' scrolling='no'></iframe>";	
	return insertString;
}
function insertFlash(name, width, height) {
	var insertString = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="360" height="264" id="2009_poland" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="' + name + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="' + name + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="2009_poland" align="middle" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_de" /></object>';
	
	var insertStringAlt = '<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + width + '" height="' + height + '"><param name="movie" value="' + name + '" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="6.0.65.0" /><!-- Dieses param-Tag fordert Benutzer von Flash Player 6.0 r65 und höher auf, die aktuelle Version von Flash Player herunterzuladen. Wenn Sie nicht wünschen, dass die Benutzer diese Aufforderung sehen, löschen Sie dieses Tag. --><param name="expressinstall" value="/includes/Scripts/expressInstall.swf" /><!-- Das nächste Objekt-Tag ist für Nicht-IE-Browser vorgesehen. Blenden Sie es daher mit IECC in IE aus. --><!--[if !IE]>--><object type="application/x-shockwave-flash" data="' + name + '" width="' + width + '" height="' + height + '"><!--<![endif]--><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="swfversion" value="6.0.65.0" /><param name="expressinstall" value="/includes/Scripts/expressInstall.swf" /><!-- Im Browser wird für Benutzer von Flash Player 6.0 und älteren Versionen der folgende alternative Inhalt angezeigt. --><div><h4>Für den Inhalt dieser Seite ist eine neuere Version von Adobe Flash Player erforderlich.</h4><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Adobe Flash Player herunterladen" width="112" height="33" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object>';
	
	return insertString;
}

//------------------------------
//--> DELETE MYSQL DATA
//------------------------------
function del_data(id, bezeichnung, url) {
	var message = "Wollen Sie diesen Datensatz "+bezeichnung+" wirklich löschen?";
	if(confirm(message)) {
  		ClosesWindow=false; //Variable so setzen, dass funktion nicht aufgerufen wird
		//document.form.submit();
		window.location.href = url + "?delete_id=" + id;
  	}
}

//------------------------------
//--> COOKIES
//------------------------------
function GetCookie(sName) {
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  } // end for

  // a cookie with the requested name does not exist
  return null;
}

function deleteCookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function Set_Cookie( name, value, expires, path, domain, secure ) {
	
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) ); 
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


function setScrollCookie(obj){
	if(obj) {
		if(obj.scrollTop) {
		var scrollNum = obj.scrollTop;
		var ablauf = new Date(); var sechs_monate = ablauf.getTime() + (150 * 24 * 60 * 60 * 1000);
			ablauf.setTime(sechs_monate);
		document.cookie = 'scrollNum='+scrollNum+'; expires=' + ablauf.toGMTString();
		}
	} // end if
}

