// Scripts

//slide disclaimer
function toggle(anything) {
	Effect.toggle(anything, 'blind', {duration: 0.5});
};


// update producten
function ajaxUpdater(id,url) {
 new Ajax.Updater(id,url,{asynchronous:true});
}

 
// offerte

function alertselected(){
		Element.show("fill_me");
		var check = $F('categorie');
		if ( check == 1){
			$('fill_me').update('Maak een keuze');
		} else if ( check == 'Intercoms'){
			$('fill_me').update('Intercoms, wij verkopen ook.');
		} else if ( check == 'Deurtelefonie') {
			$('fill_me').update('Deurtelefonie');
		} else if ( check == 'Omroepapparatuur') {
			$('fill_me').update('Omroepapparatuur');
		} else if ( check == 'Zorgsystemen') {
			$('fill_me').update('Zorgsystemen');
		} else if ( check == 'Onbekend') {
			Element.hide('fill_me');
		}
}
//*********************
// textarea
function sz(t) {
a = t.value.split('\n');
b=1;
for (x=0;x < a.length; x++) {
 if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
 }
b+= a.length;
if (b > t.rows) t.rows = b;
}

//************************
// formvalidation

function Highlight(element){
       new Effect.Highlight(element, 
                      {
                        startcolor: "#da1b1b",
                        endcolor: "#ec6a55",
                        restorecolor: "#ec6a55",
                        duration: 3
                      })
   }


function checkForm(){
	counter = 0;
	checkname();
	checkmail();
	message();
	tel();
	if (counter > 0){
		$('fillAll').update('U ben vergeten enkele velden in te vullen.');
		Element.show("fillAll");
		Highlight("fillAll");
		return false
	}
	Element.hide("fillAll");
	return true
}
function checkname(){	
	if ($F("naam") == ""){
		$("nameinhere").update("Vul hier uw naam in.");
		Element.show("nameinhere");
		counter++;
	}
	else {
		$("nameinhere").hide();
	}
}
function checkmail(){
	if ($F("email") == ""){
		$("mailinhere").update("Vul hier uw emailadres in.");
		Element.show("mailinhere");
		counter++;
	}
	else { 
		$("mailinhere").hide();
	}
}
function tel(){
	if ($F("tel") == ""){
		$("telinhere").update("Vul hier uw telefoonnummer in.");
		Element.show("telinhere");
		counter++;
	}
	else { 
		$("telinhere").hide();
	}
}
function message(){
	if ($F("wensen") == ""){
		$("messageinhere").update("Weet u zeker dat u geen wensen heeft?");
		Element.show("messageinhere");
		counter++;
	}
	else { 
		$("messageinhere").hide();
	}
}

