// JavaScript Document

function loadWork(catID, ancr) {
	$.ajax({
		type: "POST",
		url: 'http://www.david-philip.com/wp-content/themes/davidphilip/getwork.php',
		data: ({'cat' : catID}),
		beforeSend: function(ahx) {
			setActive(catID);
			$('#loader').css('visibility', 'visible');
  		},
		success: function(data) {
			$('#content-work').html(data);
  		},
		complete:function(){
			$('#loader').css('visibility', 'hidden');
			
			var adr = window.location.href.split("?");
			
			if (ancr != "") {
				window.location.href = ancr;
			}
		} 
	});
};

function setLoader(state) {
	if (state) {
		$('#loader').css('visibility', 'visible');
	} else {
		$('#loader').css('visibility', 'hidden');
	}
}

function setActive(id) {
	$(".catblock").each(function() {
		$(this).removeClass('cat-active');
		$(this).addClass('inactive');
	});
	
	$('#cat-'+id).addClass('cat-active');
	
	$('.cats').ready(function () {
		setNavigation();
	});
}

function setNavigation() {
	$(".catblock h3 a").each(function(){
		$(this).mouseover(function() {
			$(this).css('color', '#ED1E79');
		});
	});
	
	$(".inactive h3 a").each(function(){
		$(this).mouseout(function() {
			$(this).css('color', '#999999');
		});
	});
}

$(window).load(function () {
	setNavigation();
});

$(document).ready(function(){			   
	//Examples of how to assign the ColorBox event to elements
	var _self = this;
	
	$("a[rel='cb_image']").colorbox();
	$(".cb_image").colorbox();
	//$(".cb_youtube").colorbox({width:"43.75%", height:"56.25%", iframe:true});
	$(".cb_youtube").colorbox({innerWidth:"810px", innerHeight:"460px", iframe:true});
	//$("#navigation li").blend();
	$(".tickets a img").mouseover(function() {
		$(this).attr('src', 'http://www.david-philip.com/wp-content/themes/davidphilip/images/tickets_hover.png');
		$(this).attr('width', '663');
		$(this).attr('height', '307');
		
		$("#navigation").css('margin-right', '-394px');
		
	});
	
	$(".tickets a img").mouseout(function() {
		$(this).attr('src', 'http://www.david-philip.com/wp-content/themes/davidphilip/images/tickets.png');
		$(this).attr('width', '375');
		$(this).attr('height', '307');
		
		$("#navigation").css('margin-right', '-106px');

	});
});
