function redirectToMobileSite(){

		var stay = false;
		var link = window.location.href;
		if (link.indexOf('#') >= 0){
			link = link.substring(0, link.indexOf('#'));
		}
		
		//var serializedobj = '{"' + decodeURI(link.substring(link.indexOf('?')+1)).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}';
		//var obj = JSON.parse(serializedobj);
		var obj = getQueryParams(document.location.search);
		
		if ($.cookie("stayInDesktop")){
			stay = true;
		}
		if ('StayInDesktop'in obj){
			stay = true;
			$.cookie("stayInDesktop", 1 , { path: '/'});
		}
		if (($.browser.mobile && !$.cookie("stayInDesktop")) || ($.browser.mobile && stay == false)  ){
			
			var mobileDomain = $('#mobileDomain').attr('href');
			var desktopDomainPrefix = '';
			if(isNotBlank($('#b2cServerDomainPrefix').attr('href')))
			{
				desktopDomainPrefix = $('#b2cServerDomainPrefix').attr('href');
				window.location.href = mobileDomain + window.location.pathname.replace('/' + desktopDomainPrefix, '') + window.location.search;
			}	
			else
			{
				window.location.href = mobileDomain + window.location.pathname + window.location.search;
			}	
		}
}

function getQueryParams(qs) {
    qs = qs.split("+").join(" ");

    var params = {}, tokens,
        re = /[?&]?([^=]+)=([^&]*)/g;

    while (tokens = re.exec(qs)) {
        params[decodeURIComponent(tokens[1])]
            = decodeURIComponent(tokens[2]);
    }

    return params;
}

function isNotBlank(str)
{
	return str && str != '' && str != undefined;
}

// HK: 04/06/2017
//redirectToMobileSite();		 	
