//var sheet = document.createElement('style')
//sheet.innerHTML = "a.woningitem img.woningthumb {display:none;} ";
//document.body.appendChild(sheet);


var nip = "index_new.php";
var nip = "index.php";
var starttimer;
var nofade = 0;
$(document).ready(function(){
	/*
	$('a[href*=index.php]').click(function() {
		$(this).attr('href',$(this).attr('href').replace('index.php',nip));
	});
	*/
	$('#gasnelzoeken').click(function(event) {
		$('#snelzoekform').animate({top: -70, opacity: 0},200, '');
		starttimer = setTimeout("window.location.href = nip+'?id=22&ditto_sz_filter='+$('#sz_prijzen').val()+$('#sz_plaats').val();",200);
		return false;
		event.preventDefault(); //stop default browser behaviour
	});
    $("a#snelzoekerlink").hover(
		function () {
			$('#snelzoekform').css({top: -40, opacity: 0, display: 'block'});
			//$('#snelzoekform').fadeIn();
			$('#snelzoekform').animate({top: 0, opacity: 1},200, '');
			$('#snelzoekerlink').hide();
			clearTimeout(starttimer);
			starttimer = setTimeout("nofade = 1;",50);
			nofade = 1;
		}, 
		function () {
			//nofade=0;
			//starttimer = setTimeout("szfade()",1900);
		}
	);
	$("body, #wrapper, #fullheightcontainer").click(function () {
			nofade=0;
			starttimer = setTimeout("szfade()",100);
		}
	);
	$("#snelzoekform, #snelzoekform input").click(function () {
			nofade = 1;
			clearTimeout(starttimer);
			starttimer = setTimeout("nofade = 1;",50);
			$('#snelzoekform').show();
			$('#snelzoekerlink').hide();
			
		}
	);
	$("#snelzoekform, #snelzoekform input").hover(function () {
			nofade = 1;
			clearTimeout(starttimer);
			starttimer = setTimeout("nofade = 1;",50);
		}, 
		function () {
			nofade=0;
			starttimer = setTimeout("szfade()",3000);
		}
	);
	
	$("#subheader1 ul ul").hover(function () {
			nofade = 0;
			$('#snelzoekform').animate({top: -70, opacity: 0},200, '');
			starttimer = setTimeout("$('#snelzoekerlink').show();",100);
		}
	);
	
	var dt=$(document).attr('title');
	//alert(dt.indexOf('Tilburg') + " " + dt.indexOf('Breda'));
	if ((dt.indexOf('Tilburg')!=-1) && (dt.indexOf('Breda')==-1)){
		$('#makelaarsfoto').attr('src','assets/images/makelaars_tilburg.jpg');
		$('a#footerlogolink').fadeIn('slow');
		$('#homebutton').css('background','#fff url(assets/templates/wbb/images/homebutton_tilburg.png) no-repeat left bottom');
	}
	if ((dt.indexOf('Breda')!=-1) && (dt.indexOf('Tilburg')==-1)){
		$('#makelaarsfoto').attr('src','assets/images/makelaars_breda.jpg');
		$('a#footerlogolink').fadeIn('slow');
		$('#homebutton').css('background','#fff url(assets/templates/wbb/images/homebutton_breda.png) no-repeat left bottom');
	}
	
	if(window.location.href.indexOf("ditto_sz_filter")>0){
		var szr=getUrlVars()["ditto_sz_filter"];
		var szra = getUrlVars()["ditto_sz_filter"].split(".");
		var vanprijs = szra[0].substring(szra[0].indexOf(",")+1,(szra[0].length-2));
		var totprijs = szra[1].substring(szra[1].indexOf(",")+1,(szra[1].length-2));
		var regio   = szra[2].substring(szra[2].indexOf(",")+1,(szra[2].length-2));
		zoekopdracht = 'van <strong>&euro; <span class="prijs">'+vanprijs+'</span></strong> tot <strong>&euro; <span class="prijs">'+totprijs+'</span></strong>';
		if (vanprijs=="0"){
			zoekopdracht = '<strong>tot &euro; <span class="prijs">'+totprijs+'</span></strong>';
		}
		if (totprijs=="999000"){
			zoekopdracht = '<strong>vanaf &euro; <span class="prijs">'+vanprijs+'</span></strong>';
		}
		$('h1.top').after('<p class="zoekopdracht">Er is gezocht in de prijsklasse '+zoekopdracht+', in de regio: <strong>'+regio+'</strong>.</p>');	
	}
	
    if(window.location.href.indexOf("ref=")>0){
    	$('#referentienr').val(getUrlVars()["ref"]);
    }
    $('#hfdstkid2 #cfContact').click(function (event) {
            var newhash = window.location.href;
            $("#EmailForm").attr("action",newhash); 
            
            //alert('Dit formulier kan pas gaan werken als de website "echt" on-line is...');
			//event.preventDefault(); //stop default browser behaviour
			//return false;
        }
    );
	
	$('.prijs').currency();
	
	
	$("a#snelzoekerlinkkk").fancybox({
        'overlayOpacity'    :   0.5,
        'overlayColor'      :   '#00346E',
        'padding'			:   0,
		'autoScale'			:   false,
		'transitionIn'		:   'none',
		'transitionOut'		:   'none',
        'hideOnContentClick':   false,
        'autoDimensions'	: 	false,
        'width'				:   350,
		'height'			:   350,
		'scrolling'			: 	'no',
		'titleShow'			: 	false
    });
    
    //$('.waardering').mouseenter(function () {
    //	$(this).css("width","auto");
    //});

	//$('.waardering').mouseout(function () {
	//	$(this).css("width","50px");
	//});
    
});

function szfade() {
	if(nofade==0){
		$('#snelzoekform').animate({top: -70, opacity: 0},200, '');
		//$('#snelzoekerlink').hide();
		starttimer = setTimeout("$('#snelzoekerlink').show();",100);
	}
}




/* Copyright (c) 2009 Michael Manning (actingthemaggot.com) Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.*/
(function(A){A.fn.extend({currency:function(B){var C={s:".",d:",",c:0};C=A.extend({},C,B);return this.each(function(){var D=(C.n||A(this).text());D=(typeof D==="number")?D:((/\./.test(D))?parseFloat(D):parseInt(D)),s=D<0?"-":"",i=parseInt(D=Math.abs(+D||0).toFixed(C.c))+"",j=(j=i.length)>3?j%3:0;A(this).text(s+(j?i.substr(0,j)+C.s:"")+i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+C.s)+(C.c?C.d+Math.abs(D-i).toFixed(C.c).slice(2):""));return this})}})})(jQuery);jQuery.currency=function(){var A=jQuery("<span>").text(arguments[0]).currency(arguments[1]);return A.text()};


// var test = getUrlVars()["test"];
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}







