﻿Config = {
    MinSLVersion: "1.0.20816.0",
    //MinSLVersion: "10.0.20816.0",
    defaultLocale: "th-th",
    localeCookieKey: "LanguagePreference"
};

onPageLoad = function() {
    //init browser detection
    BrowserDetect.init();
    
    initNav();
    
    smoothScroll: new SmoothScroll()
}

openwindow = function(aa)
{
window.open(aa);
}

setVisibility = function(dom,visibility) {
    if (dom != null) {
        dom.style.visibility = visibility;
    }
}

getQueryString = function (ji) {
    var hu = window.location.search.substring(1);
    var gy = hu.split("&");
    for (var i=0;i<gy.length;i++) {
       var ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

getLanguagePreference = function()
{
    var ret = Config.defaultLocale;
//	var cookieName = Config.localeCookieKey + "=";
//	var cookies = document.cookie.split(';');
//	for(var i=0; i < cookies.length; i++)
//	{
//		var c = cookies[i];
//		while (c.charAt(0) == ' ') 
//		{
//    		c = c.substring(1, c.length);
//		}
//		if (c.indexOf(cookieName) == 0)
//		{
//		    cookieValue = c.substring(cookieName.length, c.length).toLowerCase();
//		    if (cookieValue.length > 0)
//		    {
//		        ret = cookieValue;
//		    }
//		}
//	}
    return ret;
}

getOSSpecificUrl = function(otherOSUrl,macOSUrl) {
    if (BrowserDetect.OS == "Mac") {
        window.open(macOSUrl);
    }
    else {
        window.open(otherOSUrl);
    }
}

//for SL installation
getOSSepectifInstall = function(platform)
{
    var directDownload = "http://go.microsoft.com/fwlink/?LinkID=92799";
    if (platform == "detect")
    {
        if ((navigator.userAgent.indexOf('PPC Mac OS X') != -1))
        {
            directDownload = "http://go.microsoft.com/fwlink/?LinkID=92807";
        }
        else if ((navigator.userAgent.indexOf('Intel Mac OS X') != -1))
        {
            directDownload = "http://go.microsoft.com/fwlink/?LinkID=92808";
        }
    }
    else
    {
        if (platform == "mac")
        {
            directDownload = "http://go.microsoft.com/fwlink/?LinkID=92808"; // default Mac set to "Intel Mac OS X"
        }
    }
    return directDownload;
}

doOSSepectifInstall = function(platform)
{
    var altasTrackingImage = new Image();
    altasTrackingImage.src = 'http://switch.atdmt.com/action/mrtyou_FY08SilverlightMSCOMclicktodownload4_1';

    var thePlatform = ((typeof(platform) == "undefined") || (platform == null)) ? "detect" : platform;
    window.location.href = getOSSepectifInstall(thePlatform);
}