window.addEvent( "load", function()
{
	if( window.google && google.gears )
	{
		$( "gGears_Info" ).set( "html", "<span style=\"color: orange; font-weight: bold;\">Google Gears installed</span>" );

		if( !google.gears.factory.hasPermission )
		{
			if( !google.gears.factory.getPermission( "Ecchi-RO.net", "http://ecchi-ro.net/Images/default/cbg.gif", "Ecchi-RO Website" ) ) return;
		}
		else $( "gGears_Info" ).set( "html", "<span style=\"color: green; font-weight: bold;\">Google Gears installed & has Access</span>" );

		// Shortcuts for the Google Gears Classes
		var gFactory = google.gears.factory;
		var gLocal_Server = gFactory.create( "beta.localserver" );

		var store = gLocal_Server.createManagedStore( "website" );
		$( "gGears_Info" ).set( "text", "Checking for Updates..." );
		store.manifestUrl = "../Include/cache.php";
		store.enabled = true;
		store.checkForUpdate();

		store.oncomplete = function( data )
		{
			if( data.newVersion != "" ) $( "gGears_Info" ).set( "html", "<span style=\"color: green; font-weight: bold;\">Update Completed</span>" );
			else $( "gGears_Info" ).set( "html", "<span style=\"color: green; font-weight: bold;\">Google Gears Up-to-Date</span>" );
		};

		store.onerror = function( data )
		{
			$( "gGears_Info" ).set( "html", "<span style=\"color: red; font-weight: bold;\">Update failed: " + data.message + "</span>" );
		};

		store.onprogress = function( data )
		{
			$( "gGears_Info" ).set( "html", "<span style=\"color: orange; font-weight: bold;\">Updating: " + data.filesComplete + " / " + data.filesTotal + " completed</span>" );
		};
	}
	else
	{
		$( "gGears_Info" ).set( "html", "<a style=\"color: red; font-weight: bold;\" href=\"http://gears.google.com/?action=install&name=Ecchi-RO Website&message=Install this in order to get advanced features for the Website&icon_src=http://ecchi-ro.net/Images/default/cbg.gif&return=http://ecchi-ro.net\">Install Google Gears</a>" );
		return;
	}
} );
