
function createDateFilterCookie(elementID, cookieName)
{
    var date = document.getElementById(elementID).value;
                
    // erase the cookie if it exists
    if (readCookie(cookieName) != null)
        eraseCookie(cookieName);                                                               
        
    createCookie(cookieName, date, 365); 	
}

function getDateFilterCookie(elementID, cookieName)
{              
    // initalize the date filter criteria stored in a cookie     
    var value = readCookie(cookieName);
     
    if (value != null)
        document.getElementById(elementID).value = value;
}

function createSelectInputCookie(elementID, cookieName)
{
    // store the area select input
    var selectbox = document.getElementById(elementID);	
    var selectedOption = selectbox.options[selectbox.selectedIndex].value;
    
    // erase the cookie if it exists
    if (readCookie(cookieName) != null)
        eraseCookie(cookieName);                                                               
        
    createCookie(cookieName, selectedOption, 365); 	
}

function getSelectInputCookie(elementID, cookieName)
{
    // initalize the select box input filter criteria stored in a cookie     
    var value = readCookie(cookieName);   
    
    if (value != null)
        document.getElementById(elementID).value = value;
}

function createCheckBoxInputCookie(elementID, cookieName)
{
    // store check box states
    var checked = document.getElementById(elementID).checked;       
    
    // erase the cookie if it exists
    if (readCookie(cookieName) != null)
        eraseCookie(cookieName);                                                              
        
    createCookie(cookieName, checked, 365);   
}

function getCheckBoxInputCookie(elementID, cookieName)
{
    // initalize the check box input filter criteria stored in a cookie     
    var value = readCookie(cookieName);
       
    if (value != null)
        document.getElementById(elementID).value = (value == "true" ? true : false);
}

function createTextInputCookie(elementID, cookieName)
{
    var txtValue = document.getElementById(elementID).value;
         
    // po number cookie 
    if (readCookie(cookieName) != null)
        eraseCookie(cookieName);                                                               
        
    createCookie(cookieName, txtValue, 365);   
}

function getTextInputCookie(elementID, cookieName)
{
    // initalize the text input filter criteria stored in a cookie     
    var value = readCookie(cookieName);       
    
    if (value != null)
        document.getElementById(elementID).value = value;
}

function createTabSelectedCookie(elementID, pageName)
{
   
}

function createCookie(name, value, days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}