﻿//-----------
// EmptyField - form validation
// if a field is empty, output warning and return true
//-----------
function EmptyField( input, showname) {
	
	if (isEmpty(showname)) showname = input.name ;

    if ( isEmpty( input.value ) ) {
        input.focus() ;
        alert ("You did not enter a value for '" + showname  +
            "'\n\nThis is a required field. Please enter it now.");
        return true ;
    }
    return false ;
}

// return true if the string is null or its length = 0
function isEmpty(str) {
    return ((str == null) || (str.length == 0))
}

function setCookie(cookieName,cookieValue,cookieDays){
    if (cookieDays>0) {
        var expiry = new Date();
        expiry.setDate(expiry.getDate() + cookieDays);
        document.cookie = cookieName+'=' +escape(cookieValue) + ';expires=' + expiry.toGMTString();
    }
    else {
        document.cookie = cookieName+'=' +escape(cookieValue) ;
    }
}

function getCookie(cookieName){
    // regexp from Carlos Reche (http://gorondowtl.sourceforge.net/wiki/Cookie)
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(cookieName) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
}

function clearCookie(cookieName) {
    document.cookie = cookieName + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}

