var images = new Array();
var lastImg = 0;
var currentImg = 0;

//load page _gets
var page = '';
var part = '';
url = String(window.location);
url = url.split('/');
urlLength = url.length;
page = url[urlLength-2];
part = url[urlLength-1];
partT = part.split('.');
part = partT[0];


//effects
$(document).ready(function(){
	/* ## Navihation ########################### */
	/* @ load ambuBox verstecken */ 
	if(page == 'AmbulanteRehabilitation') {
		$("div#ambuBox").show();
		$("div#ambuLinkArrow").hide();
	} else {
		$("div#ambuBox").hide();
		$("div#ambuLinkArrow").show();
	}
    $("div#ambuLink").click(function () {
      $("div#ambuBox").toggle("fast");
      $("div#ambuLinkArrow").toggle();
    });
    /* @ load theraBox verstecken */ 
	if(page == 'Therapieverfahren') {
		$("div#theraBox").show();
		$("div#theraLinkArrow").hide();
	} else {
		$("div#theraBox").hide();
		$("div#theraLinkArrow").show();
	}
    $("div#theraLink").click(function () {
      $("div#theraBox").toggle("fast");
      $("div#theraLinkArrow").toggle();
    });
    /* @ load erreichBox verstecken */ 
	if(page == 'Erreichbarkeit') {
		$("div#erreichBox").show();
		$("div#erreichLinkArrow").hide();
	} else {
		$("div#erreichBox").hide();
		$("div#erreichLinkArrow").show();
	}
    $("div#erreichLink").click(function () {
      $("div#erreichBox").toggle("fast");
      $("div#erreichLinkArrow").toggle();
    });
    
    
    /* ## Login ########################### */
    $("input#login_name").click(function() {
    	if(document.getElementById('login_name').value == "Benutzername") {
    		document.getElementById('login_name').value = '';
    	}
    });
    $("input#login_password").click(function() {
    	if(document.getElementById('login_password').value == "Passwort") {
    		document.getElementById('login_password').value = '';
    	}
    });
    
    /* ## Heilmittel ########################### */
    if(page == 'Heilmittel') {
		$('div#imageSchlingentisch').hide();
		$('div#imageBodenuebung').hide();
		$('div#imageTherapieraum').hide();
		$('div#imageKgBabsi').hide();
		$('div#imageMtHolm').hide();
    }
    
    /* ## Galery ########################### */
    if(page == "Galerie") {
    	$('#nextImageShow').click(function() {
    		if(currentImg < lastImg) {
    			$('div#imageBig' + (currentImg + 1)).show("fast");
    			$('div#imageBig' + currentImg).hide("slow");
    			currentImg = currentImg + 1;
    		}
    	});
    	$('#backImageShow').click(function() {
    		if(currentImg > 1) {
    			$('div#imageBig' + currentImg).hide("fast");
    			$('div#imageBig' + (currentImg - 1)).show("fast");
    			currentImg = currentImg - 1;
    		}
    	});
    }    
    
    
    /* WALKTROUGH */
    $('#walkDescMap').css("opacity","0");
    $('#walkDescArrows').css("opacity","0");
    $('#walkBackgroundMap').hover(function() {
    	$('#walkDescMap').stop().animate({opacity:1},{duration:100});
    	$('#walkDescArrows').stop().animate({opacity:0},{duration:10});  
    }, function() {
    	$('#walkDescMap').stop().animate({opacity:0},{duration:4000});   	
    });
    $('#walkForegroundBottomLeft').hover(function() {
    	$('#walkDescArrows').stop().animate({opacity:1},{duration:100});
    	$('#walkDescMap').stop().animate({opacity:0},{duration:10}); 
    }, function() {
    	$('#walkDescArrows').stop().animate({opacity:0},{duration:4000});    	
    });
    
 /*
	var hoverTimeMainNavi = 300;
	$("a").find(".mainNaviHover").each(function(i) {
		$(this).hover(function() {
			$(this).stop().animate({opacity:1},{duration:hoverTimeMainNavi});
		}, function() {
			$(this).stop().animate({opacity:0},{duration:hoverTimeMainNavi});
		});
	});	*/
    
});


//////////////////////////////////////////////////
// function to make display block or none
//////////////////////////////////////////////////
function switchlayer(Layer_Name) {
	$("div#" + Layer_Name).toggle("fast");
}

//////////////////////////////////////////////////
// function to public/depublic news
//////////////////////////////////////////////////
function publicNews(url,id) {
	location.href=url + '&public=' + id;
}

//////////////////////////////////////////////////
// function to delete News
//////////////////////////////////////////////////
function deleteNews(url,id,headline) {
	var reply = false;
	reply = confirm("Soll der Newsfeed '" + headline + "' endgültig gelöscht werden?");
	
	if (reply == true) {
		location.href=url + '&delete=' + id;
	} else {
		location.href=url;
	}
}

var currentImage = 'imageKgGudrun';
//////////////////////////////////////////////////
// function tswitch images
//////////////////////////////////////////////////
function heilmittelSwitchImages(Layer) {
	if(Layer != currentImage) {
		$('div#' + currentImage).fadeOut('fast');
		$('div#' + Layer).fadeIn('slow');
		currentImage = Layer;
	}
}

//////////////////////////////////////////////////
// galery
//////////////////////////////////////////////////
function addImage(desc,id) {
	var i = images.length
	images[i] = new Array();
	images[0] = desc;
	images[1] = id;
	
	if(i > 0) {
		$('div#imageBig' + i).hide();
	}
}
//////////////////////////////////////////////////
// showGaleryImage
//////////////////////////////////////////////////
function showGaleryImage(id) {
	if(currentImg != id) {
    	$('div#imageBig' + currentImg).hide("fast");
  		$('div#imageBig' + id).show("fast");
		currentImg = id;
	}
}

