function isEmail(str) 
{ 
   var at="@" 
   var dot="." 
   var lat=str.indexOf(at) 
   var lstr=str.length 
   var ldot=str.indexOf(dot) 
   if (str.indexOf(at)==-1)                                       return false 
   if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)      return false 
   if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)   return false 
   if (str.indexOf(at,(lat+1))!=-1)                                 return false 
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)      return false 
   if (str.indexOf(dot,(lat+2))==-1)                                 return false 
   if (str.indexOf(" ")!=-1)                                       return false 
   return true                
}

function isEven(value)
{
	if (value%2 == 0)
		return true;
	else
		return false;
}

function confirmpopup(Message, url) { 
    var is_confirmed = confirm(Message);
    if (is_confirmed) 
	{
	   location.href = url;
    }
	else return is_confirmed;
} 


function hideControl(object_name)
{
	var obj = document.getElementById(object_name);
	if (obj != null)
	{
		//disableControl(object_name);
		obj.style.display = 'none';
	}
}

function showControl(object_name)
{
	var obj = document.getElementById(object_name);
	if (obj != null)
	{
		//enableControl(object_name);	
		obj.style.display = '';
	}
}

function disableControl(object_name)
{
	var obj = document.getElementById(object_name);
	if (obj != null)
	{
		obj.disabled = true;		
		//obj.style.background = '#E5E5E5';
	}
}

function enableControl(object_name)
{
	var obj = document.getElementById(object_name);
	if (obj != null)
	{
		obj.disabled = false;		
		//obj.style.background = '#ffffff';
	}
}

function getControl(object_name)
{
	return document.getElementById(object_name);
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

// dit gaat ook niet lekker in firefox!
function addElement(objectName, title, value, selected)
{
	var object = document.getElementById(objectName);
	
	var option = document.createElement('option');
	var option = new Option(title,value,selected,selected);
	option.text = title;
	option.value = value;

	try 
	{
		object.add(option); // standards compliant; doesn't work in IE
	}
	catch(ex) 
	{
		object.add(option, null); // IE only
	}
}

function removeAllOptions(objectName)
{
	var obj = document.getElementById(objectName);
	
	if (obj!=null && obj.options!=null)
		document.getElementById(objectName).options.length = 0;
}

function newWindow(URL, height, width)
{
	var newWindow;

	var  myWin = "" ;
	var  x = screen.width ;
	var  y = screen.height ;
	var  top = parseInt( ( y - height ) / 2 ) ;
	var  left = parseInt( ( x - width  ) / 2 ) ;
	var  props = "scrollbars=yes,toolbars=no,status=no,resizable=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;


	newWindow = window.open(URL,"",props);
}