
function overTR(obj)
{
	obj.className = obj.className + ' hover';
}

function outTR(obj)
{
	obj.className = obj.className.replace(' hover', '');
}


function deleteCategory(id)
{
	document.getElementById('frm').submit();

	if (confirm("Weet u zeker dat u deze category wilt verwijderen?"))
	{
		document.getElementById('myaction').value='delete';
		document.getElementById('myid').value=id;
		document.getElementById('frmke').submit();
	}
}

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	s = s.replace(".",",");
	if(s.indexOf(',') < 0) { s += ',00'; }
	if(s.indexOf(',') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function SetLoginFocus()
{	
	try
	{
		document.getElementById('username').focus();
	}
	catch(e)
	{
	}
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate)
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return null
}

		function showSub(subID) 
		{
			var id = subID;
			subID = "smenu" + subID;
			
			try
			{
				document.getElementById('mainmenu'+id).src=document.getElementById('mainmenu_ov'+id).src;
			}
			catch(e)
			{
				//
			}
		}

		function hideSub(subID) 
		{
			var id = subID;
			subID = "smenu" + subID;
			
			try
			{
				document.getElementById('mainmenu'+id).src=document.getElementById('mainmenu_ov'+id).src.replace('_ov.png','.png');
			}
			catch(e)
			{
				//
			}
		}

	function openLink(link, navid, subnavid)
	{
		setCookie("selectedmainmenu",navid,null);
		setCookie("selectedsubmenu",subnavid,null);
		document.location.href=link;
	}
		
function switchLanguage(lang)
{
	setCookie('lang', lang, null);
	document.location.reload();
}

function subMenuMouseOut(id)
{
	try
	{
		document.getElementById('submenu'+id).src=document.getElementById('submenu_ov'+id).src.replace('_ov.png','.png');
	}
	catch(e)
	{
		//
	}
}

function subMenuMouseOver(id)
{
	try
	{
		document.getElementById('submenu'+id).src=document.getElementById('submenu_ov'+id).src;
	}
	catch(e)
	{
		//
	}
}

function focusme(field, element)
{
	if (field=='mail')
	{
		if (element.value=='e-mail')
		{
			element.value = '';
		}
	}
	else
	{
		if (element.value=='wachtwoord')
		{
			element.value = '';
		}
	}
}

function blurme(field, element)
{
	if (field=='mail')
	{
		if (element.value=='')
		{
			element.value = 'e-mail';
		}
	}
	else
	{
		if (element.value=='')
		{
			element.value = 'wachtwoord';
		}
	}
}

function toggleLabels(val)
{
	setCookie('editlabels', val, null);
	document.location.reload();
}

function showsubmenu(subID) 
{
	var oSubMenu = document.getElementById(subID)
	try
	{
		if (oSubMenu.getElementsByTagName('DIV').length > 0) 
		{
			if (oSubMenu)
				oSubMenu.style.visibility = 'visible';
		}
	}
	catch(e)
	{
	}
}

function hidesubmenu(subID) 
{
	var oSubMenu = document.getElementById(subID)
	if (oSubMenu) oSubMenu.style.visibility = 'hidden';
}


function getPlaces(id)
{
	if (id=='')
	{
		removeAllPlaces();
	}
	else
	{
		removeAllPlaces();
		//myData = JSON.parse(places);	
		myData = eval(places);
		for (i=0;i<myData.length;i++)
		{
			if (myData[i].pl_p_id==id)
			{
				appendPlace(myData[i].pl_id, myData[i].pl_name);
			}
		}
		loadPlaces(id);
	}
}

function getProvinces(id)
{
	if (id=='')
	{
		removeAllProvinces();
	}
	else
	{
		removeAllProvinces();
//		myData = JSON.parse(provinces);	
		myData = eval(provinces);	
		for (i=0;i<myData.length;i++)
		{
			if (myData[i].p_country_id==id)
			{
				appendProvince(myData[i].p_id, myData[i].p_name);
			}
		}
	}
}

function placesFetched(value) 
{
	removeAllPlaces();
	myData = JSON.parse(value);	
	for (i=0;i<myData.length;i++)
	{
		appendPlace(myData[i].pl_id, myData[i].pl_name);
	}
}

function removeAllProvinces()
{
  var elSel = document.getElementById('provinces');
  while (elSel.length > 1)
  {
    elSel.remove(elSel.length - 1);
  }
}

function removeAllPlaces()
{
  var elSel = document.getElementById('places');
  while (elSel.length > 1)
  {
    elSel.remove(elSel.length - 1);
  }
}

function appendPlace(value, text)
{
  var elOptNew = document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = value;
  var elSel = document.getElementById('places');

  try 
  {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) 
  {
    elSel.add(elOptNew); // IE only
  }
}

function appendProvince(value, text)
{
  var elOptNew = document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = value;
  var elSel = document.getElementById('provinces');

  try 
  {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) 
  {
    elSel.add(elOptNew); // IE only
  }
}

function search(id)
{
    if (id!='')	document.location.href='/?m=search&pl=' + id;
}

function loadPlaces(id)
{
	document.location.href='/?m=search&pr=' + id;
}

function checkThisForm(frm)
{
	var retval = checkFrm(frm);
	if (retval==true)
	{
		if ($('referentieander').checked==true)
		{
			if ($('andersnamelijk').value=='')
			{
				alert('U heeft bij ander geen waarde ingevuld.');
				try
				{
					$('andersnamelijk').focus();
				}
				catch(e)
				{
					//
				}
				return false;
			}
		}
	}
	else
	{
		return false;
	}
	return true;
}


function inputBlur(obj, myvalue)
{
	if (obj.value=='') obj.value=myvalue;
}

function inputFocus(obj, myvalue)
{
	if (obj.value==myvalue) obj.value='';
}

function checknieuwsbriefform(formobj, naamtext, emailtext)
{
	if ($('nieuwsbriefnaam').value==naamtext) 
	{
		alert(getattr($('nieuwsbriefnaam'),'formErrormsg'));
		try
		{
			$('nieuwsbriefnaam').focus();
		}
		catch(e)
		{
		}
		return false;
	}
	if ($('nieuwsbriefemail').value==emailtext) 
	{
		alert(getattr($('nieuwsbriefemail'),'formErrormsg'));
		try
		{
			$('nieuwsbriefemail').focus();
		}
		catch(e)
		{
		}
		return false;
	}
	if (checkFrm(formobj)==false)
	{
		return false;
	}
	
	formobj.submit();
}


function getattr(objItem, strAttribName)
{
	return (objItem.getAttribute(strAttribName)) ? objItem.getAttribute(strAttribName) : '';
}
