$(document).ready(function () {

 $(".otheritem p a, #right a, #footer a").attr('target','_blank');
 
 
	$('a:contains("Lees verder")').attr('target','').css('color','#b10000').css('font-weight','bold');
	
	
	
			$('#topbanner').cycle({fx:'fade',speed:500,timeout:6000,pause:1,random:1});
	
 
 
 $('#name').focus(function(){
 
		$.get('/?ajax=true&x=hash', function(data){
			$('#hash').attr('value',data);
		});
 
 
 });
 
 
$('form input[type="text"]').each(function() {
    var default_value = this.value;
    $(this).focus(function() {
    
    
    
        if(this.value == default_value) {
            this.value = '';
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            this.value = default_value;
        }
    });
});


	$('.swfbanner').each(function(){
		var swf=$(this).attr('rel');
		
		//$(this).children('img').remove();
		//$(this).prepend('<div class="banny'+$(this).children('img').attr('class')+' banny"></div>');
		//$(this).children('img').attr('alt','');
		//console.log($(this).next().html());
		//$(this).attr('href','');
		var width=$(this).css('width');
		var height=$(this).css('height');
		
		$(this).flash({
			src: swf,
			width:width,
			height:height,
          	flashvars: {clickTag: 'http://www.bedandbreakfast.eu'}
		});

	});
	
	$('.poll').click(function(){
	
		$('#pollvote').attr('value',$(this).attr('value'));
	
		$('#polle ul').hide();
		
		$('#captcha').show();
	
	});
	
	$('#vote').click(function(){
	
		$.get('/?ajax=true&x=vote&id='+$('#pollvote').attr('value')+'&captcha='+$('#captchai').attr('value')+'&email='+$('#captchaemail').attr('value'), function(data){
			if(data){
				$('#polle').html(data);
			}
		});
	});
	
	$('#domath').click(function(){
	
		//console.log($('#prijs').attr('value'));
		
		if($('input[name="soort"]:checked').attr('value')=='1'){
			var v=$('#prijs').attr('value');
		
			if (v.indexOf(",") > -1) { v = v.replace(/,/, "."); }
			var n = parseFloat(v);
			var no=n/(parseFloat($('input[name="tarief"]:checked').attr('value'))+1);
			
			
			var non=n-no;
			$('#btw').attr('value',String(non.toFixed(2)).replace(".",","));
			$('#prijsex').attr('value',String(no.toFixed(2)).replace(".",","));
		}
		
		if($('input[name="soort"]:checked').attr('value')=='2'){
			var v=$('#btw').attr('value');
		
			if (v.indexOf(",") > -1) { v = v.replace(/,/, "."); }
			var n = parseFloat(v);
			var no=n/$('input[name="tarief"]:checked').attr('value');
			var non=no+n;
			
			$('#prijs').attr('value',String(non.toFixed(2)).replace(".",","));
		
		
			$('#prijsex').attr('value',String(no.toFixed(2)).replace(".",","));
		
		}
		
		if($('input[name="soort"]:checked').attr('value')=='3'){
			var v=$('#prijsex').attr('value');
		
			if (v.indexOf(",") > -1) { v = v.replace(/,/, "."); }
			var n = parseFloat(v);
			var no=n*(parseFloat($('input[name="tarief"]:checked').attr('value'))+1);
			var non=n*(parseFloat($('input[name="tarief"]:checked').attr('value')));
		
			$('#prijs').attr('value',String(no.toFixed(2)).replace(".",","));
			$('#btw').attr('value',String(non.toFixed(2)).replace(".",","));
		
		
		}
		
	});
	
	
	$('#reset').click(function(){
	
			$('#prijsex').attr('value','0,00');
			$('#prijs').attr('value','0,00');
			$('#btw').attr('value','0,00');
	
	});
	
		tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox

	var width=$(window).width();
	
	if(width>1199){

		$('#leftbanner').show();

	}



});

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

