function isMobileDevice() { var useragent = navigator.userAgent.toLowerCase(); if (useragent.indexOf('android') > 0 && useragent.indexOf('mobile') > 0) return true; mobile = ['iphone','blackberry','opera mini','opera mobi','windows mobile','symbianos','ipod']; for (var i in mobile) if (useragent.indexOf(mobile[i]) > 0) return true; return false; } function GetURLParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); var Value=""; for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { if (Value=='') { Value=sParameterName[1]; } else { Value=Value+','+sParameterName[1]; } } } return Value; } function URLToArray(url) { var request = {}; var pairs = url.substring(url.indexOf('?') + 1).split('&'); for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split('='); var value=""; if (decodeURIComponent(pair[1]) === "undefined") { value = ''; } else { value = decodeURIComponent(pair[1]); } if (typeof request[decodeURIComponent(pair[0])] === "undefined") { request[decodeURIComponent(pair[0])] = value; } else { request[decodeURIComponent(pair[0])] = request[decodeURIComponent(pair[0])] + "," + encodeURIComponent(value); } } return request; } if (!isMobileDevice() && GetURLParameter("mobile")=="1") { if(typeof window.location.href.split("#")[1] == 'undefined') { hash=""; } else { hash="#"+window.location.href.split("#")[1]; } var newURL=window.location.href.split("?")[0]; var Params=URLToArray(window.location.href.split("#")[0]); var i=0; for (var property in Params) { if (Params.hasOwnProperty(property)) { if (encodeURIComponent(property).toLowerCase()!='mobile'){ if (i==0) { newURL=newURL + '?' + encodeURIComponent(property) + '=' + Params[property]; } else { newURL=newURL + '&' + encodeURIComponent(property) + '=' + Params[property]; } i++; }; }; }; window.location.href = newURL + "" + hash; } if (isMobileDevice() && GetURLParameter("mobile")!="1") { var hash =""; var uri = window.location.href.split("#")[0]; if(typeof window.location.href.split("#")[1] == 'undefined') { hash=""; } else { hash="#"+window.location.href.split("#")[1]; } if (uri.indexOf("?") !=-1) { var Host=window.location.href.split("?")[0]+'?'; var newURL=""; var Params=URLToArray(uri); for (var property in Params) { if (Params.hasOwnProperty(property)) { if (encodeURIComponent(property).toLowerCase()!='mobile'){ if (newURL!='') { newURL=newURL+"&"; } newURL=newURL + encodeURIComponent(property) + '=' + Params[property] }; }; }; if (newURL=='') { window.location.href = Host+"mobile=1"+hash; } else { window.location.href = Host+newURL+"&mobile=1"+hash; } } else { window.location.href = uri + "?mobile=1"+hash; } }