function openWindow(url, height, width, name) 
	{
	   var left = Math.floor( (screen.width - width) / 2);
	   var top = Math.floor( (screen.height - height) / 2);   
	   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
	   winParms += ",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no";   
	   var win = window.open(url, name, winParms);
	   //if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	   return;
	}

function hiliteMenu(id)
	{
		document.getElementById(['menubutton'+id]).className = 'menubutton_hi';
	}
	
function unliteMenu(id)
	{
		document.getElementById(['menubutton'+id]).className = 'menubutton';
	}
	
function hiliteArrowLink(id)
	{
		document.getElementById([id]).className = 'link_hi';
	}
	
function unliteArrowLink(id)
	{
		document.getElementById([id]).className = 'link';
	}
	
function hiliteSubmenu(id)
	{
		document.getElementById(['linksub'+id]).className = 'leftsubmenu_hi';
		document.getElementById(['imgsub'+id]).src = 'images/arrow_forward_hi.gif';
	}
	
function unliteSubmenu(id)
	{
		document.getElementById(['linksub'+id]).className = 'leftsubmenu';
		document.getElementById(['imgsub'+id]).src = 'images/arrow_forward.gif';
	}
	
function hiliteSubSubmenu(id,depthId)
	{
		document.getElementById(['linksubsub_'+depthId+'_'+id]).className = 'leftsubmenu_hi';
		document.getElementById(['imgsubsub_'+depthId+'_'+id]).src = 'images/arrow_forward_hi.gif';
	}
	
function unliteSubSubmenu(id,depthId)
	{
		document.getElementById(['linksubsub_'+depthId+'_'+id]).className = 'leftsubmenu';
		document.getElementById(['imgsubsub_'+depthId+'_'+id]).src = 'images/arrow_forward.gif';
	}

function toggle(id)
{
	var obj = document.getElementById(id);
	if (obj)
		obj.style.display == 'none' ? obj.style.display = 'block' : obj.style.display = 'none';

	var img = document.getElementById('img_'+id);
	if (img)
	{
		if (img.src.indexOf('plus.gif') != -1)
		{
			img.src = 'images/min.gif';
			img.alt = 'Menu inklappen';
		}
		else
		{
			img.src = 'images/plus.gif';
			img.alt = 'Menu uitklappen';
		}
	}
}
	
function hiliteOogstmenu(id)
	{
		document.getElementById(['linkoogst'+id]).className = 'leftsubmenu_hi';
		document.getElementById(['imgoogst'+id]).src = 'images/arrow_forward_hi.gif';
	}
	
function unliteOogstmenu(id)
	{
		document.getElementById(['linkoogst'+id]).className = 'leftsubmenu';
		document.getElementById(['imgoogst'+id]).src = 'images/arrow_forward.gif';
	}
	
function hiliteDownload(id)
	{
		document.getElementById(['linkdownload'+id]).className = 'leftsubmenu_hi';
		document.getElementById(['imgdownload'+id]).src = 'images/arrow_forward_hi.gif';
	}
	
function unliteDownload(id)
	{
		document.getElementById(['linkdownload'+id]).className = 'leftsubmenu';
		document.getElementById(['imgdownload'+id]).src = 'images/arrow_forward.gif';
	}
	
function doShowSub(id)
	{
		document.getElementById(['foldout_submenu_'+id]).className = 'menu_visible';
	}
	
function doHideSub(id)
	{
		document.getElementById(['foldout_submenu_'+id]).className = 'menu_invisible';
	}


function print_product(id)
{
	window.open('shop_product_details_print.asp?pid='+id);
}

function show_afbeelding(sAfbeelding)
{
	if (sAfbeelding != '')
	{
		var x = window.open('','','menubar=no,scrollbars=no,resizable=no,width=50,height=50');
		x.document.open();
		x.document.write('<html><head><title>Wijnhandel Robbers &amp; van den Hoogen</title></head><body bgcolor=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 onLoad="window.resizeTo(document[\'pic\'].width+12,document[\'pic\'].height+50);">');
		x.document.write('<div align=center><a href="javascript:window.close();">');
		x.document.write('<img src="sitemanager/images/'+sAfbeelding+'" name="pic" align=center border=0 ALT="Sluit Venster">');
		x.document.write('<br><p align=center>');
		x.document.write('<font size="1" face="arial,verdana, Helvetica, sans-serif">');
		x.document.write('Sluit Venster</a></font></div></body></html>');
		var hi = x.document["pic"].height+50;
		var wi = x.document["pic"].width+20;
		x.window.resizeTo(wi,hi);

		x.document.close()
	}
}

function get_options(id)
{
	var streek = document.getElementById('streek_opties');

	advAJAX.get(
	{
		url: "__ajax_streek.asp?landid="+id,

		onSuccess : function(obj)
		{
			streek.innerHTML = obj.responseText;
		},
		onError : function(obj)
		{
			//document.getElementById('id').innerHTML = "Er is iets mis gegaan:"+obj.status;
		},
		onFinalization : function()
		{
			//
		},
		onLoading : function()
		{
			//streek.innerHTML = "Loading..."
		}
	});
}

function nieuwsbrief(actie)
{
	with (frmNieuwsbrief)
	{
		aanaf.value = actie;

		if (Emailadres.value != 'Uw e-mailadres')
			submit();
		else
			alert('vul uw emailadres in');
	}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return {left : curleft, top: curtop};
}

/*
AJAX Webwinkel
*/

function init_webshop_links()
{
	return true;
	var aLinks = document.links;
	for (var i=0;i<aLinks.length;i++)
	{
		iStart = aLinks[i].toString().indexOf('shop.asp?actie');
		if (iStart > 0)
		{
			var s = aLinks[i].toString().substring(iStart);
			aLinks[i].href = 'javascript:webshop("'+s.replace(/shop.asp/,'_ajax_shop.asp')+'", '+i+')';
			aLinks[i].id   = 'webshop_'+i;
		}
	}
}

function webshop(sUrl, id)
{
	var oDiv   = document.getElementById('dynwebshop');
	var oLink  = document.getElementById('webshop_'+id);
	var oAlert = document.getElementById('oAlert');

	advAJAX.get(
	{
		url: sUrl,

		onSuccess : function(obj)
		{
			oDiv.innerHTML = obj.responseText;
		},
		onError : function(obj)
		{
			oDiv.innerHTML = obj.responseText;
		},
		onFinalization : function()
		{
			setTimeout("closeAlert()", 2000);
		},
		onLoading : function()
		{
			oDiv.innerHTML = '<img src="images/loading.gif" alt="" align="center"/>';
		}
	});

	var test = findPos(oLink);

	oAlert.style.display = 'block';
	oAlert.style.top  = ( test.top - 80 ) + 'px';
	oAlert.style.left = ( test.left - 162) + 'px';
	oAlert.innerHTML = '<h1>Product toegevoegd</h1><p>Uw winkelwagentje wordt rechtsboven getoond.';
}

function closeAlert()
{
	var oAlert = document.getElementById('oAlert');

	oAlert.style.display = 'none';
}

function isEmailAdres(string)
{
	var patroon = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	return patroon.test(string);
}

function MailAFriend()
{
	var oForm = document.frmMailAFriend;
	var eStr  = '';

	with (oForm)
	{
		if (pid.value == '') eStr += '#INTERN ID Ontbreekt\n';
		if (f_friends_name.value == '') eStr += 'Vriend(in) naam;\n';
		if (!isEmailAdres(f_friends_email.value)) eStr += 'Email vriend(in);\n';
		if (f_sender_name.value == '') eStr += 'Uw naam;\n';
		if (!isEmailAdres(f_sender_email.value)) eStr += 'Uw email;\n';
	}

	if (eStr == '')
		return oForm.submit()
	else
		return alert('De volgende velden zijn verplicht in te vullen:\n\n'+eStr);
}

function toggle_search(id)
{
	var os1 = document.getElementById('search_1');
	var os2 = document.getElementById('search_2');
	var ol1 = document.getElementById('searchl_1');
	var ol2 = document.getElementById('searchl_2');

	if (id == 1)
	{
		os1.style.display = 'block';
		os2.style.display = 'none';
		ol1.className = 'selected';
		ol2.className = '';
	}
	else
	{
		os1.style.display = 'none';
		os2.style.display = 'block';
		ol1.className = '';
		ol2.className = 'selected';
	}
}

function set_rembours()
{
	var bool = document.frm1.betalingswijze[3].checked;


	document.frm1.f_s_bezorgenop.disabled = bool;
	document.frm1.f_s_geengehoor.disabled = bool;
	document.frm1.f_s_ophalenop.disabled  = bool;


	if (bool)
		document.getElementById('aflever_div').style.display = 'none';//document.frm1.f_s_ophalen_bezorgen[2].checked = bool;
	else
		document.getElementById('aflever_div').style.display = 'block';//document.frm1.f_s_ophalen_bezorgen[0].checked = true;

	for (var i=0;i<document.frm1.betalingswijze.length;i++)
	{
		document.frm1.betalingswijze[i].onchange = set_rembours;
		document.frm1.betalingswijze[i].onfocus = set_rembours;
	}

}