var detect = navigator.userAgent.toLowerCase();

if (detect.indexOf("firefox") > -1) { var FireFox = 1; }

if(document.all && !document.getElementById) { document.getElementById = function(id) { return document.all[id]; } }

var allstop = 0;
var i = 0;

function highlight(id, action)
{
	var el = document.getElementById(id);

	if (action == "off")
	{
		if (FireFox)
			el.setAttribute("style", "-moz-opacity: 1.0; opacity: 1.0;");
		else
			el.style.setAttribute("cssText",  "filter:alpha(opacity=100);");
	}
	else if (action == "on")
	{
		if (FireFox)
			el.setAttribute("style", "-moz-opacity: 0.5; opacity: 0.5;");
		else
			el.style.setAttribute("cssText",  "filter:alpha(opacity=50);");
	}
}

function tab_on(id, action, target)
{
	var el = document.getElementById(id);
	var elp = document.getElementById(id+'p');
	var elc = document.getElementById(id+'c');
	
	if (FireFox == 1)
	{
		el.setAttribute("style", "cursor: pointer; color: #000000; background-image: url(/www.veenman.nl/site_styling/images/template/tabs/tab_active.gif);");
		elp.setAttribute("style", "visibility: visible;");
		elc.setAttribute("style", "visibility: visible;");
	}
	else
	{
		el.style.setAttribute("cssText",  "cursor: pointer; color: #000000;  background-image: url(/www.veenman.nl/site_styling/images/template/tabs/tab_active.gif);");
		elp.style.setAttribute("cssText",  "visibility: visible;");
		elc.style.setAttribute("cssText",  "visibility: visible;");
	}

	if (action == 'stop')
	{
		if (target == "" || target == undefined) { target = "default.aspx"; } 

		clearTimeout(tabtimer);
		for (ii =1; ii < 6; ii++) 
		{
			a = 'tab' + ii;
			if (a != id) { tab_off(a); }
			else { location.href=target; }
		}
	}
	if (action == 'halt')
	{
		clearTimeout(tabtimer);
		for (ii =1; ii < 4; ii++) 
		{
			a = 'tab' + ii;
			if (a != id) { tab_off(a); }
		}
	}
}

function tab_off(id)
{
	var el = document.getElementById(id);
	var elp = document.getElementById(id+'p');
	var elc = document.getElementById(id+'c');

	if (FireFox)
	{
		el.setAttribute("style", "cursor: pointer; color: #000000; background-image: url(/www.veenman.nl/site_styling/images/template/tabs/tab_inactive.gif);");
		elp.setAttribute("style", "visibility: hidden;");
		elc.setAttribute("style", "visibility: hidden;");
	}
	else
	{
		el.style.setAttribute("cssText",  "cursor: pointer; color: #000000; background-image: url(/www.veenman.nl/site_styling/images/template/tabs/tab_inactive.gif);");
		elp.style.setAttribute("cssText",  "visibility: hidden;");
		elc.style.setAttribute("cssText",  "visibility: hidden;");
	}
}

function rolloverTimer(action)
{
	if (action == 'go' || action == 'start')
	{
		if (action == 'start') { i = 1; }
		i++;
		if (i == 4) { i = 1; }
		if (i == 1) { vorige = 3; }
		else { vorige = i - 1; }
		volgende = i;
		tabtimer = setTimeout("tab_off('tab'+vorige); tab_on('tab'+volgende); rolloverTimer('go')",10000);
	}
}

function initTabs()
{
	tab_on('tab1','');
	rolloverTimer('start');

	var el = document.getElementById('bdy');
	if (FireFox)
			el.setAttribute("style", "visibility: visible");
		else
			el.style.setAttribute("cssText",  "visibility: visible");

}

function SendMail(target, domain)
{
	if (domain="")
		domain="veenman.nl";
	document.write('<a href="mailto:'+target+'@'+domain+">'+target+'@'+domain+'</a>'");
}

function LinkTo(page, target)
{
	if (!target)
		location.href=page;
	else
		window.open(page, 'mywin');
}

function SetErrorElement(s, e)
{
	e.style.background = "#EEEEEE";
	if (s)
	 e.focus();
}

function CheckSubmitionValues(fields)
{
	var bSuccess = true;
	id = fields.split(',');	
	var curElement;
	for (x=0; x < id.length; x++)
	{
		curElement = document.getElementById(id[x]);
		curElement.style.background ="#FFFFFF";

		if (id[x] == "form_email")
		{
			regex= new RegExp(/^(.+)@(.+)\.(.+)$/);
			
			if (!regex.test(document.getElementById("form_email").value))
			{
				SetErrorElement(bSuccess,curElement);		
				bSuccess=false;
			}

		}
		if (curElement.value == "")
		{
			SetErrorElement(bSuccess,curElement);
			bSuccess=false;
		}
	}
	
	if (!bSuccess)
	    alert("Een of meerdere geselecteerde velden ontbreken of zijn onjuist ingevuld.\nWilt u zo vriendelijk zijn om deze aan te passen?\n");

	return bSuccess;
}

var qsParm = new Array();
function qs() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
   var pos = parms[i].indexOf('=');
   if (pos > 0) {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);
      qsParm[key] = val;
      }
   }
}
