﻿$(document).ready(function() {
    fixFlash();
    $('img[@src$=.png]').ifixpng();
});

//window.onload = function() {
//    
//}

function fixFlash() {
    try {
        document.getElementById("webnet4u").innerHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"16\" height=\"19\" id=\"w-logo_WHITE\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"webnet4u.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"bgcolor\" value=\"#000000\" /><embed src=\"webnet4u.swf\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#000000\" width=\"16\" height=\"19\" name=\"w-logo_WHITE\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object><br/><a href=\"http://www.webnet4u.be\">webdesign</a>";
    }
    catch(e) {
    }
}

function checkTextBoxes() {
	var naam, telefoon, email, bericht, error_color;
	error_color = "#efe5af";
	ok_color = "#FFFFFF";
	
	naam = document.getElementById("ctl00_cphLeftContent_txtNaam").value;
	telefoon = document.getElementById("ctl00_cphLeftContent_txtTelefoon").value;
	email = document.getElementById("ctl00_cphLeftContent_txtEmail").value;
	bericht = document.getElementById("ctl00_cphLeftContent_txtBericht").value;
	
	
	
	if ((naam.length < 1) || (telefoon.length < 9) || (bericht < 1) || (email < 1)) {
		if (naam.length < 1) {
			window.document.getElementById("ctl00_cphLeftContent_txtNaam").style.backgroundColor = error_color;
		}
		else {
			window.document.getElementById("ctl00_cphLeftContent_txtNaam").style.backgroundColor = ok_color;
		}
		
		if (telefoon.length < 1) {
			window.document.getElementById("ctl00_cphLeftContent_txtTelefoon").style.backgroundColor = error_color;
			window.document.getElementById("rqrTelefoon").innerHTML = "(*)";
		}
		else {
		    if (telefoon.length < 9) {
		        window.document.getElementById("ctl00_cphLeftContent_txtTelefoon").style.backgroundColor = error_color;
		        window.document.getElementById("rqrTelefoon").innerHTML = "ongeldig";
		    }
		    else {
		        window.document.getElementById("ctl00_cphLeftContent_txtTelefoon").style.backgroundColor = ok_color;
		        window.document.getElementById("rqrTelefoon").innerHTML = "(*)";
		    }
		}
		
		if (email.length < 1) {
			window.document.getElementById("ctl00_cphLeftContent_txtEmail").style.backgroundColor = error_color;
			window.document.getElementById("rqrEmail").innerHTML = "(*)";
		}
		else {
			if (validateEmail(email)) {
				window.document.getElementById("ctl00_cphLeftContent_txtEmail").style.backgroundColor = ok_color;
				window.document.getElementById("rqrEmail").innerHTML = "(*)";
			}
			else {
				window.document.getElementById("ctl00_cphLeftContent_txtEmail").style.backgroundColor = error_color;
				window.document.getElementById("rqrEmail").innerHTML = "ongeldig";
			}
		}
		
		if (bericht.length < 1) {
			window.document.getElementById("ctl00_cphLeftContent_txtBericht").style.backgroundColor = error_color;
		}
		else {
			window.document.getElementById("ctl00_cphLeftContent_txtBericht").style.backgroundColor = ok_color;
		}
		
		return false;
	}
	else {
		window.document.getElementById("ctl00_cphLeftContent_txtNaam").style.backgroundColor = ok_color;
		window.document.getElementById("ctl00_cphLeftContent_txtTelefoon").style.backgroundColor = ok_color;
		window.document.getElementById("ctl00_cphLeftContent_txtEmail").style.backgroundColor = ok_color;
		window.document.getElementById("ctl00_cphLeftContent_txtBericht").style.backgroundColor = ok_color;
		
		if (validateEmail(email)) {
			return true;
		}
		else {
			window.document.getElementById("ctl00_cphLeftContent_txtEmail").style.backgroundColor = error_color;
			window.document.getElementById("rqrEmail").innerHTML = "invalid e-mail.";
						
			return false;
		}
	}
}

function validateEmail(strEmail) {
	//var strEmail = document.getElementById("txtEmail").value;
   
    var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
    var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
   
  	if (!reg1.test(strEmail) && reg2.test(strEmail)) { // if syntax is valid
    	return true;
  	}
  	
	//window.document.getElementById("txtEmail").style.backgroundColor = error_color;
	  	  
 	return false;
}

function undoColor() {
	this.style.backgroundColor = "#FFFFFF";
}