/* 
	init.js
	===============================================================
	It's a Sellebration
	Calls Functions
	
	Created 14.04.2009 by DS
	Last Updated: See SVN	
	
	#t-* used to apply template level override of shared styles
	#st-* used to apply sub template level override of shared styles	
	
	To sort, search for '@'		
	Debugging is via the Firebug console: console.debug
  ===============================================================
*/

/*	
	@ $(document).ready
  ---------------------------------------------------------------
	Functions to initialise when the DOM has loaded
	_______________________________________________________________
*/		

	sifr(); // run before document.ready		

	$(document).ready(function() 
	{		
		if (whichbrowser.isHiFi)
		{					
			if ( (whichbrowser.isSafari) && (whichbrowser.isWin) )
			{
				attach_stylesheet('/resources/sellebration/ui/styles/imported/browser/screen-win-safari.css');
			}
			else if ( (whichbrowser.isSafari) && (whichbrowser.isMac) )
			{
				attach_stylesheet('/resources/sellebration/ui/styles/imported/browser/screen-mac-safari.css');
			}			
			
			// cufon
			$('#t-player #content h4 span').text( $('#t-player #content h4 span').text() + ' ' );
			Cufon.replace('#t-player #content h4 span', { fontFamily: 'helveticaNeueRegular' });
			
			//$('#t-player #content h5 span').text( $('#t-player #content h5 span').text() + ' ' );
			Cufon.replace('#t-player #content h5 span', { fontFamily: 'helveticaNeueRegular' });
			Cufon.replace('#t-player #content #discuss legend', { fontFamily: 'helveticaNeueRegular' });
			Cufon.replace('#t-general #content h4 span', { fontFamily: 'helveticaNeueRegular' });
			Cufon.replace('#t-general #content h5 span', { fontFamily: 'helveticaNeueRegular' });
		
		
			// sifr
			// add a clearing element, as the flash embeds are floated to allow for several movies (text and date category)
			
			$('#content').find('.header h4')
			.append(
				$('<div/>')
				.addClass('clear')
			);										
		
			var body_id = $('body').attr('id');					
		
			//console.debug( "$('body').attr('id') = ", body_id );												
			
			// faux noscript, to work around noscript nesting/validation issues
			$('.noscript')
			.addClass('access');		
			
			generate_ad_player();						
			
			add_curves('#t-player .tvcs'&&'#t-general .tvcs');
			
			listener_textfields();																										
			
			add_curves();		
						
			// IE fixes		
			ie_keyboard_access();							

			tvc_frame_hovers();	
			
			// preloaders - LAST!
			listener_fg_hover_states_incl_preload('#primary-nav a img');	
			listener_fg_hover_states_incl_preload('#back-nav a img');				
			
			listener_fg_hover_states_incl_preload('button img');			
			$('<img/>').attr('src', '/resources/sellebration/ui/images/flash/i-like-this.gif');
			
			if ( (whichbrowser.isSafari) && (whichbrowser.isMac) )
			{
				$('<img/>').attr('src', '/resources/sellebration/ui/images/flash/i-like-this.png');				
			}
			
			preload_bg_images();						
		}
	});	
