/*  @author Edenspiekermann */

/**
 * @descr Add stylesheet specifically for javascript-enabledviewers to head-section in html-page
 * 
 */
var headerAppend = $('<link rel="stylesheet" href="/cms/system/modules/nl.srk/resources/css/js-enabled.css" type="text/css" media="screen" />').appendTo($('head')[0]);
/**
 * @descr Set default easing
 * 
 */
var ease = 'easeOutQuad';
var ie6 = navigator.appVersion.indexOf("MSIE 6")!=-1 ? true:false;
var ie8 = navigator.appVersion.indexOf("MSIE 8")!=-1 ? true:false;
var activeSliderHome = "";
/**
 * @descr Initialization function for when page is loaded
 * 
 */
$(document).ready(function() {
	//Initialize the modalscreen layer for popups and overlays
	ModalScreen.init();
	
	//Initialize the navigation
	Nav.init();
	
	// preload loading animation for slider content 
	Toolbox.preloadImages("/cms/system/modules/nl.srk/resources/img/icons/icon-loader.gif");
	Sliders.init();
	ToolTip.init();
	ExpanderList.init();
	FormFocus.init();
	ContactForm.init();
	PrintPage.init();
	
	// enable search field value to be cleared on focus (first focus only)
	if($('#zoekvraag').length !=0 && $('#zoekvraaglabel').length !=0 ){	
		var siteSearchValue = $('#zoekvraaglabel').text();
		if($('#zoekvraag').val().length == 0) { $('#zoekvraag').val(siteSearchValue); }
		$('#zoekvraag').click(function(){ if ($(this).val() == siteSearchValue) { $(this).val('');  }});	
		$('#zoekvraag').blur(function(){ if($(this).val().length == 0) { $(this).val(siteSearchValue); } });
	}
	
	if($('#zoekfaq').length !=0 && $('#zoekfaqlabel').length !=0){	
		var searchFormValue = $('#zoekfaqlabel').text();
		if($('#zoekfaq').val().length == 0) { $('#zoekfaq').val(searchFormValue); }
		$('#zoekfaq').click(function(){ if ($(this).val() == searchFormValue) { $(this).val('');  }});	
		$('#zoekfaq').blur(function(){ if($(this).val().length == 0) { $(this).val(searchFormValue); } });
	}

	// hover for input type='submit'
	$('input:submit').hover(
		function(){
			$(this).addClass('hover');	
		},
		function(){
			$(this).removeClass('hover');
		}
	);
});
/**
  * Nav
  * @descr Create Navigation for use of subnavigation with javascript
  * 
  */

Nav = {
	hideTimer:null,//timer will be activated when cursor leaves menu-panel(s);
	showing:999,//index nr for subnav wich is shown
	visible:false,//true if menu is visible
	init:function(){
		
		//create a container that will hold all menu items that are shown when menu is clicked:
		var menuHTML = '<div id="MenuContainer"><div class="site-nav-block" id="Links"></div><div class="nav-block" id="MainNav"></div><div class="sub-nav" id="SubNav"></div></div>';
		var menu = $('body').append(menuHTML);
		$('#Links').html($('.site-nav-block:first').html());	
		$('#MainNav').html($('.nav-block:first').html());	
		$('#MainNav form input:text').attr('id','ClonedInput');
		$('#SubNav').html($('.sub-nav:first').html());
		
		//When submit-button is clicked in the menu overlay. Transfer values to the underlying 'ORIGINAL' search form and submit the latter. 
		//Because that contains all the right id's and stuff;
		$('#MainNav form input:submit').click(function(){
			Nav.formUpdate();
			$(".nav-block:first form").submit();
			return false;
		});	
			
		//Create an empty span that enables a hovered menu-item to look like the design (with a white border-bottom and blue borders top, right and left)
		$('#MainNav li a').append('<span class="hover-border"></span>');
		
		//If IE6/7 set a specific width (exception)
		if(jQuery.browser.msie && jQuery.browser.version < 8){
			$('#MainNav.nav-block ul li a span.hover-border').each(function(){
				$(this).css({width:'1px'});
				$(this).css({width:($(this).closest('a').width()-7)+'px', marginBottom:'-1px'});
			})
		}
		
		//To position all the section-links correctly when the overlay is shown add a width to all the 'non-visible' links and empty them.
		$('#Links ul li a').each(function(){
			if($(this).hasClass('active')) return;
			$(this).css({width:($(this).width())+'px', display:'block', height:'20px'});
			$(this).empty();
			/*$(this).hover(function(){
				clearTimeout(Nav.hideTimer);
				Nav.hideTimer = setTimeout(function(){Nav.hide()},1000);
			},function(){})*/
		});
		
		//Create an extra span within the section-links. This makes it possible to use transparent round-corners.
		$('#Links ul li a.active span').wrap('<span class="extra-span"></span>');
		
		//When a navigation links is clicked show the corresponding submenu (if there is one)
		$('.nav-block:first li').each(function(){
			$(this).click(function(){
				var i = $('.nav-block:first li').index(this);
				Nav.showing = i;
				if (!($(this).hasClass('no-submenu'))){
					//If first link has no submenu then index for corresponding submenu has to be lowered by 1;
					if ($('.nav-block:first li:first').hasClass('no-submenu')) i--;
					Nav.show(i);					
				}
				else return true;
				return false;
			});
		});
		
		//Add functionality for navigational links when submenu's and overlay are shown.
		$('#MenuContainer .nav-block li').each(function(){
			
			$(this).hover(function(){
				$('#MenuContainer .nav-block li a').each(function(){
					$(this).removeClass('hover');
				});
				if(!($(this).hasClass('no-submenu'))) $(this).children('a').addClass('hover');
				var i = $('#MenuContainer .nav-block li').index(this);
				if(Nav.showing==i) return;
				if ($(this).hasClass('no-submenu')) Nav.hide();
				else if ($('.nav-block:first li:first').hasClass('no-submenu')) {
					i--;
					Nav.loadContent(i);
				}
			},function(){ 
				//When no subnav is shown the var showing=999 (e.g. out of range)
				Nav.showing=999;
			 });
			//As long as this link has a corresponding submenu de-activate click-event
			if(!($(this).hasClass('no-submenu'))){
				$(this).click(function(){
					return false;
				});	
			}
		});	
		// Bind actions to certain events for #ModalScreen
		$('#ModalScreen').mouseout(function(){
			if(Nav.visible) clearTimeout(Nav.hideTimer);
		});
		$('#ModalScreen').mouseover(function(){
			if(Nav.visible) Nav.hideTimer = setTimeout(function(){Nav.hide()},1000);
		});
		$('#ModalScreen').click(function(){
			if(Nav.visible) Nav.hide();
		});	
	},
	//update search-form in overlay, show modalscreen and position and show submenu
	show:function(i){	
		Nav.visible = true;
		$('#MainNav form input:text').attr('value', $('.nav-block:first form input:text').attr('value'));
		ModalScreen.show();
		var menu = $('#MenuContainer');
		var offset = $('.site-nav-block:first').offset();
		$('#SubNav').html($('.sub-nav:eq('+i+')').html());	
		var endHeight = $('.sub-nav:eq('+i+')').height();
		menu.css({top:(offset.top)+'px',left:offset.left+'px'});
		if(jQuery.browser.msie && jQuery.browser.version < 7) return;
		$('#SubNav').css({height:'0px',paddingBottom:'0px'});		
		$('#SubNav').stop().animate({height:endHeight,paddingBottom:60},{ duration: 400, easing: 'easeInSine',complete: function(){
			
		}}).animate({paddingBottom:0}, {duration: 300, easing: 'easeOutSine', complete:function(){	}});
	},
	//update underlying search-form, hide modalscreen and submenu
	hide:function(){
		Nav.visible = false;
		Nav.formUpdate();
		ModalScreen.hide();
		$('#MenuContainer .nav-block li a').each(function(){
			$(this).removeClass('hover');
		});
				
		if (jQuery.browser.msie && jQuery.browser.version < 7) {
			$('#MenuContainer').css({
				left: '-9999px'
			});
		} else {
			var endHeight = document.getElementById('SubNav').offsetHeight;
			$('#SubNav').stop().animate({
				height: 0
			}, {
				duration: 400,
				easing: 'easeOutSine',
				complete: function(){
					$('#MenuContainer').css({
						left: '-9999px'
					});
					$('#SubNav').css({
						height: endHeight+'px'
					});
					Nav.showing = 999;
				}
			});
		}
	},
	//Hide without animation (for example when browserwindow is being resized)
	immediateHide:function()
	{
		Nav.visible = false;
		Nav.formUpdate();
		ModalScreen.immediateHide();
		$('#MenuContainer .nav-block li a').each(function(){
			$(this).removeClass('hover');
		});
		$('#MenuContainer').css({left: '-9999px'});
		Nav.showing = 999;
	},
	//When overlay is shown update the underlying 'ORIGINAL' searchform
	formUpdate:function(){
		$('.nav-block:first form input:text').attr('value', $('#MainNav form input:text').attr('value'));
	},
	//Show new submenu. When another submenu is allready showing then only load html for new sub
	loadContent:function(i){
		Nav.visible = true;
		if($('#ModalScreen').css('display')=='none'||$('#ModalScreen').css('opacity')!='0.5') ModalScreen.show();
		var currentHeight = $('#SubNav').height();	
		$('#SubNav').html($('.sub-nav:eq('+i+')').html());
		if(jQuery.browser.msie && jQuery.browser.version < 7) return;
		var newHeight = $('.sub-nav:eq('+i+')').height();
		$('#SubNav').stop().animate({height:newHeight},{ duration: 500, easing: 'easeOutExpo'});
	}
}
/**
  * ModalScreen
  * @descr Create ModalScreen
  * 
  */
ModalScreen = {
	init:function(){
		if($('#ModalScreen').length>0) return;
		
		//create modal screen
		if($('#ModalScreen').length == 0){
			$('body').append('<div id="ModalScreen"></div>');		
		} 
		//create iframe mask
		if($('#ModalMask').length == 0) $('body').append('<iframe id="ModalMask" src="/cms/system/modules/nl.srk/resources/img/fake-src.gif"></iframe>');
		
	},
	// size the modalscreen according to browserwindow's height and width
	sizing:function(){
				
		var h = $(window).height()>=$('#page-container').height() ? $(window).height() : $('#page-container').height();
				
		if($('#OverlayFrame').length>0){
			h = h >=($('#OverlayFrame').height()) ? h : ($('#OverlayFrame').height());
		}
		$('#ModalScreen').height(h);
		$('#ModalMask').height(h);
		
		var w = $(window).width()>=$('#page-container').width() ? $(window).width() : $('#page-container').width();
		$('#ModalScreen').width(w);
		$('#ModalMask').width(w);
	},
	show:function(){
		ModalScreen.init();
		ModalScreen.sizing();
		if(!(jQuery.browser.msie && jQuery.browser.version < 7)) $('#ModalScreen').css({opacity:'0'});
		$('#ModalMask').show();		
		$('#ModalScreen').show();
		if(!(jQuery.browser.msie && jQuery.browser.version < 7)) $('#ModalScreen').stop().animate({opacity:'0.5'},{ duration: 500, easing: 'easeInExpo'});
		$(window).bind("resize", function(){
			ModalScreen.sizing();
		});
	},
	hide:function(){	
		if(jQuery.browser.msie && jQuery.browser.version < 7){
			$('#ModalScreen').hide(); $('#ModalMask').hide();
		} 
		else $('#ModalScreen').stop().animate({opacity:'0'},{ duration: 300, easing: 'easeInExpo', complete:function(){$('#ModalScreen').hide(); $('#ModalMask').hide();}});		
		
		$(window).unbind("resize", function(){
			ModalScreen.sizing();
		});
	},
	//Show without animation (for example when an iframe is being loaded otherwise animation can get clunky)
	immediateShow:function(){
		ModalScreen.init();
		ModalScreen.sizing();
		$('#ModalMask').show();		
		$('#ModalScreen').show();
		$(window).bind("resize", function(){
			ModalScreen.sizing();
		});
	},
	//Hide without animation (for example when browserwindow is being resized)
	immediateHide:function(){
		$('#ModalScreen').hide(); 
		$('#ModalMask').hide();
		$(window).unbind("resize", function(){
			ModalScreen.sizing();
		});
	}
}
/**
 * Window resize events
 */
$(window).resize(function(){
  Nav.immediateHide();
});

/*
 * Sliders
 * @descr	menu sliders on homepage
 * click the link to open and/or close the slider
 * sliders can also be closed with the link at the top of the panel
 * if a slider link is clicked to open while another slider is already open, 
 *    the first one will close first before the new one is activated
 *
 */
Sliders = {
	init: function(){
		if ($('.sliders').length > 0) {
			$current = null;
			
			//make all slider tabs the same height			
			var heighestTab = 0;
			var tabHeight = 0;
			var tabs = $(".sliders .tab span");
			for(var i = 0; i<tabs.length; i++)			{
				var tabHeight = $(tabs[i]).outerHeight();	
				if(tabHeight > heighestTab) { heighestTab = tabHeight; }
			}
			$(tabs).height(tabHeight-40);
			
			//set height of home-content block
			var heightHomeContent = parseInt($(".home-content").outerHeight());	
			var heightSliderTabs = parseInt($(".home-block .tab").outerHeight());	
			if(ie6 || ie8) { heightHomeContent = heightHomeContent +3;}
			$(".home-block").height(heightHomeContent+heightSliderTabs);
						
			$('div.slider-content').css({top: '0'});
			
			
			if(activeSliderHome.length != 0) {			
				$current = $(activeSliderHome);
				Sliders.sliderUp();
			} 
					
			$('.sliders li a:not(.slider-content a)').click(function(){
				if($current == null){
					$current = $(this).next();
					Sliders.sliderUp();
				}
				else {
					$prevID = $current.attr('id');
					$current = $(this).next();
					if ($current.parent().attr('class') =='open') {
						Sliders.slidersDown();
					}
					else {
						//$('.sliders li div.slider-content').animate({  top: '0', duration: 500}, 
						//	function(){ $('.sliders li.open div.slider-content').parent().removeClass('open');	 Sliders.sliderUp(); });
						$('.sliders li div.slider-content').css("top", 0);
						$('.sliders li.open div.slider-content').parent().removeClass('open');	 
						Sliders.sliderUp(); 
					}
				}
				return false;
			});
			
			// close button at top of slider
			$('.sliders .close').click(function(){
				// slide down
				Sliders.slidersDown();
				return false;
			});
		}
	},
	sliderUp: function(){		
		$current.parent().addClass('open');
		var heightHomeBlock = parseInt($(".home-block").outerHeight());	
		var heightSliderTabs = parseInt($(".home-block .tab").outerHeight());	
		var heightContent = heightHomeBlock-heightSliderTabs;
		// slide up
		$current.animate({ 
			top: '-' + heightContent + 'px',
			duration: 500
		}, 
		function(){
			if ($current.attr('id') == 'slider01'){
				SliderContent.init();
			}
		});
	},
	slidersDown: function(){			
		$('.sliders li div.slider-content').animate({ 
			top: '0',
			duration: 500
		}, 
		function(){
			$(this).parent().removeClass('open');
		});
	}
}

/* SliderContent
 * @descr	called from Slider function
 * creates a new div called content-loader
 * when links in the sub-sub-nav are moused over, 
 * the url is extracted from the href and used to load an external div into 
 * 			the default-content div inside the content-loader div.
 * 
 * content-loader is removed when any of the three sliders are closed.
 */
SliderContent = {
	sliderTimeOut:400,
	hyperlink:null,
	init: function(){
		$originalContent = $('.content-loader .default-content').html();
		$('.content-loader').hover(function(){
			clearTimeout(SliderContent.sliderTimeOut);
		});
		
		$('#slider01 span.close').hover(function(){
			$('.slider-content ul li a').removeClass('active');
			$('.content-loader .default-content').html($originalContent);
		});
		
		$('#slider01').prev().hover(function(){
			clearTimeout(SliderContent.sliderTimeOut);
			$('.slider-content ul li a').removeClass('active');
			$('.content-loader .default-content').html($originalContent);
		});
				
		$('ul.sub-sub-nav li a').hover(function(){	
			clearTimeout(SliderContent.sliderTimeOut);
			SliderContent.hyperlink = this;
			SliderContent.sliderTimeOut = setTimeout('SliderContent.showContent()',400);	
			
		});
		
		/*$('ul.sub-sub-nav li a').click(function(){
			return false;
		});*/
	},
	
	showContent: function(){		
			
		/* image is already preloaded in page initalization */
			$('.content-loader .default-content').html('<img class="loading" src="/cms/system/modules/nl.srk/resources/img/icons/icon-loader.gif" />');
			
			// make this link active
			$('.slider-content ul li a').removeClass('active');
			$(SliderContent.hyperlink).addClass('active');		
			// extract url from id
			$externalPage = $(SliderContent.hyperlink).attr('href');
			// separate the id with a space and a comma
			$externalPage = $externalPage.replace('#','?slider=true ,#');
			// load the external div into div.content-loader .default-content
			$('.content-loader .default-content').load($externalPage, "",
			function(responseText, textStatus, XMLHttpRequest) {
            	if(textStatus == 'error') {
            	    //$('.content-loader .default-content').html('<div class="ajax-error">There was an error making the AJAX request</div>');
            	}
        	});
	}
}

/*
 * ToolTip
 * @descr	adds a tooltip to span.glossary elements
 * takes the text from the title attribute  and creates the following html:
 * 
	<div class="tooltip">
		<p>
			Ut enim ad minim veniam, quis nostrud exercitation.
		</p>
	</div>
 *
 */
ToolTip = {
	init: function(){
		if ($('.default-content').length > 0) {
			$('span.glossary').hover(
				function(e){ 
					$(this).addClass('gloss-over');	
					// get the text from the title and then clear it
					$toolText = $(this).attr('title');
					$(this).attr("title","");
					$(document.createElement("div")).attr("class","tooltip").prependTo("body"); 
					$(".tooltip").append("<p>" + $toolText + "</p>");
					
					var position = Toolbox.findElementPosition($(this)[0]);
					$(".tooltip").css("left", (position[0]+ parseInt(($(this).width()/3))));
					$(".tooltip").css("top", position[1]+16);
				},
				function(){
					$(this).removeClass('gloss-over');
					$('.tooltip').remove(); 
					// put the text back in the title
					$(this).attr("title",$toolText);
				}
			);			
		}
	}
}

/*
 * ExpanderList
 * @descr	hides all content and enables them to be open and closed by clicking the title
 * only one can be open at a time
 * 
 */
ExpanderList = {
	init: function() {
		if ($('.expander-block').length > 0) {
			$('.expander-block .text').hide();
			
			$('.expander-block .title').hover(function(){
				$(this).addClass('hover');
			},
			function(){
				$(this).removeClass('hover');				
			});
		
			//make sure panel is in window frame: if not scroll
			var checkPosition = function(title) {	
				var faqListItem = jQuery(title).parent();
				var faqListItemHeight = faqListItem.outerHeight();	
								
				var position = Toolbox.findElementPosition(faqListItem[0]);
				var top = parseInt(position[1]);		
				var bottom = top + faqListItemHeight;	
						
				var windowHeight = Toolbox.getWindowHeight();
				var scrollY = Toolbox.getScrollY();
				
				var scrollPosition = bottom + 10 - windowHeight;
				if(top-scrollPosition<0) { scrollPosition = top; } //if scrolling would put the top of the item outside the viewport, then scroll to top
				
				if(bottom - scrollY > windowHeight) { jQuery.scrollTo(scrollPosition, {speed:500}  ); }	
			}
			
			$('.expander-block .title').click(function(){
				$(this).next('div').slideUp({
					duration: 800,
					easing: 'easeOutExpo', 
					complete: function(){
						$(this).parent().removeClass('open');
					}
				});
			
				if($(this).next('div').css('display') != 'block'){
					$(this).parent().addClass('open');
					$(this).next('div').slideDown({
						duration: 800,
						easing: 'easeOutExpo', 
						complete: function(){
							checkPosition(this);
						}
					});
				}
				return false;
			});
		}
	}
}

/*
 * ContactForm
 * @descr	pops the contact form up 
 * 
 */
ContactForm = {
	visible:false, //true if #ContactPopUp is visible
	init: function() {
		if ($('.contact-form').length > 0) {
			$('.contact-form').click(function() {
				ContactForm.show($(this));
				return false;	
			});
			
			$('#ModalScreen').click(function(){
				if(ContactForm.visible) ContactForm.hide();
			});	
		}
	},
	show:function(link){
		ContactForm.visible = true;
		ModalScreen.show();				
		// extract external filename from classname
		$externalPage = link.attr('class') + ".html";	
		
		// create div container
		$('body').append('<div class="popup" id="ContactPopUp"><div class="popup-content"></div><div class="popup-bottom"></div></div>');	
				
		//If not IE6 set opacity to '0' so popup can fade in
		if(!(jQuery.browser.msie && jQuery.browser.version < 7)) $('#ContactPopUp').css({opacity:'0'});
		
		//Position popup with contactform
		var x = ($(window).width()-$('#ContactPopUp').width())/2;
		var y = $(window).scrollTop()>80 ? 20 +$(window).scrollTop() : 80;
		$('#ContactPopUp').css({left:x+'px',top:y+'px'});
		
		//If not IE6 Fade in popup
		if(!(jQuery.browser.msie && jQuery.browser.version < 7)) $('#ContactPopUp').animate({opacity:'1'},{ duration: 600, easing: 'easeInExpo'});
				
		/* image is already preloaded in page initalization */
		$('#ContactPopUp .popup-content').html('<img class="loading" src="/cms/system/modules/nl.srk/resources/img/icons/icon-loader.gif" />');
			
		// extract url from id
		$externalPage = link.attr('href');
		// separate the id with a space and a comma
		$externalPage = $externalPage.replace('#',' ,#');
		// load the external div into #ContactPopUp .popup-content
		$('#ContactPopUp .popup-content').load($externalPage, "",
		function(responseText, textStatus, XMLHttpRequest) {
           	if(textStatus == 'error') {
           	   //$('#ContactPopUp .popup-content').html('<div class="ajax-error">There was an error making the AJAX request</div>');
           	}
			else {
				// loading is successful, so create close button
				$('.popup-content').append('<span class="ext-close">sluiten</span>');
				// add behaviour to close button
				$('.ext-close').hover(function(){
					$(this).addClass('hover');
				}, function(){
					$(this).removeClass('hover');		
				});
				
				$('.ext-close').click(function(){
					ContactForm.hide();		
					return false;
				});	
				// call the form focus function again for this new form
				FormFocus.init();
			}
        });
	},
	hide:function(){
		ContactForm.visible = false;		
		ModalScreen.immediateHide();
		$('.popup').remove(); 	
	}
}

/*
 * FormFocus
 * @descr	hides all form comments 
 * and then shows them on element focus
 * 
 */
FormFocus = {
	init: function() {
		if ($('form .comments').length > 0) {
			$('form .comments:not(.error)').hide();
			$('.form-content .form-group input:not(.submit), .form-content .form-group select, .form-content .form-group textarea').focus(function(){
				$('.form-group.hover').removeClass('hover');
				$('form .comments:not(.error)').hide();
				if ($(this).parent().hasClass('form-group')) {
					$(this).parent().addClass('hover');
					$(this).parent().next('.comments').show();
				}
				else {
					$(this).parent().parent().addClass('hover');
					$(this).parent().parent().next('.comments').show();
				}
			});
		}
	}
}

/*
 * PrintPage
 * @descr	enables the print button  
 */
PrintPage = {
	init: function() {
		if ($('.print-page').length > 0) {
			
			$('.print-page').hover(function(){ $(this).addClass('hover'); },
				function(){ $(this).removeClass('hover'); });
			
			$('.print-page').click(function(){ window.print(); });
		}
	}
}

/**
 * Toolbox 
 * @descr contains functions that can be very handy throughout this document
 */
//	:::::::::::::::::::::::::::::: Start General essential functions
Toolbox = {
	findElementPosition : function (elem){
		var curleft = curtop = 0;
		if (elem.offsetParent) {
		
			curleft = elem.offsetLeft
			curtop = elem.offsetTop
			while (elem = elem.offsetParent) {
				curleft += elem.offsetLeft
				curtop += elem.offsetTop
			}
		}
		return [curleft,curtop];
	},
	getWindowHeight : function () {
		var myHeight = 0;
		if( typeof( window.innerHeight ) == 'number' ) {
			//Non-IE
			myHeight = window.innerHeight;
		} else if( document.documentElement &&  document.documentElement.clientHeight  ) {
			//IE 6+ in 'standards compliant mode'
			myHeight = document.documentElement.clientHeight;
		}
		return myHeight;
	},
	getScrollY : function () {
		var scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;    
		}
		return scrOfY;
	},
	preloadImages : function() { 
		for(var i = 0; i<arguments.length; i++) {
		    jQuery("<img>").attr("src", arguments[i]);
		}	
	}
}
/**
 * @descr Window resize events
 */
$(window).resize(function(){
  Nav.immediateHide();
  ContactForm.hide();
});
