// JavaScript Document
var flag = "";
var sideflag = "";
var subsideflag = "";

var neu = null;


function naviOn (obj) {
	var imgPath = obj.firstChild.src.split("_o");
	obj.firstChild.src = imgPath[0] + "_on.gif";
}

function naviOut (obj) {
	var imgPath = obj.firstChild.src.split("_o");
	if (obj != flag && obj != sideflag && obj != subsideflag) {
		obj.firstChild.src = imgPath[0] + "_of.gif";
	} 
}

function popup_nocontrol(url,windowname,xsize,ysize)
{
    if (neu != null)
    {
        if (neu.closed != true)
        {
            neu.window.close();
        }
    }
    neu = window.open(url,windowname,'resizable,width='+xsize+',height='+ysize+'');
    if (navigator.appName == "Microsoft Internet Explorer")
    neu.moveTo((screen.width-xsize)/2,100);
}


function required (formname)
{
    var feldname=new RegExp("^"+formname+"_*","gi");
    var ok=true;
    for (i=0;i<document.formular.length;i++)
    {
        if (document.formular[i].name.match(feldname)==(formname+"_"))
        {
            if (document.formular[i].name.match(/_required$/gi)) // Feld required
            {
                if (document.formular[i].type=="checkbox")
                {
                    if (document.formular[i].checked==false)
                    {
                        ok=false;
                    }
                }
                else if (document.formular[i].type=="radio")
                {
                    var radioname = document.formular[i].name;
                    var radiook = false;
                    var radiolength=eval("document.formular."+radioname+".length");
                    for (i2=0;i2<radiolength;i2++)
                    {
                        radiook = radiook || (eval("document.formular."+radioname+"["+i2+"].checked"));
                    }
                    if (radiook==false)
                    {
                        ok=false;
                    }
                }
                else if (document.formular[i].type.match(/^select/gi))
                {
                    if ((document.formular[i].value=="undefined") || (document.formular[i].value==""))
                    {
                        ok=false;
                    }
                }
				else if (document.formular[i].name.match(/mail/gi) == "mail") {
					 var mail = document.formular[i].value;
					 if (mail.search(/^[_a-z0-9A-Z+-]+(\.[_a-z0-9A-Z+-]+)*@[a-z0-9A-Z-]+(\.[a-z0-9A-Z-]+)$/) == -1)
						ok = false;
				}
                else
                {
                    if (document.formular[i].value=="")
                    {
                        ok=false;
                    }
                }
            }
        }
    }
    if (ok==false)
    {
        alert ("Sie haben leider nicht alle zur Bearbeitung notwendigen Angaben gemacht,\nbitte versuchen Sie es noch einmal.");
    }
    return ok;
}

function formular_auswerten(name)
{
    var split=name.split("|");
    for (var i=split.length;i<4;i++)
    {
        split.push("");
    }
    var formname=split[0];

    if (required(formname))
    {
        var empfaenger=split[1];
        var subject=split[2];
        var absender=split[3];

        var feldname=new RegExp("^"+formname+"_*","gi");

        var name;
        var str="formularname="+escape(formname)+"&";
        str += "&empfaenger="+empfaenger;
        str += "&subject="+subject;
        str += "&absender="+absender;
        str += "&";
        for (i=0;i<document.formular.length;i++)
        {
            if (document.formular[i].name.match(feldname)==(formname+"_"))
            {

                name=document.formular[i].name.replace(feldname,"");
                name=name.replace(/_required$/gi,"");
                if ((document.formular[i].type=="radio") || (document.formular[i].type=="checkbox"))
                {
                    if (document.formular[i].checked==true)
                    {
                        str+= name+"="+escape(document.formular[i].value)+"&";
                    }
                }
                else if (document.formular[i].type.match(/^select/gi))
                {
                    var selectname = document.formular[i].name;
                    str+= name+"="+escape(eval("document.formular."+selectname+"[document.formular."+selectname+".selectedIndex].value"))+"&";
                }
                else
                {
                    str+= name+"="+escape(document.formular[i].value)+"&";
                }
            }
        }
        popup_nocontrol ("./formularauswertung.php?"+str,"mail",400,200);
    }
}



/***********************************************
* Ultimate Fade-In Slideshow (v1.5): � Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["photo1.jpg", "", ""] //plain image syntax
fadeimages[1]=["photo2.jpg", "http://www.cssdrive.com", ""] //image with link syntax
fadeimages[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax
 
var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages2[0]=["photo1.jpg", "", ""] //plain image syntax
fadeimages2[1]=["photo2.jpg", "http://www.cssdrive.com", ""] //image with link syntax
fadeimages2[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax
 
var fadebgcolor="eff1d8"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}

function winopener() {
	video = window.open("http://GelbeSeiten.v4all.de/v129/i32/kl/i32kl09302/i32kl09302.html","imagevideo","width=510,height=445,toolbar=no,location=no,scrollbars=1")
}

function slideDown(divName){
	//alert(lastSlideDivId);
	//alert(divName);
	if(typeof(lastSlideDivId) != "undefined"){
		$("#"+lastSlideDivId).slideUp('fast');
		if(lastSlideDivId == divName){
			lastSlideDivId = undefined;
			return false;
		}
	}
	
	$("#"+divName).slideDown('fast');
	$("#"+divName).css('display', 'block');
	//$("#"+divName).css('background-color', 'green');
	lastSlideDivId = divName;
	return false;
}

/*
function showOnly(thisSup) {
//  var menue = array('gebrauchtwagenSupDiv');
  if (thisSup == "neuwagenSupDiv") {
    document.getElementById('neuwagenSupDiv').style.display='block';
  } else {
    document.getElementById('neuwagenSupDiv').style.display='none';
  }
  if (thisSup == "gebrauchtwagenSupDiv") {
    document.getElementById('gebrauchtwagenSupDiv').style.display='block';
  } else {
    document.getElementById('gebrauchtwagenSupDiv').style.display='none';
  }
  if (thisSup == "activeSupDiv") {
    document.getElementById('activeSupDiv').style.display='block';
  } else {
    document.getElementById('activeSupDiv').style.display='none';
  }
  if (thisSup == "serviceSupDiv") {
    document.getElementById('serviceSupDiv').style.display='block';
  } else {
    document.getElementById('serviceSupDiv').style.display='none';
  }
}*/

function asyncLoadFacebookStream(){
	
	$.ajax({
		type: "GET",
		url: "facebook.php",
		success: function(html){
			$("#newsContent").html(html);
		}
	});
	
	/*
	$.ajax({
	   type: "POST",
	   url: "facebook.php",
	   data: "test=test";
	   success: function(returnData){
	     $.("#newsContent").html(returnData);
	   }
	 });
	 */
}










