$(document).ready(function(){
	initSIFR();
	menu();
	clearInput();
});
function clearInput() {
	$('.fade').focus(function() {
		$(this).select();
		$(this).prev().fadeTo(150, 0.33);
		$(this).keydown(function() {
			$(this).css('background-repeat', 'repeat');			 
		});
	});
	$('.fade').blur(function() {
		if ( $(this).val() == '' ) {
			$(this).css('background-repeat', 'no-repeat');
			$(this).prev().fadeTo(150, 1);
		}
	});
	$('.fade').each(function(){
		if ( $(this).val() != '') {
			$(this).css('background-repeat', 'repeat');
		};
	});
}
function initSIFR(){
	sIFR.replace(sifr, {
		selector: 'h2.slide'
		,css: [
		  '.sIFR-root { font-weight: bold; font-size: 55px; color: #ffffff; text-transform: uppercase; cursor: pointer}',
		  '.sIFR-root a { font-size: 55px; color: #ffffff; text-decoration: none; }',
		  '.sIFR-root a:hover { color: #ffffff; text-decoration: none; }'
		],
		wmode: 'transparent'
	});
	sIFR.replace(sifr, {
		selector: 'h2.project'
		,css: [
		  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 14px; color: #2a7bb2; line-height: 14px; height: 14px; width: auto;}'
		],
		wmode: 'transparent'
	});
	sIFR.replace(sifr, {
		selector: 'h1.content'
		,css: [
		  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 17px; color: #333333; line-height: 17px; height: 17px; width: auto;}'
		],
		wmode: 'transparent'
	});
	sIFR.replace(sifr, {
		selector: 'h2.footer'
		,css: [
		  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 15px; color: #ffffff; text-transform: uppercase; line-height: 15px; height: 15px; width: auto;}'
		],
		wmode: 'transparent'
	});
	sIFR.replace(sifr, {
		selector: 'h2.left'
		,css: [
		  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 15px; color: #333333; line-height: 15px; height: 15px; width: auto;}'
		],
		wmode: 'transparent'
	});
}
function menu(){
	$('#menu ul li').hover(function(){
		$(this).addClass('hover');
		$(this).children('ul.sub').show();
	}, function(){
		$(this).removeClass('hover');
		$(this).children('ul.sub').hide();
	});
}
function validateForm(p_sForm){
	$('#'+p_sForm).validate({
		errorPlacement: function(error, element) {
			var obj = element.parent().next('div.icon');
			error.insertAfter(obj);
			obj.attr('class','icon invalid');
		},
		errorElement: 'div',
		success: function(label) {
			label.prev('div.icon').attr('class','icon valid');
			label.remove();
		},
		submitHandler: function(form) {
			form.submit();
		}
	});	
}
function projectCycle() {
	$('#cycle')
		.cycle({
			fx:     'fade',
			timeout: 4000,
			speed:	 900,
			next:   '#cycle_next', 
    		prev:   '#cycle_prev', 
			after: function(curr,next,opts) {
				var nCurrent = opts.currSlide + 1;
				$('span#current').text(nCurrent);
			}
	});
}
function homeSlideCycle(){
	$('#slider_title').cycle({
		fx:     'fade',
		timeout: 4000,
		speed:	 900,
		next:   '#next', 
		prev:   '#prev',
		cleartypeNoBg: true,
		after: function(curr,next,opts) {
			initSIFR();
		}
	});
	$('#cycle').cycle({
		fx:     'fade',
		timeout: 4000,
		speed:	 900,
		next:   '#next', 
		prev:   '#prev', 
		cleartypeNoBg: true,
		after: function(curr,next,opts) {
			/*var sLink = $('#cycle a:visible').attr('href');
			var oLink = $('a#slider_overlay');
			if(sLink.indexOf('hellebrekers') > 0){
				oLink = oLink.removeAttr('target');	
			} else {
				oLink = oLink.attr('target','_blank');		
			}
			oLink.attr('href',sLink);*/
		}
	});
}
function initialize() {
	var startLatlng = new google.maps.LatLng(52.200924,5.770038);
	var myOptions = {
	  zoom: 8,
	  center: startLatlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP,	  
	  mapTypeControl: false
	}
	var map = new google.maps.Map(document.getElementById('map'), myOptions);
	
	var image = new google.maps.MarkerImage('images/template/google.png',
		new google.maps.Size(206, 84),
		// The origin for this image is 0,0.
		new google.maps.Point(0,0),
		// The anchor for this image is the base of the flagpole at 0,32.
		new google.maps.Point(100, 75)
	);
	var myLatlng = new google.maps.LatLng(52.377924,5.770038);
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map,
		icon: image
	}); 
	
	var myLatlng2 = new google.maps.LatLng(51.777912,5.54862);
	var marker2 = new google.maps.Marker({
		position: myLatlng2, 
		map: map,
		icon: image
	}); 
	
	var myLatlng3 = new google.maps.LatLng(52.128203,4.638124);
	var marker3 = new google.maps.Marker({
		position: myLatlng3, 
		map: map,
		icon: image
	}); 
}
