	function PlatformGet()
	{
		var agent = navigator.userAgent.toUpperCase();
		var platform = "desktop";
	
		if( agent.indexOf( "WINDOWS CE" ) >= 0 )
			platform = "pocket";
		else if( agent.indexOf( "MINIMO" ) >= 0 )
			platform = "pocket";
		else if( agent.indexOf( "GECKO" ) >= 0 )
			platform = "mozilla";
		
		return( platform );
	}
	
	function GetElementById( parent, name )
	{
		var obj = null;
		var DOCUMENT_NODE = 9;
	
		if( PlatformGet() == "pocket" )
		{	
			if( eval( "typeof(" + name + ")!='undefined'" ) )
				eval( 'obj = ' + name + ';' );
		}
		else if( parent && ( parent.nodeType != DOCUMENT_NODE ) )
		{
			var objs = parent.getElementsByTagName( "*" );
			
			for( var objnr = 0; objnr < objs.length; objnr++ )
			{
				if( ( objs[ objnr ].id && ( objs[ objnr ].id == name ) ) || ( objs[ objnr ].name && ( objs[ objnr ].name == name ) ) )
				{
					obj = objs[ objnr ];
					break;
				}
			}
		}
		else
		{
			obj = document.getElementById( name );
		}
						
		return( obj );			
	}

	function GetElementsByName( parent, name )
	{
		var objs = null;
		var DOCUMENT_NODE = 9;
	
		if( PlatformGet() == "pocket" )
		{	
			if( name != "*")
			if( eval( "typeof(" + name + ")!='undefined'" ) )
				eval( 'objs = ' + name + ';' );
			
			if( objs )
			{
				var objArray = new Array();
				objArray[0] = objs;
				objs = objArray;
				//alert("objs.length: " + objs.length);
			}
		}
		else if( parent && ( parent.nodeType != DOCUMENT_NODE ) )
		{
			objs = new Array();
			var allobjs = parent.getElementsByTagName( "*" );
		
			for( var objnr = 0; objnr < allobjs.length; objnr++ )
			if( ( allobjs[ objnr ].id && ( allobjs[ objnr ].id == name ) ) || ( allobjs[ objnr ].name && ( allobjs[ objnr ].name == name ) ) || ( name == "*" ) )
				objs[ objs.length ] = allobjs[ objnr ];
		}
		else
		{
			objs = document.getElementsByName( name );
	
		}
	
		return( objs );			
	}
	function ArgSet( args, name, value )
	{
		var baseUrl = "";
		args = StringReplaceAll( args, "&amp;", "&" );
		args = StringReplaceAll( args, "%26", "&" );
		
		var searchPos = args.indexOf("?");
		if( searchPos >= 0 )
		{
			baseUrl = args.substring( 0, searchPos + 1 );
			args = args.substring( searchPos + 1 );
		}
		else
		{
			baseUrl = args + "?";
			args = "";
		}
		
		var objs = args.split( "&" );	  
		
		var found = false;
	
		for( var objnr = 0; objnr < objs.length; objnr++ )
		{
			
			var valuepos = objs[ objnr ].indexOf( "=" );
			
			if( valuepos > 0 )
			{
				var objName = objs[ objnr ].substring( 0, valuepos  );
				
				
				if( objName == name )
				{
					objs[ objnr ] = name + "=";
					objs[ objnr ] += value;
					found = true;
				}
			}
		}
		
		
		if( found )
		{
			args = "";
			for( var objnr2 = 0; objnr2 < objs.length; objnr2++ )
			{
				if( objs[ objnr2 ].length > 0 )
				{
					if( args.length > 0 )
						args += "&";
					
					args += objs[ objnr2 ];
				}
			}
		}
		else
		{
			args += "&" + name + "=" + value;	
		}
		
		return( baseUrl + args );
	}
	
	function ArgGet( args, name )
	{
		var value = "";
		args = StringReplaceAll( args, "%26", "&" );
		
		var searchPos = args.indexOf("?");
		if( searchPos >= 0 )
			args = args.substring( searchPos + 1 );
		
		var objs = args.split( "&" );
	
		for( var i = 0; i < objs.length; i++ )
		{
			var crumb = objs[ i ].split( "=" );
			var findpos = crumb[ 0 ].indexOf( name );
	
			if( findpos >= 0 )
			if( findpos < 5 )
			if( findpos + name.length == crumb[ 0 ].length )
			{
				value = crumb[ 1 ];
				break;
			}
		}
	
		return( value );
	}
	
	function StringReplaceAll( input, findValue, replaceValue )
	{
		if( findValue.indexOf( replaceValue ) < 0 )
		while( input.indexOf( findValue ) >= 0 )
			input = input.replace( findValue, replaceValue );
		return( input );
	}
	
	
	function openWindowPreview( thisObj )
	{
		openWindow( thisObj, 1024, 650 );
	}
	
	function openWindowEditor( thisObj )
	{
		openWindow( thisObj, 750, 500 );
	}
	
	function openWindowCalendar( thisObj )
	{
		openWindow( thisObj, 240, 210 );
	}
	
	function openWindow( thisObj, width, height )
	{
		window.open( thisObj.href, '_blank', 'scrollbars = yes,width=' + width + ',height=' + height );
	}
	
	function checkTop( targetUrl )
	{
		if( window && window.top )
		{
			if( window == window.top )
			{
				var topUrl = window.top.location.href;
				var urlHash = window.top.location.hash;
				urlHash = urlHash.replace("#","");
				var url = targetUrl + '?&urlhash=' + urlHash + '&url=' + window.top.location.href;
				window.top.location.href = url;
			}
		}
	}
	
	function passToFlash( flashId, varName, varValue )
	{
		var flashObj = null;
		
		flashObj = window.top.document.getElementById( flashId );

 		if( flashObj )
			flashObj.SetVariable( varName, varValue );
	}
	
	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 MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() 
	{ 
		
	//v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	function toggleCheckBox( thisObj )
	{
		
		if( thisObj )
		{
			if( (!thisObj.value) || ( thisObj.value == '' ) || ( thisObj.value == 'off' ) )
				thisObj.value = 'on';
			else if( thisObj.value == 'on' )
				thisObj.value = 'off';
		}
		
	}
	
	var submitDone = false;
	function formulierSubmit( formname )
	{
		
		if( !formname )
		{
			formname = 'formulier';
		}
				
		var formObj = GetElementById( window.document, formname );
		
		if( formObj )
		{
			if( typeof( uploads_in_progress ) != "undefined" && ( uploads_in_progress > 0 ) )
			{
		    	alert( "File upload in progress. Please wait until upload finishes and try again!" );
			}
			else if( validateFields( formObj ) )
			{
				var submitObj = GetElementById( window.document, 'submitArea' );
				if( submitObj )
				{
					submitObj.style.display = 'none';
				}
				
				var ogenblikObj = GetElementById( window.document, 'ogenblik' );
				if( ogenblikObj )
				{
					ogenblikObj.style.display = '';
				}
				
				
				if( submitDone == false )
				{ 
					if( window.tabview_active )
					{
						formObj.action = ArgSet( formObj.action, "tab_id", tabview_active( 'TabView' ) );
						formObj.action = ArgSet( formObj.action, "parent_tab_id", ArgGet( document.location.href, 'parent_tab_id' ) );
					}
					
					submitDone = true;
					formObj.submit();
				}
			}
		} 
	}
	
	function urlSetParentActiveTab( url )
	{
		url = ArgSet( url, 'parent_tab_id', tabview_active( 'TabView' ) );
		document.location.href = url;
	}
	
	function validateFields( formObj)
	{
		var result = true;
		
		if( formObj.elements )
		{
			var count = 0;
			
			for( count = 0 ; count < formObj.elements.length ; count++ )
			{
				if( formObj.elements[count].name == 'voorwaarden')
				{
					if( !formObj.elements[count].checked )
					{
						alert('U heeft nog geen akkoord gegeven voor de leveringsvoorwaarden van Wonen in Belgie');
						result = false;
						break;
					}
				}
			}
				
			if( result )
			{
				count = 0;
				for( count = 0 ; count < formObj.elements.length ; count++ )
				{	
					if( formObj.elements[count].title.indexOf( 'verplicht' ) >= 0 )
					{
						if( !formObj.elements[count].value.length )
						{
							alert('U heeft een of meerdere verplichte velden niet ingevuld!');
							result = false;
							break;
						}
					}
					
					if( formObj.elements[count].name == 'persoon_email' )
					{
						if( !isEmail( formObj.elements[count].value ) )
						{
							alert("U heeft geen geldig e-mailadres ingevuld.");
							result = false;
							break;
						}
					}
				}
			}
		}			
		return( result );
	}
	
	function setActiveMenu( menuName )
	{
		var objs = window.document.links;
		if( objs )
		{
			var i = 0;
			for(;i<objs.length;i++)
			{
				if( objs[i].innerHTML == menuName && objs[i].className.indexOf('aMenu') >= 0 )
				{
					objs[i].className = 'aMenuActive';
				}
			}
		}
	}
	
	function IsValid( sText, ValidChars, minLength )
	{
		var IsValidText = true;
		var sChar;
		
		var i = 0;
		
		for( ; ( i < sText.length ) && ( IsValidText == true ); i++ ) 
		{ 
			sChar = sText.charAt( i ); 
			if( ValidChars.indexOf( sChar ) == -1 ) 
			{
				IsValidText = false;
			}
			
		}
		
		if( minLength != -1 && IsValidText )
		{
			IsValidText = ( sText.length >= minLength );
		}
			
		return IsValidText;
	}
	
	function isEmail( email )
	{   
		result = false;
		
		if( ( email.length > 4 ) && ( email.indexOf('@') > 0 ) && ( email.indexOf('.') > 0 ) )
			result = true;

		return( result );
	}
	
	
