if (((navigator.userAgent.toLowerCase().indexOf("iphone")) >= 0) ||
	((navigator.userAgent.toLowerCase().indexOf("ipod")) >= 0) ||
	((navigator.userAgent.toLowerCase().indexOf("android")) >= 0) ||
	((navigator.userAgent.toLowerCase().indexOf("blackberry")) >= 0) ||
	((navigator.userAgent.toLowerCase().indexOf("windows ce")) >= 0) ||
	((navigator.userAgent.toLowerCase().indexOf("opera mini")) >= 0) ||
	((navigator.userAgent.toLowerCase().indexOf("palm")) >= 0))
{
	if (LerCookie("isMobile") != "true") 
	{
		GerarCookie("isMobile", "true")
		window.location.href = "http://m.redetv.com.br";
	}
}

function GerarCookie(strCookie, strValor, lngDias)
{
    var dtmData = new Date();
	
	dtmData.setTime(dtmData.getTime() + (lngDias * 24 * 60 * 60 * 1000));
	
    if(lngDias)
    {
        dtmData.setTime(dtmData.getTime() + (lngDias * 24 * 60 * 60 * 1000));
        var strExpires = "; expires=" + dtmData.toGMTString();		
    }
    else
    {
        var strExpires = "";
    }
	
    document.cookie = strCookie + "=" + strValor + strExpires + "; path=/";
}

function LerCookie(strCookie)
{
    var strNomeIgual = strCookie + "=";
    var arrCookies = document.cookie.split(';');

    for(var i = 0; i < arrCookies.length; i++)
    {
        var strValorCookie = arrCookies[i];
        while(strValorCookie.charAt(0) == ' ')
        {
            strValorCookie = strValorCookie.substring(1, strValorCookie.length);
        }
        if(strValorCookie.indexOf(strNomeIgual) == 0)
        {
            return strValorCookie.substring(strNomeIgual.length, strValorCookie.length);
        }
    }
    return null;
}

function ExcluirCookie(strCookie)
{
    GerarCookie(strCookie, '', -1);
}
