var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function() {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};


mobileGeoLocation = function(callback)
{
	var clientGeoLat = 360.0;
	var clientGeoLong = 360.0;
	
	function getGeoLocation()
	{
		if (navigator.geolocation) {
			var options = {
			  enableHighAccuracy: false,
			  timeout: 5000,
			  maximumAge: 5000
			};
			navigator.geolocation.getCurrentPosition(locationAccepted, locationDeclined, options);
		}else{
		  locationDeclined(null);
		}
		
	}

	function locationAccepted(position)
	{
		clientGeoLat = position.coords.latitude;
		clientGeoLong = position.coords.longitude;
		var returnVal = [];
		returnVal[0] = clientGeoLat;
		returnVal[1] = clientGeoLong;
		callback(returnVal);
	}
	
	function locationDeclined(error)
	{
		var returnVal = [];
		returnVal[0] = 360.0;
		returnVal[1] = 360.0;
		callback(returnVal);
	}

	getGeoLocation();
};

isMobileDevice = function()
{
    var mobile = isMobile.any();
    if(mobile != null && mobile != 'null')
	    return isMobile.any();
    else
        return false;
};
