////////// GENERAL SCRIPTS //////////

if(typeof sIFR == "function"){
	sIFR.replaceElement("h2", named({sFlashSrc: "h2.swf", sColor: "#ffffff", sWmode:"transparent"}));
};

jQuery(function( $ ){
	$('.main_nav a').click(function(){
		$.scrollTo( this.hash, 3000);
		return false;
	});
});

$(function() {
	$('.main_nav a')
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 -51px)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:300, complete:function(){
				$(this).css({backgroundPosition: "0px 0px"})
			}})
		})
});

////////// SKY //////////

$(function() {
  $('.error').hide();

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
		var themessage = document.getElementById('themessage').value;
		if (themessage == "") {
      $("label#themessage_error").show();
      $("textarea#themessage").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&themessage=' + themessage;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
	});
});
/*
runOnLoad(function(){
  $("input#name").select().focus();
});
*/

////////// OCEAN //////////

$(document).ready(function() {
	$('#featuredvid > ul').tabs({ fx: { opacity: 'toggle' } });
	$('#vid-1 > ul').tabs({ fx: { opacity: 'toggle' } });
	$('#vid-2 > ul').tabs({ fx: { opacity: 'toggle' } });
	$('#graphics a').css({backgroundPosition: "0px -29px"})
	$('#graphics a').click(function(){
		$('#websites a').css({backgroundPosition: "0px 0px"})
		$(this).css({backgroundPosition: "0px -29px"})
	});
	$('#websites a').click(function(){
		$('#graphics a').css({backgroundPosition: "0px 0px"})
		$(this).css({backgroundPosition: "0px -29px"})
	});
});

$(document).ready(function() {
	$("a.fancy").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 300
	});
	$("#g2 a").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 300
	});
	$("#w1 a").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 300
	});
	$("#w2 a").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 300
	});
});
