	/*****************************************************************

		highslide's Expander function doesn't look for bound events, 
		just for the "onclick" attribute of each element, therefore 
		if we ever want to bind highslide clicks w/ jquery, this is 
		how we need to do it:
		
		$('a.highslide').each(function() {
		    this.onclick = function() {
		      return hs.expand(this, options);
		    };
		});

	******************************************************************/
	
	
$(document).ready(function(){

	hs.graphicsDir = 'highslide/graphics/';
	hs.outlineType = null;

	var left = (($(window).width())/2) - 470;
	left = Math.max(left,20);	
	
	var top = (($(window).height())/2) - 270;
	top = Math.max(top,20);				

	$(".nav").css("top",top);
	$(".nav").css("left",left);			


	bindBlogControls();
	$("#contactForm").ajaxForm( function(data){
		alert(data);
		$("#contactForm").children("input textarea").val("");
	});	
		
	$(".more").hover(
				   	function(){ $(this).css("cursor","pointer"); },
				 	function(){ $(this).css("cursor","default"); }
	  				);

    $(".more").click( function(){
		effectee = $(this).attr("title");
		source = [ "./imgs/more.png", "./imgs/less.png"];
			
		image = ".more[title='" + effectee + "']";
		textlink = ".morelink[title='" + effectee + "']";
			
		if( $(image).attr("src") == source[0] || $(image).attr("src") != source[1]){
			$(image).attr({src: source[1]});
			$(effectee).slideDown("fast");	
			$(textlink).text("[read less]");		
		}
		else{
			$(image).attr({src: source[0]});		
			$(effectee).slideUp("fast");	
			$(textlink).text("[read more]");		
		}
		
	});


		
	//$(".nav").css({zIndex: "5000"});
	$(".wrapper").draggable({zIndex: "2"});
	
	$(".navhome")	.click(function(){  goTo('home');  	});
	$(".navfilms")	.click(function(){ 	goTo('films'); 	});
	$(".navblog")	.click(function(){  goTo('blogs'); 	});
	$(".navcontact").click(function(){	goTo('contact');});
	$(".navmelody")	.click(function(){	goTo('about');	});


});


	  function goTo(loc){

	    switch(loc){
	    case 'home':

	        galacticCenterX = ($(window).width() - $(".wrapper").width())/2 - 6;
			galacticCenterY = ($(window).height() - $(".wrapper").height())/2 + 350;

			topOffset = galacticCenterY;
			leftOffset = galacticCenterX;

			break;
	
		case 'films':
			
			marginLeft = 200;
			marginTop = 473;
			
			filmsOffsetX = $(".films").position().left - $(".wrapper").width()/2 + $(".films").width()/2 + marginLeft;
		 	leftOffset = ($(window).width() - $(".wrapper").width() )/2 - filmsOffsetX;
			
			filmsOffsetY = $(".films").position().top - $(".wrapper").height()/2 + $(".films").height()/2 + marginTop;
			topOffset = ($(window).height() - $(".wrapper").height() )/2 - filmsOffsetY;
				
			break;
			
		case 'blogs':

			marginTop = 495;
		
			blogOffsetX = $(".blogs").position().left - $(".wrapper").width()/2 + $(".blogs").width()/2;
			leftOffset = ($(window).width() - $(".wrapper").width() )/2 - blogOffsetX;
		
			blogOffsetY = $(".blogs").position().top - $(".wrapper").height()/2 + $(".blogs").height()/2 + marginTop;
			topOffset = ($(window).height() - $(".wrapper").height() )/2 - blogOffsetY;
			
			break;

		case 'about':

			aboutOffsetX = $(".about").position().left - $(".wrapper").width()/2 + $(".about").width()/2;
			leftOffset = ($(window).width() - $(".wrapper").width() )/2 - aboutOffsetX;

			aboutOffsetY = $(".about").position().top - $(".wrapper").height()/2 + 300;
			topOffset = ($(window).height() - $(".wrapper").height() )/2 - aboutOffsetY;

			break;
			
		case 'contact':

			marginTop = 240;
	
			blogOffsetX = $(".contact").position().left - $(".wrapper").width()/2 + $(".contact").width()/2;
			leftOffset = ($(window).width() - $(".wrapper").width() )/2 - blogOffsetX;
	
			blogOffsetY = $(".contact").position().top - $(".wrapper").height()/2 + $(".contact").height()/2 + marginTop;
			topOffset = ($(window).height() - $(".wrapper").height() )/2 - blogOffsetY;

			break;	


		}
		leftOffset += 50;
	    $(".wrapper").animate( { top: topOffset+"px", left: leftOffset+"px" }, { queue:false, duration:1500 } )
	  }

function bindBlogControls(){
  $("#melofilms-blogspot-prev, #melofilms-blogspot-next").click( function(){
	$.get(this.href, function(data){
	  $("#melofilms-blogspot-blog").html(data);
	  bindBlogControls();
	});
	return false;
  });
}



	