/**
 * Injects a custom css style sheet and removes it once the viewer is closed. this Module seems to work only on newer browsers
 * so it currently not used... anymore
 */
var CustomCSSModule=MapItemModule.extend({
	/**src is an absolute or relative url.*/
	initialize:function(mediaMap, src, options)
	{
	var me=this;
	me.parent(mediaMap, src, $merge({position:'geoliveWindow_head'},options));
	me.options.name="CSSLoader";

	},
	process:function(){
		var me=this;
		var src=me.item;
		me.injectCSS(src,'templateCSS');//adds css and event listeners that remove themselves on fireing.
		me.fireEvent('onLoad');
	},
	/**link is the url (here src is just passed through) name is the css name attriibute to give. no id is specified*/
	injectCSS:function(link, name)
	{
		var me=this;
		var asset=new Asset.css(link, {title: name});
		var eventListener=function(){
			asset.parentNode.removeChild(asset);
			me.viewer.removeEvent('onClose', eventListener);
		};
		me.viewer.addEvent('onClose', eventListener);
	}
});


/**
 * extends CustomCSS but checks a list of [browser - css filenames] pairs 
 * an if the browser is in the list, the css file is loaded.
 * the browser list key value pair expects key strings matchin the browser and 
 * values matching the relative url of the css file from src but without the .css extension
 * 
 * ex new MGModule.BrowserCSS(mediaMap, "/site/css/",{browsers:{'Explorer':'IECustomStyle'}})
 * 	--injects relpath/IECustomStyle.css into the document
 * 
 * since CSSModule seems to fail for older browsers hopefuly this module will not be used 
 * except for newer browsers. additionally there seems to be no onload event for injecting css 
 * which is also not ideal
 */
var BrowserCSSModule=CustomCSSModule.extend({
	process:function(){
	var me=this;
	$each(me.options.browsers,function(value, key)
			{
		if(BrowserDetect.browser==key)
		{
			//check for .css extension and add to string if it does not exist
			me.injectCSS(me.src+value+".css", 'browserSpecificCSS');
		}
			});
	me.fireEvent('onLoad');
}
});
