// Use browser detection to add href link to download button
function link_download_button(src) {
	var platform = window.navigator.platform;
	var userAgent = window.navigator.userAgent;
	var firefoxWin = 'https://addons.mozilla.org/en-US/firefox/downloads/latest/102180/platform:5/addon-102180-latest.xpi?src=' + src;
	var firefoxMac = 'https://addons.mozilla.org/en-US/firefox/downloads/latest/102180/platform:3/addon-102180-latest.xpi?src=' + src;
	var firefoxLinux = 'https://addons.mozilla.org/en-US/firefox/downloads/latest/102180/platform:2/addon-102180-latest.xpi?src=' + src;
	var ie = 'http://addon.picscout.com/addon/ie/ImageExchangeIESetup.exe';
	var chrome = 'https://clients2.google.com/service/update2/crx?response=redirect&x=id%3Dicjmigaccjelpcchpcllbbdooeneifhe%26uc%26lang%3Den-US&prod=chrome&prodversion=10.0.648.127';
	var safari = 'https://addon.picscout.com/Addon/Safari/ImageExchange.safariextz';
	// Example IE8 text string:
	// Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
	// Example IE9 text string:
	// Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
	
	if (platform.indexOf("Linux") >= 0) {
		if (userAgent.indexOf('Firefox') > 0) {
			$('div.download-button a').attr('onClick', null);
			$('div.download-button a').attr('href', firefoxLinux);
		}
	} else if (platform.indexOf('Mac') >= 0) {
		if (userAgent.indexOf('Firefox') > 0) {
			$('div.download-button a').attr('onClick', null);
			$('div.download-button a').attr('href', firefoxMac);
		} else if (userAgent.indexOf('Chrome') > 0) {
			$('div.download-button a').attr('onClick', null);
			$('div.download-button a').attr('href', chrome);
		} else if (userAgent.indexOf('Safari') > 0) {
			$('div.download-button a').attr('onClick', null);
			$('div.download-button a').attr('href', safari);
		}
	} else if (platform.indexOf("Win") >= 0) {
		if (userAgent.indexOf('Firefox') > 0) {
			$('div.download-button a').attr('onClick', null);
			$('div.download-button a').attr('href', firefoxWin);
		} else if (userAgent.indexOf('Chrome') > 0) {
			$('div.download-button a').attr('onClick', null);
			$('div.download-button a').attr('href', chrome);
		} else if (userAgent.indexOf('Safari') > 0) {
			$('div.download-button a').attr('onClick', null);
			$('div.download-button a').attr('href', safari);
		} else if (userAgent.indexOf('MSIE') > 0) {
			if (userAgent.indexOf('MSIE 9.0') > 0) {
				// Currently not available for ie9 so leave defaults
			} else {
				$('div.download-button a').attr('onClick', null);
				$('div.download-button a').attr('href', ie);
			}
		}
	}
}

