function initCM()
	{
		document.oncontextmenu = function() {return false};
	}
function getPageSize()
	{
		var xScroll, yScroll;
		var windowWidth, windowHeight;

		if (window.innerHeight && window.scrollMaxY) 
			{	
				xScroll = document.body.scrollWidth;
				yScroll = window.innerHeight + window.scrollMaxY;
			}
		else if (document.body.scrollHeight > document.body.offsetHeight)
			{ 	// all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} 
		else 
			{ 
				// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
	
		if (self.innerHeight)
			{	// all except Explorer
				windowWidth = self.innerWidth;
				windowHeight = self.innerHeight;
			} 
		else if (document.documentElement && document.documentElement.clientHeight)
			{ 
				// Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} 
		else if (document.body)
			{ 
				// other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
	
		// for small pages with total height less then height of the viewport
		if (yScroll < windowHeight)
			{
				pageHeight = windowHeight;
			} 
		else 
			{ 
				pageHeight = yScroll;
			}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth)
			{	
				pageWidth = windowWidth;
			} 
		else 
			{
				pageWidth = xScroll;
			}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
		return arrayPageSize;
	}
function findPosX(obj) 
	{
        	var curleft = 0;
	        if (obj.offsetParent)
        		{
            			while (obj.offsetParent)
            				{
                				curleft += obj.offsetLeft;
                				obj = obj.offsetParent;
            				}
        		}
        	else if (obj.y)
        		{
            			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;
    	}

posx = 0; posy = 0; 
function capmouse(e)
	{
		// captures the mouse position
		posx = 0; posy = 0;
		if (!e)
			{
				var e = window.event;
			}
		if (e.pageX || e.pageY)
			{ 
				posx = e.pageX;
				posy = e.pageY;
			}
		else if (e.clientX || e.clientY)
			{
				posx = e.clientX;
				posy = e.clientY; 
			}
	}
function getMouseDown(e)
	{
		
		var rightclick;
		if (!e) var e = window.event;

		if (e.which) rightclick = (e.which == 3);
		else if (e.button) rightclick = (e.button == 2);
		if (rightclick)
			{
				var targ;
				if (!e) var e = window.event;
				if (e.target) targ = e.target;
				else if (e.srcElement) targ = e.srcElement;
				if (targ.nodeType == 3) // defeat Safari bug
					targ = targ.parentNode;

			}
		else
			{
				var targ;
				if (!e) var e = window.event;
				if (e.target) targ = e.target;
				else if (e.srcElement) targ = e.srcElement;
				if (targ.nodeType == 3) // defeat Safari bug
					targ = targ.parentNode;
			}
		return false;
	}
function createOverLay(id,theme,page)
	{
		var objBody = document.getElementsByTagName("body").item(0);
		var posX = findPosX(document.getElementById(id));
		var posY = findPosY(document.getElementById(id));


		if ((page == 'index') && (CSAg.indexOf("MSIE") > 0))
			{
   				var arVersion = navigator.appVersion.split("MSIE")
		   		var version = parseFloat(arVersion[1])
   				if ((version < 7)) 
		   			{
						posY = posY + 35;
					}
			}

		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay_'+id);
		objOverlay.style.display = 'block';
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = posY+'px';
		objOverlay.style.left = posX+'px';
		objOverlay.style.zIndex = '190';
	 	objOverlay.style.width = '147px';
	 	objOverlay.style.height = '125px';
		objOverlay.innerHTML = '<img src="themes/'+theme+'/images/footer/layer.png">';
		objBody.insertBefore(objOverlay, objBody.firstChild);
	}
function txtFocus(what)
	{
		document.getElementById(what.id).className="txtBox_focus";
	}
function txtBlur(what)
	{
		document.getElementById(what.id).className="txtBox";
	}

function submitContact()
	{
		xajax.$('btSend').disabled=true;
		xajax.$('btSend').value="moment.";
		xajax_addQuestion('',xajax.getFormValues("contactForm"));
		return false;
	}
function submitReachUs()
	{
		if (document.getElementById('reachUsForm'))
			{
				var fromStreet = document.getElementById('street').value;
				var fromNo = document.getElementById('no').value;
				var fromPlace = document.getElementById('place').value;
				var garageAd = document.getElementById('adresHoeksterend').value;
				var routeWay = getRadioValue('viaRoute');
				if ((fromStreet.length > 0) && (fromNo.length > 0) && (fromPlace.length > 0))
					{
						var viaRoute = document.getElementById('adresHoeksterend').value;
	
						var theUrl = "http://maps.google.nl/maps?f=d&hl=nl";
							theUrl += "&saddr="+fromStreet+"+"+fromNo+"+"+fromPlace;
						if (routeWay == 'viaGarage')
							{
								theUrl += "&daddr="+garageAd;
								theUrl += "+to:Over+de+Kelders+24,+Leeuwarden&ie=UTF8&z=9&om=1";
							}
						else
							{
								theUrl += "&daddr=Over+de+Kelders+24,+Leeuwarden&ie=UTF8&z=9&om=1";
							}
						window.open(theUrl);
						document.getElementById('routeLink').innerHTML = '<a href="'+theUrl+'" target"_blank">Klik hier voor de route als er geen scherm geopend wordt!</a>';
					}
			}
	}

function correctContact(what)
	{
		if (document.getElementById('contactForm'))
			{
				if (what.id == 'email')
					{
						var x = document.getElementById(what.id).value;
						var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
						if (filter.test(x) && (x.length > 4))
							document.getElementById('noemail').style.display='none';
						else
							document.getElementById('noemail').style.display='block';
					}
				else if (what.id == 'phone')
					{
						var x = document.getElementById(what.id).value;
						if (IsPhone(x) && (x.length > 8))
							document.getElementById('nophone').style.display='none';
						else
							document.getElementById('nophone').style.display='block';
					}
				else if (what.id == 'name')
					{
						if (document.getElementById(what.id).value.length < 2)
							document.getElementById('noname').style.display='block';
						else
							document.getElementById('noname').style.display='none';
					}
				else if (what.id == 'question')
					{
						if (document.getElementById(what.id).value.length < 2)
							document.getElementById('noquestion').style.display='block';
						else
							document.getElementById('noquestion').style.display='none';
					}
			}
	}

function IsPhone(sText)
	{
		var ValidChars = "0123456789-() ";
		var IsNumber=true;
		var Char;
		for (i = 0; i < sText.length && IsNumber == true; i++) 
      			{ 
      				Char = sText.charAt(i); 
      				if (ValidChars.indexOf(Char) == -1) 
         				IsNumber = false;
      			}
   		return IsNumber;
	}
var CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);

function storeUserBrowser()
	{
		var vers = '0';
		var userBrowser = '';
		if (CSAg.indexOf("MSIE") > 0)
			userBrowser = '_IE';

		if (CSAg.indexOf("Firefox") > 0)
			userBrowser = '_FF';


		if (CSAg.indexOf("K-Meleon") > 0)
			userBrowser = '_KM';

		if (CSAg.indexOf("Opera") > 0)
			userBrowser = '_OP';

		if (CSAg.indexOf("Safari") > 0)
			userBrowser = '_SF';

   		var arVersion = navigator.appVersion.split("MSIE")
   		var version = parseFloat(arVersion[1])
   		if ((version >= 7) && (document.body.filters)) 
   			{
				vers = 'm6';
			}
		var sW = screen.width;
		var sH = screen.height;
		xajax_storeUserBrowserName('',userBrowser,vers,sW,sH);
	}
function getRadioValue(name)
	{
		var obj = document.getElementsByName(name);
		for (var i=0; i<obj.length;i++)
			{
				if (obj[i].checked)
					{
						return obj[i].value;
						break;
					}
			}
		return '';
	}
function showExtraInfo()
	{
		if (document.getElementById('extraInfo'))
			{
				var obj = document.getElementById('extraInfo');
				var objT = document.getElementById('frontTop');
				obj.style.left = ((findPosX(objT)+objT.offsetWidth)-470)+'px';
				obj.style.top = ((findPosY(objT)+objT.offsetHeight)+20)+'px';
				obj.style.display ="block";
			}
	}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version < 7) && (document.body.filters)) // >=5.5
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\';\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}