$(document).ready(function() {
	var height=$(".content").height();
	if ( height < 512)
	{
		$(".content").addClass('fix-height');
	}
	
	$(".frontpage-box").equalHeights();
	$(".inner-text").equalHeights();
	$('#frontpage-slider').anythingFader({
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 5000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 500,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
                pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
                startText: "Go",                // Start text
                stopText: "Stop"
            });
	$(".image-list").anythingFader({
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 5000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 500,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
                pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
                startText: "Go",                // Start text
                stopText: "Stop"
            });	
	$(".cloned a").each(function() {
		$(this).attr('rel', '');
	});
	$("#newsletter_email").val('Din e-postadresse');
		$("#newsletter_email").focus(function() {
			if ( $(this).val() == 'Din e-postadresse')
			{
				$(this).val('');
			}
		});
		$("#newsletter_email").blur(function() {
			if ( $(this).val() == '')
			{
				$(this).val('Din e-postadresse');
			}
		});
	$("#newsletter_mobile").val('Mobiltelefonnummer');
		$("#newsletter_mobile").focus(function() {
			if ( $(this).val() == 'Mobiltelefonnummer')
			{
				$(this).val('');
			}
		});
		$("#newsletter_mobile").blur(function() {
			if ( $(this).val() == '')
			{
				$(this).val('Mobiltelefonnummer');
			}
		});
		$(".readmore-button").click(function() {
			$(this).fadeOut();
			$("#more-text-on-event").fadeIn();
			$(".content").removeClass('fix-height');
		});
		
		$('#newsletter_subscribe').click(function(){
		
			var email 	= $('#newsletter_email').val();
			var name 	= '';
			var mobile 	= $('#newsletter_mobile').val();
			var list 	= $('#newsletter_list').val();
			
			$.ez( 'ByteMailcom::subscribe::'+email+'::'+name+'::'+mobile+'::'+list, {arg1: 'hi!'}, function( data )
			{
				if (data.content.result.success_code > 0){
				
					//-- ALT OK
					$('#newsletter').html("<div class='infbox'>Takk, du er nå påmeldt vårt nyhetsbrev.</div>");
					
				}	else	{
					
					if (data.content.result.error_code == 2){
						
						$('#newsletter_error_message').html('Feil under lagring av e-postadresse');	
						
					} else if (data.content.result.error_code == 3){
						
						$('#newsletter_error_message').html('Ugyldig e-postadresse');	
						
					} else if (data.content.result.error_code == 9){
						
						$('#newsletter_error_message').html('E-postadressen er allerede registrert');	
						
					} else {
						
						$('#newsletter_error_message').html('Feil under lagring av e-postadresse');	
						
					}
					
				}
			
			
			});
			
			
		});
					
});
