function detectmobile(mdot, cdomain)
{

        if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/android/i) || navigator.userAgent.match(/Symbian/i) || navigator.userAgent.match(/Nokia/i) || navigator.userAgent.match(/BlackBerry/i))
        {

		if(document.cookie.indexOf("mobile_redirect=true") >= 0) {
                        window.location = mdot;
                }
                else if (document.cookie.indexOf("mobile_redirect=false") < 0)
                {
                        if (confirm("Welcome to PureInkTattoo Mobile! Click OK to view our mobile site."))
                        {
                                setCookies("true", cdomain);
				window.location = mdot;
                        }
                        else
                        {
                                setCookies("false", cdomain);
                        }
                }
                
        }
}

function detectbrowser(url, cdomain)
{
	if (!navigator.userAgent.match(/iPhone/i) && !navigator.userAgent.match(/iPod/i) && !navigator.userAgent.match(/android/i) && !navigator.userAgent.match(/Symbian/i) && !navigator.userAgent.match(/Nokia/i) && !navigator.userAgent.match(/BlackBerry/i))
	{
		if (navigator.userAgent.match(/Chrome/i) || navigator.userAgent.match(/Firefox/i) || navigator.userAgent.match(/MSIE/i) || navigator.userAgent.match(/Opera/i) || navigator.userAgent.match(/Safari/i))
		{
			window.location = url;
		}
	}
        else {
                setCookies("true", cdomain);
        }
}

function setCookies(mredirect, cdomain) {
        var date = new Date();
        var days = 1;
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = ";expires="+ date.toGMTString();
        var domain = ";domain=" + cdomain;
		var path = ";path=/";
        document.cookie = "mobile_redirect=" + mredirect + expires + domain + path;
}

