//-------------------DATEPICKER-------------------------------------------------


/* German initialisation for the jQuery UI date picker plugin. */
/* Written by Milian Wolff (mail@milianw.de). */
jQuery(function($){
	$.datepicker.regional['de'] = {
		closeText: 'schließen',
		prevText: '&#x3c;zurück',
		nextText: 'Vor&#x3e;',
		currentText: 'heute',
		monthNames: ['Januar','Februar','M&auml;rz','April','Mai','Juni',
		'Juli','August','September','Oktober','November','Dezember'],
		monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
		'Jul','Aug','Sep','Okt','Nov','Dez'],
		dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
		dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		weekHeader: 'Wo',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['de']);
});





$(document).ready(function() {
	$("#datepicker").datepicker({
		beforeShowDay: eventDays,
		onSelect: loadEvent
	});	
function eventDays(date) {
	var today = new Date();
	today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
	for (i = 0; i < events.length; i++) {
		//console.log('M',date.getMonth() , parseInt(events[i][0],10) - 1 ,'D', date.getDate() , parseInt(events[i][1],10) ,'Y', date.getFullYear() , events[i][2]);    	
		if (date.getMonth() == parseInt(events[i][0],10) - 1 && date.getDate() == parseInt(events[i][1],10) && date.getFullYear() == events[i][2]) {
			return [true, "event", events[i][3]];
			console.log(events[i][3]);
		}
	}
	return [true, ""];
}

function loadEvent(date) {
	var d = date.split('.');
	//document.location.href = 'termine.html?year='+d[2]+'&month='+d[0]+'&day='+d[1]
	$('#termindetail').load('index.php?id=727&year='+d[2]+'&month='+d[1]+'&day='+d[0]);
}	
	
});

//----------------------------------------------------------------------------------




//--------------------------------NEWS SLIDE NACH UNTEN-----------------------------

$(document).ready(function() {
		$('div.start_papier:gt(0)').hide();
		$('span.toggle:gt(0)').css({"padding-bottom": "15px"});

			$("span.toggle, div.news_datum, div.news_title").click(function() {
				 $(this).nextAll("div.start_papier:first").slideDown("normal").siblings('div.start_papier:visible').slideUp('normal');
				 $(this).nextAll("div.start_papier_rand:first").slideDown("normal").siblings('div.start_papier_rand:visible').slideUp('normal');				 
				 
				 $(this).nextAll('span.toggle').css({"padding-bottom": "15px"});
				 $(this).siblings('span.toggle').css({"padding-bottom": "15px"});
				 $(this).andSelf().css({"padding-bottom": "0px"});
				 $(this).nextUntil('div.start_papier').css({"padding-bottom": "0px"});
				 }
			);
		

			$("span.toggle").hover(
				function() {
					$(this).css({"font-style": "normal", "cursor": "pointer"});
				},
				function() {
					$(this).css({"font-style": "normal", "cursor": "auto"});
				}
			);

			$("div.news_title, div.news_datum").hover(
				function() {
					$(this).css({"cursor": "pointer"});
				},
				function() {
					$(this).css({"cursor": "auto"});
				}
			);
		}
	);

//-------------------------------------------------------------
	
	
	
	
//----------------------SHADOWBOX INITIALIZE--------------------
	var shadowBoxMimeMap ={
		img:		['png', 'jpg', 'jpeg', 'gif', 'bmp'],
		swf:		['swf'],            	flv:		['flv', 'm4v', 'mp4'],            	
		qt:			['dv', 'mov', 'moov', 'movie', 'mp4'],            	
		wmp:		['asf', 'wm', 'wmv'],            	
		qtwmp:		['avi', 'mpg', 'mpeg'],            	
		iframe:		['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php', 'php3', 'php4', 'php5', 'phtml', 'rb', 'rhtml', 'shtml', 'txt', 'vbs', 'java']            
	};			
	Shadowbox.init({				
		language:   "de",				
		players:    ["img", "flv", "swf"],				
		handleOversize: "resize",						
		ext: shadowBoxMimeMap	
	});		
//---------------------------------------------------------------------





//----------------------------HEADER ZEUG------------------------------
	var urlAddress = "http://www.bzoe.at"; 
	var pageName = "Bündnis Zukunft Österreich"; 
	function addToFavorites() { if (window.external) { window.external.AddFavorite(urlAddress,pageName) 
	} else { alert("Sorry, dein Browser unterstützt diese Funktion nicht."); 
	} }

	
//--------------------------------------------------------------------
	
	
//-------------------------MOBILE UNTERSTÜTZUNG------------------------

		$(document).ready(function() {
	//-------- Mobile Phone Unterstützung - .main_team
		$(".main_team").click(function() {
			$(".main_team li").addClass("mob_open");  
		});
		$(".main_team").mouseout(function() {
			$(".main_team li").removeClass("mob_open"); 
		});
		
	//-------- Mobile Phone Unterstützung - .main_politik	
		$(".main_politik").click(function() {
			$(".main_politik li").addClass("mob_open");  
		});
		$(".main_politik").mouseout(function() {
			$(".main_politik li").removeClass("mob_open"); 
		});
		
	//-------- Mobile Phone Unterstützung - .main_mitmachen	
		$(".main_mitmachen").click(function() {
			$(".main_mitmachen li").addClass("mob_open");  
		});
		$(".main_mitmachen").mouseout(function() {
			$(".main_mitmachen li").removeClass("mob_open"); 
		});
		
	//-------- Mobile Phone Unterstützung - .main_kontakt
		$(".main_kontakt").click(function() {
			$(".main_kontakt li").addClass("mob_open");  
		});
		$(".main_kontakt").mouseout(function() {
			$(".main_kontakt li").removeClass("mob_open"); 
		});
		
	//-------- Mobile Phone Unterstützung - .main_service
		$(".main_service").click(function() {
			$(".main_service li").addClass("mob_open");  
		});
		$(".main_service").mouseout(function() {
			$(".main_service li").removeClass("mob_open"); 
		});
	});
	
//-------------------------------------------------------------------------
	
	
	
	
$(document).ready(function() {
	 $("#chained").scrollable({circular: true}).navigator().autoscroll({interval: 10000 });
	 
//------------------------------SLIDER FADEN ETC---------------------------	 
//$(document).ready(function() {
//	 $("#chained").scrollable({speed:300, circular: true}).navigator().autoscroll({	interval: 10000 });
//
//	api = $("div.scrollable").scrollable();
//	api.onBeforeSeek(function(event,index){
		/* Use a recursive function approach here, if the image is faded out we will allow advancing to the next slide, which will trigger the onSeek event to fade the slides back in */
//		var element = jQuery("div.scrollable");
//		if (element.css('opacity') == .01) {
//			return true;
//		}
		/* The slide has not yet started fading out, so we will fade the item out */
//		element.fadeTo(150, .01, function(){
			/* Once the fade is complete we will call api.seekTo() to trigger the onBeforeSeek event again, which will now advance the slide because we will be returning true instead of false */
//			api.seekTo(index);
//		});
		// Prevent advancing the slide on the first call to onBeforeSeek
//		return false;
//	}).onSeek(function(){
		// Fade the item back in
//		jQuery("div.scrollable").fadeTo(150, 1);
//		});
//		 */
});

//------------------------------------------------------------------------------------------
