// WINDOC - on document load and window ready functions

$(window).load(
    function() {
			resizeImage();
			resizeTinyThumbs();
			hideAll();
			sortButtons();
		}
);


$(document).ready(function() {
	
	// DO THESE  	--------------------------------------------------------
	$(document).find('#home-container').hide();
	hideAllButtons();


	// GALLERY EVENTS 	--------------------------------------------------------
		
	// thumb hide and hover
	$(this).find('div.thumb-title').stop(false,true).animate({'top':190}, 0);

    $(".thumb, .a-thumb").hover(
      function () {
			 //Move and zoom the image  
				$(this).find('div.thumb-title').stop(false,true).animate({'top':130}, {duration:200}, "jswing");
        //$(this).animate({ opacity: 1 }, 200, "jswing");
      }, 
      function () {
				$(this).find('div.thumb-title').stop(false,true).animate({'top':190}, {duration:600}, "jswing");
        //$(this).animate({ opacity: 0.8 }, "jswing");
      }
    );
	
	// THUMBS PRESSED (PROJECTS)
	$(".thumb").click(
		function () {
			thumbsPressed(this);		
		}
	);

	// THUMBS PRESSED (ARTISTS)
	$(".a-thumb").click(
		function () {
			aThumbsPressed(this);		
		}
	);
	
	// NEXT THUMBS
	$(".next").click(
  	function () {
			nextPressed();	
		}
	);
	// PREV THUMBS
	$(".prev").click(
  	function () {
			prevPressed();	
		}
	);
	

	// SINGLE EVENTS 	--------------------------------------------------------
	
	// NEXT THUMBS TINY
	$(".next-small").click(
		function () {
			nextSmallPressed();	
		}
	);
	
	// PREV THUMBS TINY
	$(".prev-small").click(
		function () {
			prevSmallPressed();	
		}
	);
	
	// TINY THUMBS CLICKED
	$(".tiny-thumb").click(
		function () {
			tinyThumbPressed(this);	
		}
	);
	
	// NEXT IMAGE
	$(".next-image").click(
		function () {
			nextPrevImage("n");	
		}
	);
	
	// PREV IMAGE
	$(".prev-image").click(
		function () {
			nextPrevImage("p");	
		}
	);
	
	// BOTTOM NAVIGATION ROLL OVER
  $("#single-navigation").hover(
    function () {
		 //Show Navigation  
			$('#single-navigation .bot-nav-mid, .bot-nav-left, .bot-nav-right').fadeIn(300);
    }, 
    function () {
			// hide navigation
			$('#single-navigation .bot-nav-mid, .bot-nav-left, .bot-nav-right').fadeOut(500);
    }
  );

	// INFO BUTTON PRESSED
	$(".infoBtn").click(
		function () {
			infoPressed(this);	
		}
	);

	// INFO SCREEN PRESSED
	$(".info").click(
		function () {
			infoClose();	
		}
	);
	
	// artist MAIL PRESSED
	$(".mail").click(
		function () {
			mailOut('a');	
		}
	);
	// Projet MAIL PRESSED
	$(".p-mail").click(
		function () {
			mailOut('p');	
		}
	);



	// SORTABLE STUFF 	--------------------------------------------------------
	$("#sortable").sortable({ 		opacity: 0.7, 
	     													handle: $(".home-thumb img")
																//containment: 'parent'
																});
	
	$('#sortable').sortable({
	   update: function(event, ui) { 
			var image_order = $('#sortable').sortable('toArray');
			var io = image_order.join('-');
			$('#image-order').attr('value', io);
			//alert(io);
		 }
	});
	
// TinyMCE for text editing  	--------------------------------------------------------
	$('textarea').tinymce({
				script_url : '/js/tinymce/tiny_mce.js',
				theme : "advanced",
			    theme_advanced_buttons1 : "bold,italic,underline,link,unlink,undo", 
			    theme_advanced_buttons2 : "", 
			    theme_advanced_buttons3 : "",
			    button_tile_map: true,
				content_css : "/css/tinymce.css"
	});
		
});

// CLICKABLES

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}
function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}





