$(function() {
	show_messages();
});

function print_r(theObj)
{
	result = "";
	if(theObj.constructor == Array || theObj.constructor == Object)
	{
		result += "<ul>";
		for(var p in theObj)
		{
			if(theObj[p].constructor == Array|| theObj[p].constructor == Object)
			{
				result += "<li>["+p+"] => "+typeof(theObj)+"</li>";
				result += "<ul>";
				print_r(theObj[p]);
				result += "</ul>";
			} 
			else 
			{
				result += "<li>["+p+"] => "+theObj[p]+"</li>";
			}
		}
		result += "</ul>";
	}
	return result;
}

function show_messages()
{
	var msg = $('#msg_box').html();
	if( msg != null )
	{
		$('#msg_box').show();
		setTimeout ( function() { $('#msg_box').fadeOut(2000); }, 4000 );
	}
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
	return ( unescape ( results[2] ) );
  else
	return null;
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}


