jQuery.noConflict();
jQuery(document).ready(function(){
	
	jQuery("select.huur-price").attr('disabled', true);
	
	if (jQuery("#totale-aanbod").val() == 'huur') {
			jQuery("#totale-aanbod").attr('name', 'type');
			jQuery("select.huur-price").attr('disabled', false).show();
			jQuery("label.huur-price").show();
			jQuery("select.koop-price").attr('disabled', true).hide();	
			jQuery("label.koop-price").hide();
		}
	jQuery('#totale-aanbod').change(function(){
		if (jQuery(this).val() == 'huur'){
			jQuery(this).attr('name', 'type');
			jQuery("select.huur-price").attr('disabled', false).show();
			jQuery("label.huur-price").show();
			jQuery("select.koop-price").attr('disabled', true).hide();
			jQuery("label.koop-price").hide();
		}
		else{
			jQuery(this).attr('name', 'commercial');
			jQuery("select.koop-price").attr('disabled', false).show();
			jQuery("label.koop-price").show();
			jQuery("select.huur-price").attr('disabled', true).hide();
			jQuery("label.huur-price").hide();
		}
	});
	
	jQuery("input#huur").click(function() {
		jQuery(this).attr('name', 'type');
		jQuery("select.koop-price").attr('disabled', true).hide();
		jQuery("select.huur-price").attr('disabled', false).show();
	});
	jQuery("input#totale-aanbod, input#bestaande-woning, input#nieuwbouw-woning, input#bedrijfshuisvesting").click(function() {
		jQuery("input#huur").attr('name', 'commercial');
		jQuery("select.koop-price").attr('disabled', false).show();
		jQuery("select.huur-price").attr('disabled', true).hide();
	});
});

function checkContactForm(){
	var t = '';
	if($('naam').value=='') t += '+ Vul aub uw naam in.\n';
	if($('telefoon').value=='') t += '+ Vul aub uw telefoonnummer in.\n';
	if(t != ''){
		alert('U heeft niet alle verplichte velden ingevuld.\nU dient alle velden gemarkeerd met een * in te vullen.\n\n'+t);
		return false;
	}
	return true;
}
/*
var Search = {
	register: function(){
		if($('totale-aanbod')){
			//$('address').value='Straat en huisnummer';
			//$('postal').value='Postcode';
			$('city').value='Plaatsnaam';
			var a = [$('totale-aanbod'), $('bestaande-woning'), $('nieuwbouw-woning'), $('bedrijfshuisvesting')];
			$('huur').onclick = function(){
				var i;
				for(i = 0; i < a.length; i++){
					a[i].checked = '';
				}
				return true;
			}
			for(i = 0; i < a.length; i++){
				a[i].onclick = function(){
					jQuery('huur').checked = '';
					return true;
				}
			}
			$('searchform').onsubmit = function(){
				if($('address').value=='Straat en huisnummer')$('address').value='';
				if($('postal').value=='Postcode')$('postal').value='';
				if($('city').value=='Plaatsnaam')$('city').value='';
			}
		}
	}
}
*/
var Photos = {
	src: [],
	cur: 0,
	next: function(){
		if((Photos.cur+1) >= Photos.src.length) return false;
		Photos.setPhoto(Photos.cur+1);
	},
	previous: function(){
		if(Photos.cur == 0) return false;
		Photos.setPhoto(Photos.cur-1);
	},
	register: function(){
		if($('photo-big')){
			var large = jQuery('photo-big'), a = El.getElementsByClassName('show-photo', 'a'), j;
			for (var i = 0; i < a.length; i++){
				while(a[i].firstChild.nodeName != 'IMG'){
					El.remove(a[i].firstChild);
				}
				a[i].id = 'photo'+i;
				Photos.src[i] = a[i].firstChild.src.replace('thumbnail','photo');
				a[i].onclick = function(){
					Photos.setPhoto(this.id.substring(5));
					return false;
				}
			}
			$('prev-photo').onclick = function(){Photos.previous();  return false;}
			$('next-photo').onclick = function(){Photos.next(); return false;}
		}
	},
	setPhoto: function(i){
		Photos.cur = parseInt(i);
		$('cur-photo').innerHTML = Photos.cur+1;
		$('photo-big').src = Photos.src[i];
	}
}
Event.add(window, 'load', Photos.register);
/*
Event.add(window, 'load', Search.register);
*/
