
VRT = YAHOO.namespace("trp.vrt.common");

/*
	VRT.logger.log("message");
	writes log messages to Firefox console.
	this fails gracefully when the YUI logger libs are not included on the page, so log statements can safely
	remain in prod deployments
*/

if (typeof VRT.logger == "undefined")
{

VRT.logger = function(){
	
	var initLogger = function () { 
      //	if(trpWeb.logger.properties.isInPreview && trpWeb.logger.config.allowLogging) 
		  // YAHOO.util.Event.on(window, "load", logger.initLogReader); 
     };
        
     var initLogReader = function(){
      	if( VRT.page.properties.isInPreview)
      	{
	    	var thisLogReader = new YAHOO.widget.LogReader(null, VRT.logger.loggerConfig);
	    	if(VRT.logger.config.hideLoggerUI) thisLogReader.hide();
	   		if((YAHOO.env.ua.gecko ) || (YAHOO.env.ua.webkit > 0))
	    	{
	    		YAHOO.widget.Logger.enableBrowserConsole();
	    	}
    	}
    };
	/*
	at one point the logger worked in ie - not anymore
	*/	
	var consoleLogger = function(msg){
		if( VRT.page.properties.isInPreview) YAHOO.log(msg);

	//	if(trpWeb.logger.properties.isInPreview && trpWeb.logger.config.allowLogging) 
	//	{
	//		if(YAHOO.env.ua.ie && logger.config.allowIeAlertMsgs)
				//alert(msg)
	//		else	
	//			YAHOO.log(msg);
	//	}
	};
	

	return{
	
		//public property
        config: {
			allowLogging: true,
			hideLoggerUI: true,    //set to false if you want to see the YUI logger widget
			allowIeAlertMsgs: false,  //only set when in local sandbox
			allowSandboxAlertMessages: false //for ff alerts 
			
        },
        loggerConfig: {
        	width: "650px", 
	    	height: "30em" 
        },
        //for dynamic properties - these are set at runtime
        properties:{
        	isInPreview: true  //see  /includes/commonStylesJs.jsp
        },
        
        init:function(){
        	//initLogger();
        	initLogReader();
        },
	
		log:function(msg){
			consoleLogger(msg)			
		},
		
		alertMsg:function(msg){
			if(VRT.page.properties.isInPreview) alert(msg);
		}
		
	};
}();

}