// At this point we know Google is not accessing the page, we know that
// because Google (all web crawlers) cannot run JavaScript.

// The first thing we need to do is check if the URL is a virtual URL for
// accessing assets. The URL format we are using is "/asset/nnnn/" where nnnn
// is the ID for the asset. If the URL is virtual then we redirect the browser
// and convert the URL to one that can be used for deeplinking. This redirect
// will not (and should not) push anything into the browser's history array.
function redirect()
{
	var url = window.location.href.toLowerCase();

	// Split the URL using the domain name and root virtual directory.
	// url = url.split( "ultrashock.com/asset/" );
	var parts = url.split( "ultrashock.com/asset/" );

	// If the length of parts is 2 then we know a virtual URL is being used.
	// We also know the assetID is valid because PHP has already validated it.
	if( parts.length == 2 )
	{
		// Grab the assetID.
		//var assetID = parts[ 1 ].split( "/" )[ 0 ];
		var assetID = parts[ 1 ];
		
		// filter out .html
		//assetID = assetID.replace(".html","");

		// Create the deeplink URL.
		var deeplink = "/#/asset/" + assetID + "";

		// Do the redirect. Using replace() will not push anything into
		// the browser's history array.
		location.replace( deeplink );
	}
}

redirect();