//ON LOAD
$(document).ready(function() {
	$("a.lightbox").colorbox();
/*	
	$("#footer").constantfooter({
	    "opacity": "1",
	    "showclose": false
	});*/
});

//LOAD EVENT FUNCTION
function loadEvent(month, year, i) {	  
	$.ajax({
	   type: "POST",
	   cache: false,
	   url: "/"+urlExtend+"modules/history/ajax/loadEvent.php",
	   data: "month="+month+"&year="+year+"&i="+i,
	   success: function(data){
	     $("#history-box").html(data);
	     $("#historySlider ul li").removeClass('active');
	     $("#historySlider ul li a").removeClass('active');
	     if(month != '') {
	    	 $("#m"+month+"y"+year).addClass('active');
	     }
	     else {
	    	 $(".y"+year+" a:first").addClass('active');
	     }
	     $(".y"+year).addClass('active');
	   }	
	 });
}

//DEEP LINKING
var deepLinking = false;
$.address.autoUpdate(false);
$.address.change(function(event) {
	if(deepLinking || (event.value != '' && event.value != '/')) {
		if(event.value == '/clients/boneberger') {
			event.value = event.value + '/';
		}
		/*$("#deep-content").fadeOut("normal", function() {
			$('#deep-content').load(event.value+"&clear", function() {
				$("#deep-content").fadeIn();
			});
		});*/		
		$("#deep-content").animate({ opacity: 0 }, 300, function() {
			$('#deep-content').load(event.value+"&clear", function() {
				$("#deep-content").animate({ opacity: 1 }, 300);
				$("#officeBox table tbody tr:nth-child(4)").remove(); /// REMOVE THE Mobile: Row from Contact
			});
		});
	}
});

$('a[class*="deep-link"]').address(function() {
	deepLinking = true;
	var href = $(this).attr('href');
	if(href.substr(0,4) == 'http') {
		href = href.substr(href.indexOf('//')+parseInt(2));
		href = href.substr(href.indexOf('/')); 
	}
	$.address.value(href);
	$.address.update();
	
	if($(this).parent().attr('id') == 'overMenu') {
		$("#overMenu a").attr('id', '');
		$("#menu a").attr('id', '');
		$(this).attr('id', 'over_current');
	}

	if($(this).parent().attr('id') == 'menu') {
		$("#overMenu a").attr('id', '');
		$("#menu a").attr('id', '');
		$(this).attr('id', 'menu_current');
	}
	
	if($(this).parent().parent().attr('id') == 'categories') {
		$("#categories li").removeClass('category_current');
		$(this).parent().addClass('category_current');
	}
	
});

//SLIDE LEFT
jQuery.fn.slideLeftHide = function( speed, callback ) { this.animate( { width: "hide", paddingLeft: "hide", paddingRight: "hide", marginLeft: "hide", marginRight: "hide" }, speed, callback ); }
jQuery.fn.slideLeftShow = function( speed, callback ) { this.animate( { width: "show", paddingLeft: "show", paddingRight: "show", marginLeft: "show", marginRight: "show" }, speed, callback ); }

//SHOW STANDORTE
function showStandorte(id) {
	$('#standorte_view').load("/"+urlExtend+"standorten/view/"+id+"?clear2", function() {
		//$('#standorte_list').slideLeftHide();
		$("#standorte_list").animate({'marginLeft' : "-=560px"}, 1000);
	});
}
function showStandortenList() {
	//$('#standorte_list').slideLeftShow();
	$("#standorte_list").animate({'marginLeft' : "+=560px"}, 1000);
}
