 

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function DocfilenameExtract()
{
	return window.location.pathname.substring(location.pathname.lastIndexOf('/')+1)
}

function relocate()
{
	var theController = DocfilenameExtract();
	var theAction = gup('action');
	switch(theController)
	{
	case 'aanbod':
		switch(theAction)
		{
		case 'wekelijks_aanbod':
			window.location = "/#/Aanbod/soort=REGULIER";
			break;
		case 'direct_te_huur_aanbod':
			window.location = "/#/Aanbod/soort=DIRECT";
			break;
		case 'spoedzoeker_aanbod':
			window.location = "/#/Aanbod/soort=DAGELIJKS";
			break;
		case 'advertentie':
			var theId = gup('id');
			window.location = "/#/AanbodDetails/id=" + theId + "&bstate=Aanbod";
			break;
		default:
			window.location = "/";
		}
		break;
	default:
		switch(theAction)
		{
		case 'folders':
			window.location = "/#/Hoe_Werkt_Het/tab=folders";
		case 'hoe_kom_ik_aan_een_huis':
			window.location = "/#/Hoe_Werkt_Het/";
			break;
		case 'spelregels':
			window.location = "/#/Hoe_Werkt_Het/tab=spelregels";
			break;
		case 'veel_gestelde_vragen':
			window.location = "/#/Hoe_Werkt_Het/tab=faq";
			break;
		case 'vraag':
			var theId = gup('id');
			window.location = "/#/Hoe_Werkt_Het/tab=faq";
			break;
		case 'contact':
			window.location = "/#/Hoe_Werkt_Het/tab=contact";
			break;
		case 'contactdetails':
			window.location = "/#/Hoe_Werkt_Het/tab=contact";
			break;
		case 'uitleg_begrippen':
			window.location = "/#/Hoe_Werkt_Het/tab=begrippen";
			break;
		case 'instructie_videos':
			window.location = "/#/Hoe_Werkt_Het/tab=videos";
			break;
		case 'inschrijven':
			window.location = "/#/Inschrijven";
			break;
		case 'verantwoording':
			window.location = "/#/Verantwoording";
			break;
		case 'projecten':
			window.location = "/#/NieuwBouw";
			break;
		case 'project':
			var theId = gup('id');
			window.location = "/#/NieuwBouwDetails/id=" + theId
			break;
		default:
			window.location = "/"
		}
	}
	
}
