/*
	BrowserAbstractionFactory class
*/

function BrowserAbstractionFactory(balPath) 
{
	this.balClassName = null;
	var isSupported = true;
	
	// create BrowserDetect object
	browserDetect = new BrowserDetect();
	
	if ( browserDetect.win )
	{
		// Supported Windows browsers
		if( browserDetect.ie ){
			if ( browserDetect.ie4up ){
				this.balClassName = "WindowsIEAbstraction";
			}
		}else if( browserDetect.nav ){
			if ( browserDetect.nav5up ){
				this.balClassName = "WindowsNav6Abstraction";
			}else if ( browserDetect.nav4up ){
				this.balClassName = "WindowsNavAbstraction";
			}
		}else if(browserDetect.opera){
			if ( browserDetect.opera5 ){
				this.balClassName = "WindowsOp5Abstraction";
			}else if ( browserDetect.opera7 ){
				this.balClassName = "WindowsOp7Abstraction";
			}else if ( browserDetect.opera7up ){
				this.balClassName = "WindowsOpAbstraction";
			}
		}
	}
	else if (browserDetect.mac)
	{
		if ( browserDetect.ie5up )
		{
			this.balClassName = "WindowsIEAbstraction";//"MacIE5Abstraction";
		} 
		else if ( browserDetect.ie4up )
		{
			this.balClassName = "WindowsIEAbstraction";//"MacIE4Abstraction";
		}
		else if ( browserDetect.nav4up )
		{
			this.balClassName = "WindowsNavAbstraction";//"MacNav4Abstraction";
		}
	}
	
	//alert(this.balClassName);
	if ( this.balClassName != null ) 
	{
		document.writeln('<script language="javascript" src="' + balPath + this.balClassName + '.js"></script>');
	}
	else
	{
		isSupported = false;
		alert("Navegador no soportado");
	}
	
	// declare methods
	this.getAbstraction	= getAbstractionMethod;
	
	function getAbstractionMethod()
	{
		// Example: return new WindowsIEAbstraction();
		return eval('new ' + this.balClassName + '()');
	}
}
