/*Cookie functions*/
/*function setCookie()
{
	document.cookie="visited=recently";
}
*/
function cookieSet(nameStr,valueStr,daysForward)
{
	var today = new Date();//create a Date object
	var dateForward = today.getDate() + daysForward;//returns a value
	var expiration = new Date();//create a date Object
	expiration.setDate(dateForward);//this method takes value and returns a date Object
	
	document.cookie = nameStr + "=" + escape(valueStr) +"; expires=" + expiration.toGMTString();	
}


function cookiesCheck()
{
    if (document.cookie == "")
        return;

    var cookieObj = new Object();

    var httpCookies = document.cookie;	
	//retrieves a single string containing the name=value pairs of all cookies separated by "; "
    
	var allCookies = httpCookies.split("; "); 
	//splits the string and returns an Array of all name=value pair strings

    for (i=0; i < allCookies.length; i++) //for each element in the array
	{ 
        namevalueArray = allCookies[i].split("="); //returns an array with two string elements
		var name  = nameValue[0]; //the first element is the name string
        var value = nameValue[1];  //the second element is the value string
        cookieObj[name] = value; //build the cookie object - this syntax works because name is a string
    }           
	
    return(cookieObj);  //return the cookie object
}

function cookieCheck(name) 
{
    var value = '';

    var httpCookies = document.cookie;	
	//retrieves a single string containing the name=value pairs of all cookies separated by "; "
    
    var allCookies  = httpCookies + "; "  

    var found = allCookies.indexOf(name);  //find the cookie name 
    if (found >=0) 
	{                                 //if cookie name is found
        var beg = allCookies.indexOf("=",found) +1   //get the beginning of value
        var end = allCookies.indexOf(";",found)      //get the end of value            
        value = allCookies.substring(beg,end);       //extract of the value
    }
    return(value);				     //return the cookie value
} 
