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 confirmVoorraad()
{
	if (confirm("Om gebruik te maken van deze mailing moet u eerst inloggen.\n\nBent u nog geen klant?\nKlik dan op OK om een gebruikersaccount aan te maken."))
	{
		location.href = "http://www.camonet.eu/klanten.php?command=register";
	}
}

function hidePopup()
{
//	document.getElementById('venster').style.visibility= 'hidden';
	document.getElementById('venster').style.display = 'none';
}

function isValidObject(objToTest) 
{
	if (objToTest == null || objToTest == undefined) 
		return false;
	else
		return true;
}

function showPopup(producttype_id)
{
	var left = findPosX(document.getElementById('anchor')) + 5;
	
	if (producttype_id != 0) // als die niet 0 is, vanuit XAJAX aangeroepen
	{
		document.getElementById('producttype_id').value = producttype_id;
	}

	document.getElementById('venster').style.left = left;
//	document.getElementById('venster').style.visibility= '';
	document.getElementById('venster').style.display= '';
}

function displayOption(objectname)
{
	document.getElementById('meer_info').style.display = "none";
	document.getElementById('omschrijving').style.display = "none";
	document.getElementById('reviews').style.display = "none";
	document.getElementById('mailafriend').style.display = "none";
	document.getElementById(objectname).style.display = "";
}

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, null); // standards compliant; doesn't work in IE
	}
	catch(ex) 
	{
		object.add(option); // IE only
	}
}



function removeAllOptions(objectName)
{
	document.getElementById(objectName).options.length = 0;
}

function newWindow(URL, height, width,resizable)
{
	var newWindow;
	
	if (!resizable)
		resizable = "no";
	else	
		resizable = "yes";

	var  myWin = "" ;
	var  x = screen.width ;
	var  y = screen.height ;
	var  top = parseInt( ( y - height ) / 2 ) ;
	var  left = parseInt( ( x - width  ) / 2 ) ;
	var  props = "toolbar=no,scrollbars=no,titlebar=0,status=no,resizable="+resizable+",width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;


	newWindow = window.open(URL,"",props);
}

function confirmpopup(Message, url) { 
    var is_confirmed = confirm(Message);
    if (is_confirmed) 
	{
	   location.href = url;
    }
	else return is_confirmed;
} 

function confirmpopup2(Message, product_id, artikelnr) 
{ 
    var is_confirmed = confirm(Message);
    if (is_confirmed)
	{
		go(product_id, artikelnr);
    }
	else return is_confirmed;
} 


function roundit(Num, Places) 
{
	if (Places > 0) 
	{
		if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places + 1)) 
		{
			var Rounder = Math.pow(10, Places);
			return Math.round(Num * Rounder) / Rounder;
		}
		else 
		{	
			var tmp = Num.toString().split(".");

			if (validObj(tmp[1]) && tmp[1].length == 1 && Num.toString().lastIndexOf('.') > 0) // ronald 28-4-2008
			{
				if (tmp[1] < 10)
					Num = tmp[0] + "." + tmp[1] + "0";
			}
			return Num;
		}
   }
   else return Math.round(Num);
}

function checkprijs(objEvent) 
{
  var allowed="1234567890"
  if (allowed.indexOf(String.fromCharCode(objEvent.keyCode)) == -1)
  {
    return false;
  }
}

function validObj(objToTest) 
{
	if (objToTest == null || objToTest == undefined) 
		return false;
	else
		return true;
}