/**
 * Array.prototype.[method name] allows you to define/overwrite an objects method
 * needle is the item you are searching for
 * this is a special variable that refers to "this" instance of an Array.
 * returns true if needle is in the array, and false otherwise
 */
Array.prototype.contains = function ( needle ) {
   for (i in this) {
       if (this[i] == needle) return true;
   }
   return false;
}

// anchor navigation
function checkAnchor()
{ 
	if(currentAnchor != document.location.hash)
	{  
		currentAnchor = document.location.hash;
						
		if (!currentAnchor)
		{
			//document.location = "#" + validAnchor[0];
			currentAnchor = document.location.hash;
			load(validAnchor[0]);
		}
		else
		{
			if ( validAnchor.contains( currentAnchor.substring(1) ) )
			{
				// Valid Anchor
				load(currentAnchor.substring(1));
			}
			else
			{
				document.location = "#" + validAnchor[0];
				currentAnchor = document.location.hash;
				load(validAnchor[0]);
			}
		}
	}
}
		
function load(curAnchor)
{
	$('#m_' + oldAnchor).removeClass('select');
	$('#m_' + curAnchor).addClass('select');
	
	$('#c_' + oldAnchor).fadeOut('fast', function()
	{
		$('#c_' + curAnchor).fadeIn('fast');
	});
				
	oldAnchor = curAnchor;

	nextlinkmanagement();
}

function trim (myString) 
{ 
return myString.replace(/^\s+/g,'').replace(/\s+$/g,'') 
} 

