function setcookies(c_name) {
  Set_Cookie( c_name, document.forms[0].lat.value + ";"+ document.forms[0].long.value + ";" + document.forms[0].zone.value, 30, '/', '', '' ); 
}

function getcookies(c_name) {
  var all_params = Get_Cookie(c_name).split( ';' );
  //for ( var i = 0; i < all_params.length; i++ )
  //  {
  //   alert(all_params[i]);
  //  }
  document.getElementById("lat").value = all_params[0];
  document.getElementById("long").value =  all_params[1];
  document.getElementById("zone").value = all_params[2];
  document.getElementById("indicator").style.display = 'none';
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default false
	var i = '';
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		// and trim left/right whitespaces
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) 
	{
		return '35;139;9';
	}
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.
*/
// Set_Cookie( 'mycookie', 'visited 9 times', 30, '/', '', '' );


function Set_Cookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	// alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only
	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}


// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function validateForm()
{  
    if (document.forms[0].long.value == "" || document.forms[0].lat.value == "") {  
        window.alert("You must enter your geographical coordinates.");  
        return false;  
    }  
    else  
    {  
        if (document.forms[0].zone.value == "")   
        {  
            window.alert("You must enter your time zone.");  
            return false;  
        }  
        else  
        {  
            return true;  
        }  
    }  
}  

