// JavaScript-Routinen fuer www.dr-carl.de
// Dr. Carl GmbH Stuttgart
// ak 10.02.07

/*
window.onload = function() {
// Anzeige der fertig geladenen Seite (einfacher Preloader)
	//alert("function window.onload called");
 	$('.tab_PageFrame').show();
} 

function onload() {
// Anzeige der fertig geladenen Seite (einfacher Preloader)
	//alert("function onload called");
 	$('.tab_PageFrame').show();
} 
*/ 
 
 
 
 
function CheckEnterKey(evt) {
// ist evt.keyCode = 13 (ENTER)?
	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
	if (charCode == 13) {
		return true;
	}
	return false;
} // CheckEnterKey	


	function EnterKey_Suche(evt) {
	// onkeypress fuer Suche
		if (CheckEnterKey(evt)) {
//alert('EnterKey_Suche: ' + $("#AUTOCOMPLETE").val());			
			Submit_Suche();
		}
	}


// List Array by value
function Get_List_Value(aList) {
	var val = null;
	for (var i = 0; i < aList.length; i++) {
		if (aList[i].selected) {
			val = aList[i].value;
			break
		}
	}
	return val;
} // Get_List_Value



// Direktaufruf Projekt aus Select-Liste (projekte.php)
	function GotoProjekt() {
		document.location.replace("projekte.php?a_autoid=" + TheForm.PROJEKTE.value);
	}

// Projektsuche (projekte.php)
	function GotoProjekt_Suche() {
		document.location.replace("projekte.php?a_nr=1&a_suche=" + TheForm.SUCHE.value);
	}
	
	
// Test: Seitenausgabe verzögern via PRELOADER
// Usage: <BODY onload="hideloadinghint()">
	function hideloadinghint() {
		/*if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById('hidepage').style.visibility = 'hidden';
		}
		else {
		if (document.layers) {  // Netscape 4
		document.hidepage.visibility = 'hidden';
		}
		else {  // IE 4
		document.all.hidepage.style.visibility = 'hidden';
		      }
		   }*/
	}




// Fenster "InfoWindow" zentriert auf Bildschirmmitte oeffnen
	function OpenCenteredWindow (newWindowURL, WinName, options, w, h) {
	// 		newWindowURL: anzuzeigende HTML-Seite
	// 		WinName: Name des Fensters (fuer target=... etc.)
	// 		options: "menubar=0 toolbar=0" etc.
	//		w, h: width, height
		if (screen.availHeight < h) {
			h = screen.availHeight;}
		if (screen.availWidth < w) {
			w = screen.availWidth;}
		options = options + ',width=' + w + ',height=' + h;
		InfoWindow = window.open(newWindowURL, WinName, options);

		InfoWindow.moveTo((screen.availWidth - w) / 2, (screen.availHeight - h) / 2);
		InfoWindow.focus();
	}


// Flash-Animation in Extrafenster
	function OpenFlashWindow(a_FileName) {
		var winname = 'winFlash';
		winprops = 'top=0,left=0,scrollbars=no,resizable=yes,menubar=no,toolbar=no,directories=no,location=no,status=no';
		OpenCenteredWindow("show_swf.php?a_filename=" + a_FileName, winname, winprops, 694, 520);
	}

// Flash-Video in Extrafenster
	function OpenVideoWindow(a_FileName) {
		var winname = 'winFlash';
		winprops = 'top=0,left=0,scrollbars=no,resizable=yes,menubar=no,toolbar=no,directories=no,location=no,status=no';
		OpenCenteredWindow("show_flv.php?a_filename=" + a_FileName, winname, winprops, 694, 520);
	}



// Flash-Animation starten ohne Aktivierung
function Show_SWF(a_FileName, a_Width, a_Height) {
	//alert( '	<PARAM NAME="movie" VALUE="' + a_FileName + '"> ');
			document.write( '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
			document.write( ' codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
			document.write( ' id="swf-steuerung" width="' + a_Width + '" height="' + a_Height + '" align="middle">');
			document.write( '	<PARAM NAME="movie" VALUE="' + a_FileName + '"> ');
			document.write( '	<PARAM NAME="quality" VALUE="high">');
			document.write( '	<PARAM NAME="bgcolor" VALUE="#FFFFFF">');
			//document.write( '	<PARAM NAME="bgcolor" VALUE="#F3F8FC">');
			document.write( '	<param name="allowScriptAccess" value="sameDomain">');
			document.write( '	<EMBED src="' + a_FileName + '" ');
				document.write( '	 quality="high" bgcolor="#FFFFFF" width="' + a_Width + '" height="' + a_Height + '" NAME="swf-steuerung" ');
				document.write( '	 align="middle" allowScriptAccess="sameDomain"');
				document.write( '	 TYPE="application/x-shockwave-flash" PLUGINSPAGE="https://www.macromedia.com/go/getflashplayer">');
			document.write( '	</EMBED>');
			document.write( '</OBJECT>');
}


// Flash-Video starten ohne Aktivierung
function Show_FLV(a_FileName, a_Width, a_Height) {
	document.write( '<object id="Object1" type="application/x-shockwave-flash" data="graph/projekte/video/player_flv_maxi.swf" width="' + a_Width + '" height="' + a_Height + '">');
	//document.write( '<object id="Object1" type="application/x-shockwave-flash" data="graph/projekte/video/player_flv_maxi.swf" width="768" height="576">');
	document.write( '<noscript><a href="http://www.dvdvideosoft.com">freeware</a></noscript>');
	document.write( '<param name="movie" value="graph/projekte/video/player_flv_maxi.swf" />');
	document.write( '<param name="allowFullScreen" value="true" />');
	document.write( '<param name="wmode" value="opaque" />');
	document.write( '<param name="allowScriptAccess" value="sameDomain" />');
	document.write( '<param name="quality" value="high" />');
	document.write( '<param name="menu" value="true" />');
	document.write( '<param name="autoplay" value="true" />');
	document.write( '<param name="autoload" value="true" />');
	//document.write( '<param name="FlashVars" value="configxml=graph/projekte/video/18_x264.xml" />');
	document.write( '<PARAM NAME="FlashVars" VALUE="flv=' + a_FileName + '&autoplay=1&ondoubleclick=fullscreen&videobgcolor=0&showvolume=1&buffermessage=&showfullscreen=1&sliderovercolor=D4D0C8"> ');
	//document.write( '<param name="FlashVars" value="configxml=graph/projekte/video/18_x264.xml" />');
	document.write( '</object> ');
}


// BACKUP (NOT IN USE): Flash-Video starten ohne Aktivierung
function Show_FLV_BAK(a_FileName, a_Width, a_Height) {
	document.write( '<object id="Object1" type="application/x-shockwave-flash" data="graph/projekte/video/player_flv_maxi.swf" width="768" height="576">');
	document.write( '<noscript><a href="http://www.dvdvideosoft.com">freeware</a></noscript>');
	document.write( '<param name="movie" value="graph/projekte/video/player_flv_maxi.swf" />');
	document.write( '<param name="allowFullScreen" value="true" />');
	document.write( '<param name="wmode" value="opaque" />');
	document.write( '<param name="allowScriptAccess" value="sameDomain" />');
	document.write( '<param name="quality" value="high" />');
	document.write( '<param name="menu" value="true" />');
	document.write( '<param name="autoplay" value="false" />');
	document.write( '<param name="autoload" value="false" />');
	document.write( '<param name="FlashVars" value="configxml=graph/projekte/video/18_x264.xml" />');
	document.write( '</object> ');
}


// fade-in effect for images
 function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame

    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
	
	if (opacEnd == 100) {
		document.getElementById(id).style.zIndex = "10";
	} else {
		document.getElementById(id).style.zIndex = "1";
	}
}

// change the opacity for different browsers
// (subroutine of the "opacity" fading effect function)
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	}


// Projekt-Suche starten von home.php aus
function Submit_Suche() {
	location.href = 'projekte.php?a_keyword=' + $("#AUTOCOMPLETE").val();
}


function timedMsg() {
var t=setTimeout("alert('5 seconds!')",5000);
}
