// JavaScript Dokument

// vereifacht document.getElemetById() Aufruf:
function ebi(id){var obj = document.getElementById(id);if(obj){return obj;}}
// z.B. ebi('Layer1') anstatt document.getElemetById('Layer1')

// Abwechselnd Ein-Ausblenden von Elementen, block oder inline wird mitgegeben:
function toggleObj(id,dis){var obj = ebi(id);if(obj){if(obj.style.display=='none'){obj.style.display=dis;}else{obj.style.display='none';}}}
// z.B. toggleObj('Layer1','block') oder toggleObj('Layer1','inline')

// vereifacht document.Bestellformular.Element:
function dBf(element){var obj = document.forms['Bestellformular'].elements[''+element+''];if(obj){return obj;}}

function left(str, n){if (n <= 0){return "";}else if(n > String(str).length){return str;}else{return String(str).substring(0,n);}}


// **********************************************************************************************
// Füllt den innerHTML eines DIVs mit Inhalt der eigenen Domain
// bei Text muss jeweils unbedingt noch mit AjaxEnc(this.value); ersetzt werden.
// wenn Java per UTF-8 überträgt, am besten meta charset auf UTF-8 stellen,
//		wenn dies nicht möglich ist, mithilfe von ASP session.codepage=65001
//		nicht vergessen danach wieder zurück zu stellen: session.codepage = 1252
// Vorsicht bei multipart/form-data, dort muss UTF-8 zwingend deaktiviert werden!
// **********************************************************************************************
var div; var btn;
function FillDIV(obj,container,file,vars){
	var NoCache = new Date();div = container;btn = obj;req = createXMLHttpRequest();req.onreadystatechange = handleFillDIV;req.open('POST', file+'?NoCache='+NoCache.getTime()+'&FillDIV=1', true);req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	vars = vars.replace(/ /g,'%20');
	vars = vars.replace(/\+/g,'%2B');
	req.send(vars);
	//alert(vars);
}
function FillDIVSync(obj,container,file,vars){
	var NoCache = new Date();div = container;btn = obj;req = createXMLHttpRequest();req.onreadystatechange = handleFillDIV;req.open('POST', file+'?NoCache='+NoCache.getTime()+'&FillDIV=1', false);req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	vars = vars.replace(/ /g,'%20');
	vars = vars.replace(/\+/g,'%2B');
	req.send(vars);
	//alert(vars);
}
function AjaxEnc(source){
	source = source.replace(/%/g,'%25');
	source = source.replace(/ /g,'%20');
	source = source.replace(/\+/g,'%2B');
	source = source.replace(/\//g,'%2F');
	source = source.replace(/&/g,'%26amp%3B');
	return source;
}
function handleFillDIV(){switch(req.readyState){case 0 : case 1 : if(ebi(div)){ebi(div).style.cursor='wait';}if(btn){btn.style.display='none';} case 2 : case 3 : break; case 4: if(ebi(div)) ebi(div).innerHTML=req.responseText;if(ebi(div)){ebi(div).style.cursor='default';}if(btn){btn.style.display='inline';}break;default:;}}
function createXMLHttpRequest(){var obj = null;try{obj = new ActiveXObject("MSXML2.XMLHTTP");}catch (err_MSXML2){try{obj = new ActiveXObject("Microsoft.XMLHTTP");}catch (err_Microsoft){if(typeof XMLHttpRequest != "undefined")obj = new XMLHttpRequest;}}return obj;}
// z.B. FillDIV(this,'MyDiv2Fill','getData.asp','filldiv=1&id=123&test=test');
// **********************************************************************************************
// **********************************************************************************************
// **********************************************************************************************



/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#startBanner DIV.active');

    if ( $active.length == 0 ) $active = $('#startBanner DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#startBanner DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 6000 );
});
/***
***/



//Startseite Hover-Effekt
function teaser_hover(obj) { 
obj.className = "col1Hover";
}
function teaser_out(obj) { 
obj.className = "col1";
}


if(1 == 0){
//MainSubNavig
$jQ(document).ready(function() {
	

	function megaHoverOver(){
		$jQ(this).find(".sub").stop().fadeTo('fast', 1).show();

		//Calculate width of all ul's
		//(function($jQ) { 
			//jQuery.fn.calcSubWidth = function() {
				//rowWidth = 0;
				//Calculate row
				//$jQ(this).find("ul").each(function() {					
					//rowWidth += $jQ(this).width(); 
				//});	
			//};
		//})(jQuery); 
		
		//if ( $jQ(this).find(".row").length > 0 ) { //If row exists...
			//var biggestRow = 0;	
			//Calculate each row
			//$jQ(this).find(".row").each(function() {							   
				//$jQ(this).calcSubWidth();
				//Find biggest row
				//if(rowWidth > biggestRow) {
					//biggestRow = rowWidth;
				//}
			//});
			//Set width
			//$jQ(this).find(".sub").css({'width' :biggestRow});
			//$jQ(this).find(".row:last").css({'margin':'0'});
			
		//} else { //If row does not exist...
			
			//$jQ(this).calcSubWidth();
			//Set Width
			//$jQ(this).find(".sub").css({'width' : rowWidth});
			
		//}
	}
	
	function megaHoverOut(){ 
	  $jQ(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $jQ(this).hide(); 
	  });
	}

	var config = {    
		 sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 100, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$jQ("ul#topnav li .sub").css({'opacity':'0'});
	$jQ("ul#topnav li").hoverIntent(config);

});
}

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

