= 0) {
var value = args.substring(start);
var begin = value.indexOf("=") + 1;
var end = value.indexOf("&");
if (end == -1) {
end = value.length;
}
return value.substring(begin, end);
}
// Detect form factor from user agent.
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("iphone") != -1 || ua.indexOf("ipod") != -1) {
// iphone and ipod.
return "mobile";
} else if (ua.indexOf("portale") != -1) {
// portale.
return "portale";
} else if (ua.indexOf("ipad") != -1) {
// ipad.
return "tablet";
} else if (ua.indexOf("android") != -1 || ua.indexOf("mobile") != -1) {
/*
* Android - determine the form factor of android devices based on the diagonal screen
* size. Anything under six inches is a phone, anything over six inches is a tablet.
*/
var dpi = 160;
var width = $wnd.screen.width / dpi;
var height = $wnd.screen.height / dpi;
var size = Math.sqrt(width*width + height*height);
return (size < 6) ? "mobile" : "tablet";
}
// Everything else is a desktop.
return "desktop";
]]>