function checkBrowserWidth() {
	var theWidth = getBrowserWidth();

	if (theWidth > 800)
		setStylesheet("Version 1024x768");
	else
		setStylesheet("Version 800x600");
	
	return true;
}

function installExtension(aEvent) {
   var params = {
	   "DownThemAll!": { URL: aEvent.target.href,
		    IconURL: 'images/icon.png',
	            toString: function () { return this.URL; }
     }
   };

   var res = InstallTrigger.install(params);
   if (!res) { 
	alert("If you see an error bar at the top of your browser, follow these instructions:\n" +
		"1. Click the \"Edit Options...\" button on the error bar.\n" + 
		"2. Click the \"Allow\" button in the dialog box that appears.\n" + 
		"3. Click \"OK\" to confirm and close the dialog box.\n" + 
		"Now you can install extensions from this site.\n" +
		"Click the install link again to install the extension.\n\n" +
		"If you don't see the error bar, please make sure you have enabled \n" + 
		"extension installation from Web sites in the \"Options\" dialog."
 		);
   }

   return false;
}

function getBrowserWidth() {
	if (window.innerWidth)
		return window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth != 0)
		return document.documentElement.clientWidth;
	else if (document.body)
		return document.body.clientWidth;
	
	return 0;
}


function setStylesheet(styleTitle){	
	var currTag;
	if (document.getElementsByTagName)
		for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++)
			if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title")) {
				currTag.disabled = true;
				if(currTag.getAttribute("title") == styleTitle) {
					currTag.disabled = false;
				}
			}
	return true;
}

