$(document).ready(function() {



	// put all your jQuery goodness in here.
	$('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	$('.slideshow-1').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	$('.slideshow-3').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	
	
	$('.fade').css('opacity',0.99);
		
		$('.fade').hover(  
    		function() {
    			$(this).fadeTo("slow", 0.50);
    		},
    		  
    		function() {
    		  	$(this).fadeTo("slow", 0.99);
    		}
    	);

	

	$('#event-1-frame .content').hide();
	
	$('.headerlinks a').click(function(){
	
		return false;
	});


	$('.hover-frame').hide();
	$('.hover-frame-2').hide();
	$('.hover-frame-3').hide();
	$('.hover-frame-4').hide();
	$('.hover-frame-5').hide();
	
	
	
	$('.hover-img').hover(  
    		function() {
    			var id = $(this).attr("id");
    			$('#hover-'+ id).show();
    		},
    		  
    		function() {
    		
    			var id = $(this).attr("id");
    		  	$('#hover-'+ id).hide();
    		}
    );
	
	
	
	$('#event-1-frame .bottom').click(function() {
	
		$('#event-1-frame .content').slideToggle(800);
	});
	
	$('#event-2-frame .content').hide();
	
	
	$('#event-2-frame .bottom').click(function() {
	
		$('#event-2-frame .content').slideToggle(800);
	});
	
	
	$('#event-1-2-button').click(function(){
		$('#event-2-frame .content').slideToggle(800);
	});
	
	$('#submit-frame').hide();
	
	$('.eventstart').click(function(){
	
		$('.eventbox').slideToggle(1500);
		$('.eventstart').toggleClass('eventstart-red');
		
		return false;
	});
	
	$('#signup').click(function() {
	   var elementClicked = $(this).attr("href");
	   var destination = $(elementClicked).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1000 );
	   
	   $("input.focus:last").focus(); 
	   $('.intgray').animate({ backgroundColor:'#EDEDED'}, 800).animate({backgroundColor: 'yellow'}, 800).animate({backgroundColor: '#EDEDED'}, 1000);
	    
	   
	   return false;
	});
	
	$('#signup-2').click(function() {
	   var elementClicked = $(this).attr("href");
	   var destination = $(elementClicked).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1000 );
	   
	   $("input.focus:last").focus(); 
	   $('.intgray').animate({ backgroundColor:'#EDEDED'}, 1000).animate({backgroundColor: 'yellow'}, 500).animate({backgroundColor: '#EDEDED'}, 1000);
	    
	   
	   return false;
	});
	$('#signup-3').click(function() {
	   var elementClicked = $(this).attr("href");
	   var destination = $(elementClicked).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1000 );
	   
	   $("input.focus:last").focus(); 
	   $('.intgray').animate({ backgroundColor:'#EDEDED'}, 1000).animate({backgroundColor: 'yellow'}, 500).animate({backgroundColor: '#EDEDED'}, 1000);
	    
	   
	   return false;
	});
	$('#eventet').click(function() {
	   var elementClicked = $(this).attr("href");
	   var destination = $(elementClicked).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1000 );
	    
	   
	   return false;
	});
	 
 
    // bind form using 'ajaxForm' 
    
    
    function showRequest(formData, jqForm, optionsTips) { 
	 	$("#form-frame").slideToggle(800);
	 	$("#submit-frame").slideToggle(800);
	 	
	 	var name = $('#friend-name').val();
	 	var email = $('#friend-email').val();
	 	
	 	
	 	$('.intgray').animate({ backgroundColor:'#2CB719'}, 1000);
	 	
	 	_gaq.push(['_trackPageview', '/tack-for-ditt-intresse']);
	    
	    return true; 
	} 
    
    var options = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest  // pre-submit callback 

    };
    
    $('#application-form').ajaxForm(options); 
   	
   
    
    // bind form 'Tip Form' 
    
  
    
    $('.dialog-tip').dialog({
    	autoOpen: false,
    	width:340,
    	closeText: 'Stäng rutan'
    });
    
    $('.dialog-tip-link').button().click(function(){
    		$('.dialog-tip').dialog('open');
    });
    
    function showRequestTip(formData, jqForm, optionsTips) { 
	 	$("#form-frame-tip").slideToggle(800);
	 	$("#submit-frame-tip").slideToggle(800);
	 	
	 	_gaq.push(['_trackPageview', '/tack-for-ditt-intresse']);
	    
	    return true; 
	} 
    
    var optionsTip = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequestTip // pre-submit callback 

    };
    
    $('#tip-form').ajaxForm(optionsTip); 
    
    
    
   // bind form 'Event-1-form' 
   
    $('#event-1-submit').click(function(){
    	
    	$('#event-1-form').submit();
    
    });
    
    $('.event-form-suc').hide();
    $('.event-2-form-suc').hide();
   
    
    function showRequestEvent1(formData, jqForm, optionsTips) { 
    
    	$("#event1").slideToggle(800);
    	$("#event-1-submit").slideToggle(800);
    	$(".event-form-suc").slideToggle(800);
    	
    	_gaq.push(['_trackPageview', '/tack-for-ditt-intresse']);

	    return true;     	
    }
   
    var optionsevent = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequestEvent1  // pre-submit callback 

    }; 
    
   
    $('#event-1-form').ajaxForm(optionsevent);
    
    
    
    // Bind form 'Event-2-form'
    
    $('#event-2-submit').click(function(){
    	
    	$('#event-2-form').submit();
    
    });
    
    $('.event-form-suc').hide();
   
    
    function showRequestEvent2(formData, jqForm, optionsTips) { 
    
    	$("#event2").slideToggle(800);
    	$("#event-2-submit").slideToggle(800);
    	$(".event-2-form-suc").slideToggle(800);
    	
    	_gaq.push(['_trackPageview', '/tack-for-ditt-intresse']);

	    return true; 

    }
   
    var optionsevent = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequestEvent2  // pre-submit callback 

    }; 
    
   
    $('#event-2-form').ajaxForm(optionsevent);
   
});
