var curImage = 1;

function switchImageLeft(strBlockId, strImagePath, intMax) {
	if(curImage > 1) {
		curImage--;
		
	}
	
	switchImageColor(strBlockId, strImagePath);
	document.getElementById(strBlockId + '_number').innerHTML = curImage;
	toggleArrows(strBlockId, intMax);
}


function switchImageRight(strBlockId, strImagePath, intMax) {
	if(curImage < intMax) {
		curImage++;
	}
	
	switchImageColor(strBlockId, strImagePath);
	document.getElementById(strBlockId + '_number').innerHTML = curImage;
	toggleArrows(strBlockId, intMax);
}


function toggleArrows(strBlockId, intMax) {
	if(curImage > 1) {
		showElement(strBlockId + '_left');
	}
	else {
		hideElement(strBlockId + '_left');
	}

	if(curImage < intMax) {
		showElement(strBlockId + '_right');
	}
	else {
		hideElement(strBlockId + '_right');
	}
}


function switchImageColor(strBlockId, strImagePath) {
	objNode = document.getElementById(strBlockId);
	objNode.src = strImagePath + curImage + '_c.jpg';
}

function switchImageBW(strBlockId, strImagePath) {
	objNode = document.getElementById(strBlockId);
	objNode.src = strImagePath + curImage + '.jpg';
}



function showElement(strElementId) {
	setElementVisibility(strElementId, true);
}

function hideElement(strElementId) {
	setElementVisibility(strElementId, false);
}

function setElementVisibility(strElementId, blnVisibility) {
	objElement = document.getElementById(strElementId);
	if(blnVisibility && objElement !== null) {
		objElement.style.visibility = 'visible';
		objElement.style.display='inline';
	} else if (objElement !== null) {
		objElement.style.visibility = 'hidden';
		objElement.style.display='none';
	}
}

function email() {
	email = 'bodan' + '.' + 'sdeurope' + '@' + 'hft-stuttgart' + '.' + 'de';
	href = 'mail' + 'to:' + email;
	window.location.href = href;
}


function dropdownhover()
{
        if(!document.getElementById("cssmenu"))
                return;
        var lis = document.getElementById("cssmenu").getElementsByTagName("LI");
        for (var i=0;i<lis.length;i++)
        {
                lis[i].onmouseover=function(){this.className+=" iehover";}
                lis[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" iehover\\b"), "");}
        }
}
if (window.attachEvent)
        window.attachEvent("onload", dropdownhover);
        
function dropdownhover1()
{
        if(!document.getElementById("dropdown"))
                return;
        var lis = document.getElementById("dropdown").getElementsByTagName("LI");
        for (var i=0;i<lis.length;i++)
        {
                lis[i].onmouseover=function(){this.className+=" iehover";}
                lis[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" iehover\\b"), "");}
        }
}

var slideMenu=function(){
	var sp,st,t,m,sa,l,w,gw,ot;
	return{
		build:function(sm,sw,mt,s,sl,h){
			sp=s; st=sw; t=mt;
			m=document.getElementById(sm);
			sa=m.getElementsByTagName('li');
			l=sa.length; w=m.offsetWidth; gw=w/l;
			ot=Math.floor((w-st)/(l-1)); var i=0;
			for(i;i<l;i++){s=sa[i]; s.style.width=gw+'px'; this.timer(s)}
			if(sl!=null){m.timer=setInterval(function(){slideMenu.slide(sa[sl-1])},t)}
		},
		timer:function(s){
			s.onmouseover=function(){clearInterval(m.htimer);clearInterval(m.timer);m.timer=setInterval(function(){slideMenu.slide(s)},t)}
			s.onmouseout=function(){clearInterval(m.timer);clearInterval(m.htimer);m.htimer=setInterval(function(){slideMenu.slide(s,true)},t)}
		},
		slide:function(s,c){
			var cw=parseInt(s.style.width);
			if((cw<st && !c) || (cw>gw && c)){
				var owt=0; var i=0;
				for(i;i<l;i++){
					if(sa[i]!=s){
						var o,ow; var oi=0; o=sa[i]; ow=parseInt(o.style.width);
						if(ow<gw && c){oi=Math.floor((gw-ow)/sp); oi=(oi>0)?oi:1; o.style.width=(ow+oi)+'px';
						}else if(ow>ot && !c){oi=Math.floor((ow-ot)/sp); oi=(oi>0)?oi:1; o.style.width=(ow-oi)+'px'}
						if(c){owt=owt+(ow+oi)}else{owt=owt+(ow-oi)}}}
				s.style.width=(w-owt)+'px';
			}else{clearInterval(m.timer);clearInterval(m.htimer)}
		}
	};
}();