// JavaScript Document

function setFlashBGHeight(){
	var numPageHeight = $("#MainWrapper").height();// De sidste 30 kan nok skiftes ud med noget padding p? containeren
	var numWinHeight = window.innerHeight;
	var numWindowHeight = $(window).height();
	if(numPageHeight>numWindowHeight){
		numOutputHeight = numPageHeight;
	}
	else
	{
		numOutputHeight = numWindowHeight;
	}
	$("#NZWebBGFlash").css("height", numOutputHeight + "px");
	$("#FlashWrapper").css("height", numOutputHeight + "px");
}

// Facebook status
function fbFetch(){
	//Set Url of JSON data from the facebook graph api. make sure callback is set with a '?' to overcome the cross domain problems with JSON
	var url = "https://graph.facebook.com/530857471/feed?callback=?"; // set limit: &limit=10
	var maxNum = 3;
	//Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data.
	$.getJSON(url,function(json){
		var html = "";
		var count = 1;
		//loop through and within data array's retrieve the message variable.
		$.each(json.data,function(i,fb){
			if(fb.type=='status' && count <= maxNum){
				count = count+1;
				html += '<div class="BoxContent">' + fb.message + '</div>';
			}
		});
		
		//A little animation once fetched
		$('#fbFeed').html(html);
			$('#fbStatus').hide();						
			$('#fbFeed').fadeIn(500);
		
	});
}


// Document ready functions
$(document).ready(function(){

	fbFetch();

	/*************************************/
	/*****Replace text in input fields****/
	/*************************************/
	
	$('.Doc2Form').find('.umbEditorTextField').addClass('replaceInput');
	$('.Doc2Form').find('.umbEditorTextFieldMultiple').addClass('replaceInput');
	
	$('.replaceInput').each(function(){
		var thisVal = $(this).attr('value');							
		$(this).focus(function(){
			if($(this).attr('value')==thisVal){
				$(this).attr('value','');
			}
		}).blur(function(){
			if($(this).attr('value')==''){
				$(this).attr('value',thisVal);
			}
		});														
	});

 });
