﻿         function swfft2(divid,w,h,timeout){
	       setTimeout(function(){document.getElementById(divid).style.width = (isNaN(w))? w : w+"px";document.getElementById(divid).style.height = (isNaN(h))? h : h+"px";},timeout);     
	     }
        
        var flashvars_content = {};
        flashvars_content.xmlPath = "PijlersXml.aspx"; 
	    var params_content= {};
	    params_content.wmode = "transparent"	 
	    swfobject.embedSWF("/lib/flash/content_navigate.swf", "flashding", "800", "600", "9.0.0", "/lib/flash/expressInstall.swf", flashvars_content,params_content);
    


	function ShowTag(text) {
	    // alert(text)
	    
	    var ele = document.getElementById('showmassage');
        
        if (ele) {
            ele.innerText = text;
        }
	}
	
	function OpenPics(url, iwidth, iheight) {
    window.open(url, "afbeelding", "width=" + iwidth + ",height=" + iheight + ",left=125,top=100");
}

function validateForm()
{
	jQuery('#form_contact').submit(
		function() { 
			
			var validForm = true;
			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			jQuery("fieldset.persoonsgegevens input").each(
				function(){
					if (jQuery(this).val() == "") { validForm = false; return false }
				}
			);
			if (jQuery('#frm_bericht').val() == "") { validForm = false; }
			if (!validForm) alert('Vul svp alle verplichte velden in.')
			else {
				if(!emailReg.test(jQuery("#frm_email").val())) { validForm = false; alert('Vul een geldig e-mailadres in.') }
			}
			return validForm;
		}
	);
}


	function totaal1()
	{
		var a1 = parseFloat($('#frm_onderzoektabel1').val().replace(",","."));
		var a2 = parseFloat($('#frm_trainingtabel1').val().replace(",","."));
		var a3 = parseFloat($('#frm_coachingtabel1').val().replace(",","."));
		var a4 = parseFloat($('#frm_werkconferentiestabel1').val().replace(",","."));
		var a5 = parseFloat($('#frm_elearningtabel1').val().replace(",","."));
		var aTotaal = parseFloat(a1+a2+a3+a4+a5)
	    $('#frm_subtotaaltabel1').val((aTotaal + '').replace(".",","))
	    totalekosten($('#frm_subtotaaltabel1').val().replace(",","."),$('#frm_subtotaaltabel2').val().replace(",","."));
	}
	function totaal2()
	{
		var a1 = parseFloat($('#frm_onderzoektabel2').val().replace(",","."))
		var a2 = parseFloat($('#frm_trainingtabel2').val().replace(",","."))
		var a3 = parseFloat($('#frm_coachingtabel2').val().replace(",","."))
		var a4 = parseFloat($('#frm_werkconferentiestabel2').val().replace(",","."))
		var a5 = parseFloat($('#frm_elearningtabel2').val().replace(",","."))
		var aTotaal = parseFloat(a1+a2+a3+a4+a5)
	    $('#frm_subtotaaltabel2').val((aTotaal + '').replace(".",","))
	    totalekosten($('#frm_subtotaaltabel1').val().replace(",","."),$('#frm_subtotaaltabel2').val().replace(",","."));
	}
	
	function totaal3()
	{
		var a2 = parseFloat($('#frm_trainingtabel3').val().replace(",","."))
		var a3 = parseFloat($('#frm_coachingtabel3').val().replace(",","."))
		var a4 = parseFloat($('#frm_werkconferentiestabel3').val().replace(",","."))
		var a5 = parseFloat($('#frm_elearningtabel3').val().replace(",","."))
		var aTotaal = parseFloat(a2+a3+a4+a5)
	    $('#frm_subtotaaltabel3').val((aTotaal + '').replace(".",","))
	}
	
	function totalekosten(a,b)
	{
		var total = parseFloat(a) + parseFloat(b)
		$('#frm_totalekosten').val((total + '').replace(".",","))
	}
	
	function totaalROI()
	{
		if ($('#frm_subtotaaltabel3').val()=="0")
		{
		}
		else
		{

			var result = (parseFloat($('#frm_subtotaaltabel3').val().replace(",",".")) - parseFloat($('#frm_totalekosten').val().replace(",",".")))/ parseFloat($('#frm_totalekosten').val().replace(",","."))* 100

			if (result=="Infinity")
			{
				$('#frm_roi').val("berekening onmogelijk");
			}
			else 
			{
				var res = roundVal(result)
				$('#frm_roi').val((res + '').replace(".",","));
			}
		}
	}
	
	function roundVal(val){
		var dec = 2;
		var result = Math.round(val*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}

jQuery.noConflict();
jQuery(document).ready(function() {

	validateForm();
	
	function controleer(waarde)
    {
      var komma = false;
      var a = waarde.split('');
      var uit = "";
      for (var i = 0; i < a.length; i++)
      {
        if (("0123456789").indexOf(a[i]) != -1)
        {
          uit += a[i];
        }
        if ( ((".,").indexOf(a[i]) != -1) && (!komma) )
        {
          uit += a[i];
          komma = true;
        }
      }
      return uit;
    }
	
	jQuery('table.blok1 input').keyup(function() {
		jQuery(this).val(controleer(jQuery(this).val()));
		if (controleer(jQuery(this).val())!="") 
		{ 
			totaal1();
			totaalROI()
		}
	} );
	jQuery('table.blok1 input').blur(function() {
		if (controleer(jQuery(this).val())=="") jQuery(this).val("0,00")
		totaal1();
		totaalROI()
	} );
	jQuery('table.blok2 input').keyup(function() {
		jQuery(this).val(controleer(jQuery(this).val()));
		if (controleer(jQuery(this).val())!="") 
		{
			totaal2();
			totaalROI()
		}
	} );
	jQuery('table.blok2 input').blur(function() {
		if (controleer(jQuery(this).val())=="") jQuery(this).val("0,00")
		totaal2();
		totaalROI()
	} );
	jQuery('table.blok3 input').keyup(function() {
		jQuery(this).val(controleer(jQuery(this).val()));
		if (controleer(jQuery(this).val())!="") 
		{
			totaal3();
			totaalROI()
		}
	} );
	jQuery('table.blok3 input').blur(function() {
		if (controleer(jQuery(this).val())=="") jQuery(this).val("0,00")
		totaal3();
		totaalROI()
	} );
	

	jQuery('table.roi input').focus(function() {
		jQuery(this).select();
	} );
	
	initFlash();
	
});

function initFlash()
{
	jQuery('#flashhomepage').flashembed(
    {
        src: '/lib/flash/home_media_v1.swf',
        version: [9, 115],
        widht:950,
        height: 600,
        expressInstall: '/lib/flash/expressinstall.swf',
        wmode: 'transparent',
        scale: 'noscale'
    },
    {	//dit zijn flashvars
        xmlPath: '/lib/xml/media.ashx'
	}
	);
}

