$(document).ready(function(){
		
		$('#home-vid-thumb').click( function() {openVid(); return false; }  );
		
		
		//Clear the input text on focus
		var clearMePrevious = '';
	
		// clear input on focus
		$('.email').focus(function() {
			if($(this).val()==$(this).attr('title')) {
				clearMePrevious = $(this).val();
				$(this).val('');
			}
		});
		
		// if field is empty afterward, add text again
		$('.email').blur(function() {
			if($(this).val()=='') {
				$(this).val(clearMePrevious);
			}
		});

});

openVid = function () {
	
	var title, embed,
	scroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	
	
	title = 'Watch What Our Visitors Had To Say'; 
	embed = '<iframe width="700" height="395" src="http://www.youtube.com/embed/V9Qz_HCiUt4" frameborder="0" allowfullscreen></iframe>';
	
   	if(!$.browser.msie) {
   		
   		$('body').append('<div id="vid-wrap"><div id="vid"><h1><a id="close">close</a><em>'+title+'</em></h1>'+embed+'</div></div><div id="overlay"></div>');
   		
   		$('#overlay').css({ opacity: 0, display: 'block' }).height( $('body').height() ).fadeTo('300', 1.0, function () { 
   			
			if (scroll > 100) {
				var s = parseInt($('#vid').css('top')) + scroll;
				$('#vid').css( 'top', s );
			}
   			
   			$('#vid-wrap').css({ display: 'block' });
   			$('#close').bind('click', closer);
   			
   		});
		
   	} else {
   		
   		var pop = $('<div/>').html('<div id="vid-wrap"><div id="vid"><h1><a id="close">close</a><em>'+title+'</em></h1>'+embed+'</div></div><div id="overlay"></div>');
   		
   		$('body')[0].innerHTML = $('body').html() + pop.html();
   		
		if (scroll > 100) {
			var s = parseInt($('#vid').css('top')) + scroll;
			$('#vid').css( 'top', s );
		}
   		
   		$('#vid-wrap').css({ display: 'block' });
   		$('#close, #vid-wrap').bind('click', closer); 
   		
   		setTimeout( function () { $('#overlay').css({ display: 'block' }).height( $('body').height() );}, 0);
   	}

}

closer = function () {
	
	$('#overlay, #vid-wrap').remove();
	
}
