// Prevent conflict with other js libraries (e.g. prototype.js)
jQuery.noConflict();

jQuery(document).ready(function(){
	
	// Epi Lightbox
	jQuery('a.lrlink').removeAttr('href');
	jQuery('div.lrThumb').click(function()
	{
		var arrayPageScroll = document.viewport.getScrollOffsets();
		var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
		jQuery('div.splashLightRoom').css('margin-top', lightboxTop);
		jQuery(this).parent('div.lrItem').next('div.splashScreenLightRoom').show();
		jQuery(this).parent('div.lrItem').next('div.splashScreenLightRoom').next('div.screen').show();
		jQuery('div.lrImage').load(
			"typo3conf/ext/epi_lightbox/pi1/ajax.php",
			{
				url: jQuery(this).attr('ajurl')
			}
			);
	}
	);
	
	jQuery('div.splashScreenLightRoom').click(function()
	{
		jQuery(this).hide();
		jQuery(this).next('div').hide();
		jQuery(this).children('div.lrImage >img').remove();
	}
	);
	
	
	// slide cal events
	jQuery('.event-content').hide();
  		jQuery('.event-item').click(function()
    	{
      		jQuery(this).next('.event-content').slideToggle().parent().siblings('div').find('.entry:visible').slideUp();
    	});

	// slide management content 	
	jQuery('h6').siblings().hide();
	jQuery('h6').hover(
		function()
			{
				jQuery(this).css('color', '#b49632');
			},
		function(){
			jQuery(this).css('color', '#80898a');
		}
		
	);
	jQuery('h6').click(function()
		{	
			// hide alle open Elements
			jQuery(this).parent().siblings('div').children('h6').siblings().slideUp();
			jQuery(this).siblings().slideToggle(100);
		}
	);
	
	// slide publications	
	jQuery('div.pubHead').siblings().hide();
	jQuery('div.bibData').hover(
		function()
			{
				jQuery(this).css('color', '#b49632');
			},
		function(){
			jQuery(this).css('color', '#80898a');
		}
		
	);
	jQuery('div.bibData').click(function()
		{	
			jQuery(this).parent().siblings().slideToggle(100);
		}
	);
	
	// Publications
	// Hide Login Box
	jQuery('div.tx-txpublicationslist-pi1 > div#splashScreen').hide();
	jQuery('img.downLinkHidden').click(function() 
		{
			jQuery(this).parents('.tx-txpublicationslist-pi1-listrow').siblings('#splashScreen').show();
		}
	);
	jQuery('div.bibDataLink').click(function() 
		{
			jQuery(this).parents('.tx-txpublicationslist-pi1-listrow').siblings('#splashScreen').show();
		}
	);
	
	jQuery('span.close').click(function() 
		{
			jQuery(this).parents('#splashScreen').hide();
		}
	);
	
	
	// SPLASH SCREEN
	// install
	//jQuery("div#footer").append('<div id="splashScreen"><div id="splash"><div id="stepOne"><h1>Please Select Your Location</h1><p><a id="us" style="cursor: pointer;">Within the United States</a></p><p><a id="int" style="cursor: pointer;">International</a></p></div><div id="stepTwo"><h1>Information for Domestic U.S. customers</h1><p>I acknowledge that the products Epi <i>pro</i>Colon and Epi <i>pro</i>Lung<br> are currently not sold in the U.S.</p><p><span class="button">CONTINUE</span></p></div></div>');
	
	// switch steps on splash screen
	
	if(jQuery.cookie("epiAcknowledgement") != 'ackColon') {
		jQuery('div#splashScreenColon').show();
	}
	
	if(jQuery.cookie("epiAcknowledgement") != 'ackLung') {
			jQuery('div#splashScreenLung').show();
		}
	
	if(jQuery.cookie("epiAcknowledgementProgress") != 'ackProgress') {
			jQuery('div#splashScreenProgress').show();
	}
	
	if(jQuery.cookie("epiAcknowledgementKapital") != 'ackKapital') {
			jQuery('div#splashScreenKapital').show();
	}
	
	jQuery('div#stepTwo').hide(); // hide stepTwo
	
	jQuery('a#intLung').click(function()
		{
			jQuery.cookie("epiAcknowledgement", "ackLung", { expires: 7 }); // set cookie epi:ack
			jQuery('#splashScreenLung').remove(); // and remove splashScreen
		}
	);
	
	jQuery('a#intProgress').click(function()
		{
			jQuery.cookie("epiAcknowledgementProgress", "ackProgress", { expires: 7 }); // set cookie epi:ack
			jQuery('#splashScreenProgress').remove(); // and remove splashScreen
		}
	);
	
	
	jQuery('a#intColon').click(function()
		{
			jQuery.cookie("epiAcknowledgement", "ackColon", { expires: 7 }); // set cookie epi:ack
			jQuery('#splashScreenColon').remove(); // and remove splashScreen
		}
	);
	
	jQuery('a#int').click(function()
		{
			jQuery.cookie("epiAcknowledgement", "ack", { expires: 7 }); // set cookie epi:ack
			jQuery('#splashScreen').remove(); // and remove splashScreen
		}
	);
	
	jQuery('a#us').click(function()
		{
			jQuery('#stepOne').hide();
			jQuery('#stepTwo').show();
		}
	);
	
	jQuery('span.button').click(function()
		{
			jQuery.cookie("epiAcknowledgement", "ack", { expires: 7 }); // set cookie epi:ack
			jQuery('div#splashScreen').remove(); // and remove splashScreen
		}
	);
	
	jQuery('span.buttonLung').click(function()
		{
			jQuery.cookie("epiAcknowledgement", "ackLung", { expires: 7 }); // set cookie epi:ack
			jQuery('div#splashScreenLung').remove(); // and remove splashScreen
		}
	);
	
	jQuery('span.buttonColon').click(function()
		{
			jQuery.cookie("epiAcknowledgement", "ackColon", { expires: 7 }); // set cookie epi:ack
			jQuery('div#splashScreenColon').remove(); // and remove splashScreen
		}
	);
	
	jQuery('span.buttonProgress').click(function()
		{
			jQuery.cookie("epiAcknowledgementProgress", "ackProgress", { expires: 7 }); // set cookie epi:ack
			jQuery('div#splashScreenProgress').remove(); // and remove splashScreen
		}
	);
	
});
