$(function(){

    var input = $('input#s');
    var divInput = $('div.input');
    var width = divInput.width();
    var outerWidth = divInput.parent().width() - (divInput.outerWidth() - width) - 28;
    var submit = $('#button');
    var txt = input.val();
    
    input.bind('focus', function() {
        if(input.val() === txt) {
            input.val('');
        }
        $(this).animate({color: '#000'}, 300); // text color
        $(this).parent().animate({
            width:  '150px',
            backgroundColor: '#fff', // background color
            paddingRight: '0px'
        }, 300, function() {
            if(!(input.val() === '' || input.val() === txt)) {
                if(!($.browser.msie && $.browser.version < 9)) {
                    submit.fadeIn(300);
                } else {
                    submit.css({display: 'block'});
                }
            }
        }).addClass('focus');
    }).bind('blur', function() {
        $(this).animate({color: '#b4bdc4'}, 300); // text color
        $(this).parent().animate({
            width: '70px',
            backgroundColor: '#e8edf1', // background color
            paddingRight: '0px'
        }, 300, function() {
            if(input.val() === '') {
                input.val(txt)
            }
        }).removeClass('focus');
        if(!($.browser.msie && $.browser.version < 9)) {
            submit.animate(100);
			  width: '70px'
        } else {
            submit.css({display: 'none'});
        }
    }).keyup(function() {
        if(input.val() === '') {
            if(!($.browser.msie && $.browser.version < 9)) {
                submit.animate(300);
				  width: '70px'
            } else {
                submit.css({display: 'none'});
            }
        } else {
            if(!($.browser.msie && $.browser.version < 9)) {
                submit.animate(300);
				  width: '70px'
            } else {
                submit.css({display: 'block'});
            }
        }
    });
});
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


$(document).ready(function(){
$(".dark_blue_button").fadeTo("fast", 1.0); 
$(".dark_blue_button").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});

$(".dark_blue_button-large").fadeTo("fast", 1.0); 
$(".dark_blue_button-large").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});

$(".tws_play_button").fadeTo("fast", 1.0); 
$(".tws_play_button").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});

$(".play_button").fadeTo("fast", 1.0); 
$(".play_button").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});

$(".small_play_button_padding").fadeTo("fast", 1.0); 
$(".small_play_button_padding").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});


$(".dark_blue_a_css_button").fadeTo("fast", 1.0); 
$(".dark_blue_a_css_button").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});

$(".dark_blue_a_c_d_css_button").fadeTo("fast", 1.0); 
$(".dark_blue_a_c_d_css_button").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});


$(".button_hl").fadeTo("fast", 1.0); 
$(".button_hl").hover(function(){
$(this).fadeTo("fast", 0.8); 
},function(){
$(this).fadeTo("fast", 1.0); 
});

$(".abs_header .header_inner .header_right form table tr td #button").fadeTo("fast", 1.0); 
$(".abs_header .header_inner .header_right form table tr td #button").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});



$(".social_ic").fadeTo("fast", 1.0); 
$(".social_ic").hover(function(){
$(this).fadeTo("fast", 0.7); 
},function(){
$(this).fadeTo("fast", 1.0); 
});


$("#introduction_video").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'scrolling'			: 'no',
			'transitionOut'	: 'fade',
			'title'			: this.title,
			'width'		: 670,
			'height'		: 400,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'			: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

	return false;
});

$(".video_iframe").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'scrolling'			: 'no',
			'transitionOut'	: 'fade',
			'title'			: this.title,
			'width'		: 670,
			'height'		: 400,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'			: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

	return false;
});

$("#twvt").click(function() {
$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'scrolling'			: 'no',
			'transitionOut'	: 'fade',
			'title'			: this.title,
			'width'		: 670,
			'height'		: 400,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});

$(".rst_video").click(function() {
$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'scrolling'			: 'no',
			'transitionOut'	: 'fade',
			'title'			: this.title,
			'width'		: 670,
			'height'		: 400,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});



$("#email_pop_up_iframe").fancybox({
			'padding'		: 	0,
			'autoScale'		: true,
			'scrolling'		: 'no',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade'
});
	$("#show_more_info").fancybox({
			'padding'		: 	0,
			'autoScale'		: true,
			'scrolling'		: 'no',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade'
});

$("#email_pop_up_footer").fancybox({
			'padding'		: 	0,
			'autoScale'		: true,
			'scrolling'		: 'no',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade'
});
	
	
	
$("#become_extra_member").fancybox({
			'padding'		: 	0,
			'autoScale'		: true,
			'scrolling'		: 'no',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade'
});
	
	
$("#become_extra_member_footer").fancybox({
			'padding'		: 	0,
			'autoScale'		: true,
			'scrolling'		: 'no',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade'
});
	
	
$(".default_pop_up").fancybox({
			'padding'		: 	0,
			'autoScale'		: true,
			'scrolling'		: 'no',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade'
});

$("#show_info").fancybox({
			'padding'		: 	0,
			'autoScale'		: true,
			'scrolling'		: 'no',
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade'
});
	
});

(function($) {

	var defaults = {};

	$.fn.fixedscroll = function(opts) {

		var options = $.extend(defaults, opts);

		var el = $(this);
		if (el.css('position') !== 'fixed') return;
		
		var lockPosition =  options.lockElement.offset().top - el.outerHeight();
		var offsetTop = options.offset.top || 0;

		$(window).bind('load scroll', function(e) {

			if ($(window).scrollTop() + offsetTop >= lockPosition) {
				el.css({ position: "absolute", top: lockPosition });
			} else {
				el.css({ position: "fixed", top: offsetTop });
			}
		});
	};

})

