// browser sniff
var sniff =  {
	isIE: false,
	isIE6: false,
	isIE7: false,
	isIE8: false,
	isFFMac: false,
	isChrome3: false,
	isFF30: false,
	isOpera: false,
	init: function() {
		if (navigator.userAgent.indexOf("MSIE 6.0") != -1) {
			this.isIE6 = true;
		} else if (navigator.userAgent.indexOf("MSIE 7.0") != -1) {
			this.isIE7 = true;
		} else if (navigator.userAgent.indexOf("MSIE 8.0") != -1) {
			this.isIE8 = true;
		}
		if (this.isIE6 || this.isIE7 || this.isIE8) { this.isIE = true }
		if (navigator.userAgent.indexOf("Macintosh") != -1 && navigator.userAgent.indexOf("Firefox") != -1) {
			this.isFFMac = true;
		}
		if (navigator.userAgent.indexOf("Chrome") != -1 && (
				navigator.userAgent.indexOf("3.0.195.38") != -1 || 
				navigator.userAgent.indexOf("3.0.195.33") != -1 ||
				navigator.userAgent.indexOf("3.0.195.27") != -1 || 
				navigator.userAgent.indexOf("3.0.195.21") != -1 )) {
			this.isChrome3 = true;
		}
		if (navigator.userAgent.indexOf("Firefox") != -1 && (
				navigator.userAgent.indexOf("3.0.16") != -1 || 
				navigator.userAgent.indexOf("3.0.17") != -1  || 
				navigator.userAgent.indexOf("3.0.10") != -1 || 
				navigator.userAgent.indexOf("3.0.15") != -1 || 
				navigator.userAgent.indexOf("3.0.11") != -1 || 
				navigator.userAgent.indexOf("3.0.14") != -1 || 
				navigator.userAgent.indexOf("3.0.13") != -1 || 
				navigator.userAgent.indexOf("3.0.5") != -1  || 
				navigator.userAgent.indexOf("3.0.8") != -1  ||
				navigator.userAgent.indexOf("3.0.1") != -1  ||
				navigator.userAgent.indexOf("3.0.6") != -1  ||
				navigator.userAgent.indexOf("3.0.3") != -1  ||
				navigator.userAgent.indexOf("2.0.0.11") != -1  ||
				navigator.userAgent.indexOf("3.0.7") != -1  ||
				navigator.userAgent.indexOf("3.0.4") != -1  ||
				navigator.userAgent.indexOf("3.0") != -1  ||
				navigator.userAgent.indexOf("2.0.0.14") != -1  ||
				navigator.userAgent.indexOf("2.0.0.12") != -1  ||
				navigator.userAgent.indexOf("3.0.12") != -1  ||
				navigator.userAgent.indexOf("1.5.0.9") != -1  ||
				navigator.userAgent.indexOf("2.0.0.9") != -1  ||
				navigator.userAgent.indexOf("3.0.9") != -1  ||
				navigator.userAgent.indexOf("1.5.0.12") != -1  ||
				navigator.userAgent.indexOf("2.0.0.6") != -1  ||
				navigator.userAgent.indexOf("2.0") != -1  )) {
			this.isFF30 = true;
		}
		if (navigator.userAgent.indexOf("Opera") != -1 && (
				navigator.userAgent.indexOf("10.10") != -1 || 
				navigator.userAgent.indexOf("9.80") != -1  || 
				navigator.userAgent.indexOf("9.30") != -1 || 
				navigator.userAgent.indexOf("9.64") != -1 || 
				navigator.userAgent.indexOf("9.63") != -1   )) {
			this.isOpera = true;
		}
		if (!this.isIE) {
			document.write('<script type="text/javascript" src="/lib/global/scripts/pt-add-ons/lightview.js"></script>');
		}

		if (this.isChrome3 || this.isFF30 || this.isOpera) {
			document.write('<link type="text/css" rel="stylesheet" media="screen" href="/lib/css/default.css">');
		}
	}
}
sniff.init();

// trace function for firebug
var trace = function(obj) {
	try {
		window.console.log(obj)
	} catch(err) {
		// made of fail
	}
}

// ad call object
var dart =  {
	dartSite: null,
	dartZone: null,
	dartGenre: null,
	dartSubGenre: null,
	dartGlobalID: null,
	dartESRB: null,
	dartTimestamp: null,
	dartRichMedia: false,
	roadBlock: false,
	indexCountdown: false,
	rightCountdown: false,
	leaderAdServed: false,
	rightAdServed: false,
	countdownAdServed: false,
	adCheckWait: 1500,
	checkAd: function(unit) {
		switch(unit) {
			case "leader":
				var adCheckLeader =  window.setTimeout(function() {
					var imgList = $A($('leaderboard').getElementsByTagName('img'));
					if (imgList.length != 0) {
						imgList.each(function(imgAt) {
							if (imgAt.src.indexOf("817-grey.gif") == -1) {
						    	dart.leaderAdServed = true;
						    }
						});
					} else if ( $('leaderboard').childNodes.length > 4) {
						dart.leaderAdServed = true;
					} else if ( $('leaderboard').select('iframe').length != 0) {
						try {
							$('leaderboard').select('iframe')[0].contentDocument.baseURI;
						}
						catch(err) {
							if (err) {
							    dart.leaderAdServed = true;
							}
						}
					}
					if (dart.leaderAdServed) {
						$('ad_bar').addClassName('show');
					}
				}, dart.adCheckWait);
			break;
			
			case "right":
				var adCheckRight =  window.setTimeout(function() {
					var imgList = $A($('ad').getElementsByTagName('img'));
					if (imgList.length != 0) {
						imgList.each(function(imgAt) {
							if (imgAt.src.indexOf("817-grey.gif") == -1) {
						    	dart.rightAdServed = true;
						    }
						});
					} else if ( $('ad').childNodes.length > 4) {
						dart.rightAdServed = true;
					} else if ( $('ad').select('iframe').length != 0) {
						try {
							$('ad').select('iframe')[0].contentDocument.baseURI;
						}
						catch(err) {
							if (err) {
							    dart.leaderAdServed = true;
							}
						}
					}
					if (dart.rightAdServed) {
						$('ad').addClassName('show');
					} else {
						$('ad').addClassName('hide');
					}
				}, dart.adCheckWait);
			break;
			
			case "countdown":
				(function(){
					if (dart.rightCountdown) {
						$('right_countdown').addClassName('show');
					}					
				}).delay(1);
			break;
			
			case "article":
				(function(){
					if (dart.roadBlock) {
						$('rb_ad').addClassName('show');
					} else {
						var is817 = false;
						$('rb_ad').select('img').each(function(imgAt) {
							if (imgAt.src == '817-grey.gif') {
								is817 = true;
							}
						});
						if (!is817) {
							$('rb_ad').addClassName('show');
						}
					}
				}).delay(1)
			break;
			
		  case "product":
				(function(){
					if (dart.roadBlock) {
						$('rb_ad').addClassName('show');
					} else {
						var is817 = false;
						$('rb_ad').select('img').each(function(imgAt) {
							if (imgAt.src == '817-grey.gif') {
								is817 = true;
							}
						});
						if (!is817) {
							$('rb_ad').addClassName('show');
						}
					}
				}).delay(1)
			break;

			case "index_countdown":
				(function(){
					if (dart.indexCountdown) {
						$('index_countdown').addClassName('show');
					}					
				}).delay(1);
			break;
		}
	},
	adCall: function (site,zone,genre,subgenre,global_id,esrb) {
		this.dartSite = site;
		this.dartZone = zone;
		this.dartGenre = genre;
		this.dartSubGenre = subgenre;
		this.dartGlobalID = global_id;
		this.dartESRB = esrb;
		this.dartTimestamp = Math.floor(Math.random() * 1000000000);
	}
}

var avp = {
	currentSkin: 1,
	changeSkin: function() {
		try {
			var skinClass = 'skinOne';
			if (avp.currentSkin == 1) {
				skinClass = 'skinTwo';
			} else if (avp.currentSkin == 2) {
				skinClass = 'skinThree';
			} else if (avp.currentSkin == 3) {
				skinClass = 'skinOne'
			}

			var url = '/bin/ads/sponsorships/avp/lib/img/'+skinClass;
			var body = $$("body")[0];
			body.className = skinClass;
			goog.ad(settings.pageType,skinClass);
			if (avp.currentSkin < 3) {
				avp.currentSkin++;
			} else {
				avp.currentSkin = 1;
			}
		} catch (error) {
			// fail
		}
	},
	clickableSkin: function() {
		Event.observe($('outer-wrap'), 'click', function(e){
			var currentNode = Event.element(e);
			if (currentNode.parentNode == $$('body')[0]) {
				avp.changeSkin();
				return false;
			}
		});
	}
}


var ads = {
	sponsorWrite: function(cssPath,urlPath) {
		var newLink = new Element('link',{
			rel: 'stylesheet',
			type: 'text/css',
			media: 'screen',
			href: cssPath
		});
		$$('head')[0].appendChild(newLink);
		if (urlPath) {
			ads.clickableSkin(urlPath);
		}
		avp.clickableSkin();
	},
	clickableSkin: function(urlPath) {
		Event.observe($('outer-wrap'), 'click', function(e){
			var currentNode = Event.element(e);
			if (currentNode.parentNode == $$('body')[0]) {
				var newWindow = window.open(urlPath, '_blank');
				newWindow.focus();
				return false;
			}
		});
	},
	writeVideoSkin: function(swfPath,height) {
		var videoCode = '<object width="100" height="'+height+'"> <param value="'+swfPath+'" name="video_ad" /><param name="mode" value="transparent"/><embed width="1000" height="'+height+'" wmode="transparent" type="application/x-shockwave-flash" src="'+swfPath+'"/></object>'; 
		$('ad_bar').update(videoCode);
	},
	changeSkin: function(style) {
		alert(style);
		try {
			var body = $$("body")[0];
			body.className = style;
		} catch (error) {
			// fail
		}
	},
	startTimer: function() {
		return;
		if (!$('leader_iframe')) { return;}
		var adTimer = window.setTimeout(function(){
			ads.refresh();
			ads.startTimer();
		},30000);
	},
	refresh: function() {
		// leaderboard refresh
		if($('leader_iframe')) {
			var newLeader = new Element ('iframe',{
				id: 'leader_iframe',
				src: $('leader_iframe').src,
				className: $('leader_iframe').className,
				height: 90,
				width: 728,
				frameBorder: 0,
				marginHeight: 0,
				marginWidth: 0,
				vspace: 0,
				hspace: 0,
				scrolling: 'no'
			});
			$('leader_iframe').remove();
			$('leaderboard').update(newLeader);			
		}
		
		// 300xwhatever refresh
		if($('tower_iframe')) {
			var newTower = new Element ('iframe',{
				id: 'tower_iframe',
				src: $('tower_iframe').src,
				className: $('tower_iframe').className,
				height: $('tower_iframe').height,
				width: $('tower_iframe').width,
				frameBorder: 0,
				marginHeight: 0,
				marginWidth: 0,
				vspace: 0,
				hspace: 0,
				scrolling: 'no'
			});
			$('tower_iframe').remove();
			$('ad').update(newTower);			
		}
	}
}

// search helper app
var search = {
	isInited: false,
	init: function() {
		if (!search.isInited) {
			if ($('searchField_label').visible()) {
				$('searchField_label').hide();
			}
			searchAsYouType.initialize(document.getElementById('searchField'), true);
			Event.observe('searchField','focus',this.focusApp);
			Event.observe('searchField','blur',this.blurApp);			
		}
	},
	focusApp: function(e) {
		var target = Event.element(e);
		if (!$F(target)) {
			$('searchField_label').hide();
		}
	},
	blurApp: function(e) {
		var target = Event.element(e);
		if (!$F(target)) {
			$('searchField_label').show();
		}
	}
}

// login helper object
var login = {
	promptLogin: function(type) {
		if (!$('dialog')) {
			new Ajax.Request('/login/ajax/get_login_prompt/', {
				method: 'post',
				parameters: {
					formType: type	
				},
				onSuccess: function(t) {
					$('wrapper').insert(t.responseText);
					$('dialog').appear(.5);
				},
				onComplete: function(t) {
					setTimeout("Form.Element.activate('username_login');",200);
				}
			});
		} else {
			$('dialog').appear(.5);
			setTimeout("Form.Element.activate('username_login');",100);
		}
		return false;
	},
	closeLogin: function() {
		$('dialog').fade(.5);
	},
	passwordReset: function() {
		new Ajax.Request('/login/ajax/password_email_form/', {
			onSuccess: function(t) {
				$('login_cont').update(t.responseText);
			}
		});
		return false;
	},
	sendPassReset: function() {
		new Ajax.Request('/login/ajax/password_reset/', {
			method: 'post',
			parameters: $('passReset').serialize(true),
			onFailure: function(t){
				_tools.ajaxBug(t);
			},
			onSuccess: function(t) {
				$('login_cont').update(t.responseText);
			}
		});
	},
	validatePassReset: function() {
		var errorMssg = [];
		if (!$F('password_1') || !$F('password_2')) {
			errorMssg.push('Please enter matching passwords in both supplied fields.');
		}
		if ($F('password_1') && $F('password_2')) {
			if ($F('password_1') != $F('password_2')) {
				errorMssg.push('Passwords do not match');
			}
		}
		if (errorMssg.length == 0) {
			$('passForm').submit();
		} else {
			var mssg = {
				"header": "There is an error",
				"bodyContent": ""
			}
			mssg.bodyContent += "<ol>";
			$(errorMssg).each(function(mssgAt) {
				mssg.bodyContent += "<li>" + mssgAt + "</li>";
			});
			mssg.bodyContent += "</ol>";
			util.talkbox($H(mssg).toJSON());
		}
	},
	toolBar: function() {
		new Effect.toggle('user_tools_menu','blind',{duration: .5});
	}
}

// wishlist
var wishlist =  {
	addList: function(globalID,type) {
		new Ajax.Request('/ajax/prodlist/add/', {
			method: 'post',
			parameters: {
				globalID: globalID,
				type: type
			},
			onSuccess: function(t) {
				util.talkbox(t.responseText);
			},
			onFailure: function(t) {
				_tools.ajaxBug(t);
			}
		});
	}
}

var polls =  {
	submitPoll: function(pollID) {
		var pollChecked = false;
		$('pollForm').select('input').each(function(itemAt){
		    if (itemAt.type == 'radio' && itemAt.checked) {
				pollChecked = true;
			}
		});
		if (!pollChecked) {
			$('pollError').show();
			new Effect.Pulsate('pollError',{
				from: .5
			})
			return false;
		}
		var formData = $('pollForm').serialize(true);
		new Ajax.Request('/ajax/polls/post/', {
			method: 'post',
			parameters: $('pollForm').serialize(true),
			onFailure: function(t){
				_tools.ajaxBug(t);
			},
			onSuccess: function(t) {
				polls.setResults(t.responseText);
			}
		});
	},
	viewResults: function(pollID) {
		new Ajax.Request('/ajax/polls/get_results/', {
			method: 'post',
			parameters: {
				pollID: pollID
			},
			onFailure: function(t){
				_tools.ajaxBug(t);
			},
			onSuccess: function(t) {
				polls.setResults(t.responseText);
			}
		});
	},
	setResults: function(markup) {
		$('pollForm').update(markup);
		$('pollForm').select('span.results').each(function(itemAt){
			var rawNum = parseInt(itemAt.id.split('_')[1]);
			var offSet = 10;
			if (rawNum == 100) {
				offSet = 0;
			}
		    var newNum = (rawNum + offSet) + '%';
		    var animateFunction = function () {
		        itemAt.morph('width: ' + newNum,{duration: 2});
				itemAt.update(itemAt.id.split('_')[1] + '%');
		    }
		    animateFunction();
		});
	}
}

// cookie helper app
var Cookie = {
  set: function(name, value, daysToExpire) {
    var expire = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire);
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  }
}

// new cookie helper app
var Cookies = Class.create({
    initialize: function(path, domain) {
        this.path = path || '/';
        this.domain = domain || null;
    },
    // Sets a cookie
    set: function(key, value, days) {
        if (typeof key != 'string') {
            throw "Invalid key";
        }
        if (typeof value != 'string' && typeof value != 'number') {
            throw "Invalid value";
        }
        if (days && typeof days != 'number') {
            throw "Invalid expiration time";
        }
        var setValue = key+'='+escape(new String(value));
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var setExpiration = "; expires="+date.toGMTString();
        } else var setExpiration = "";
        var setPath = '; path='+escape(this.path);
        var setDomain = (this.domain) ? '; domain='+escape(this.domain) : '';
        var cookieString = setValue+setExpiration+setPath+setDomain;
        document.cookie = cookieString;
    },
    // Returns a cookie value or false
    get: function(key) {
        var keyEquals = key+"=";
        var value = false;
        document.cookie.split(';').invoke('strip').each(function(s){
            if (s.startsWith(keyEquals)) {
                value = unescape(s.substring(keyEquals.length, s.length));
                throw $break;
            }
        });
        return value;
    },
    // Clears a cookie
    clear: function(key) {
        this.set(key,'',-1);
    },
    // Clears all cookies
    clearAll: function() {
        document.cookie.split(';').collect(function(s){
            return s.split('=').first().strip();
        }).each(function(key){
            this.clear(key);
        }.bind(this));
    }
});

// various global utility functions, stuff that gets run onload, etc.
var util =  {
	init: function() {
		util.setMainNav();
		util.ie6Pwn();
		util.setKonami();
	},
	ie6Pwn: function() {
		if (sniff.isIE6 && Cookie.get('ie_alert') == null) {
			var newDiv = new Element('div',{id: 'ie6_alert'});
			var mssg = '<h2>You are using Internet Explorer 6.</h2>';
			mssg += '<p>You\'re using IE 6 and this site works best with FireFox and/or IE7. We suggest you upgrade or switch to one of the following: </p>';
			mssg += '<ul>';
			mssg += '<li class="ff"><a href="http://www.mozilla.com/en-US/products/download.html?product=firefox-2.0.0.12&os=win&lang=en-US">Mozilla Firefox</a></li>';
			mssg += '<li class="safari"><a href="http://www.apple.com/safari/download/">Apple Safari</a></li>';
			mssg += '<li class="ie7"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Microsoft Internet Explorer 7</a></li>';
			mssg += '<li class="ie8"><a href="http://www.microsoft.com/windows/products/winfamily/ie/ie8/readiness/Install.htm">Microsoft Internet Explorer 8 beta</a></li>';
			mssg += '<li class="close"><a href="##" onclick="util.hideIEMssg(); return false;">hide this message</a></li>';
			mssg += '</ul>';
			newDiv.update(mssg);
			$('wrapper').insertBefore(newDiv,$('content'));
		}
	},
	hideIEMssg: function() {
		Cookie.set('ie_alert','false',7);
		new Effect.BlindUp('ie6_alert',{duration: .5});
		var removeTimer = window.setTimeout(function(){
			$('ie6_alert').parentNode.removeChild($('ie6_alert'));
		},1000);
	},
	suckerfish: function() {
		if (!sniff.isIE) { return };
		$A(document.getElementsByClassName('suckerfish')).each(function(menuAt){
			menuAt.onmouseover = function() {
				//$(menuAt).addClassName('hover');
			}
			menuAt.onmouseout = function() {
				//$(menuAt).removeClassName('hover');
			}
		});	
	},
	
	// getting basic non-secure user data
	userData: function() {
		if (Cookie.get('USER')) {
			return $H(Cookie.get('USER').evalJSON())._object;	
		} else {
			return null;
		}
	},
	userName: function() {
		if (util.userData()) {
			return util.userData().login_name;
		} else {
			return null;
		}
	},
	userNameID: function() {
		if (util.userData()) {
			return util.userData().login_name + ':' + util.userData().user_id;
		} else {
			return "";
		}
	},
	
	// makes dialog box for messaging users
	talkbox: function(h) {
		var content = $H(h.evalJSON()).toObject();
		if ($('talkBox')) {
			$('talkHeader').update(content.header);
			$('talkTarget').update(content.bodyContent);
			new Effect.Highlight('talkTarget');
			return;
		}
		var newX = $('wrapper').getWidth() / 2 - 400 / 2;
		if (self.pageYOffset) {
			newY = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop) {
			newY = document.documentElement.scrollTop;
		}
		else if (document.body) {
			newY = document.body.scrollTop;
		}
		newY += 200;
		var newDiv = Builder.node('div',{
				id: 'talkBox', 
				className: 'app-window',
				style: 'top: ' + newY + 'px; left: ' + newX +'px; display: none;'},
			[Builder.node('a',
				{href: '#', className: 'close', onclick: 'util.removebox(); return false;'},
				[Builder.node('span','close')]
			)]
		);
		var content = $H(h.evalJSON()).toObject();
		var talkHeader = Builder.node('h2',{id: 'talkHeader'}, content.header);
		var targetDiv = Builder.node('div',{id: 'talkTarget'}, '');
		$('wrapper').appendChild(newDiv);
		$('talkBox').appendChild(talkHeader);
		$('talkBox').appendChild(targetDiv);
		$('talkTarget').update(content.bodyContent);
		new Effect.Appear('talkBox', {duration: .5});
		util.toggleLeader('off');
		new Draggable('talkBox',{handle: 'talkHeader'});
		var highLightTimer = window.setTimeout(function(){
			new Effect.Highlight('talkTarget');
		},500);
	},
	removebox: function() {
		util.toggleLeader('on');
		new Effect.Fade('talkBox', {duration: .5});
		var removeTimer = window.setTimeout(function(){
			$('talkBox').parentNode.removeChild($('talkBox'));	
		}, 500);
	},
	toggleLeader: function(mode) {
		if (!$('leaderboard')) { return false; }
		switch(mode) {
			case "off":
				if ($('leaderboard').select('iframe').length != 0) {
					$('leaderboard').hide();
				}
			break;
			case "on":
				if (!$('leaderboard').visible()) {
					$('leaderboard').show();
				}
			break;
		}
	},
	setLoading: function() {
		var mssg = {
			"header": 'Loading Content',
			"bodyContent": "<div class=\"loading\"><p>Loading</p></div>"
		}
		util.talkbox($H(mssg).toJSON());
	},
	setSaving: function() {
		var mssg = {
			"header": 'Saving Data',
			"bodyContent": "<div class=\"loading\"><p>Saving</p></div>"
		}
		util.talkbox($H(mssg).toJSON());
	},
	promptLogin: function() {
		login.promptLogin('content');
	},
	setMainNav: function() {
		
		if (!settings.pagePlatform) { return;}
		var target = $('mast-nav');
		switch(settings.pagePlatform) {
			case 'ps3': 
				target.select('li')[0].addClassName('on');
				break;
			case 'xbox360': 
				target.select('li')[1].addClassName('on');
				break;
			case 'wii': 
				target.select('li')[2].addClassName('on');
				break;
			case 'pc': 
				target.select('li')[3].addClassName('on');
				break;
			case 'psp': 
				target.select('li')[4].addClassName('on');
				break;
			case 'ds': 
				target.select('li')[5].addClassName('on');
				break;
			case 'ds': 
				target.select('li')[6].addClassName('on');
				break;
		}
		//set it to all if platform is not part of nav
		if (settings.pagePlatform == 'pc' || settings.pagePlatform == 'psp' || settings.pagePlatform == 'ds' || settings.pagePlatform == 'xbox360' || settings.pagePlatform == 'ps3' || settings.pagePlatform == 'wii') {
			// set 2nd nav

			$('second_nav').select('a').each(function(linkAt){
				if (linkAt.href.indexOf('/all/') != -1 && settings.pagePlatform != 'free-games' && settings.pagePlatform != 'mobile' && settings.pagePlatform != 'downloads') {
					linkAt.href = linkAt.href.replace("all", settings.pagePlatform);
				}
			});	
		}
	},
	setKonami: function() {
		var kkeys = [];
		var konami = "38,38,40,40,37,39,37,39,66,65";
		Event.observe(window, 'keydown', function(e){
			kkeys.shift();
			kkeys[9] = e.keyCode;
			if ( kkeys.toString() == konami ) {
				try {
					Lightview.show({ href: 'http://www.youtube.com/v/v6TCQRrhMZo&hl=en&fs=1&color1=0x006699&color2=0x54abd6&border=1', rel: 'flash', options: { width: 800, height: 500 }});
					pageTracker._trackEvent('lulz', 'easter eggs', 'konami code');
				} catch (err) {
					window.location.href = "http://web.archive.org/web/19970127061931/www.gamepro.com/cgi-bin/w3com/start?gamepro+guest";
				}
			}
		});
	}
}

var settings = {
	pagePlatform: null,
	pageType: null
}

// dev debug toolz
var _tools = {
	ajaxBug: function(t) {
		var overLay = new Element('div',{
			id: 'bugOverlay',
			style: 'z-index: 1000; padding: 20px; background: #FFF; position: absolute; left: 0; top: 0; width: ' + document.viewport.getWidth() + 'px; height: ' + document.viewport.getHeight() + 'px;'
		}).update(t.responseText);
		overLay.onclick = function() {
			$('bugOverlay').remove();
		}
		$$('body')[0].appendChild(overLay);
	}
}


//Legacy Video SWF object stuff

if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;

// Vid Embed Script
//SWFObject('http://www.gamepro.com/bin/vid-bin/yume/yEPlayer.swf?vId='+str+'&p='+mode+'&ae=d','player',MainW,MainH,'9','##000');
var vidEmbed = {
	
	playContent:function(str,el,w,h,mode){
	
	if(typeof(mode)=='undefined'){mode = 'e';}
		
	var MainW=w;
  	var MainH=h;
	var ViewH=h-40;
	var so = new SWFObject('/bin/vid-bin/yume/yEPlayer.swf?vId='+str+'&p='+mode+'&ae=d','player',MainW,MainH,'9','##000');
	so.addVariable("yume_start_time", Number(6));
	so.addVariable("yume_normalscreen_x",Number(0));
	so.addVariable("yume_normalscreen_y",Number(0));
	so.addVariable("yume_normalscreen_width",Number(608));
	so.addVariable("yume_normalscreen_height",Number(342));
	so.addVariable("yume_leader_slot","true");
	so.addVariable("yume_preroll_playlist",encodeURIComponent("http://pl.yumenetworks.com/dynamic_preroll_playlist.fmil?domain=116xjUfjnQG&width=608&height=342&imu=medrect"));
	so.addVariable("yume_branding_playlist",encodeURIComponent("http://pl.yumenetworks.com/dynamic_branding_playlist.fmil?domain=116xjUfjnQG&width=608&height=342&imu=medrect"));
 	so.addVariable("yume_midroll_playlist",encodeURIComponent("http://pl.yumenetworks.com/dynamic_midroll_playlist.fmil?domain=116xjUfjnQG&width=480&height=360&imu=medrect"));
	 so.addVariable("yume_postroll_playlist",encodeURIComponent("http://pl.yumenetworks.com/dynamic_postroll_playlist.fmil?domain=116xjUfjnQG&width=480&height=360&imu=medrect"));
	// so.addVariable("publisher_content_url","treefrog.flv");
	 so.addVariable("yume_swf_url","/bin/vid-bin/yume/yume_player_4x3.swf");
	 so.addVariable("yume_library_swf_url","/bin/vid-bin/yume/yume_ad_library.swf");
	 so.addVariable("yume_flash_id","flash_flv_player");
	 so.addVariable("yume_css_url","/bin/vid-bin/yume/example.css");
	 so.addVariable("yume_branded_player","false");
	 so.addVariable("yume_space_branded_player",Number(0));
	 so.addParam("allowFullScreen", "true");
	 so.addParam("wmode","transparent");
	 so.addParam("allowScriptAccess", "always");
		  //so.addParam("scale", "noscale");
	so.write(el);
	
}
}


document.observe('dom:loaded',util.init);