/* define cometmarks globalData const variables */
if( typeof( CometBirdFileDefine ) == "undefined" )
{
	try
	{
		eval('																						\r\n\
			const CometBirdFileDefine =																\r\n\
			{																						\r\n\
				logFileName					:	"cometbird.log",										\r\n\
			};																						\r\n\
		');
	} 
	catch( e ) 
	{
		alert ( e ); 
	}
}

var CometBirdFile = 
{
	writeLog : function( data )
	{
		// 0x02 | 0x10 to open file for appending.
		var file = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get('ProfD', Components.interfaces.nsIFile);
		file.append( CometBirdFileDefine.logFileName );
		if ( !file.exists() )
		{
			file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666 )
		}
		
		 // begin to write log into file
		var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
		foStream.init( file, 0x02 | 0x10, 0666, 0 ); 

		data = data + "\r";
		foStream.write( data, data.length );
		foStream.close();
	},

	deleteLog : function()
	{
		var file = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get('ProfD', Components.interfaces.nsIFile);
		file.append( CometBirdFileDefine.logFileName );
	  
		if ( file.exists() )
			file.remove( true );
	},

	showLogs : function()
	{
		var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
		var file = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties).get('ProfD', Components.interfaces.nsIFile);
		file.append( CometBirdFileDefine.logFileName );
		var uri = ios.newFileURI(file);
		CometBirdUtility.openURL( uri.spec );
	}
};