// FAMILYWARE FUNCTIONS
var allowedChars = '-1234567890abcdefghijklmnopqrstuvwxyz';	
	
function ValidateEmail() {
	return true;
}
function SetDomainName() {
	var email = GetElementValue('Email');
	var i = email.indexOf('@');
	if (i >= 0) email = email.substr(0, i);
	var c;
	var domain = '';
	for (i = 0; i < email.length; i++) {
		c = email.substr(i, 1).toLowerCase();
		if (allowedChars.indexOf(c) < 0) c = '-';
		domain += c;
	}
	SetElementValue('Domain', domain);
	SetUrlDomain();
}
function SetUrlDomain() {
	FindElement('urlDomain').innerText = 'https://' + GetElementValue('Domain') + '.familyware.nl';
}
function ValidateDomain() {
	var keyCode = window.event.keyCode; 
	var key = String.fromCharCode(keyCode).toLowerCase();
	var retVal = (keyCode <= 31) || (allowedChars.indexOf(key) >= 0);
	return retVal;
}
function ValidatePhone() {
	var keyCode = window.event.keyCode;
	var typedChar = String.fromCharCode(keyCode);
	var allowedChars = '-1234567890';	
	return (keyCode <= 31) || (allowedChars.indexOf(typedChar) >= 0);
}
function SubmitClick() {
	var agreed = FindElement('chkAgree');
	if (agreed == null || !agreed.checked) {
		alert('U dient eerst akkoord te gaan met de algemene voorwaarden door het selectievakje voor akkoordverklaring aan te vinken.');
	}
	else {
		FindElement('trSubmit').style.display = 'none';
		FindElement('trPatience').style.display = 'block';
		SubmitForm();
	}
}

// function below used to prevent 'Click here to activate this control' message 
function AddFlash()
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n');
	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0"\n');
	document.write('id="familyware4" width="910" height="200">\n');
	document.write('<param name="movie" value="fwbanner.swf">\n');
	document.write('<param name="bgcolor" value="#FFFFFF">\n');
	document.write('<param name="quality" value="high">\n');
	document.write('<param name="allowscriptaccess" value="samedomain">\n');
	document.write('<embed type="application/x-shockwave-flash"\n');
	document.write('pluginspage="http://www.macromedia.com/go/getflashplayer"\n');
	document.write('width="910" height="200"\n');
	document.write('name="familyware4" src="fwbanner.swf"\n');
	document.write('bgcolor="#FFFFFF" quality="high"\n');
	document.write('swLiveConnect="true" allowScriptAccess="samedomain"\n');
	document.write('></embed>\n');
	document.write('</object>\n');
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}



function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}