var GB_ANIMATION = true;
$(document).ready(function(){
	$("a.greybox").click(function(){
		var t = this.title || $(this).text() || this.href;
		GB_show(t,this.href,245,515,'confirm_leave');
		return false;
	});
});

$(document).ready(function(){
	$("a.greybox_mission").click(function(){
	
		// Hide the button so the user can't click on it again
		this.style.display = 'none';

		var t = this.title || $(this).text() || this.href;
		GB_show(t,this.href,420,639,'mission_details');

		return false;
	});
});

$(document).ready(function(){
	$("a.tournament_rules").click(function(){
		var t = this.title || $(this).text() || this.href;

		window.open(this.href, 'tournament_rules', 'status=0,toolbar=0,width=435,height=640');

		//GB_show(t,this.href,639,430,'tournament_rules');
		return false;
	});
});

$(document).ready(function(){
	$("a.greybox_statinfo").click(function(){
		GB_show("View Image",'http://www.callofduty.com/popup-zombie-image?image='+this.href,650,850,'download_image');
		//GB_show("Call of Duty Stats",this.href,650,850,'download_image');
		return false;
	});

	$("a.greybox_statinfo_zombie_iphone").click(function(){
		GB_show("View Image",'http://www.callofduty.com/popup-zombie-image?image='+this.href,380,719,'download_image');
		return false;
	});

	$("a.greybox_statinfo_zombie_stats").click(function(){
		GB_show("View Image",'http://www.callofduty.com/popup-zombie-image?image='+this.href,539,800,'download_image');
		return false;
	});
});

// for intel
$(document).ready(function(){
	$("a.screenshot").click(function(){
		GB_show("Screenshot View",this.href,550,950,'screenshot_view');
        $("#GB_window_screenshot_view").click(function(){
        	GB_hide('screenshot_view');
        });
		return false;
	});
});

// for intel
$(document).ready(function(){
	$("a.download_image").click(function(){
		GB_show("View Image",this.href,500,800,'download_image');
		return false;
	});
});

// for supplies
$(document).ready(function(){
	$("a.supplies_image").click(function(){
		GB_show("View Image",'http://www.callofduty.com/popup-iphone-companion?image='+this.href,750,400,'download_image');
		return false;
	});
});

// for zombies
$(document).ready(function(){
	$("a.zombie_image").click(function(){
		GB_show("View Image",'http://www.callofduty.com/popup-zombie-image?image='+this.href,370,530,'download_image');
		return false;
	});
});

$(document).ready(function(){
	$("a.zombie_iphone_image").click(function(){
		GB_show("View Image",'http://www.callofduty.com/popup-zombie-image?image='+this.href,370,700,'download_image');
		return false;
	});
});


$(document).ready(function(){
	$("a.greybox_add_friends").click(function(){
		var t = this.title || $(this).text() || this.href;
		GB_show(t,this.href,245,515,'add_friends');
		return false;
	});
});

// added by brad:
function trackMedia(media_location)
{	
	pageTracker._trackPageview(media_location);
    //alert ("tracking: " + media_location);
}


function set_page_as_default() {
	var url = location.href.replace('http://' + document.domain, '');
	document.cookie = "page_default=" + url + "; expires=Sun 20 Dec 2009 16:10:34 America/Los_Angeles;path=/";
	//writeSessionCookie ('page_default', hub);
	alert('This page has been set as your default.');
}


function add_this() {
	GB_show('', 'http://www.callofduty.com/add_this/', 750, 595, 'add_this');
}

// added by brad
function show_xlarge_video(id, args){
	var qs = '?';
	if (args != null) {
		for (var i in args) {
			qs += i + '=' + args[i];// + '&';
		}
	}
	GB_show('', 'http://www.callofduty.com/video_player'+ qs +'#'+ id, 642, 946, 'video_player');
}

function forgot_password() {
	GB_show('', 'http://www.callofduty.com/forgot_password/', 245, 515, 'forgot_password');
}

function official_rules() {
	GB_show('', 'http://www.callofduty.com/official_rules/', 560, 515, 'official_rules');
}

function sweepstakes_detail() {
	GB_show('', 'http://www.callofduty.com/sweepstakes_detail/', 560, 515, 'sweepstakes_detail');
	return false;
}

function confirm_leave(url) {
	GB_show('', 'http://www.callofduty.com/confirm_leave/?url='+ escape(url), 245, 515, 'confirm_leave');
	return false;
}

function confirm_leave_to_activision(url) {
	GB_show('', 'http://www.callofduty.com/confirm_leave/?url='+ escape(url) +'&activision=1', 245, 515, 'confirm_leave');
	//return false;
}

function image_popup(image) {
	GB_show('', 'http://www.callofduty.com/image_popup/?image='+ escape(image), 420, 639, 'image_popup');
	//return false;
}

function openRecruitFriend(){
	GB_show('', 'http://www.callofduty.com/recruit-friend', 420, 639, 'mission_details');
}

function confirm_leave_flash(url) {
	if (url.indexOf('infinityward.com') != -1) {
		window.open(url);
		return;
	}
	GB_show('', 'http://www.callofduty.com/confirm_leave/?url='+ escape(url), 245, 515, 'confirm_leave');
}

function openZombieAlert(){
	GB_show('', 'http://www.callofduty.com/zombies_coming', 298, 678, 'zombie_coming');
	setTimeout('GB_hide()', 6000);
}

var swfobject_params = { wmode: true };

function send_to_friend(param, type) {
	if (type == null) {
		type = '';
	}
	if (param == null) {
		param = document.location;
	}
	var url = 'http://www.callofduty.com';
	switch (type) {
	default:
		url = param;
		break;
	case 'video':
	case 'screenshots':
	case 'concept_art':
	case 'wallpapers':
		url += '/reconnaissance/' + type + '#' + param;
		break;
	}
	alert('Send to Friend: ' + url);
}
function set_url_id(id) {
	var loc = document.location.toString();
	var newLoc;
	if (loc.match('#')) {
		newLoc = loc.split('#')[0];
	} else {
		newLoc = loc;
	}
	document.location = newLoc + '#' + id;
}
function get_url_id() {
	var loc = document.location.toString();
	var id = 0;
	if (loc.match('#')) {
		id = loc.split('#')[1];
	}
	return id;
}

$(document).ready(function(){
	$("a.external_link").click(function(){
		var t = this.title || $(this).text() || this.href;
		GB_show(t,'/confirm_leave/?url='+ escape(this.href),245,515,'confirm_leave');
		return false;
	});
});


$(document).ready(function(){
	$("a.intel_image").click(function(){
		var t = this.title || $(this).text() || this.href;
		GB_show('', 'http://www.callofduty.com/image_popup/?filename='+ escape(this.href), 638, 430, 'image_popup');
		return false;
	});
});
