/*
Contentpapst wurde von der sandoba.de medien agentur (www.sandoba.de) aus Berlin entworfen und unterliegt dem Urheberrecht. Jedwede Änderung des Codes außerhalb der Lizenzrechte ist nicht erlaubt. Anfragen bitte an "contact@sandoba.de".

Website: www.sandoba.de
© sandoba.de medien agentur, 2002-2006
*/


function changePicture( _sFile, _sCaption, _Id ) {

	if ( _Id == undefined ) {
		_Id = '' ;
	}

	if ( document.getElementById( 'picture' + _Id ) ) {
		var _oImage = new Image() ;
		var _sParameter = '' ;
		
//		_oImage.src = _sFile ;
//
//		var _iNewHeight = 180 / ( _oImage.width / _oImage.height ) ;
//		var _iNewWidth  = 120 / ( _oImage.height / _oImage.width ) ;
//		 	
//		if ( _oImage.width > 180 || _oImage.height > 120 ) {
//			if ( _oImage.width > _oImage.height && _iNewHeight < 120 ) {
				_sParameter = '&width=500' ;
//			}
//			else {
//				_sParameter = '&height=120' ;
//			}  
//		}
	
		document.getElementById( 'picture' + _Id ).innerHTML = '<a href="javascript:openWndPicture(\'' + _sFile + '\') ;"><img alt="" border="0" name="image' + _Id + '" src="img.resize.php?path=' + _sFile + _sParameter + '" title="" /></a>' ;
		document.getElementById( 'pictureZoom' + _Id ).href = 'javascript:openWndPicture(\'' + _sFile + '\') ;' ;
	}
	
	if ( document.getElementById( 'caption' + _Id ) ) {
		document.getElementById( 'caption' + _Id ).innerHTML = _sCaption.length == 0 ? '&nbsp;<br/>' : _sCaption ;
	}
}

function openWndPicture( _sFile ) {
	
	var _oImage = new Image() ;
	
	var _iSize = 800 ;
	
	_oImage.src = _sFile ;
	
	if ( _oImage.width > _oImage.height ) {
		var _sParameter = '%26width=' + _iSize ;
	
		var _iNewHeight  = Math.floor( _iSize / ( _oImage.width / _oImage.height ) ) ;		
		var _iNewWidth = _iSize ;

		var left = ( screen.availWidth / 2 ) - ( _iSize / 2 ) ;
		var top  = ( screen.availHeight / 2 ) - ( _iNewHeight / 2 ) ;
	}
	else if ( _oImage.width < _oImage.height ) {
		var _sParameter = '%26height=' + _iSize ;
	
		var _iNewWidth  = Math.floor( _iSize / ( _oImage.height / _oImage.width ) ) ;
		var _iNewHeight = _iSize ;

		var left = ( screen.availWidth / 2 ) - ( _iNewWidth / 2 ) ;
		var top  = ( screen.availHeight / 2 ) - ( _iSize / 2 ) ;
	}
	else if ( _oImage.width == 0 && _oImage.height == 0 ) {
		loadPicture = window.setTimeout( "openWndPicture('" + _sFile + "')", 500 ) ;
	}
	else {
		var _sParameter = '%26height=' + _iSize + '%26width=' + _iSize ;
	
		var _iNewWidth  = _iSize ;
		var _iNewHeight = _iSize ;

		var left = ( screen.availWidth / 2 ) - ( _iNewWidth / 2 ) ;
		var top  = ( screen.availHeight / 2 ) - ( _iNewHeight / 2 ) ;		
	}
	
	if ( _sParameter.length > 0 ) {
		_wndPicture = window.open( 'index.php?file=fast_gallery&show=img.resize.php%3Fpath=' + _sFile + _sParameter + '&clean=yes', 'openPicture', 'scrollbars=0, toolbar=0, statusbar=0, status=0, resizable=no, location=no, width=' + _iNewWidth + ', height=' + _iNewHeight + ', left=' + left + ', top=' + top ) ;
		_wndPicture.focus() ;
	}
}

function open_element(number) {
	post_number = "post"+number;
	get_number = "get"+number;
	post = document.getElementById(post_number).style;
	get = document.getElementById(get_number).style;

	if(get.display == "") {
		get.display = "none";
	} else {
		get.display = "";
	}
}

function clean_table(theLink,sql) {

	if (clean_text == '' || typeof(window.opera) != 'undefined') {
		return true;
	}

	var confirmed = confirm(clean_text + '\nSQL-Befehl: ' + sql);
	if (confirmed) {
		theLink.href += '&action=1';
	}

	return confirmed;

}

function drop_table(theLink,sql) {

	if (drop_text == '' || typeof(window.opera) != 'undefined') {
		return true;
	}

	var confirmed = confirm(drop_text + '\nSQL-Befehl: ' + sql);
	if (confirmed) {
		theLink.href += '&action=1';
	}

	return confirmed;

}

function message_check(theLink,text) {

	if (text == '' || typeof(window.opera) != 'undefined') {
		return true;
	}

	var confirmed = confirm(text);
	if (confirmed) {
		theLink.href += '&action=1';
	}

	return confirmed;

}

function select_tables(form,select,proove) {

	var selected = document.forms[form].elements[select];
	var selectCount = selected.length;

	for (var i = 0; i < selectCount; i++) {
		selected.options[i].selected = proove;
	}

	return true;

}

function bild(img_url, img_title, img_width, img_height)
{
  wnd = open("",
             "Bildanzeige",
             "width=" + (img_width + 32) + ",height=" + (img_height + 50) +
             ",innerWidth=" + (img_width + 32) + ",innerHeight=" + (img_height + 64) +
             ",toolbar=0,location=0,directories=0,status=0,menubar=0" +
             ",scrollbars=0,resizable,dependent")

  var baseadr = location.href
  var lastsl  = location.href.lastIndexOf("\\")
  if(lastsl >= 0)
    baseadr = baseadr.substring(0, lastsl + 1)
  else
  {
    lastsl = location.href.lastIndexOf("/")
    if(lastsl >= 0)
      baseadr = baseadr.substring(0, lastsl + 1)
  }
  with(wnd.document)
  {
    open("text/html")
    writeln("<HTML>")
    writeln("<HEAD><TITLE>" + img_title + "</TITLE>")
    writeln("<BASE HREF=\"" + baseadr + "\"></HEAD>")
    writeln("<BODY BGCOLOR=WHITE>")
    writeln("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=4 WIDTH=\"100%\">")
    writeln("<TR><TD ALIGN=CENTER VALIGN=MIDDLE><IMG SRC=\"" + img_url +
            "\" WIDTH=" + img_width +
            " HEIGHT=" + img_height +
            " HSPACE=0 VSPACE=0 ALT=\"" + img_title + "\"></TD></TR>")
    write("<TR><TD ALIGN=LEFT VALIGN=BOTTOM><BIG><STRONG>")
    write("<A HREF=\"javascript:self.close()\"><font face=verdana size=1>Fenster schlie&szlig;en</font></A>")
    writeln("</STRONG></BIG></TD></TR>")
    writeln("</TABLE>")
    writeln("</BODY></HTML>")
    close()
  }
  wnd.focus()
}

function change_bgcolor(sElementId, sNewColor, sPointer) {
	eval("document.getElementById('"+sElementId+"').style.backgroundColor='"+sNewColor+"';");
	if (sPointer=='') {
		eval("document.getElementById('"+sElementId+"').style.cursor='default';");
	} else {
		if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.substring(22,23)<="5") {
			eval("document.getElementById('"+sElementId+"').style.cursor='default';");
		} else {
			eval("document.getElementById('"+sElementId+"').style.cursor='"+sPointer+"';");
		}
	}
}

function admin_help_window() {

	var url = opener.window.location.href;

	if (url.match(/(admin.php\?file=help)/g)) {
		opener.window.history.back();
		window.focus();
	} else {
		opener.window.location.href = 'admin.php?file=help';
	}

}

function doWindowOpen(width, height, url, name) {
	var left = (screen.availWidth/2) - width/2;
	var top = (screen.availHeight/2) - height/2;
	
	var openWindow = window.open(url, name, 'menubar=1, scrollbars=1, toolbar=0, statusbar=1, width='+width+', height='+height+', left='+left+', top='+top);
}

function article_unlimited_from() {
	document.cform.date_start_day.options[0].selected=true;
	document.cform.date_start_month.options[0].selected=true;
	document.cform.date_start_year.options[0].selected=true;
	document.cform.date_start_hour.options[0].selected=true;
	document.cform.date_start_minute.options[0].selected=true;
}

function article_unlimited_to() {
	document.cform.date_stop_day.options[0].selected=true;
	document.cform.date_stop_month.options[0].selected=true;
	document.cform.date_stop_year.options[0].selected=true;
	document.cform.date_stop_hour.options[0].selected=true;
	document.cform.date_stop_minute.options[0].selected=true;
}

function module_unlimited_from(_sForm) {
	_sForm.date_start_day.options[0].selected=true;
	_sForm.date_start_month.options[0].selected=true;
	_sForm.date_start_year.options[0].selected=true;
	_sForm.date_start_hour.options[0].selected=true;
	_sForm.date_start_minute.options[0].selected=true;
}

function module_unlimited_to(_sForm) {
	_sForm.date_stop_day.options[0].selected=true;
	_sForm.date_stop_month.options[0].selected=true;
	_sForm.date_stop_year.options[0].selected=true;
	_sForm.date_stop_hour.options[0].selected=true;
	_sForm.date_stop_minute.options[0].selected=true;
}

function setSWF( _sFile, _iWidth, _iHeight, _bNotWrite, _sAlternativeFile, _sAlternativeLink ) {

	var _sReturn = '' ;

	if ( bFlashPlugIn ) {
		var _sParameter = ' Menu=FALSE swModifyReport=TRUE width=' + _iWidth + ' height=' + _iHeight + ' ' ;

	 	_sReturn  = "<SCR" + "IPT LANGUAGE=\"JavaScript\" TYPE=\"text/javascript\">\n" ;
	 	_sReturn += "<!--\n" ;
	 	_sReturn += "  function MM_reloadPage(init) {\n" ;
	 	_sReturn += "    //reloads the window if Nav4 resized\n" ;
	 	_sReturn += "    if ( init == true ) {\n" ;
	 	_sReturn += "      with (navigator) {\n" ;
	 	_sReturn += "        if ( ( appName == 'Netscape' ) && ( parseInt(appVersion) == 4 ) ) {\n" ;
	 	_sReturn += "          document.MM_pgW = innerWidth ;\n" ;
	 	_sReturn += "          document.MM_pgH = innerHeight ;\n" ;
	 	_sReturn += "          onresize = MM_reloadPage ;\n" ;
	 	_sReturn += "        }\n" ;
	 	_sReturn += "      }\n" ;
	 	_sReturn += "    }\n" ;
	 	_sReturn += "    else if ( innerWidth != document.MM_pgW || innerHeight != document.MM_pgH ) {\n" ;
		_sReturn += "      location.reload();\n" ;
	 	_sReturn += "    }\n" ;
	 	_sReturn += "  }\n" ;
	 	_sReturn += "  MM_reloadPage(true);\n" ;
	 	_sReturn += "// -->\n" ;
	 	_sReturn += "</SCRI" + "PT>\n" ;
	 	_sReturn += "<SCRI" + "PT LANGUAGE=\"VBScript\">\n" ;
	 	_sReturn += "Sub ban_FSCommand( ByVal command, ByVal args )\n" ;
	 	_sReturn += "  call ban_DoFSCommand( command, args )\n" ;
	 	_sReturn += "end sub \n" ;
	 	_sReturn += "</SCRI" + "PT>\n" ;

	 	_sReturn += "<object id=\"flash\" width=\"" + _iWidth + "\" height=\"" + _iHeight + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0\"" + _sParameter + ">" ;
	 	_sReturn += "  <param name=\"src\" value=\"" + _sFile + "\">" ;
	 	_sReturn += "  <param name=\"quality\" value=\"autohigh\">" ;
	 	_sReturn += "  <param name=\"loop\" value=\"true\">" ;
	 	_sReturn += "  <param name=\"play\" value=\"true\">" ;
	 	_sReturn += "  <param name=\"menu\" value=\"false\">" ;
	 	_sReturn += "  <param name=\"wmode\">" ;
	 	_sReturn += "  <param name=\"quality\" value=\"high\">" ;
	 	_sReturn += "  <embed name=\"flash\" allowscriptaccess=\"always\" width=\"" + _iWidth + "\" height=\"" + _iHeight + "\" src=\"" + _sFile + "\" " + _sParameter + " pluginspage=\"http://www.macromedia.com/shockwave\" type=\"application/x-shockwave-flash\" PLAY=\"true\" LOOP=\"true\" QUALITY=\"autohigh\">" ;
	 	_sReturn += "  </embed>" ;
	 	_sReturn += "</object>" ;
	}
	else if ( _sAlternativeLink || _sAlternativeFile ) {
	  _sReturn = "<a href=\"" + _sAlternativeLink + "\" target=\"_blank\"><img src=\"" + _sAlternativeFile + "\" width=\"" + _iWidth + "\" height=\"" + _iHeight + "\" border=\"0\" alt=\"\"></a>" ;
	}
	else {
		_sReturn = "Flash Player is missing. You can find on Site <a href=\"http://www.macromedia.com/shockwave\" target=\"_blank\">http://www.macromedia.com/shockwave</a>" ;
	}

	if ( ! _bNotWrite ) {
		document.write( _sReturn ) ;
	}
	else {
		return _sReturn ;
	}

	return true ;
}

bFlashPlugIn = (    navigator.mimeTypes
                 && navigator.mimeTypes["application/x-shockwave-flash"]
                 && navigator.userAgent.indexOf("Safari") == -1
               )
               
               ?
               
               navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin
               
               :
               
               0
               
               ;

if ( bFlashPlugIn ) {

	bFlashPlugIn = parseInt( bFlashPlugIn.description.substring( bFlashPlugIn.description.indexOf(".") -1 ) ) > 4 ;

}

else if (    navigator.userAgent
          && navigator.userAgent.indexOf("MSIE") >= 0
          && (    navigator.userAgent.indexOf("Windows 95") >= 0
               || navigator.userAgent.indexOf("Windows 98") >= 0
               || navigator.userAgent.indexOf("Windows NT") >= 0
             )
        ) {

	document.write( "<SCR" + "IPT LANGUAGE=VBScript\> \n" ) ;
	document.write( "on error resume next \n" ) ;
	document.write( "bFlashPlugIn = ( IsObject( CreateObject(\"ShockwaveFlash.ShockwaveFlash.5\") ) )\n" ) ;
	document.write( "</SCR" + "IPT> \n" ) ;

}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function downloadKOGGE( iData ) {
	IE  = document.all && ! window.opera ;
	
	_Object = document.getElementById(iData) ;
	
	_Object.style.display = 'inline' ;
}

var xhttp ;
    
function createXMLHttpRequest() { 
	if ( window.ActiveXObject ) {  
  	try {  
     // IE 6 and higher 
     xhttp = new ActiveXObject("MSXML2.XMLHTTP") ; 
    } 
    catch (e) { 
  		try { 
     		// IE 5 
      	xhttp = new ActiveXObject("Microsoft.XMLHTTP") ; 
    	} 
    	catch (e) { 
        xhttp = false ; 
      } 
    } 
  } 
  else if (window.XMLHttpRequest) { 
		try { 
    	// Mozilla, Opera, Safari ... 
      xhttp = new XMLHttpRequest() ; 
    } 
    catch (e) { 
    	xhttp = false ; 
		} 
	} 
}

function xhttpRequest_callback_screen() {
	if ( xhttp.readyState == 4 ) {
		if ( xhttp.status != 200 ) {
			alert( "Fehler " + xhttp.status + ": " + xhttp.statusText ) ;
		}
		else {
			var sResponseText = xhttp.responseText ;
		}
	}
}

function hansa_popup() 
{ 
	IE  = document.all && ! window.opera ;

  var breite=400 ; 
  var hoehe=600 ; 
  
  if ( ! IE ) {
  	breite = 390 ;
  	hoehe = 650 ;
  }
  	
 var positionX = ( (screen.availWidth / 2) - ( breite / 2 ) ) ; 
 var positionY = ( (screen.availHeight / 2) - ( hoehe / 2 ) ) ; 
 var url='http://www.fc-hansa.de/hansa_popup.htm'; 
 pop=window.open('','','width='+breite+',height='+hoehe+',location=no,top=10000,left=10000'); 
 pop.resizeTo(breite,hoehe); 
 pop.moveTo(positionX,positionY); 
 pop.location=url; 
}

function hansa_popup_js() { 
	
	var toDay = new Date() ;

	// Parse Date-Format: MM/DD/YYYY hh:mm:ss Timezone
	if ( toDay.getTime() > Date.parse( "06/30/2010 13:00:00 GMT+2" ) ) {
		return ;
	}

	var _oImage = new Image() ;

	var _sImage       = String('popup/pop_trikot_100224.gif') ;
	// http://www.fc-hansa.de/index.php?id=154&oid=10390
	// http://www.fc-hansa.de/index.php?id=308
	var _sLink        = String('https://www.hansa-fanshop.de/') ;
	// _self
	var _sTarget      = String('_self') ;
	// LIDL Ticket-Spezial - F.C. HANSA ROSTOCK VS. FORTUNA DÜSSELDORF - Sa. 19.12.2009 13:00 Uhr, DKB-Arena
	var _sTitle       = String('Alle Trikots nur 29,90 EUR!') ;
	var _sBottomTitle = String('ANZEIGE - Trikot Aktion') ;

	var _overlayDuration = 0.2 ;
	var _oCloseImage     = new Image() ;
  var _sCloseImage     = new String('tools/lightbox/images/closelabel.gif') ;
	
	_oImage.src = _sImage ;
	_oCloseImage.src = _sCloseImage ;
	
	if ( ( _oImage.width == 0 && _oImage.height == 0 ) || ( _oCloseImage.width == 0 && _oCloseImage.height == 0 ) ) {
		window.setTimeout( "hansa_popup_js()", 500 ) ;
	}
	else {		

		IE  = document.all && ! window.opera ;
			
		var iLeft = ( ( IE ? document.body.clientWidth : window.innerWidth ) / 2 ) - ( ( _oImage.width + 24 ) / 2 ) ;
		var iTop  = ( ( IE ? document.body.clientHeight : window.innerHeight ) / 2 ) - ( ( _oImage.height + _oCloseImage.height + 24 ) / 2 ) ;		


		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div") ;
		objOverlay.setAttribute( 'id', 'pop_up' ) ;
		objOverlay.style.display = 'none' ;
		objBody.appendChild(objOverlay) ;
		
		var objLink = document.createElement("a") ;
		objLink.setAttribute( 'id', 'pop_up_link' ) ;
		objLink.setAttribute( 'href', _sLink ) ;
		objLink.setAttribute( 'target', _sTarget ) ;
		objLink.setAttribute( 'title', _sTitle ) ;
		objLink.onclick = function () {
			new Effect.Fade( 'pop_up', { duration: _overlayDuration} ) ;
			return true ;
		}
		objOverlay.appendChild(objLink) ;

		var objImage = document.createElement("img") ;
		objImage.setAttribute( 'src', _sImage ) ;
		objLink.appendChild(objImage) ;
		
		var objBottom = document.createElement("div") ;
		objBottom.setAttribute( 'id', 'bottom' ) ;
		objBottom.style.height = _oCloseImage.height + 'px' ;
		objOverlay.appendChild(objBottom) ;
		
		var objBottomText = document.createElement("div") ;
		objBottomText.setAttribute( 'id', 'bottom_text' ) ;
		objBottom.appendChild(objBottomText) ;
		
		var objBottomButton = document.createElement("div") ;
		objBottomButton.setAttribute( 'id', 'bottom_button' ) ;
		objBottom.appendChild(objBottomButton) ;


		var objBottomLink = document.createElement("a") ;
		objBottomLink.setAttribute( 'id', 'bottom_link' ) ;
		objBottomLink.setAttribute( 'href', '#' ) ;
		objBottomLink.onclick = function () {
			new Effect.Fade( 'pop_up', { duration: _overlayDuration} ) ;
			return false ;
		}
		objBottomButton.appendChild(objBottomLink) ;

		var objBottomLinkImg = document.createElement("img") ;
		objBottomLinkImg.setAttribute( 'src', _sCloseImage ) ;
		objBottomLink.appendChild(objBottomLinkImg) ;

		widthCurrent = Element.getWidth('pop_up');
		heightCurrent = Element.getHeight('pop_up');
			
		Element.setWidth( 'pop_up', _oImage.width + 4 ) ;
		Element.setWidth( 'bottom', _oImage.width + 4 ) ;
		Element.setTop( 'pop_up', iTop ) ;
		Element.setLeft( 'pop_up', iLeft ) ;

		Element.hide( 'pop_up' ) ;

		Element.setInnerHTML( 'bottom_text', _sBottomTitle ) ;
		
		new Effect.Appear( 'pop_up', { duration: _overlayDuration, from: 0.0, to: 1 } ) ;		
	}
}

function setStatistic() {

	if ( bVisited == true ) {
		return true ;
	}

	hansa_popup_js() ;

	IE  = document.all && ! window.opera ;

	var sOutput = new String() ;
	
	sOutput  = '&form[availheight]=' + screen.availHeight ;
	sOutput += '&form[availwidth]=' + screen.availWidth ;
	sOutput += '&form[colordepth]=' + Math.pow(2, screen.colorDepth) ;
	sOutput += '&form[height]=' + screen.height ;
	sOutput += '&form[width]=' + screen.width ;
	sOutput += '&form[innerheight]=' + ( IE ? document.body.clientHeight : window.innerHeight ) ;
	sOutput += '&form[innerwidth]=' + ( IE ? document.body.clientWidth : window.innerWidth ) ;

	createXMLHttpRequest() ;
	xhttp.open( "GET", "index.php?file=statistic&mode=screen&clean=yes" + sOutput, true ) ;
	xhttp.onreadystatechange = xhttpRequest_callback_screen ;
	xhttp.send(null) ;
}				

var bVisited = new Boolean(false) ;

if ( navigator.cookieEnabled == true ) {
	if ( document.cookie.match(/FCHansaRostock-visited/) )  {
  	bVisited = true ;
	}
	else {
  	var daDate = new Date() ;
  	var iNewDate = daDate.getTime() + ( 60 * 60 * 1000 ) ;
  	daDate.setTime(iNewDate) ;
  	document.cookie =  "FCHansaRostock-visited=FCHansaRostock-visited; expires=" +  daDate.toGMTString() ;
	}
}
