

function GetScreenAndBrowserSizes()
{
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers 
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	if(x) SetCookie('ranger_WindowInnerWidth', x, 365);
	if(y) SetCookie('ranger_WindowInnerHeight', y, 365);
	
	x = screen.availWidth;
	y = screen.availHeight;
	
	if(x) SetCookie('ranger_ScreenAvailWidth', x, 365);
	if(y) SetCookie('ranger_ScreenAvailHeight', y, 365);	
}


function SetCookie (xstrName, xstrValue, xiDays)
{ 
	var dtExpires;
	dtExpires = new Date();
	dtExpires.setTime(dtExpires.getTime() + (xiDays * 24 * 60 * 60 * 1000));
	document.cookie = xstrName + '=' + escape (xstrValue) + ((xiDays) ? ('; expires=' + dtExpires.toGMTString()) : '') + '; path=/'
}

function GetCookie(xstrName)
{
    var dc = document.cookie;
    var prefix = xstrName + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
	
}

GetScreenAndBrowserSizes();




// google analytics:
// utmvCookieCheck(): http://www.startupcto.com/marketing-tech/google-analytics/setvar-and-the-zero-bounce-rate-bug
function utmvCookieCheck(value) {
	var utmvCookie = GetCookie("__utmv"); 
 
	if (utmvCookie == null)
		return false;
 
	// get rid of the Google's domain prefix ID, which appear on all
	// GA cookies
	utmvCookie = utmvCookie.replace(/^\d*\./, '');
 
	return (utmvCookie == value) ? true : false;
}

function nooxGaSetVar(tracker, value)
{
	if(!utmvCookieCheck(value)) 
	{
		tracker._setVar(value);
	}
}
