//var gotIE9Full = "";
$(document).ready(function () {
							
	
		if(isWindowsXP()) {
			/****************************************************************************************************************************
			******************************************** WINDOWS XP! ********************************************************************/
			window.location.href = "internet-explorer-8/index.html";
		}
        else if (isWrongOS()) {
            /****************************************************************************************************************************
			******************************************** WRONG OS! ********************************************************************/
            $("div.cta.wrongOs").show();
        }
        else if (isIE9() ) {
			    if (  isIE9Optimised() ) {
					/**************************************************************************************************************************
			        ******************************************** ALREADY GOT! ********************************************************************/
                    $("div.cta.alreadyGot").show();	
				}
				else {
			        /****************************************************************************************************************************
					******************************************** has IE9 - UPGRADE! *************************************************************/
					$("div.cta.upgrade").show();
				
				    //LITE VERSIONS
				    if ( is64Bit()) {
					
					    $("div.cta.upgrade a#upgradeBtn").attr("href", downloadLiteUrl64());
				    }
				    else {
				        $("div.cta.upgrade a#upgradeBtn").attr("href", downloadLiteUrl32());
				    }
				}
        }
        else {
            /**************************************************************************************************************************
			******************************************** FULL DOWNLOAD *****************************************************************/
            $("div.cta.download").show();
            $("div.cta.wrongOs").hide();
            $("div.cta.alreadyGot").hide();
			$("div.cta.upgrade").hide();
			//summary text
			$("summary").html("<p>As amazing as the web is, its potential is immeasurably greater. Internet Explorer 9 was designed to let that potential shine through.</p>");
			
			//hide 32 / 64 bit text if IE (all versions)
			if ( isIE() ) {
				$("#afterDownload").hide();
			}
			//now hiding for all users
			$("#afterDownload").hide();

			
			//WINDOWS VISTA
			if ( isWindowsVista()){
			   if ( is64Bit()) {
				   $("div.cta.download a#downloadBtn").attr("href", downloadUrl64());
				   $("div.cta.download #thisVersion").text("Windows Vista 64-bit");
				   
				   $("div.cta.download a#download2").text("Download 32-bit version");
                   $("div.cta.download a#download2").attr("href", downloadUrl32());
			   }
			   else
			   {
				   $("div.cta.download a#downloadBtn").attr("href", downloadUrl32());
				   $("div.cta.download #thisVersion").text("Windows Vista 32-bit");
				   
				   $("div.cta.download a#download2").text("Download 64-bit version");
                   $("div.cta.download a#download2").attr("href", downloadUrl64());
			   }
			}
			//WINDOWS 7
			else {
			   if ( is64Bit()) {
				    $("div.cta.download a#downloadBtn").attr("href", downloadUrl64());
				    $("div.cta.download #thisVersion").text("Windows 7 64-bit");
					
					$("div.cta.download a#download2").text("Download 32-bit version");
                    $("div.cta.download a#download2").attr("href", downloadUrl32());
			   }
			   else
			   {
				    $("div.cta.download a#downloadBtn").attr("href", downloadUrl32());
				    $("div.cta.download #thisVersion").text("Windows 7 32-bit");
					
					$("div.cta.download a#download2").text("Download 64-bit version");
                    $("div.cta.download a#download2").attr("href", downloadUrl64());
			   }
			}
        }
		
		//detect if Apple devices
		if ( isIphone() || isIpad() )
		{
			$("#soundMute").hide();	
		}
		
    });





	
	function isWindowsXP() {
		return /Windows NT 5.1/.test(navigator.userAgent);
		//return /xxxx/.test(navigator.userAgent);
	}
	
	function isIphone() {
		return /iPhone/.test(navigator.userAgent);
		//return /xxxx/.test(navigator.userAgent);
	}
	
	function isIpad() {
		return /iPad/.test(navigator.userAgent);
		//return /xxxx/.test(navigator.userAgent);
	}
	
	function isWindowsVista() {
		return /Windows NT 6.0/.test(navigator.userAgent);
		//return /xxxx/.test(navigator.userAgent);
	}
	
	function isWindows7() {
		return /Windows NT 6.1/.test(navigator.userAgent);
		//return /xxxx/.test(navigator.userAgent);
	}
	
    function isWrongOS() {
        return !(/Windows NT 6.0/.test(navigator.userAgent) || /Windows NT 6.1/.test(navigator.userAgent));
		//return /xxxx/.test(navigator.userAgent);
    }
	
	function isIE() {
        return /MSIE/.test(navigator.userAgent);
		//return /Windows/.test(navigator.userAgent);
    }

    function isIE9() {
        return /Trident\/5.0/.test(navigator.userAgent) && navigator.appMinorVersion.toLowerCase() != "rc" && navigator.appMinorVersion.toLowerCase() != "beta";
		//return /xxxx/.test(navigator.userAgent);
    }

    function is64Bit() {
        return /WOW64/.test(navigator.userAgent) || /Win64/.test(navigator.userAgent) || /x64/.test(navigator.userAgent);
		//return /xxxx/.test(navigator.userAgent);
    }
	
	function isIE9Optimised() {
        return /BOIE9/.test(navigator.userAgent);
		//return /xxxx/.test(navigator.userAgent);
    }


    function downloadUrl32() {
		return isWindowsVista() ? "http://view.atdmt.com/action/ukmukh_OptimisedDownload32bvisfull_9" : "http://view.atdmt.com/action/ukmukh_OptimisedDownload32bwin7full_9";
    }

    function downloadUrl64() {
		return isWindowsVista() ? "http://view.atdmt.com/action/ukmukh_OptimisedDownload64bvisfull_9" : "http://view.atdmt.com/action/ukmukh_OptimisedDownload64bwin7full_9";
    }
	
	// LITE VERSIONS
	
	 function downloadLiteUrl32() {
		return isWindowsVista() ? "http://view.atdmt.com/action/ukmukh_OptimisedDownload32bvislite_9" : "http://view.atdmt.com/action/ukmukh_OptimisedDownload32bwin7lite_9";
    }

    function downloadLiteUrl64() {
		return isWindowsVista() ? "http://view.atdmt.com/action/ukmukh_OptimisedDownload64bvislite_9" : "http://view.atdmt.com/action/ukmukh_OptimisedDownload64bwin7lite_9";
    }
