	var usePer100KmDuracar = 14.5
	var pricePerKWh = 0.15
	var EmissionDurarPerKM = 30; // gram/km
	var kWhprijzen = new Array(3)
	kWhprijzen[0] = 0.14;
	kWhprijzen[1] = 0.1069;
	kWhprijzen[2] = 0.0802;

// Find an element in the DOM by name (browser compatible)
	function findElement(objectName)
	{
		if (document.all == null)
			return document.getElementById(objectName);
		else
			return document.all(objectName);
	}
	
	function Button1_onclick() 
	{
		if (ValidateInputFields())
		{
			Calculate();
			Hide("EntryDataFormId");
			Show("CalculatedDataId");
		}
	}
	
	function CopyValue(inId, outId)
	{
		var a = findElement(inId);
		var b = findElement(outId);
		if (a != null && b != null)
		{
			b.value = a.value;
		}
	}

	function Calculate()
	{
		CopyValue("PricePerLiterIn", "PricePerLiterOut");
		CopyValue("distancePerYearIn", "distancePerYearOutDuraCar");
		CopyValue("distancePerYearIn", "distancePerYearOutCar");
		CopyValue("usePerHundredKmIn", "usePerHundredKmOutCar");
		SetValue("usePerHundredKmOutDuraCar", usePer100KmDuracar);
		SetValue("EmissionDurarPerKM", EmissionDurarPerKM);
		
		SetValue("totalUseOutCar", parseInt(GetValue("PricePerLiterIn") * GetValue("distancePerYearIn") * GetValue("usePerHundredKmIn") /100));
		SetValue("totalUseOutDuraCar", parseInt(GetValue("pricePerKWhOut") * GetValue("distancePerYearIn") * usePer100KmDuracar / 100));
		SetValue("EmissionOutCar", parseInt(GetValue("EmissionIn") * GetValue("distancePerYearIn") / 1000 / 10) / 100);
		SetValue("EmissionOutDuraCar", parseInt((EmissionDurarPerKM * GetValue("distancePerYearIn")) / 1000 / 10) / 100);

		var totalValue = (GetValue("totalUseOutCar") - GetValue("totalUseOutDuraCar"));
		SetInnerHtml("Result", "Uw winst: € " + totalValue);
	}
	
	function CalculateTotalUseDuracar()
	{
		
	}

	function Hide(objId)
	{
		var a = findElement(objId);
		if (a != null)
		{
			a.style.display = "none";
		}
	}
	
	function Show(objId)
	{
		var a = findElement(objId);
		if (a != null)
		{
			a.style.display = "block";
		}
	}
	
	function ValidateInputFields()
	{
		var retVal = true;
	//!document.EntryDataFormId.PricePerLiterIn.value.match(/^\d+$/)

		if (GetValue("PricePerLiterIn") - 0 <= 0)
		{
			retVal = false;
			SetColor("PricePerLiterIn", true)
		}
		else
			SetColor("PricePerLiterIn", false)

		if (GetValue("usePerHundredKmIn") - 0 <= 0)
		{
			retVal = false;
			SetColor("usePerHundredKmIn", true)
		}
		else
			SetColor("usePerHundredKmIn", false)

		if (GetValue("distancePerYearIn") - 0 <= 0)
		{
			retVal = false;
			SetColor("distancePerYearIn", true)
		}
		else
			SetColor("distancePerYearIn", false)

		if (GetValue("EmissionIn") == "0")
		{
			retVal = false;
			SetColor("EmissionIn", true)
		}
		else
			SetColor("EmissionIn", false)

		return retVal;
	}

	var isIE = document.all?true:false;
	var isNS = document.layers?true:false;
	function onlyDigits(e) {
		var _ret = true;
		if (isIE) {
			if (window.event.keyCode < 46 || window.event.keyCode > 57) {
				window.event.keyCode = 0;
				_ret = false;
			}
		}
		if (isNS) {
			if (e.which < 46 || e.which > 57) {
				e.which = 0;
				_ret = false;
			}
		}
		return (_ret); 
	}

	function SetValue(objId, val)
	{
		var a = findElement(objId);
		if (a != null)
		{
			if (a.options == null)
				a.value = val;
			else
			{
				a.options.value = val;
			}
		}
	}

	function GetValue(objId, val)
	{
		var a = findElement(objId);
		if (a != null)
		{
			if (a.options == null)
				return a.value;
			else
			{
				return a.options.value;
			}
		}
		return "";
	}

	function SetSelectedValue(objId, val)
	{
		var a = findElement(objId);
		if (a != null)
		{
			a.selected = val;
		}
	}
	
	function SetInnerHtml(objId, val)
	{
		var a = findElement(objId);
		if (a != null)
		{
			a.innerHTML = val;
		}
	}
	
	function Reset1_onclick() 
	{
		SetValue("PricePerLiterIn", "1.35");
		SetValue("usePerHundredKmIn", "10");
		SetValue("distancePerYearIn", "15000");
		SetValue("EmissionIn", "150");
	}

	function Button2_onclick() {
		Hide("CalculatedDataId");
		Show("EntryDataFormId");
	}
	
	function SetColor(objId, error)
	{
		var obj = findElement(objId);
		if (obj != null)
		{
			if (error)
				obj.style.backgroundColor='#ffbbbb';
			else
				obj.style.backgroundColor='';
		}
	}

	function resizeOuterTo(w,h) {
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") 
			{
				top.outerWidth=w;
				top.outerHeight=h;
			}
			else 
			{
				top.resizeTo(w,h);
			}
		}
	}
	
	function GotoUrl(url)
	{
		if (page != url)
		{
			window.location = url;
		}
	}
	
	function Calculator_onclick() {
		var win = window.open('Calculate.htm','Calculator','width=700,height=500,resizable=no,scrollbars=no,toolbar=no,alwaysRaised=yes') 
		win.focus();
	}

	var ShowNieuwsBriefDivCount = 0;
	function ShowNieuwsBriefDiv() {
		ShowNieuwsBriefDivCount++;
		var objName = findElement("nieuwsBriefDiv");
		if (objName != null)
			objName.className = "nieuwsbriefDiv";
	}

	function HideNieuwsBriefDiv() {
		ShowNieuwsBriefDivCount--;
		var objName = findElement("nieuwsBriefDiv");
		if (objName != null && ShowNieuwsBriefDivCount == 0)
			objName.className = "hidden";
	}

	function drieD_onclick() 
	{
		if (isIE) {
			var win = window.open('3dview.htm','3d_View','width=820,height=540,resizable=no,scrollbars=no,toolbar=no,alwaysRaised=yes') 
			win.focus();
		}
		else
		{
			alert("Onze excuses, maar de 3d View is alleen in Internet Explorer te bekijken.")
		}
	}

	function setPictureValues(pictureUrl, subtext)
	{
		var bigPic = findElement("bigPicture")
		if (bigPic != null)
		{
			var innerHTML = "<span class='blur'><span class='shaduw'><span class='inhoud'>" + "<IMG SRC='" + pictureUrl + "'>" + "</span></span></span>";
			bigPic.innerHTML = innerHTML;
		}

		var bigPictureSubtext = findElement("bigPictureSubtext");
		if (bigPictureSubtext != null)
		{
			if (subtext != null)
				bigPictureSubtext.innerHTML = "<B>" + subtext + "</B>";
			else
				bigPictureSubtext.innerHTML = "";
		}
	}
	
	var designStripScrollWindowsPosition = 0;
    var items = 18;
    var goLeftP = false;
    var goRightP = true;
    function goStripLeft()
    {
		if (goLeftP)
		{
	        designStripScrollWindowsPosition += 600;
		    DesignStripScrollWindows().style.marginLeft = designStripScrollWindowsPosition;
			
	        ShowHideStripButtons();
	    }
    }
    
    function goStripRight()
    {
		if (goRightP)
		{
	        designStripScrollWindowsPosition -= 600;
		    DesignStripScrollWindows().style.marginLeft = designStripScrollWindowsPosition;
        
			ShowHideStripButtons();
		}
    }

    function ShowHideStripButtons()
    {
        var opacity = 100;
        var nobuttonOpacity = 30;

        var leftButton = findElement("LeftButtonStrip");
        if (leftButton) 
        {
            if (designStripScrollWindowsPosition == 0)
            {
                opacity = nobuttonOpacity;
                goLeftP = false;
            }
            else
            {
               goLeftP = true;
            }
            leftButton.style.filter = "alpha(opacity="+ opacity +")";
	        leftButton.style.opacity = opacity/100;
    
        }
        opacity = 100;
        var rightButton = findElement("RightButtonStrip");
        if (rightButton)
        {
            if (-designStripScrollWindowsPosition/100 + 7 >= items)
            {
                opacity = nobuttonOpacity;
                goRightP = false;
            }
            else
            {
				goRightP = true;
            }
            rightButton.style.filter = "alpha(opacity="+ opacity +")";
	        rightButton.style.opacity = opacity/100;
        }
    }

    function DesignStripScrollWindows()
    {
        return findElement("designStripScrollWindows2");
    }
    
   	function onloadHandler()
	{
		resizeOuterTo(830, 750);
		document.title = "Tijdelijke Website / Temporary Website - Nieuwe website onder constructie / New website under construction<BR clear=all>";
	}
		
		
	var origVidRapper = "";
	function PlayVideo(url)
	{
		var grayoutDiv = findElement("grayoutWrapper")
		var vidDiv = findElement("vidWrapper")
		var videoObj = findElement("VIDEO")
		if (CheckObjects(grayoutDiv, vidDiv, videoObj))
		{
			origVidRapper = vidDiv.innerHTML;
			grayoutDiv.style.display = "block";
			vidDiv.style.display = "block";
			PlayTheVideo("VIDEO", url);
		} 
	}
	
	function StopVideo()
	{
		var grayoutDiv = findElement("grayoutWrapper")
		var vidDiv = findElement("vidWrapper")
		var videoObj = findElement("VIDEO")
		if (CheckObjects(grayoutDiv, vidDiv, videoObj))
		{
			vidDiv.innerHTML = origVidRapper;
			grayoutDiv.style.display = "none";
			vidDiv.style.display = "none";				
		}
	} 
	
	function FullScreenVideo()
	{
		var grayoutDiv = findElement("grayoutWrapper")
		var vidDiv = findElement("vidWrapper")
		var videoObj = findElement("VIDEO")
		if (CheckObjects(grayoutDiv, vidDiv, videoObj))
		{
			var embeddedVideo = findElement("embeddedVideo");
			embeddedVideo.fullScreen = "1";
		}
	}

	function PlayTheVideo(divId, url)
	{
		var myVideoDiv = findElement(divId);
		if (myVideoDiv != null)
		{
			innerHtml = "<EMBED id='embeddedVideo' SRC='" + url + "' TYPE='application/x-mplayer2' NAME='VIDEO' WIDTH=512 HEIGHT=353 DISPLAYSIZE='4' AUTOSIZE='-1' BGCOLOR='darkblue' SHOWCONTROLS='-1' SHOWTRACKER='-1' SHOWDISPLAY='0' SHOWSTATUSBAR='-1' VIDEOBORDER3D='-1' AUTOSTART='1' DESIGNTIMESP='5311'></EMBED>";
			myVideoDiv.innerHTML = innerHtml;
		}
	}	
	
	function CheckObjects(grayoutDiv, vidDiv, videoObj)
	{
		if (grayoutDiv == null)
			alert("grayoutDiv is null");
		if (vidDiv == null)
			alert("vidDiv is null");
		if (videoObj == null)
			alert("videoObj is null");
			
		return !(grayoutDiv == null || vidDiv == null || videoObj == null)
		
	}
	

