var caution = false
/* reads the query and sets cookie */
var af; 
var af_app;
if ( location.search ) {
	var query=location.search.substr(1,location.search.length-1); af = query
}
if (!af || (af == 0) || (af == '')) {
	af = getCookie('affiliate')
}
if (af>0) {
	setCookie('affiliate',af,'Mon, 31-Aug-2020 00:00:00 GMT');
}
if (navigator.appName.indexOf("WebTV") != -1) { 
	document.location.replace("webtv.html?"+af)
}

//testing cookie
setCookie('test','test');
if (!getCookie('test')){document.location = '/scripts/cookie.php?'+location.search.substr(1,location.search.length-1);}
	
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) + 
		((expires) ? "; expires=" + expires : "") + 
		"; path=/" + 
		"; domain=.flixxxnow.com" +
		((secure) ? "; secure" : "")
	if (!caution || (name + "=" + escape(value)).length <= 4000)
		document.cookie = curCookie
	else
		if (confirm("Cookie exceeds 4KB and will be cut!"))
			document.cookie = curCookie
}
function getCookie(name) {
	var prefix = name + "="
	var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1) return ''
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
	if (cookieEndIndex == -1) {
		cookieEndIndex = document.cookie.length
	}
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}