function installXPI(filename) {
	var xpi = new Object();
	xpi["Minggl"] = {
		URL: "https://downloads.minggl.com/2/" + filename,
		IconURL: "http://static.minggl.com/images/minggl-logo.png",
		toString: function () { return this.URL; }
	};
	InstallTrigger.install(xpi);
	return false;
}


$(document).ready(function(){	

	// browser detection
 	var browser_type = navigator.userAgent.toLowerCase();
 	var platform = navigator.appVersion.toLowerCase();

 	if(browser_type.indexOf('gecko/') > 0) { // gecko based, "gecko/" because safari gives a string containing a "gecko like"
 		if(platform.indexOf('mac') > 0) { // MAC
 			
 			if (browser_type.indexOf('ppc') > 0)
 				$("#ffosx-ppc").show();
 			else
 				$("#ffosx-intel").show();

 			$(".actionButtonWht")
 				.attr("href","#")
 				.unbind('click')
 				.click(function(){
 					//PPC or Intel?
 					if (browser_type.indexOf('ppc') > 0)
 						installXPI("minggl-osx-ppc.xpi");
 					else
 						installXPI("minggl-osx-i386.xpi");
 					return false;
 				});
 
 		} else if(platform.indexOf('windows') > 0) { // WIN
 			$("#ffwin").show();
 		
 			$(".actionButtonWht")
 			.attr("href","#")
 			.unbind('click')
 			.click(function(){
 				installXPI("minggl-win-i386.xpi");
 				return false;
 			});
		} else {
			$("#other").show();
		}
		
 	} else if(browser_type.indexOf('msie') > 0) {
 		$("#ie").show();
 		
 		$(".actionButtonWht")
 			.attr("href","http://downloads.minggl.com/2/MingglInstaller.exe")
 			.unbind('click');
 	} else {
		$("#other").show();
	};
	
});
