$(document).ready(function() {
	init();	
	//$(".b-w").pixastic("desaturate"); // desaturate all images with this class
	$(".biobut").click(function () {
	$(this).siblings('.bio').slideToggle("fast");
	return false;
	});
	
	$('a.tooltip').tooltip();

});

function init(){
$("#roomform").hide();
$(".folderform").hide();
$('#uploadcont').hide();

$("#username").click(function () {
	$('#username').value('');
});


$("#rosternav").click(function () {
$("#roster").slideToggle("fast");
return false;
});

$(".scAbout").click(function () {
	var myoffset = $('#about').offset();
	myypos = myoffset.top - 150;
	$.scrollTo.window().queue([]).stop();
	$.scrollTo( myypos, 500 );
	secondnavup();
	return false;
});


$(".scContact").click(function () {
	var myoffset = $('#contacts').offset();
	myypos = myoffset.top - 150;
	$.scrollTo.window().queue([]).stop();
	$.scrollTo( myypos, 500 );
	secondnavup();
	return false;
});

$(".scArtists").click(function () {
	var myoffset = $('#artists').offset();
	myypos = myoffset.top - 200;
	$.scrollTo.window().queue([]).stop();
	$.scrollTo( myypos, 500 );
	//$('#artists').animate({height:900});
	$('#artists').slideDown("slow");
	$('#secondnav').slideDown("slow");
return false;
});

$(".scLogin").click(function () {
	var myoffset = $('#login').offset();
	myypos = myoffset.top - 149;
	$.scrollTo.window().queue([]).stop();
	$.scrollTo( myypos, 500 );
	secondnavup();
return false;
});

$(".bwimg").mouseenter(function () {
$(this).fadeOut("fast");
return false;
});

$(".colrimg").mouseleave(function() {
    $(".bwimg").fadeIn("fast");
return false;
});


$(".artnav").click(function () {
							 
	var tempid = $(this).parent().attr("id");
	var splitid = tempid.split("_");
	var id = splitid[1];
	var myselector = "#artist_"+id;
		
							 
							 
	var myoffset = $(myselector).offset();
	myypos = myoffset.top - 230;
	$.scrollTo.window().queue([]).stop();
	$.scrollTo( myypos, 500 );
	//$('#artists').animate({height:900});
	$(myselector).slideDown("slow");
	$('#secondnav').slideDown("slow");
	$('.artnav').removeClass('active');
	$(this).addClass('active');
return false;
});



};

/*
$(".sohohome").click(function () {
	
	$("#recentwork").children('.right-column').hide();
	$("#recentwork").children('.right-column').load("bucket/getselected.php");
	$("#recentwork").children('.right-column').fadeIn('slow');
	$("#recentwork").children('.left-column').children('h2').html("SELECTED WORK");
	$.scrollTo( '#recentwork', 500 );
	secondnavup();
	$(".b-w").pixastic("desaturate"); // desaturate all images with this class
	init();
	return false;
});
*/
///// home /////
$(function() {
		$('.sohohome').live("click",function() {					

	
			$.ajax({
				type: "POST",
				url: "bucket/getselected.php",
				success: function(result){
					$("#recentwork").children('.right-column').hide();
					$("#recentwork").children('.right-column').html(result);
					$("#recentwork").children('.right-column').fadeIn("slow");
					$("#recentwork").children('.left-column').hide();
					$("#recentwork").children('.left-column').children('h2').html("SELECTED WORK");
					$("#recentwork").children('.left-column').fadeIn('slow');
					$.scrollTo.window().queue([]).stop();
					$.scrollTo( '#recentwork', 500 );
					secondnavup();
					//$(".b-w").pixastic("desaturate"); // desaturate all images with this class
					init();
					
				}
			});

			return false;
		});
		
});




$(function() {
		$('.getcg').live("click",function() {					
		var id = 1;
		
		
		var string = 'cat_id=' + id;
	
			$.ajax({
				type: "POST",
				url: "bucket/getcg.php",
				data: string,
				success: function(result){
					$("#recentwork").children('.right-column').hide();
					$("#recentwork").children('.right-column').html(result);
					$("#recentwork").children('.right-column').fadeIn("slow");
					$("#recentwork").children('.left-column').hide();
					$("#recentwork").children('.left-column').children('h2').html("SHOWING ALL CG");
					$("#recentwork").children('.left-column').fadeIn('slow');
					$.scrollTo.window().queue([]).stop();
					$.scrollTo( '#recentwork', 500 );
					secondnavup();
					//$(".b-w").pixastic("desaturate"); // desaturate all images with this class
					init();
					
				}
			});

			return false;
		});
		
});

$(function() {
		$('.getdesign').live("click",function() {					
		var id = 5;
		
		
		var string = 'cat_id=' + id;
	
			$.ajax({
				type: "POST",
				url: "bucket/getcg.php",
				data: string,
				success: function(result){
					$("#recentwork").children('.right-column').hide();
					$("#recentwork").children('.right-column').html(result);	
					$("#recentwork").children('.right-column').fadeIn("slow");
					$("#recentwork").children('.left-column').hide();
					$("#recentwork").children('.left-column').children('h2').html("SHOWING ALL DESIGN");
					$("#recentwork").children('.left-column').fadeIn('slow');
					$.scrollTo.window().queue([]).stop();
					$.scrollTo( '#recentwork', 500 );
					secondnavup();
					//$(".b-w").pixastic("desaturate"); // desaturate all images with this class
					init();
				}
			});

			return false;
		});
});

$(function() {
		$('.getfx').live("click",function() {					
		var id = 2;
		
		
		var string = 'cat_id=' + id;
	
			$.ajax({
				type: "POST",
				url: "bucket/getcg.php",
				data: string,
				success: function(result){
					$("#recentwork").children('.right-column').hide();
					$("#recentwork").children('.right-column').html(result);	
					$("#recentwork").children('.right-column').fadeIn("slow");
					$("#recentwork").children('.left-column').hide();
					$("#recentwork").children('.left-column').children('h2').html("SHOWING ALL FX");
					$("#recentwork").children('.left-column').fadeIn('slow');
					$.scrollTo.window().queue([]).stop();
					$.scrollTo( '#recentwork', 500 );
					secondnavup();
					//$(".b-w").pixastic("desaturate"); // desaturate all images with this class
					init();
				}
			});

			return false;
		});
});

$(function() {
		$('.getendtags').live("click",function() {					
		var id = 4;
		
		
		var string = 'cat_id=' + id;
	
			$.ajax({
				type: "POST",
				url: "bucket/getcg.php",
				data: string,
				success: function(result){
					$("#recentwork").children('.right-column').hide();
					$("#recentwork").children('.right-column').html(result);	
					$("#recentwork").children('.right-column').fadeIn("slow");
					$("#recentwork").children('.left-column').hide();
					$("#recentwork").children('.left-column').children('h2').html("SHOWING ALL END TAGS");
					$("#recentwork").children('.left-column').fadeIn('slow');
					$.scrollTo.window().queue([]).stop();
					$.scrollTo( '#recentwork', 500 );
					secondnavup();
					//$(".b-w").pixastic("desaturate"); // desaturate all images with this class
					init();
				}
			});

			return false;
		});
});

$(function() {
		$('.gettext').live("click",function() {					
		var id = 3;
		
		
		var string = 'cat_id=' + id;
	
			$.ajax({
				type: "POST",
				url: "bucket/getcg.php",
				data: string,
				success: function(result){
					$("#recentwork").children('.right-column').hide();
					$("#recentwork").children('.right-column').html(result);	
					$("#recentwork").children('.right-column').fadeIn("slow");
					$("#recentwork").children('.left-column').hide();
					$("#recentwork").children('.left-column').children('h2').html("SHOWING ALL TEXT");
					$("#recentwork").children('.left-column').fadeIn('slow');
					$.scrollTo.window().queue([]).stop();
					$.scrollTo( '#recentwork', 500 );
					secondnavup();
					//$(".b-w").pixastic("desaturate"); // desaturate all images with this class
					init();
				}
			});

			return false;
		});
});



//// get .MOV file for clientpage ////
$(function() {
		$('.openmov').live("click",function() {					
		var tempid = $(this).attr("id");
		var splitid = tempid.split("_");
		var id = splitid[1];
		var clicked = $(this);
		
		var string = 'spot_id=' + id;
			if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1))
			{
				/// if it's mobile safari
				$.ajax({
					type: "POST",
					url: "bucket/getmovipad.php",
					data: string,
					success: function(result){
						$("#content").html(result);
							
							$('#videoplayer').lightbox_me({
        						centered: true,
								overlayCSS: {background: 'white',opacity: .9},
								closeSelector: '.close',
        						onLoad: function() { 
								},
								onClose: function(){
									$("#content").html('');
								}
							});
					}
				});
			}else{
				/// otherwise use the jw player		
				
				
					$.ajax({
						type: "POST",
						url: "bucket/getmov.php",
						data: string,
						success: function(result){
							//$("#rightcontainer").html(result);
							$("#content").html(result);
							
							$('#videoplayer').lightbox_me({
        						centered: true,
								overlayCSS: {background: 'white',opacity: .9},
								closeSelector: '.close',
        						onLoad: function() { 
								},
								onClose: function(){
									$("#content").html('');
								}
						});
					}
				});
			}
			return false;
		});
});

function secondnavup(){
	$('#secondnav').slideUp("slow");
}
