function printpage()
{
	var ua = window.navigator.userAgent
	var msie = ua.indexOf("MSIE ")
	var version = parseInt(ua.substring(msie+5,ua.indexOf(".",msie)))
	if(msie != 0)
	{
		if (version != 4) window.print();
	}
	else
	{
		window.print();
	}
}

function openvenster(durl,dnaam,dfeatures)
{
	window.open(durl,dnaam,dfeatures);
}

goods='0123456789'

function getkey(e)
{
	if (window.event)
		return window.event.keyCode;
	else if (e)
   		return e.which;
	else
  	 	return null;
}

function goodchars(e)
{
	var key, keychar;
	key = getkey(e);
	if (key == null) return true;
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	if (goods.indexOf(keychar) != -1)
		return true;
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
		return true;
		return false;
}

function checkMail(formname,elementname,taal)
{
	var x = trim(document.forms[''+formname+''].elements[''+elementname+''].value);
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)==false)
	{
		if(x!='')
		{
			email = document.forms[''+formname+''].elements[''+elementname+''].value;
			document.forms[''+formname+''].elements[''+elementname+''].value = '';
			if(taal=='nl') { alert('\'' + email + '\' is geen geldig e-mailadres.'); }
			else { alert('\'' + email + '\' is not valid.'); }
		}
	}
}

function trim(value) {
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}

function saveMail(naam,backstring,frontstring,firstletter,lastletter)
{
	var newMail = firstletter + frontstring + '@' + backstring + lastletter;
	document.write('<a href=mailto:'+newMail+' class=normalelink>'+naam+'</a>');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function enlarge(imagesrc,shopurl,width,height)
{
	if(imagesrc.indexOf('thumbs/')!=-1)
	{
		openvenster('http://blobs.shoppay.be/view.asp?externalurl='+shopurl+'&w='+width+'&file='+imagesrc.split('/')[imagesrc.split('/').length-1],'Preview','width=' + width + ',height=' + height + ',screenX=50,screenY=50,top=50,left=50');
	}
	else if(imagesrc.indexOf('resize.asp?folder=products')!=-1)
	{
		openvenster(imagesrc.replace('resize.asp?folder=products','view.asp?externalurl=' + shopurl),'Preview','width=' + width + ',height=' + height + ',screenX=50,screenY=50,top=50,left=50');
	}
	else if(imagesrc.indexOf('blobs.shoppay.be/uploads/')!=-1)
	{
		openvenster(imagesrc.replace('http://blobs.shoppay.be/uploads/','http://blobs.shoppay.be/view.asp?externalurl=' + shopurl + '&folder=uploads&w=' + width + '&file=').replace('&w=' + width + '','&w=' + width + ''),'Preview','width=' + width + ',height=' + height + ',screenX=50,screenY=50,top=50,left=50');
	}
	else
	{
		openvenster(imagesrc.replace('http://blobs.shoppay.be/products/','http://blobs.shoppay.be/view.asp?externalurl=' + shopurl + '&w=' + width + '&file=').replace('&w=' + width + '','&w=' + width + ''),'Preview','width=' + width + ',height=' + height + ',screenX=50,screenY=50,top=50,left=50');
	}
}

function fix_detail_leftpictures()
{
	if((document.getElementById('detail_leftpictures'))&&(document.getElementById('detail_text')))
	{
		if(document.getElementById('detail_text').offsetHeight<document.getElementById('detail_leftpictures').offsetHeight)
		{
			document.getElementById('detail_text').style.height = document.getElementById('detail_leftpictures').offsetHeight;
		}
	}
}

function checkextendeddeaelersearch()
{
	if(document.ExtendedDealerSearchForm.elements['Name'].value=='')
	{
		document.ExtendedDealerSearchForm.elements['Name'].style.backgroundColor='Beige';
		document.ExtendedDealerSearchForm.elements['Name'].style.borderColor='Red';
		document.ExtendedDealerSearchForm.elements['Name'].focus();
		return false;
	}
	else if(document.ExtendedDealerSearchForm.elements['Email'].value=='')
	{
		document.ExtendedDealerSearchForm.elements['Email'].style.backgroundColor='Beige';
		document.ExtendedDealerSearchForm.elements['Email'].style.borderColor='Red';
		document.ExtendedDealerSearchForm.elements['Email'].focus();
		return false;
	}
	else if(document.ExtendedDealerSearchForm.elements['Country'].options[document.ExtendedDealerSearchForm.elements['Country'].selectedIndex].value=='')
	{
		document.ExtendedDealerSearchForm.elements['Country'].style.backgroundColor='Beige';
		document.ExtendedDealerSearchForm.elements['Country'].style.borderColor='Red';
		document.ExtendedDealerSearchForm.elements['Country'].focus();
		return false;
	}
	else if(document.ExtendedDealerSearchForm.elements['Zipcode'].value=='')
	{
		document.ExtendedDealerSearchForm.elements['Zipcode'].style.backgroundColor='Beige';
		document.ExtendedDealerSearchForm.elements['Zipcode'].style.borderColor='Red';
		document.ExtendedDealerSearchForm.elements['Zipcode'].focus();
		return false;
	}
	else
	{
		return true;
	}
}