var domain = document.domain;
var domainArray = domain.split(".");
if (domainArray.length > 2) {
	var newDomain = domainArray[domainArray.length - 2] + "." + domainArray[domainArray.length - 1]
	document.domain = newDomain;
}

/***************************************************************************************************
*	Cookies
***************************************************************************************************/
function getAgeGateCookie() {
	var name = "MatureCurtain";
	var returnVal = "";
	var allcookies = document.cookie;
	if (allcookies.length > 0) {
		var pos = allcookies.indexOf(name + "=");
		if (pos != -1) {
			var start = allcookies.indexOf("=", pos) + 1;
			var end = allcookies.indexOf(";", start);
			if (end == -1) {
				end = allcookies.length;
			}
			var value = allcookies.substring(start, end);
			//value = unescape(value);
			returnVal = value;
		}
	}
	if (returnVal == "OK=m") {
		return false;
	} else {
		return true;
	}
}
function setAgeGateCookie(val) {
	var expiredays = 1;
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = "MatureCurtain=" + "OK=" + val + ";domain=" + escape(document.domain) + ";path=" + escape("/");
}
	
function getIntroViewedCookie() {
	var name = "Uncharted2IntroViewed";
	var returnVal = "";
	var allcookies = document.cookie;
	if (allcookies.length > 0) {
		var pos = allcookies.indexOf(name + "=");
		if (pos != -1) {
			var start = allcookies.indexOf("=", pos) + 1;
			var end = allcookies.indexOf(";", start);
			if (end == -1) {
				end = allcookies.length;
			}
			var value = allcookies.substring(start, end);
			returnVal = value;
		}
	}
	return returnVal;
}
function setIntroViewedCookie(val) {
	document.cookie = "Uncharted2IntroViewed=1;domain=" + escape(document.domain) + ";path=" + escape("/");
}
function getLocaleCookie() {
	var name = "portalLocaleCookie";
	var returnVal = "";
	var allcookies = document.cookie;
	if (allcookies.length > 0) {
		var pos = allcookies.indexOf(name + "=");
		if (pos != -1) {
			var start = allcookies.indexOf("=", pos) + 1;
			var end = allcookies.indexOf(";", start);
			if (end == -1) {
				end = allcookies.length;
			}
			var value = allcookies.substring(start, end);
			returnVal = value;
		}
	}
	return returnVal;
}
function setLocaleCookie(val) {
	var expiredays = 1;
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = "portalLocaleCookie=" + val + ";domain=" + escape(document.domain) + ";path=" + escape("/") + "; expires=" + exdate.toGMTString();
}

/***************************************************************************************************
*	Resizing
***************************************************************************************************/
function fnResize() {
	var h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
	var legalBuffer = 300;
	var flashHeight = h;
	if (h < 600) {
		flashHeight = 600;
	} else if (h < 840) {
		flashHeight = h
	} else {
		flashHeight = 840;
	}
	var mainHeight = flashHeight + legalBuffer;

	var flashFrame = document.getElementById("flashContent"); 
	flashFrame.style.height = mainHeight + "px";
}
function fnGetContentHeight() {
	var h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
	var legalBuffer = 300;
	var flashHeight = h;
	if (h < 600) {
		flashHeight = 600;
	} else if (h < 840) {
		flashHeight = h
	} else {
		flashHeight = 840;
	}
	var mainHeight = flashHeight + legalBuffer;
	return mainHeight;
}


/***************************************************************************************************
* Webmonkey GET Parsing Module
* Language: JavaScript 1.0
* The parsing of GET queries is fundamental
* to the basic functionality of HTTP/1.0.
* This module parses GET with JavaScript 1.0.
* Source: Webmonkey Code Library
* (http://www.hotwired.com/webmonkey/javascript/code_library/)
* Author: Patrick Corcoran
* Author Email: patrick@taylor.org
***************************************************************************************************/

function createRequestObject() {
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  separator = ',';
    // The token used to separate data from multi-select inputs
  query = '' + this.location;
  qu = query
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }
  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.<
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }
  return FORM_DATA;
}

// This is the array/object containing the GET data.
// Retrieve information with 'FORM_DATA [ key ] = value'.
FORM_DATA = createRequestObject();
