
(function ($) {
  // add tabs ui
  $(document).ready(function(){ 
    $('#vision-tabs').tabs();
  });
  
  // add in more drop down for tab content 
  $(document).ready(function(context) {
    $('#vision-tabs .view-more a, #section-roadmap .view-more a')
      .click(function(event){
        event.preventDefault();
        $(this).parent().next().toggleClass('hide');    
      });
  });
  
  // form dropdown and pre-populate the comment
  $(document).ready(function(){
    $('#section-community .join-options-wrapper .join-option').click(function(){
      $('#join-form-wrapper-outer-thanks').addClass('hide');
      $id_value = $(this).attr('id');
      $(this).parent().next()
        .find('#00N600000022P3z').val("I want to " + $id_value + ":");
    });
  });
  
  // do scrolling.
  $(document).ready(function() {
    $('#header').localScroll({
      axis: 'y',
      duration: 500
    });
  });

  // handle thankyou page after form submission.
  $(document).ready(function() {
    if(window.location.hash == '#thankyou') {
      $.scrollTo($('#community-anchor'));
      $('#join-form-wrapper-outer').addClass('hide');
      $('#join-form-wrapper-outer-thanks').removeClass('hide');
    }
  });

  // use fancybox for the lightboxes
  $(document).ready(function(){
    $("#op-download").fancybox({
      'width':730,
      'height':620,
      'type': 'iframe'
    });
  });

  $(document).ready(function(){
    $("#letmeknowform a").fancybox({
      'width':650,
      'height':450,
      'type': 'inline'
    });
  });
  // Add By Mehul as on 22-4-2011
   $(document).ready(function(){
    $("a[rel='casestudies'] , a[rel='casestudies_thumb'] , a[rel='products'] , a[rel='products_thumb'] ").fancybox();
  });
// Add By Mehul as on 22-4-2011

  $(document).ready(function() {
    $("#letusknow-email").bind('change', function(){
      $("#loop-form #email").val($("#letusknow-email").val());
    });
  });
  
  // fancybox vimeo links
  $(document).ready(function() {
  	$("#section-vision .vision-video a.vimeo").click(function() {
  		$.fancybox({
  			'padding'		: 0,
  			'autoScale'		: false,
  			'transitionIn'	: 'elastic',
  			'transitionOut'	: 'none',
  			'title'			: this.title,
  			'width'			: 601,
  			'height'		: 338,
  			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
  			'type'			: 'swf'
  		});
   
  		return false;
  	});


	$('#two').ContentSlider({
		width : '1020px',
		height : '378px',
		speed : 400,
		easing : 'easeOutQuad',
		textResize : true
	});

	var autoslide = setInterval(headline_rotate, 5000);

	$("#two").hover(function() {
	clearInterval(autoslide);
	}, function() {
	autoslide = setInterval(headline_rotate, 5000);
	});

	function headline_rotate() {
	$leftD = $(".cs_leftBtn").css("display");
	$rightD = $(".cs_rightBtn").css("display");
	if($leftD == "none"){
	$dir = "goRight";
	}
	if($rightD == "none"){
	$dir = "goLeft";
	}
	($dir == "goRight") ? $curButt=".cs_rightBtn" : $curButt=".cs_leftBtn";
	$($curButt).trigger("click");
	}

  });
  
  $(document).ready(function(){
    $('#op-download').click(function() {
      _gaq.push(['_trackEvent', 'download', 'Initial Download Click', 'php']);
    });
  });
  
})(jQuery);;

