
/// <summary>
/// Function get all DOM objects with a certain class value on certain tags
/// within a certain node.  Pass document in for the node if you want to parse
/// the entire page.
/// <seealso href="http://www.dustindiaz.com/getelementsbyclass/">getElementsByClass</seealso>
/// <summary>
function getElementsByClass( searchClass, node, tag ) 
{
    // Object Container
	var classElements = new Array();
	
	// Make sure we have a node, otherwise parse the entire document
	if ( node == null )
	{
		node = document;
    }
    
    // Make sure we have a tag, otherwise inspect all tags
	if ( tag == null )
	{
		tag = '*';
    }
    
    // Get all tags that are a match
	var els = node.getElementsByTagName(tag);
	
	// See how many we have
	var elsLen = els.length;
	
	// Regex Pattern
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	
	// Loop through all our matching objects by tag
	for (i = 0, j = 0; i < elsLen; i++) 
	{
	    // See if we have a match
		if ( pattern.test(els[i].className) ) 
		{
		    // Add to our return container
			classElements[j] = els[i];
			
			j++;
		}
	}
	
	// Return our matches
	return classElements;
	
}; //getElementsByClass

/// <summary>
/// Function to create/update a new cookie
/// <seealso href="http://www.quirksmode.org/js/cookies.html">Cookies</seealso>
/// <summary>
function createCookie( name, value, days ) 
{
    // Expiration Container
    var expires = "";
    
    // Figure out when this should expire
	if (days) 
	{
	    // Get Current Date
		var date = new Date();
        
        // Calculate Expiration Date/Time
		date.setTime(date.getTime()+(days*24*60*60*1000));
		
		// Update Container
		expires = "; expires="+date.toGMTString();
	}
	
	// Send to Client
	document.cookie = name+"="+value+expires+"; path=/";
	
}; //createCookie

/// <summary>
/// Function to Get the Value of a Cookie
/// <seealso href="http://www.quirksmode.org/js/cookies.html">Cookies</seealso>
/// <summary>
function readCookie( name ) 
{
    // Container for Name (modified with seperator)
	var n = name + "=";
	
	// Split all the existing cookies
	var ca = document.cookie.split(';');
	
	// Loop through the collection
	for(var i=0;i < ca.length;i++) 
	{
	    // Get the Cookie from Cookie Array (ca)
		var c = ca[i];
		
		// Strip out the spaces at the beginning, if there are any
		while (c.charAt(0)==' ') 
		{
		    c = c.substring(1,c.length);
		}
		
		// See if we have a match
		if (c.indexOf(n) == 0) 
		{
		    return c.substring(n.length,c.length);
		}
	}
	
	// It didn't exist, return empty value
	return null;
	
}; //readCookie

/// <summary>
/// Function to Remove a cookie
/// <seealso href="http://www.quirksmode.org/js/cookies.html">Cookies</seealso>
/// <summary>
function eraseCookie( name ) 
{
    // Create/Update the cookie with empty value and to expire yesterday
	createCookie(name,"",-1);
	
}; //eraseCookie




