function deepLink()
{
	// VARS
	this.doc = null;
	
	
	
	
	
	//--------------------------------------
	// INIT
	//--------------------------------------
	
	this.init = function()
	{
		// Document
		this.doc = this.defineDocument();
	}
	
	
	
	
	//--------------------------------------
	// GET POST
	//--------------------------------------
	
	this.getPost = function( url )
	{
		// Get the Location
		var _location = this.doc.location;
		var _hash = _location.toString().replace( url, "" );
		var _id;
		
		
		// Get ID from Hash
		if( _hash != "" )
		{
			if( _hash.search("preview=") >= 0 )
			{
				_hash = _hash.replace( "?", "" );
				_hash = _hash.split( "&" );
				
				for( i = 0; i < _hash.length; i++ )
				{
					if( _hash[ i ].search("p=") >= 0 )
					{
						_id = _hash[ i ].replace( "p=", "" );
					}
				}
			}
			else
			{
				_hash = _hash.split( "/" );
				_id = _hash[ 0 ];
			}
			
			
			// Return
			return _id;
		}
		else
		{
			return "";
		}
	}
	
	
	
	
	//--------------------------------------
	// GET LOCATION
	//--------------------------------------
	
	this.getLocation = function( url1, url2 )
	{
		var _location = this.doc.location;
		
		if( _location.toString().search( url1 ) >= 0 )
		{
			// LOCAL
			return url1;
		}
		else
		{
			// CHECK URL
			if( _location.toString().search( "www." ) < 0 )
			{
				window.location.href = url2;
			}
			
			// WEB
			return url2;
		}
	}
	
	this.getRealLocation = function()
	{
		var _hash = this.doc.location.hash;
		
		_location = this.doc.location;
		_location = _location.toString().replace( _hash, "" );
		_location = _location.toString().replace( "#", "" );
		
		return _location;
	}
	
	
	
	
	
	//--------------------------------------
	// GET HASH
	//--------------------------------------
	
	this.getHash = function()
	{
		var _hash = this.doc.location.hash;
		
		_hash = _hash.toString().replace( "#/", "" );
		if( _hash != "" )
			_hash = _hash.toString().replace( "/", "" );
		
		// Return
		return _hash;
	}
	
	
	
	
	
	//--------------------------------------
	// CHANGE HASH
	//--------------------------------------
	
	this.changeHash = function( _hash )
	{
		// Update Hash
		if( _hash != "" )
		{
			this.doc.location.hash = "#/" + _hash;
		}
		else
		{
			this.doc.location.hash = "";
		}
	}
	
	
	
	
	//--------------------------------------
	// DEFINE DOCUMENT
	//--------------------------------------
	
	this.defineDocument = function()
	{
		try
		{
			return top.document !== undefined ? top: window
		}
		catch(a)
		{
			return window
		}
	}
}
