jQuery(function($) {

    $.slider();
	
	$('#ctCont .details a').lightBox({
		overlayOpacity: 0.9,
		imageLoading: template_directory+'/css/images/lightbox-ico-loading.gif',
		imageBtnPrev: template_directory+'/css/images/arrBtnPrev.gif',
		imageBtnNext: template_directory+'/css/images/arrBtnNext.gif'
	});
	
	$('ul.timeLine a').click(function() {
									  
		$('ul.timeLine a').each(function() {
			var year = $(this).children('span').text();	
			$(this).addClass('highlight').html('<span class="highlight">'+year+'</span> &raquo;');
		});		
		
		var year = $(this).children('span').text();
		
		$(this).removeClass('highlight').html('<span>'+year+'</span>');
		
		$('.yearBox').hide();
		
		$('.year_'+year).show();
		
	});
	
	$('img.JM_thumb').unbind().die().click(function() {
	   
	   $(this).parent().find('.videoscreen').remove();
	   
	   var temp = $(this).siblings('img.JM_preview').attr("src");
	   
	   
	   // temp = temp.substr(0,temp.length-5);
	   temp = temp.split("/");
	   temp.pop();
	   temp = temp.join("/");
	   
	   var name = $(this).attr("title")+".jpg";
	   var path = temp.replace(/^\s+|\s+$/g,"")+"/"+name.replace(/^\s+|\s+$/g,"");
	   
	   $(this).parent().find('.JM_preview').attr("src",path);
	});
	
	$('div.videoplayer').unbind().die().click(function() {
       
       $(this).parent().find('.videoscreen').remove();
       var filename = $(this).attr("rel").replace(/^\s+|\s+$/g,"");
       $(this).parent().prepend('<script type="text/javascript">'
                                +'  var flashvars = { videoSource: "http://www.kirstengeisler.com/wp-content/themes/KirstenGeisler/video/'+filename+'"};'
                                +'  var params = { menu : "true", wmode : "transparent", allowfullscreen : "true", allowscriptaccess : "always"};'
                                +'  var attributes = { id:"'+filename+'", name:"app" };'
                                +'  swfobject.embedSWF("http://www.kirstengeisler.com/wp-content/themes/KirstenGeisler/swf/player.swf", "'+filename+'", "502", "340", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);'
                                +'</script>'
                                +'<div class="videoscreen"><div id="'+filename+'"></div></div>');
    });
	
});
