jQuery.noConflict();
jQuery(function() {

//	Visar menyn   
jQuery("#menu_Btn").click(function () {
      jQuery("#menu").toggle("slide", { direction: "down" }, 1000);
	});

//	Animerar sträcket under menyn
jQuery(function() { jQuery(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 })});

//	Gör så att pusslet hamnar bakom huvudfältet (Main)
jQuery("#puzzle").insertBefore("#left");



 //	Flytta Element, gör puzzelbitarna dragbara
	jQuery(".column").sortable({
			connectWith: '.column'
		});

		jQuery(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
			.find(".portlet-header")
				.addClass("ui-widget-header ui-corner-all")
				
				.end()
			.find(".portlet-content");

		jQuery(".portlet-header .ui-icon").click(function() {
			jQuery(this).toggleClass("ui-icon-minusthick");
			jQuery(this).parents(".portlet:first").find(".portlet-content").toggle();
		});

		jQuery(".column").disableSelection();
		
		jQuery(".right_down").click(function() {
  jQuery(this).next().slideToggle("slow");
	});
		
	
	
		
		jQuery("#viewportfolio").click(function () {
      jQuery("#portfolio_div, #portfolio").fadeIn("slow")
	});
		
			jQuery(".close_portfolio").click(function () {
      jQuery("#portfolio_div, #portfolio").fadeOut("fast")
	});
		
			jQuery("#viewportfolio").click(function () {
      jQuery("#main, #menu").toggle("slide", { direction: "left" }, 1000);
	});	
				jQuery(".close_portfolio").click(function () {
      jQuery("#main, #menu").toggle("slide", { direction: "left" }, 1000);
	});
				
				
//		Förhindrar så man inte kan höger klicka	på bilder, för att spara ner dem och dyligt
    jQuery("img").bind("contextmenu",function(){
        return false;
    });
	
	//		Att Thumbsen är skuggade när sidan öppnas
 	jQuery(".thumbs").css("opacity",0.55);
//		När musen går över en thumb så försvinner opaciteten
	jQuery(".thumbs").hover(function () {
    	jQuery(this).fadeTo("slow", 1);
	});
//		När musen flyttas från thumben så fadas den ut igen
	jQuery(".thumbs").mouseout(function () {
      	jQuery(this).fadeTo("slow", 0.55);
    }); 
				
			
	jQuery(".sendMessBtn").click(function () {
		msg = jQuery("textarea[name=msg]").val();
		jQuery("textarea[name=msg]").val('');
		
		jQuery.ajax({
			url: "insert.php?message="+msg,
			cache: false,
			success: function(html){
			updateChat();
			jQuery("#handler").html(html);
			}
		});
		
	});
	
		
		
		/* NYHETS VISARE, AUTO SCROLL
	//cache the ticker
		var ticker = jQuery("#ticker");
		  
		//wrap dt:dd pairs in divs
		ticker.children().filter("dt").each(function() {
		  
		  var dt = jQuery(this),
		    container = jQuery("<div>");
		  
		  dt.next().appendTo(container);
		  dt.prependTo(container);
		  
		  container.appendTo(ticker);
		});
				
		//hide the scrollbar
		ticker.css("overflow", "hidden");
		
		//animator function
		function animator(currentItem) {
		    
		  //work out new anim duration
		  var distance = currentItem.height();
			duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.015;

		  //animate the first child of the ticker
		  currentItem.animate({ marginTop: -distance }, duration, "linear", function() {
		    
			//move current item to the bottom
			currentItem.appendTo(currentItem.parent()).css("marginTop", 0);

			//recurse
			animator(currentItem.parent().children(":first"));
		  }); 
		};
		
		//start the ticker
		animator(ticker.children(":first"));
				
		//set mouseenter
		ticker.mouseenter(function() {
		  
		  //stop current animation
		  ticker.children().stop();
		  
		});
		
		//set mouseleave
		ticker.mouseleave(function() {
		          
          //resume animation
		  animator(ticker.children(":first"));
		  
		});*/
		  });
