var isNav, isIE, is4;
var coll = "";
var styleObj = "";
var posx;var posy;
var Dposx=0;var Dposy=0;
var aktiv;
var aktivMenu;
var notMove;
var zu=0;
var bg="#ffffff";

if (parseInt(navigator.appVersion) >= 4) {
    if (navigator.appName == "Netscape") {
      isNav = true;
			if (parseInt(navigator.appVersion) >= 5) {
    		is4=true;
       coll = "all.";
       styleObj =".style";
			}
   }
    else {
       isIE = true;
       coll = "all.";
       styleObj =".style";
    	is4=true;
   }
} else {
   	is4=false;
}



function setZelleStatus(theCell, thePointerColor,theLink) {
    // Opera does not return valid values with "getAttribute"
	if (thePointerColor=="#7687c6") x="#ffffff";
	else x="#ffffff";
	
    if (typeof(window.opera) == 'undefined'
        && typeof(theCell.getAttribute) != 'undefined' && typeof(theCell.setAttribute) != 'undefined') {
            // theCell.setAttribute('bgcolor', thePointerColor, 0);
			theCell.style.backgroundColor = thePointerColor;

    }
    else {

            theCell.style.backgroundColor = thePointerColor;


    }
	// topmenuStyle (theLink, x);
    return true;
} 

function setZeileStatus(theCell, thePointerColor) {
    // Opera does not return valid values with "getAttribute"
	if (thePointerColor=="#7687c6") x="#ad1f2b";
	else x="#ffffff";
	
    if (typeof(window.opera) == 'undefined'
        && typeof(theCell.getAttribute) != 'undefined' && typeof(theCell.setAttribute) != 'undefined') {
            // theCell.setAttribute('bgcolor', thePointerColor, 0);
			theCell.style.backgroundColor = thePointerColor;

    }
    else {

            theCell.style.backgroundColor = thePointerColor;


    }
	
    return true;
} 


function get_div(welches) {
	return (document.getElementById) ? document.getElementById(welches) : (isNav) ? eval("document."+welches) : eval("document.all."+welches);
}
function get_obj(welches) {
	return (document.getElementById) ? document.getElementById(welches).style : (isNav) ? eval("document."+welches) : eval("document.all."+welches+".style");
}

function topmenuStyle (was, thePointerColor) {

	var here = get_obj(was);
	here.color=thePointerColor;
	// alert(thePointerColor)

}


 function getInitialWidth() {
   if (isNav) {

     if (is4 && window.scrollbars.visible==true) return window.innerWidth;
		 else return window.innerWidth-15;		 
   }
   else {
    return document.body.clientWidth;
   }
 }
var links;
var rechts;

var aktiv = new Array;
aktiv[1]="";
aktiv[2]="";

var pos = new Array;
pos[1]=links+345;
pos[2]=rechts-92;
var richtung = new Array;
richtung[1]="1";
richtung[2]="-1";
var sto = new Array;

sto[1]=15;

sto[2]=6;

function positionieren(hm) {	
	var x=getInitialWidth();
	if (hm==0) {
		aktion=(isNav && !is4) ? "show" : "visible";
		l=(x/2)-493;
		links=l;
		var here=get_obj("start1");
		here.left=l+345;here.visibility=aktion;	
		l=(x/2)+292;
		rechts=l;
		var here=get_obj("start2");
		here.left=l-92;here.visibility=aktion;
	}
	aktion=(isNav && !is4) ? "hide" : "hidden";
	l=(x/2)-332;
	var here=get_obj("grossbild");
	here.left=l;here.visibility=aktion;	

}

function lauft() {
	for (i=1;i<3;i++) {
		x=2*i;
		// loslegen (i);
	}
	loslegen (2);
	setTimeout("loslegen(1)",2000);

}

var hereA=new Array;
var iA=new Array;


function loslegen (welches) {

	var aktdiv=welches;
	// alert(aktdiv)
	// hereA[aktdiv]=get_obj("start"+i);
	neu=0;
	if (richtung[aktdiv]==1) {
		if (pos[aktdiv]<rechts) {
			pos[aktdiv]+=1;
			hereA[aktdiv].left=pos[aktdiv];

		} else {
			richtung[aktdiv]=-1;
			pos[aktdiv]=rechts-1;
			hereA[aktdiv].left=pos[aktdiv];
			neu=1;
		}
	} else {
		if (pos[aktdiv]>links) {
			pos[aktdiv]-=1;
			hereA[aktdiv].left=pos[aktdiv];

		} else {
			pos[aktdiv]=links+1;
			
			hereA[aktdiv].left=pos[aktdiv];
			richtung[aktdiv]=1;
			neu=1;
		}	
	}
	if (neu==1) {
			x=Math.random();
			x=Math.round(x*20);
			if (x==0) x=10;
			nichtaktiv=(aktdiv==1) ? 2 : 1;
			if (x==sto[nichtaktiv]) sto[aktdiv]=x+5;
			else sto[aktdiv]=x;
			
			abst=Math.abs(sto[1]-sto[2])
			// alert(aktdiv+"\n\nabs="+abst+"\nsto[1]="+sto[1]+"\nsto[2]="+sto[2])
			if (abst<4)  {
				// nichtaktiv=(sto[aktdiv]==1) ? 2 : 1;
			 	sto[aktdiv]= (sto[aktdiv]>sto[nichtaktiv]) ? sto[aktdiv]-10 : sto[aktdiv]+10;
// alert(aktdiv+"\n\nabs="+abst+"\nsto[1]="+sto[1]+"\nsto[2]="+sto[2])
			}

			


				if (sto[1]<sto[2]) {
					var here1=get_obj("start1");
					here1.zIndex=4;
					var here1=get_obj("start2");
					here1.zIndex=3;
				} else {
					var here1=get_obj("start1");
					here1.zIndex=3;
					var here1=get_obj("start2");
					here1.zIndex=4;
				}
	}
	
setTimeout("loslegen('"+aktdiv+"')",sto[aktdiv]);
	// aktiv[aktdiv]=window.setTimeout("loslegen2()",sto[aktdiv]);
aktdiv="";
x="";
}


var wechseln=2;
var wb;
function wechselbild() {
	if (wechseln==1) {
		b1=1;
		b2=2;
		wechseln=2;
	} else {
		b1=2;
		b2=1;
		wechseln=1;
	}
	x=get_div("bild1");
	x.innerHTML=kopfbild[b1];
	x=get_div("bild2");
	x.innerHTML=kopfbild[b2];
	
	wb=window.setTimeout("wechselbild()",10000);
}

function html_kleinbild(bild) {
	hstr='<table border="0" cellspacing="7" cellpadding="0" bgcolor="#073a77"><tr><td>'+bild+'</td></tr></table>';
	return hstr;
}

var kopfbild=new Array;
var grossbild=new Array;

function grossbild_zeigen(bild) {
	clearTimeout(wb);
	x=get_div("grossbild");
	x1=get_obj("grossbild");	
	aktion=(isNav && !is4) ? "show" : "visible";
	aktion1=(isNav && !is4) ? "hide" : "hidden";

	if (x1.visibility==aktion1) {
		x.innerHTML=grossbild[bild];
		x1.visibility=aktion;	
	}
// alert(grossbild[x.visibility])

}

function grossbild_verbergen() {
	aktion=(isNav && !is4) ? "hide" : "hidden";
	x=get_obj("grossbild");
	x.visibility=aktion;	
	if (bildwechseln>1) wb=window.setTimeout("wechselbild()",30000);
	// alert(grossbild[x.visibility])
}

function init(hm,anzbilder) {
	positionieren(hm);
	if (hm==0) {
		pos[1]=links+345;
		pos[2]=rechts-92;
		hereA[1]=get_obj("start1");
		hereA[2]=get_obj("start2");
		setTimeout("lauft()",2000);
	}
	if (bildwechseln>1) {
		wechselbild();
	}
}


//**********************************************************
//
// Formularcheck
//
//**********************************************************


ja = new Image;
ja.src="images/ja.gif";
nein = new Image;
nein.src="images/nein.gif";



function checkGeschlecht(was) {
	x= document.Formular.anrede.value;
	if (x==0) {
		b=eval ("document.Formular.g"+was);

		b.src=ja.src
		document.Formular.anrede.value=was;
	} else {

		for (i=1;i<3;i++) {
			b=eval ("document.Formular.g"+i);
			if (i==was) {
				b.src=ja.src;
				document.Formular.anrede.value=i;
			} else {
				b.src=nein.src;
			}
		}
	}
}

var deutsch=new Array;
deutsch["Anrede"]="Bitte geben Sie Ihre Anrede ein!";
deutsch["Vorname"]="Bitte geben Sie Ihren Vornamen ein!";
deutsch["Nachname"]="Bitte geben Sie Ihren Nachnamen ein!";
deutsch["Strasse"]="Bitte geben Sie Ihre Strasse ein!";
deutsch["PLZ"]="Bitte geben Sie Ihre Postleitzahl ein!";
deutsch["Ort"]="Bitte geben Sie Ihren Wohnort ein!";
deutsch["Nachricht"]="Bitte geben Sie Ihre Nachricht ein!";
deutsch["Firma"]="Bitte geben Sie Ihre Firma ein!";
deutsch["Tel"]="Bitte geben Sie Ihre Telefonnummer ein!";
deutsch["Email"]="Bitte geben Sie Ihre Emailadresse ein!";
deutsch["Email1"]="Bitte geben Sie eine gültige Emailadresse ein!";
deutsch["suchen"]="Bitte geben Sie einen Suchbegriff ein!";


var eng=new Array;
eng["Anrede"]="Please fill out your title!";
eng["Vorname"]="Please fill out your surname!";
eng["Nachname"]="Please fill out your name!";
eng["Strasse"]="Please fill out your street!";
eng["PLZ"]="Please fill out your Area code!";
eng["Ort"]="Please fill out your Community!";
eng["Nachricht"]="Please fill out your message!";
eng["Firma"]="Please fill out your company!";
eng["Tel"]="Please fill out your telephone number!";
eng["Email"]="Please fill out your email adress!";
eng["Email1"]="Please fill out your email adress!";
eng["suchen"]="Please feed a search term!";


function checkFormular() {
	// return true;
	var x;
	var fehler=new Array;
	
	
	if (document.suchform.sprache.value && document.suchform.sprache.value==2) fehler=eng
	else fehler=deutsch
	
	
	var x=document.Formular.anrede.value
	
	if (x<1 || x>2) {
		alert (fehler["Anrede"]);
		return false;	
	}
	if (checkLeer(document.Formular.Vorname.value)==0) {
		alert (fehler["Vorname"]);
		document.Formular.Vorname.focus();
		return false;
	} 
	if (checkLeer(document.Formular.Nachname.value)==0) {
		alert (fehler["Nachname"]);
		document.Formular.Nachname.focus();
		return false;
	} 

	
	
	if (checkLeer(document.Formular.Email.value)==0) {
		alert (fehler["Email"]);
		document.Formular.Email.focus();
		return false;
	} 

	
	if (checkEmail(document.Formular.Email.value)==0) {
		alert (fehler["Email1"]);
		document.Formular.Email.focus();
		return false;
	} 

	if (checkLeer(document.Formular.Nachricht.value)==0) {
		alert (fehler["Nachricht"]);
		document.Formular.Nachricht.focus();
		return false;
	} 
	

//	x=document.Formular.bp_speichern.value
//	y=document.Formular.bp_mode.value	
//	if (y>1 && x!=1) {
//		alert (fehler["speichern"]);
//		return false;	
//	}
	
	return true;

}



function checkLeer(was) {

	hstr1=was.replace(/\b\s\b/g," ");
	hstr1=hstr1.replace(/\s/g,"")
	if (hstr1=="") {
		return 0;
	} else {
		return 1;	
	}
}

function checkEmail(was) {

	var checkEmailrg   = /.*\@.*\.\w+/i;
	var checkEmailrg   = /^[_\.0-9a-z-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,4}$/ig;	
	if (checkEmailrg.test(was) == false){
		return 0;
	} else {
		return 1;	
	}
}

function checkZahl(was) {
	if (checkLeer(was)==0) return 0;
	was=parseInt(was);	
 if(isNaN(was) == true)  return 0;
 return was;
}

function checkDatum(tag,monat,jahr) {
		monat=monat-1;
	  var Jetzt = new Date();
    JetztP = Date.parse(Jetzt);	
		x=jahr+18;
		var vglDat =new Date(x,monat,tag);	
    vglDatP = Date.parse(vglDat);
				


		if (vglDat>Jetzt) return 0;
		return 1;
}



function check_suchbegriff() {
	var x;
	var fehler=new Array;
	
	
	if (document.suchform.sprache.value && document.suchform.sprache.value==2) fehler=eng
	else fehler=deutsch
	x=document.suchform.search.value;
	if (checkLeer(x)==0 || x=="Suchbegriff" || x=="search term") {
		alert (fehler["suchen"]);
		document.suchform.search.value="";
		document.suchform.search.focus();
		return false
	}
	return true

}

function tus() {
	//alert(a);
	location.href="mailto:info@mergeconsult.ch"
}

function sem() {
document.write('<br><table border="0" cellspacing="0" cellpadding="3"><tr><td><img src="/images/pfeil1b.gif" width="5" height="9" alt="e-Mail" border="0"></td><td class="text"><a href="javascript:tus();"><strong>e-Mail</strong></a></td></tr></table>')
}