$(document).ready(function(){
	initSIFR();	
	clearInput();
	menu();
	selectboxForms();
	tellafriend();
});
function selectboxForms(){
	$('div.form div.select select').selectbox();
	var zIndex = 9999;
	$('div.form div.entry').each(function(){
		$(this).css('z-index',zIndex);
		zIndex--;
	});
}
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 menu(){
	var obj = $('#menu ul li');
	
	obj.hover(function(){
		menuHover($(this));			   
	}, function(){
		menuHover($(this));
	});
}
function menuHover(obj){
	var oSubmenu = obj.children('ul.sub');
	if(oSubmenu.length > 0){
		obj.children('a').toggleClass('hover');
		oSubmenu.toggle();
	}
}
function initSIFR(){
	sIFR.replace(sifr, {
	selector: 'h1'
	,css: [
	  '.sIFR-root { padding: 0px; font-weight: normal; font-size: 29px; color: #009edc; line-height: 29px; height: 29px; width: auto;}'
	],
	wmode: 'transparent'
	});
	sIFR.replace(sifr, {
	selector: 'h2.footer'
	,css: [
	  '.sIFR-root { padding: 0px; font-weight: normal; font-size: 20px; color: #009edc; line-height: 20px; height: 20px; width: auto;}'
	],
	wmode: 'transparent'
	});
	sIFR.replace(sifr, {
	selector: 'h2.left'
	,css: [
	  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 23px; color: #009edc; line-height: 30px; height: 30px; width: auto;}'
	],
	wmode: 'transparent'
	});
	sIFR.replace(sifr, {
	selector: 'h2.keukens'
	,css: [
	  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 18px; color: #000000; line-height: 18px; height: 18px; width: auto; text-transform: uppercase;}'
	],
	wmode: 'transparent'
	});
	sIFR.replace(sifr, {
	selector: 'h2.prijs'
	,css: [
	  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 18px; color: #0fa2de; line-height: 21px; height: 21px; width: auto;}'
	],
	wmode: 'transparent'
	});
	sIFR.replace(sifr, {
	selector: 'h2.gray18'
	,css: [
	  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 18px; color: #404040; line-height: 21px; height: 21px; width: auto;}'
	],
	wmode: 'transparent'
	});
	sIFR.replace(sifr, {
	selector: 'h2.accessoires'
	,css: [
	  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 15px; color: #ffffff; line-height: 19px; height: 19px; width: auto; text-transform: uppercase;}'
	],
	wmode: 'transparent'
	});
}
function sfeerCycle() {
	$('#cycle')
		.after('<div id="nav">')
		.cycle({
			fx:     'fade',
			timeout: 6000,
			speed:	 900,
			pager: '#nav',
			after: function(curr,next,opts) {

			}
	});
}
function scrollToBedankt(){
	var oPos = $('#afspraak_maken').offset();
	var nTop = oPos.top;
	$('html, body').animate({
		scrollTop:nTop
	}, 'slow');
}
function keukens(p_sVal){
	$('div.style a').click(function(){
		$('div.style').removeClass('active');
		$(this).parent().addClass('active');
		var sVal = $(this).attr('title');
		loadKeukens(p_sVal + '=' + sVal);
	});
	$('#selectpage div ul li').click(function(){
		var nPerPage = $(this).text();
		loadKeukens('perpage=' + nPerPage);
	});
}
function loadKeukens(p_sData){
	$.ajax({
		type: 'POST',
		url: sDomain+'inc/keukens.inc.php',
		data: p_sData,
		success: function(result){
			$('#ajax').html(result);
			initSIFR();
		}
	});		
}
/*function accessoires(){
	$('div.style a').click(function(){
		$('div.style').removeClass('active');
		$(this).parent().addClass('active');
		var sCat = $(this).attr('title');
		loadAccessoires('categorie=' + sCat);
	});
	$('#selectpage div ul li').click(function(){
		var nPerPage = $(this).text();
		loadAccessoires('perpage=' + nPerPage);
	});
}
function loadAccessoires(p_sData){
	$.ajax({
		type: 'POST',
		url: sDomain+'inc/accessoires.inc.php',
		data: p_sData,
		success: function(result){
			$('#ajax').html(result);
			initSIFR();
		}
	});		
}*/

function initialize() {
	var myLatlng = new google.maps.LatLng(51.751158,4.16281);
	var myOptions = {
	  zoom: 10,
	  center: myLatlng,
	  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_marker.png',
		// This marker is 20 pixels wide by 32 pixels tall.
		new google.maps.Size(141, 101),
		// 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(70, 101)
	);
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map,
		icon: image
	});   
}

function gaDirectNaar(){
	$('#gadirectnaar div div ul li').each(function(){
		var sVal = $(this).text();
		$(this).attr('onclick','pageTracker._trackEvent(\'Ga direct naar\', \'view\', \''+sVal+'\')');
	});
	$('#gadirectnaar div div ul li').click(function(){
		var sLink = $(this).attr('id').replace('sDirectNaar_input_','');
		if(sLink != ''){
			window.location.href = sLink;	
		}
	});
}

function tellafriend(){
	$('#tell-a-friend-button').click(function(){
		$('#tell-a-friend').toggle();
		initSIFR();
	});
}

function detailSlideshow(){
	$('#keukenslider').slideKey({
		sEasing: 'easeInOutBack',
		bKeyboard: true,
		sDirection: 'y',
		sExtension: 'detail'
	});	
	$('#numbering').fadeTo(0,0.8);
}

function googleTracker(sKnop, sReferrer){
	pageTracker._trackPageview(sKnop);
	pageTracker._trackEvent(sKnop,'view',sReferrer);
}