/* CIARA */
/* Javascript Functions
----------------------------------------------------------------------------- */


	$(document).ready(function() { });


/* POST-LOAD FUNCTION
----------------------------------------------------------------------------- */


	$(window).load(function() {

		killTabs();
		tabs('removeEmptyTabs');
		twitter();
		cufon();
		videoPlayer();
		markup();		
		
		// PLUGIN: CLIQUE FORMS (Adds text into input forms)
		$('#mailing_list_entry_email').cliqueForms({ placeholder: "Enter your e-mail address to receive Ciara updates" });

	});	


/* FUNCTION: TWITTER FEED
----------------------------------------------------------------------------- */


	function twitter() {
	
		$('div.tweets').tweet({
		
        	username: "ciara",
          	count: 5,
          	loading_text: "Loading tweets..."

     	 });
     	 
     	 // Using setTimeout since tweet plugin doesn't have callback
     	 setTimeout(cufon, 1000);
     	 setTimeout(function() {
     	 
			$('#ticker ul.tweet_list').cycle({
	
				speed: 300,
				timeout: 7000
	
			});
     	 
     	 }, 1000);
   	 
	}	
	

/* FUNCTION: CUFON REPLACEMENTS
----------------------------------------------------------------------------- */

	function cufon() {
	
		var geometric_extrabold = [
		
			'h2:not(.markdown h2)',
			'ul.tabs a',
			'ul.faketabs a',
			'div.widget-alert h3',
			'div.sidebar > h3',
			'.section-legal h3',
			'.section-legal h4',
			'div.widget-tag li h4 a',
			'div.widget-tag > h3',
			'#page-biography div.story > h3',
			'#details > h3',
			'#tracks > h3',
			'div.widget-event.display > h4',
			'#video-browse > h3',
			'#lyrics > h3'
					
		];
		
		var geometric_medium = [
		

			
		];

		Cufon.replace(geometric_extrabold, { fontFamily: 'Geometric Extrabold', hover: true });
		Cufon.replace(geometric_medium, { fontFamily: 'Geometric Medium', hover: true });

		$(geometric_extrabold.toString()).css('visibility', 'visible');
		$(geometric_medium.toString()).css('visibility', 'visible');
				
	}	


/* FUNCTION: VIDEO PLAYER
----------------------------------------------------------------------------- */


	function videoPlayer() {
	
		if (page == "index") {
	
			function playVideo() {
			
				var video = $(this).attr('href').replace('index','display');
			
				$('#video-load').empty().load(video, function() {
				
					$('#video').each(function() {
					
						var $this = $(this);
					
						$('#featured').hover(function() {
						
							$this.children('ul.controls').animate({ bottom: '-8px' });
							$this.children('#video > var').animate({ bottom: '19px' });
							$this.children('h3').animate({ top: 0 });
							
							// Internet Explorer
							if (navigator.userAgent.match('MSIE')) {
							
								$this.find('div.flash').children('div').animate({
								
									height: '400px',
									marginTop: '40px',
									marginBottom: '40px'
								
								});
							
							}
			
						}, function() {
						
							$this.children('ul.controls').animate({ bottom: '-65px' });
							$this.children('#video > var').animate({ bottom: '-47px' });
							$this.children('h3').animate({ top: '-65px' });
			
							// Internet Explorer
							if (navigator.userAgent.match('MSIE')) {
			
								$this.find('div.flash').children('div').animate({
								
									height: '480px',
									marginTop: '0',
									marginBottom: '0'
								
								});
							
							}
			
						});
						
					});				

					$('div.widget-media.player').cliquePlayer();
			
				});

				return false;
				
			}

			$('#video-browse ul.clips a').click(playVideo);
			$('#video-browse ul.clips > li:first-child a').each(playVideo);

		
		}
		
		
		if (page == "video") {
	
			$('div.widget-media.player').cliquePlayer();

			$('#video').each(function() {
			
				var $this = $(this);
			
				$('#container #video').hover(function() {
			
					$this.children('ul.controls').animate({ top: '427px' });
					$this.children('#video > var').animate({ top: '446px' });
					$this.children('h3').animate({ top: 0 });
										
					// Internet Explorer
					if (navigator.userAgent.match('MSIE')) {
					
						$this.find('div.flash').children('div').animate({
						
							height: '400px',
							marginTop: '40px',
							marginBottom: '40px'
						
						});
					
					}
	
				}, function() {
				
					$this.children('ul.controls').animate({ top: '493px' });
					$this.children('#video > var').animate({ top: '512px' });
					$this.children('h3').animate({ top: '-65px' });
						
					// Internet Explorer
					if (navigator.userAgent.match('MSIE')) {
	
						$this.find('div.flash').children('div').animate({
						
							height: '480px',
							marginTop: '0',
							marginBottom: '0'
						
						});
					
					}
	
				});
				
			});
		
		}
	
	}
	
	
/* FUNCTION: MARKUP CHANGES
----------------------------------------------------------------------------- */

	function markup() {
	
		//Homepage Editorial Browse links fix
		$("#hotnews ul.actions a.browse").attr("href", "/hotnews/Hot_News");
		$("#fashion ul.actions a.browse").attr("href", "/fashion/Fashion");
		$("#beauty ul.actions a.browse").attr("href", "/beauty/Beauty");
		$("#love ul.actions a.browse").attr("href", "/love/Love");
		$("#fitness ul.actions a.browse").attr("href", "/fitness/Fitness");
		
		//Video page Tags Removal
		$("#video div.details dt:eq(2)").remove();
		$("#video div.details dd:eq(2)").remove();
		
		//Alert replacement
		$('#footer div.widget-alert').prependTo('#page');
		
		Cufon.refresh();

	}	
