/**
 * @author Nils Hendriks for Eden { design and communication
 */

/* ::Enable Javascript-enabled stylesheet */
var head_css = $('<link rel="stylesheet" href="/site/Presentation/Design/StandardScheme/CSS/RaboVastgoedGroep/js-enabled.css" type="text/css" media="screen" />').appendTo($('head')[0]);
/*var head_js_dropdown = $('<script type="text/javascript" src="/site/Presentation/Functional/ClientScript/RaboVastgoedGroep/lib/jquery.custom-dropdown.js"></script>').appendTo($('head')[0]);
 -------------------------------------- */

/* ::Global Vars */


/* -------------------------------------- */


/* ::Document Ready function Callers  */
$(document).ready(function(){

	/* =Initialize default Functions (Fn) */
	//FnDefault.init();
	FnInputFocus.init();
	FnSubmitHover.init();
	FnFAQList.init();
	FnPrintBtn.init();
	//FnCustomDropdown.init();
});
/* -------------------------------------- */



/* ::Default Functions */
FnDefault = {
	init:function() {}	
	
	
	/* -------------------------------------- */
}



/* !FnInputFocus */
/* :: remove and replace text field example content */
FnInputFocus = {
	init:function() {
		
	// when text field gets clicked
	$(':input.example').focus(function() {
		// if not empty and if class example get value
		if ($ (this) .is('.example') && !(this.value == ''))  {
			// store value
			exampleValue = this.value;
			// empty value
			$(this).attr({'value' : ''})
			// remove class example
			$(this).removeClass('example');
		};
	}).blur(function() {
		// if empty: replace example value
		if (this.value == '') {
			$(this).addClass('example')
			$(this).attr({'value' : exampleValue})
		};
	});
	}
	
	/* -------------------------------------- */
}

/* ::Submit hover */
FnSubmitHover = {
	init:function() {
		$(':input.submit').hover(function() {
			$(this).addClass('hover');
		},
		function() {
			$(this).removeClass('hover');
		});
	}	
	
	
	/* -------------------------------------- */
}

/* ::Default Functions */
FnFAQList = {
	init:function() {
		$('.faq-block li a.toggle').toggle(function() {
			// click open
			$(this).parent().addClass('open');
		},
		function() {
			// click close
			$(this).parent().removeClass('open');
		});
	}	
	
	
	/* -------------------------------------- */
}

/* ::Click handler for print button */
FnPrintBtn = {
	init:function() {
		$('a.print-link').click(function() {
			window.print();
			return false;
		});			
	}	
	
	
	/* -------------------------------------- */
}


FnCustomDropdown = {
	init:function() {
		var dropdownSites = '<div id="dropdown-site-switch"></div>';
		$('#meta-nav select').wrap(dropdownSites);
		$('#dropdown-site-switch').fdd2div({OpenStatus:0,GenerateHyperlinks:0, AnimationSpeed: "fast"});
		
		if($(".refine-selection").length > 0) {
			$('.refine-selection').find('select').each(function() {
				var dropdownId = $(this).attr('id');
				var dropdownWrapper = '<div class="wrapped-dropdown" id="wrapped_'+dropdownId+'"></div>';
				var dropdownWrapperId = 'wrapped_'+ dropdownId;
				$(this).wrap(dropdownWrapper);
				$(this).parent().fdd2div({OpenStatus:0,GenerateHyperlinks:0, AnimationSpeed: "fast"});
			});
			$(".refine-selection .wrapped-dropdown:last").addClass('no-margin');
		}
		
	}
}


