/**
 * @author sven
 */
/*######## HEADER IMAGE HOME #########*/
function initializeEffects(siteName){
	
	$('#nav').droppy();
	
    if (siteName == "home") {
		
		//$(".container").addClass('sliderUp');
    
        $(".parentOfA").hover(function(){
            $(".childA").stop(true, false).animate({
                opacity: 0
            }, 1000);
            $(".childAA").stop(true, false).animate({
                opacity: 0.7
            }, 1000);
        }, function(){
            $(".childA").stop(true, false).animate({
                opacity: 0.7
            }, 1000);
            $(".childAA").stop(true, false).animate({
                opacity: 0
            }, 1000);
        });
        $(".parentOfB").hover(function(){
            $(".childB").stop(true, false).animate({
                opacity: 0
            }, 1000);
            $(".childBA").stop(true, false).animate({
                opacity: 0.7
            }, 1000);
        }, function(){
            $(".childB").stop(true, false).animate({
                opacity: 0.7
            }, 1000);
            $(".childBA").stop(true, false).animate({
                opacity: 0
            }, 1000);
        });
        $(".parentOfC").hover(function(){
            $(".childC").stop(true, false).animate({
                opacity: 0
            }, 1000);
            $(".childCA").stop(true, false).animate({
                opacity: 0.7
            }, 1000);
        }, function(){
            $(".childC").stop(true, false).animate({
                opacity: 0.7
            }, 1000);
            $(".childCA").stop(true, false).animate({
                opacity: 0
            }, 1000);
        });
    } 
	
	
	else{
		
		if (siteName == "concept") {
			
			selected(".concept");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("3d,illustration,realfilm,coding");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "minisites") {
			
			selected(".minisites");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("minisite");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "konfiguratoren") {
			
			selected(".konfiguratoren");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("konfigurator");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "content") {
			
			selected(".content");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("3d,illustration,realfilm,minisites,konfiguratoren,vrrundgang");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "3danimation") {
			
			selected(".3danimation");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("3d");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "realfilm") {
			
			selected(".realfilm");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("realfilm");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "illustration") {
			
			selected(".illustration");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("illustration");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "coding") {
			
			selected(".coding");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("coding");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "minisites_coding") {
			
			selected(".minisites_coding");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("minisite");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "apps_coding") {
			
			selected(".apps_coding");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("apps");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "konfiguratoren_coding") {
			
			selected(".konfiguratoren_coding");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("konfigurator");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "vrrundgang_coding") {
			
			selected(".vrrundgang_coding");
            
            $(".childBsub h2, .childBsub h3").click(function(){
				loadGal("vr");
                $("div#makeMeScrollable").slideToggle(1000);
				if($('div.beispiele').css('top') == '0px'){
					$('div.beispiele').animate({top: '412px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowdown').addClass('arrowup');
				}else{
					$('div.beispiele').animate({top: '0px'}, 1000);
					$('div.beispiele h2:last').removeClass('arrowup').addClass('arrowdown');
				}
            });
        }
		
		else if (siteName == "kunden") {
        	selected(".kunden");
        }
		
		else if (siteName == "wirueberuns") {
        	selected(".wirueberuns");
        }
		
		else if (siteName == "team") {
        	selected(".team");
        }
		
		else if (siteName == "impressum") {
        	selected(".impressum");
        }
		
		else if (siteName == "kontakt") {
        	selected(".kontakt");
        }
		
		$('.container').stop(true, false).animate({
				top: '110px'
			}, 1000, function() {
				
			});
			
		$(".parentOfA").hover(function(){
			$(".parentOfA").stop(true, false).animate({
				top: '0px'
			}, 1000);
		}, function(){
			$(".parentOfA").stop(true, false).animate({
				top: '110px'
			}, 1000);
		});
		$(".parentOfB").hover(function(){
			$(".parentOfB").stop(true, false).animate({
				top: '0px'
			}, 1000);
		}, function(){
			$(".parentOfB").stop(true, false).animate({
				top: '110px'
			}, 1000);
		});
		$(".parentOfC").hover(function(){
			$(".parentOfC").stop(true, false).animate({
				top: '0px'
			}, 1000);
		}, function(){
			$(".parentOfC").stop(true, false).animate({
				top: '110px'
			}, 1000);
		});
	}
}


function selected(obj){
	
	var lilist = document.getElementById('nav');
	var alist = lilist.getElementsByTagName('a');
	for (i=0; i<alist.length; i++ ){
		$(alist[i]).removeClass("active");
	}
	if(obj == ".concept" || obj == ".content" || obj == ".coding"){
		$(obj).addClass("active");
		$(".leistungen").addClass("active");
	}
	else if(obj == ".wirueberuns" || obj == ".team"){
		$(obj).addClass("active");
		$(".unternehmen").addClass("active");
	}
	else if(obj == ".minisites" || obj == ".konfiguratoren"){
		$(obj).addClass("active");
		$(".leistungen").addClass("active");
		$(".concept").addClass("active");
	}
	else if(obj == ".minisites_coding" || obj == ".apps_coding" || obj == ".konfiguratoren_coding" || obj == ".vrrundgang_coding"){
		$(obj).addClass("active");
		$(".leistungen").addClass("active");
		$(".coding").addClass("active");
	}
	else if(obj == ".3danimation" || obj == ".realfilm" || obj == ".illustration"){
		$(obj).addClass("active");
		$(".leistungen").addClass("active");
		$(".content").addClass("active");
	}
	else{
		$(obj).addClass("active");
	}
}



function startDivScrolling(){

    $("div#makeMeScrollable").smoothDivScroll({
        autoScroll: "onstart",
        autoScrollDirection: "backandforth",
        autoScrollStep: 1,
        autoScrollInterval: 15,
        visibleHotSpots: "always"
    });
    
    $("div#makeMeScrollable a").colorbox({
        speed: "500"
    });
    
    // Pause autoscrolling if the user clicks one of the images
    $("div#makeMeScrollable").bind("click", function(){
        $(this).smoothDivScroll("stopAutoScroll");
    });
    
    // Start autoscrolling again when the user closes
    // the colorbox overlay
    $(document).bind('cbox_closed', function(){
        $("div#makeMeScrollable").smoothDivScroll("startAutoScroll");
    });
}



/*######## LIGHTBOX FÜR NEWS #########*/
function showInfos(boxID){
	
	var tempBoxID = "#" + boxID;
	
	if($(tempBoxID).parent().hasClass("arrowup")){
		$(tempBoxID).parent().removeClass("arrowup");
	}else{
		$(tempBoxID).parent().addClass("arrowup");
	}
	
	$(tempBoxID).slideToggle('slow');
}


function loadGal(param){
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
			alert ("Browser does not support HTTP Request");
			return;
	}
	var url="/php/load_galerie.php?p=" + param;
	//url=url+"?q="+str+"&L="+jsLang;				// startflughafen		
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);


}

function stateChanged(){ 

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			//alert(xmlHttp.responseText);
			document.getElementById("galleryContainer").innerHTML=xmlHttp.responseText;
			//$(".scrollableArea").innerHTML=xmlHttp.responseText;
			//evalScript(xmlHttp.responseText);
			startDivScrolling();
		} 
}



function GetXmlHttpObject()
{
		
		var xmlHttp=null;
		try{
				// Firefox, Opera 8.0+, Safari
				xmlHttp=new XMLHttpRequest();
		}catch (e){
				//Internet Explorer
				try {					 
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");				  
				}catch (e){					 
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
		}
		return xmlHttp;
}

