$(document).ready(function(){


// PAGE LOAD EFFECTS
	
	$('#main_wrapper').hide().fadeIn(1000);
	
	
// NAVIGATION

	$(function(){
	  
	  // Bind an event to window.onhashchange that, when the hash changes, gets the
	  // hash and adds the class "selected" to any matching nav link.
	  $(window).hashchange( function(){
		
		// Hide all the content divs - hiding all of them instead of just visible ones compensates for really fast clicking
		$('#content').children().fadeOut(350).css({"display":"none"});
		$('.success').hide();
	
		// Set hash to either the current location's hash or, failing that, the id of the first div inside #main-content		
		var hash = window.location.hash || '#' + $('#content :first-child').attr('id');;
		
		// Get the clicked menu item
		var clickedLink = $('#main_links ul li a[href=' + hash + ']');
		
		// Get the class of the clicked menu item	
		var linkClass = clickedLink.attr('class');
		
		// Remove the active class from all the menu items
		$('#main_links ul li a').removeClass('active');
		
		// Add the active class to the clicked item
		clickedLink.addClass('active');
		
		// Show the content div with the same id as the selected menu item's class name
		$(hash).hide().fadeIn(350);
	  
	  
	  	
	  })
	  // Since the event is only triggered when the hash changes, we need to trigger
	  // the event now, to handle the hash the page may have loaded with.
	  $(window).hashchange();
	  
	});

	
// NAV HOVER EFFECTS 
	$("#main_links ul li a").hover(
	function() {		
		$(this).stop().animate({"color":"#fff"}, 300);
	},
	function() {
		$(this).stop().animate({"color":"#96967a"}, 300);
	});
	
// CONTENT HOVER EFFECTS 

	$('#content a').hover(function() {
		$(this).stop().animate({"color":"#96967a"}, 150);
		
	},
	function() {
		$(this).stop().animate({"color":"#666"}, 150);
	});


	
	
// IMAGE SLIDER

	
	$('#game_dev_slider').hide();
	$('.arrow_wrapper2').hide();
	$('.cycle_next2').hide();
	$('.cycle_prev2').hide();
	$('#web_dev_btn').css({"color":"#fff"});
	
	$('#web_dev_btn').bind('click', function() {
		$('#web_dev_slider').show();
		$('.arrow_wrapper').show();
		$('.cycle_next').show();
		$('.cycle_prev').show();
		$('.arrow_wrapper2').hide();
		$('.cycle_next2').hide();
		$('.cycle_prev2').hide();
		$('#game_dev_slider').hide();
		$('#web_dev_btn').css({"color":"#fff"});
		$('#game_dev_btn').css({"color":"#96967a"});
	});
	
	$('#game_dev_btn').bind('click', function() {
		$('#web_dev_slider').hide();
		$('.arrow_wrapper').hide();
		$('.cycle_next').hide();
		$('.cycle_prev').hide();
		$('.arrow_wrapper2').show();
		$('.cycle_next2').show();
		$('.cycle_prev2').show();
		$('#game_dev_slider').show();
		$('#game_dev_btn').css({"color":"#fff"});
		$('#web_dev_btn').css({"color":"#96967a"});
	});
	
	$('.websites, #web_dev_slider .slider_text_wrapper').cycle({fx:'fade',
		next: '.cycle_next',
		prev: '.cycle_prev',
		timeout:0
	});
	
	$('.music, #music_group .slider_text_wrapper').cycle({fx:'fade',
		next: '.cycle_next3',
		prev: '.cycle_prev3',
		timeout:0
	});
	
	$('.games, #game_dev_slider .slider_text_wrapper').cycle({fx:'fade',
		next: '.cycle_next2',
		prev: '.cycle_prev2',
		timeout:0
	});

// CONTACT FORM
	var options = { 
        //target:        '#output1',   // target element(s) to be updated with server response 
        //beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
 
        // other available options: 
        url:       'contact_form.php',        // override for form's 'action' attribute 
        type:      'post',        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        clearForm: true,        // clear all form fields after successful submit 
        resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 

	$('#contact_form').ajaxForm(options);
	function showResponse() {
    	$('.success').show().fadeIn(150); 
	};
	

//GA
	var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-24978872-1']);
  _gaq.push(['_setDomainName', '.katbella.com']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
	  
});
