/*

NAME: COOKIES.JS
FUNCTIONS:

name:           set_cookie()
parameters:     1. name - name of the cookie
		2. value - value of the cookie 
		3. expires - the time in daysfrom now to expire the cookie
		4. path - the path you wish the cookie to control
		5. domain - the (sub)domain you wish the cookie to control
		6. secure - deprecated
returns :       true - upon completion of cookie set

name:		get_cookie( name )
parameters:	1. name - the name of the cookie to retrieve
returns:	unescaped value of the cookie if found 	
		false - if the cookie is not present

name: 		delete_cookie( name, path, domain )
parameters:	1. name - name of the cookie
		2. path - the path the cookie controls
		3. domain - the domain the cookie controls
returns:	true - if cookie deleted
		false - if the cookie is not present

name:           delete_all_cookies()
parameters:     0 
returns:        true - if all cookies deleted
                false - if the cookie is not present

name:           get_all_cookies()
parameters:     0
returns:        true - if all cookies deleted
                false - if the cookie is not present

*/

function html5StorageSupported() 
{  
	return ('localStorage' in window) && window['localStorage'] !== null;  
}


function setStorage( name, value, persist )
{
	if( persist == 'true' )
	{
		window.localStorage.setItem( name, value );
	} else 	{
			window.sessionStorage.setItem( name, value );
		}
}

function getStorage( name, persist )
{
	if( persist == 'true' )
	{  
		return window.localStorage.getItem( name ); 
	} else	{
			return window.sessionStorage.getItem( name ); 
		}
}

function deleteStorage( name )
{
        if ( get_cookie( name ) )
        {
                window.localStorage.removeItem( name );
        } else	{
			return false;
		}
}

function clearStorage( persist )
{
 	if ( persist == 'true' )
	{
		window.localStorage.clear();
	} else	{
			window.sessionStorage.clear();
		}
}



