/******************************************************************/
/* © DMC 01 Consulting & Development GmbH - gerald.urbas@dmc01.at */
/******************************************************************/
/* www.jquery.com based scripts for ARD Videoportal               */
/******************************************************************/
/* The kalender provides 2 major funcitons rewrite of             */
/* special "multi" hrefs to show layer with more Movie links      */
/* Deefine Jumps through major periods (Morinin to Night)         */
/******************************************************************/

$(document).ready(function() {// Page is ready
	
	function onPopupLoad() { // set close button
		$("#popup .close").bind( // find close button in ppup
	    'click',
	    function() {
				$("#modalLayer").remove(); // remove Layer prevetning clicks / hovers
				$("#popup").remove(); // remove the popup
	    }
		)
	}
	
	/* set opener for multiple broadcasts */
	$(".multi").bind( // bind click
    'click',
    function()
    {		
    	$(".modCalendar").append("<div id='popup'></div>"); // append popup layer
    	$(".modCalendar").append("<div id='modalLayer'></div>"); // generate modal layer (prevetns clicks and hovers
    	loading($("#popup")); // set laoding anim
			$('#popup').load($(this).attr('href'),null,onPopupLoad); // wen popup is loaded generate close button
			return false; //don't follow href
    }
  )	
	
	/* set period scrolling -  read positions and sets button clicks ion the left sided  major periods*/
	$("#p1").bind('click', function()
    {				
    	var offsetTop = parseInt($("#period1").offset().top - parseInt($("#entriesPane").offset().top));      	     	
    	$("#entriesPane")[0].scrollTo(offsetTop);          
    }
  )
	$("#p2").bind('click', function()
    {				
    	var offsetTop = parseInt($("#period2").offset().top - parseInt($("#entriesPane").offset().top));      	     	
    	$("#entriesPane")[0].scrollTo(offsetTop);          
    }
  )
	$("#p3").bind('click', function()
    {				
    	var offsetTop = parseInt($("#period3").offset().top - parseInt($("#entriesPane").offset().top));      	     	
    	$("#entriesPane")[0].scrollTo(offsetTop);          
    }
  )
	$("#p4").bind('click', function()
    {				
    	var offsetTop = parseInt($("#period4").offset().top - parseInt($("#entriesPane").offset().top));      	     	
    	$("#entriesPane")[0].scrollTo(offsetTop);          
    }
  ) 

	/* set popup calendar */  
	$('#inputDate').calendar();
	popUpCal.minDate = timeRange[0];
	popUpCal.maxDate = timeRange[1];
   
  
}); // Page is ready
