//TRACK MOUSE POSITION
var globalMouseX;
var globalMouseY;
$(document).ready(function()
{
	$("body").mousemove(
		function(e)
		{
			globalMouseX = e.pageX;
			globalMouseY = e.pageY;
		}
	);
});
//*****************************
//*****************************
function hoverPopupShow(element, event, content)
{
	var popup = document.getElementById("HOVERPOPUP");
	if (popup == null)
	{
		//CREATE POPUP
		var e = document.createElement("div");
		e.id = "HOVERPOPUP";
		e.style.display = "none";
		e.style.position = "absolute";
		e.style.zIndex = 1000;
		e.className = "popup";
		//INSERT POPUP INTO DOM
		var n1 = document.body.firstChild;
		while (n1.nodeType != 1)
			n1 = n1.nextSibling;
		document.body.insertBefore(e, n1);
		popup = document.getElementById("HOVERPOPUP");
	}
	//DISPLAY
	if (popup.style.display == "none")
		popup.innerHTML = decodeURIComponent(unescape(content));
	popup.style.top = globalMouseY  - ($('#HOVERPOPUP').height()/2) + "px";
	popup.style.left = globalMouseX + 10 + "px";
	popup.style.display = "block";
}
function hoverPopupHide()
{
	var popup = document.getElementById("HOVERPOPUP");
	if (popup != null)
		document.getElementById("HOVERPOPUP").style.display = "none";
}


function onclickPopupShow(element, content, halign, valign)
{
	$('#ONCLICKPOPUP').css('display', 'none');
	var popup = document.getElementById("ONCLICKPOPUP");
	if (popup == null)
	{
		//CREATE POPUP
		e = document.createElement("div");
		e.id = "ONCLICKPOPUP";
		e.style.display = "none";
		e.style.position = "absolute";
		e.style.zIndex = 1000;
		e.className = "popup";
		e.style.top = "0px";
		e.style.left = "0px";
		//INSERT POPUP INTO DOM
		n1 = document.body.firstChild;
		while(n1.nodeType != 1)
			n1 = n1.nextSibling;
		document.body.insertBefore(e, n1);
		popup = document.getElementById("ONCLICKPOPUP");
	}
	//CONTENT
	if (popup.style.display == "none")
		popup.innerHTML = decodeURIComponent(unescape(content));
	//POSITION
	var offset = $(element).offset();
	$('#ONCLICKPOPUP').css('display', 'block');
	if (valign == 'top')
		$('#ONCLICKPOPUP').css('top', offset.top + $(element).height() - $('#ONCLICKPOPUP').height());
	else if (valign == 'center')
		$('#ONCLICKPOPUP').css('top', offset.top + $(element).height() - ($('#ONCLICKPOPUP').height()/2));
	else
		$('#ONCLICKPOPUP').css('top', offset.top);
	if (halign == 'left')
		$('#ONCLICKPOPUP').css('left', offset.left - $('#ONCLICKPOPUP').width());
	else if (halign == 'center')
		$('#ONCLICKPOPUP').css('left', offset.left - ($('#ONCLICKPOPUP').width()/2));
	else
		$('#ONCLICKPOPUP').css('left', offset.left + $(element).width());
};
function onclickPopupHide()
{
	$('#ONCLICKPOPUP').css('display', 'none');
}
function isValidEmail(str)
{
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if(filter.test(str))
		return true;
	return false;
}
function trim(str)
{
	return str.replace(/\s+/, "");
}

function PopupShow(element, content, halign, valign)
{
	var popup = document.getElementById("POPUP");
	if (popup == null)
	{
		//CREATE POPUP
		e = document.createElement("div");
		e.id = "POPUP";
		e.style.display = "none";
		e.style.position = "absolute";
		e.style.top = "0px";
		e.style.left = "0px";
		e.style.zIndex = 1000;
		e.style.color = "black";
		e.style.fontSize = "8pt";
		e.innerHTML = '\n\
			<table id="POPUPWIDTH" width="1%" style="border-style:none; border-width:0px; border-spacing:0px 0px; border-collapse:collapse; background-color: white;">\n\
				<tr>\n\
					<td style="width:9px; height:1px;  padding:0px; margin:0px;">\n\
						&nbsp;&nbsp;&nbsp;\n\
					</td>\n\
					<td valign="top" style="height:20px; overflow:hidden; padding:0px; margin:0px;; background-repeat: repeat-x;">\n\
						<table width="100%" style="height:36px;" >\n\
							<tr>\n\
								<td align="right">\n\
									<a href="javascript:closePopup();">Close</a>\n\
								</td>\n\
							</tr>\n\
						</table>\n\
					</td>\n\
				</tr>\n\
				<tr>\n\
					<td style="width:9px; overflow:hidden; padding:0px; margin:0px;; background-repeat: repeat-y;">\n\
						&nbsp;\n\
					</td>\n\
					<td valign="center">\n\
						<div id="POPUPCONTENT" style="padding:1px; text-align:center;">\n\
						</div>\n\
					</td>\n\
					<td style="width:9px; overflow:hidden; padding:0px; margin:0px; ; background-repeat: repeat-y;">\n\
						&nbsp;\n\
					</td>\n\
				</tr>\n\
				<tr>\n\
					<td style="width:9px; height:9px; overflow:hidden; padding:0px; margin:0px; background-repeat: no-repeat;">\n\
						&nbsp;\n\
					</td>\n\
					<td style="height:9px; overflow:hidden; padding:0px; margin:0px; background-repeat: repeat-x;">\n\
						&nbsp;\n\
					</td>\n\
					<td style="width:9px; height:9px; overflow:hidden; padding:0px; margin:0px; background-repeat: no-repeat;">\n\
						&nbsp;\n\
					</td>\n\
				</tr>\n\
			</table>';
		//INSERT POPUP INTO DOM
		n1 = document.body.firstChild;
		while(n1.nodeType != 1)
			n1 = n1.nextSibling;
		document.body.insertBefore(e, n1);
		//BIND EVENTS TO POPUP
		$("#POPUPCLOSE").click(function(e)
		{
			$('#POPUP').css('display', 'none');
		});
		popup = document.getElementById("POPUP");
	}
	if (popup.style.display == "none")
		$('#POPUPCONTENT').html(decodeURIComponent(content));
	//POSITION
	var offset = $(element).offset();
	$('#POPUP').css('display', 'block');
	if (valign == 'top')
		$('#POPUP').css('top', offset.top + $(element).height() - $('#POPUPWIDTH').height());
	else if (valign == 'center')
		$('#POPUP').css('top', offset.top + $(element).height() - ($('#POPUPWIDTH').height()/2));
	else
		$('#POPUP').css('top', offset.top);
	if (halign == 'left')
		$('#POPUP').css('left', offset.left - $('#POPUPWIDTH').width());
	else if (halign == 'center')
		$('#POPUP').css('left', offset.left - ($('#POPUPWIDTH').width()/2));
	else
		$('#POPUP').css('left', offset.left + $(element).width());
};





//*****************************************
//*****************************************
function numbersonly(event)
{
	var unicode = event.charCode ? event.charCode : event.keyCode;
	if (unicode == 8)
		return true;
	if (unicode >= 48 && unicode <= 57)
		return true;
	return false;
}
//*****************************************
//*****************************************
function submitShoutcastPricing()
{
	var userCount = document.order_shoutcast.slots.value;
	re = new RegExp("^[0-9]+$");
	if (!userCount.match(re))
	{
		alert('The minimum number of listeners is ' + document.order_shoutcast.minSlots.value);
		return false;
	}
	if (userCount > parseInt(document.order_shoutcast.maxSlots.value))
	{
		alert('The maximum number of listeners is ' + document.order_shoutcast.maxSlots.value);
		return false;
	}
	if (userCount < parseInt(document.order_shoutcast.minSlots.value))
	{
		alert('The minimum number of listeners is ' + document.order_shoutcast.minSlots.value);
		return false;
	}
	return true;
}
//*****************************************
//*****************************************
function getShoutcastPricing()
{
	var userCount	= document.order_shoutcast.slots.value;
	re = new RegExp("^[0-9]+$");
	if(!userCount.match(re))
	{
		document.getElementById('order_shoutcast_order').style.display = 'none';
		document.getElementById('order_shoutcast_error').style.display = 'block';
		document.getElementById('order_shoutcast_error').innerHTML = 'The minimum number of listeners is ' + document.order_shoutcast.minSlots.value;
		document.getElementById('total').innerHTML = 'N/A';
		return;
	}
	if(userCount > parseInt(document.order_shoutcast.maxSlots.value))
	{
		document.order_shoutcast.slots.value = 1000;
		return;
	}
	if(userCount < parseInt(document.order_shoutcast.minSlots.value))
	{
		document.getElementById('order_shoutcast_order').style.display = 'none';
		document.getElementById('order_shoutcast_error').style.display = 'block';
		document.getElementById('order_shoutcast_error').innerHTML = 'The minimum number of listeners is ' + document.order_shoutcast.minSlots.value;
		document.getElementById('total').innerHTML = 'N/A';
		return;
	}
	document.getElementById('order_shoutcast_order').style.display = 'block';
	document.getElementById('order_shoutcast_error').style.display = 'none';
	document.getElementById('order_shoutcast_error').innerHTML = '';


	var bitrate		= document.order_shoutcast.bitrate.options[document.order_shoutcast.bitrate.selectedIndex].value;
	//price = getOrderPrice(userCount, bitrate).toFixed(2);
	price = getOrderPrice(userCount, bitrate);
	price = price / document.order_shoutcast.exchangeRate.value;
	price = price.toFixed(2);
	document.getElementById('total').innerHTML = document.order_shoutcast.exchangeSymbol.value + price;
}





//*****************************
//*****************************
function submitAffiliateStep1()
{
	var thisform = document.affiliate_step1;
	if(trim(thisform.last_name.value) == "")
	{
		alert("Please enter your last name.");
		thisform.last_name.focus();
		return false;
	}
	if(!isValidEmail(thisform.email.value))
	{
		alert("Please enter a valid e-mail address.");
		thisform.email.focus();
		return false;
	}
	if(trim(thisform.address1.value) == "")
	{
		alert("Please enter your address");
		thisform.address1.focus();
		return false;
	}
	if(thisform.country.value == "US" && trim(thisform.zip.value) == "")
	{
		alert("Please enter your zip code");
		thisform.zip.focus();
		return false;
	}
	return true;
}
function submitAffiliateStep2()
{
	var accept_text = "I hereby submit my electronic signature";
	var thisform = document.affiliate_step2;
	if(thisform.accept_field.value != accept_text)
	{
		alert('Please enter \'' + accept_text + '\' into the box to accept the terms of this agreement and proceed with registration.');
		thisform.accept_field.focus();
		return false;
	}
	return true;
}
function submitContact()
{
	var thisform = document.contact;
	if(trim(thisform.contact_name.value) == "")
	{
		alert("Please enter your name.");
		thisform.contact_name.focus();
		return false;
	}
	if(!isValidEmail(thisform.contact_email.value))
	{
		alert("Please enter a valid e-mail address.");
		thisform.contact_email.focus();
		return false;
	}
	if(trim(thisform.contact_comments.value) == "")
	{
		alert("Please enter your comments.");
		thisform.contact_comments.focus();
		return false;
	}
	return true;
}
function submitContactApply()
{
	var thisform = document.contact_apply;
	if(trim(thisform.contact_name.value) == "")
	{
		alert("Please enter your name.");
		thisform.contact_name.focus();
		return false;
	}
	if(!isValidEmail(thisform.contact_email.value))
	{
		alert("Please enter a valid e-mail address.");
		thisform.contact_email.focus();
		return false;
	}
	if(trim(thisform.contact_education.value) == "")
	{
		alert("Please enter your education.");
		thisform.contact_education.focus();
		return false;
	}
	if(trim(thisform.contact_experience.value) == "")
	{
		alert("Please enter your experience.");
		thisform.contact_experience.focus();
		return false;
	}
	if(trim(thisform.contact_dhavailability.value) == "")
	{
		alert("Please enter your days & hours of availability.");
		thisform.contact_dhavailability.focus();
		return false;
	}
	if(trim(thisform.contact_reason.value) == "")
	{
		alert("Please answer question 1");
		thisform.contact_reason.focus();
		return false;
	}
	if(trim(thisform.contact_fixserver.value) == "")
	{
		alert("Please answer question 2");
		thisform.contact_fixserver.focus();
		return false;
	}
	if(trim(thisform.contact_qualify.value) == "")
	{
		alert("Please answer question 3");
		thisform.contact_qualify.focus();
		return false;
	}
	return true;
}
function submitClanpay()
{
	var thisform = document.clanpay;
	var val = thisform.pmt_amt.value;
	var check_re = /^[^\d]*(\d*\.?\d*).*$/;
 	if(!val.match(check_re))
	{
		alert("Please enter a valid amount between $5.00 and $500.00.");
 		thisform.pmt_amt.focus();
		return false;
	}
 	var amount = parseFloat(val.replace(check_re, "$1"));
	amount = amount.toFixed(2);
	if(isNaN(amount))
	{
		alert("Please enter a valid amount between $5.00 and $500.00.");
		thisform.pmt_amt.focus();
		return false;
	}
	if(amount < 5)
	{
		alert("The minimum amount ClanPay accepts is $5.00.");
		thisform.pmt_amt.focus();
		return false;
	}
	if(amount > 500)
	{
		alert("The maximum amount ClanPay accepts is $500.00.");
		thisform.pmt_amt.focus();
		return false;
	}
	if(!confirm("Are you sure you want to submit this payment for $" + amount.toString() + " via PayPal?"))
	{
		return false;
	}
	thisform.amount.value = amount.toString();
	return true;
}
function submitGameservers()
{
	var thisform = document.gameservers;
	if(trim(thisform.query.value) == '')
	{
		alert('Please enter a game to search for.');
		thisform.query.value = "";
		thisform.query.focus();
		return false;
	}
	return true;
}
var coupon_submit=false;
function submitOrderStep2()
{
	if(typeof(coupon_submit) != 'undefined' && coupon_submit)
	{
		//alert('coupon_submit');
		coupon_submit = false;
		return true;
	}
	else
	{
		//alert('form submit');
	}
	var thisform = document.order_step2;
	if(thisform.first_name.value == "")
	{
		alert("Please enter your first name");
		thisform.first_name.focus();
		return false;
	}
	if(thisform.last_name.value == "")
	{
		alert("Please enter your last name");
		thisform.last_name.focus();
		return false;
	}
	if(thisform.address1.value == "")
	{
		alert("Please enter your address");
		thisform.address1.focus();
		return false;
	}
	if(thisform.city.value == "")
	{
		alert("Please enter your city");
		thisform.city.focus();
		return false;
	}
	if(thisform.email.value == "")
	{
		alert("Please enter your e-mail address");
		thisform.email.focus();
		return false;
	}
	if(thisform.email.value != thisform.email1.value)
	{
		alert("You entered two different e-mail addresses. Please make sure they match.");
		thisform.email1.focus();
		return false;
	}
	if(!thisform.policy_dob_agree.checked )
	{
		alert("You must be 13 years of age to fill out this application. If you are not 13, please have a guardian complete this order.");
		thisform.policy_dob_agree.focus();
		return false;
	}
	if(!thisform.policy_tos_agree.checked )
	{
		alert("You must agree to our terms of service before completing your order.");
		thisform.policy_tos_agree.focus();
		return false;
	}
	if(thisform.DCID != null)
	{
		//BACKORDER
		var datacenterBackOrderPattern	= /(\d+),(backorder)$/;
		var dataCenterBackOrderArray	= thisform.DCID.value.match(datacenterBackOrderPattern);
		if(dataCenterBackOrderArray != null)
		{
			alert("This chosen location is not available for ordering. Please choose another location.");
			thisform.DCID.focus();
			return false;
		}
		//NO DATACENTER SELECTED
		if(thisform.game != null && thisform.DCID.selectedIndex == 0)
		{
			alert("Please choose the datacenter location you want your gameserver installed at.");
			thisform.DCID.focus();
			return false;
		}
	}
	return true;
}
//*****************************
//*****************************
// /game_servers/game_view.php
var public_array = new Array();
var public_prices = new Array();
var private_array = new Array();
var private_prices = new Array();
function changeOrderTypeSelection(e)
{
	selectedType = e.value;
	var formTop = document.ordertop;
	var formBot	= document.orderbot;
	var prices = document.hidden_prices;
	//ORDER TYPE
	formTop.type.value	= selectedType;
	formBot.type.value	= selectedType;
	//ORDER PLAYERS
	var selectElementTop		= formTop.players;
	var selectElementBottom		= formBot.players;

	if(selectedType == 'public')
	{
		selectElementTop.length				= 0;
		selectElementBottom.length			= 0;
		for(var i=0; i<prices.hidden_prices_public.options.length; ++i)
		{
			selectElementTop.options[i]		= new Option(prices.hidden_prices_public.options[i].text,prices.hidden_prices_public.options[i].value);
			selectElementBottom.options[i]	= new Option(prices.hidden_prices_public.options[i].text,prices.hidden_prices_public.options[i].value);
			//new Option(public_array[i].text, public_array[i].value);
		}
		selectElementTop.selectedIndex		= 0;
		selectElementBottom.selectedIndex	= 0;
	}
	else if(selectedType == 'private')
	{
		selectElementTop.length				= 0;
		selectElementBottom.length			= 0;
		for(var i=0; i<prices.hidden_prices_private.options.length; ++i)
		{
			selectElementTop.options[i]		= new Option(prices.hidden_prices_private.options[i].text,prices.hidden_prices_private.options[i].value);
			selectElementBottom.options[i]	= new Option(prices.hidden_prices_private.options[i].text,prices.hidden_prices_private.options[i].value);
		}
		selectElementTop.selectedIndex		= 0;
		selectElementBottom.selectedIndex	= 0;
	}
	showExchangeRatePrice()
}
function changePlayerCountSelection(e)
{
	var formTop = document.ordertop;
	var formBot	= document.orderbot;
	var selectedIndex					= e.selectedIndex;
	var selectElementTop				= formTop.players;
	var selectElementBottom				= formBot.players;
	selectElementTop.selectedIndex		= selectedIndex;
	selectElementBottom.selectedIndex	= selectedIndex;
	showExchangeRatePrice();
}

function gameserversGameviewChangeGame()
{
	var gmid = document.getElementById("game_list").value;
	window.location.href = 'game_view.php?GMID=' + gmid;
}

function showExchangeRatePrice()
{
	var formTop = document.ordertop;
	if(formTop.type.value == "public")
	{
		price = public_prices[formTop.players.selectedIndex];
		if(price != '' && document.getElementById('converted_price') != null)
		{
			document.getElementById('converted_price').innerHTML = price;
		}
	}
	else if(formTop.type.value == "private")
	{
		price = private_prices[formTop.players.selectedIndex];
		if(price != ''&& document.getElementById('converted_price') != null)
		{
			document.getElementById('converted_price').innerHTML = price;
		}
	}
}
// /clanpay/index.php
function clanpayUpdateCurrency()
{
	exchange_price = document.clanpay.pmt_amt.value / currencyExchangeRate;
	exchange_price = exchange_price.toFixed(2);
	document.getElementById("currency").innerHTML= "(Approximately " + currencySymbol + exchange_price + ")";
}


function changeGameLocation()
{
	var thisform = document.order_step2;
	var datacenterBackOrderPattern	= /(\d+),(backorder)/;
	var dataCenterBackOrderArray	= thisform.DCID.value.match(datacenterBackOrderPattern);
	if(dataCenterBackOrderArray != null)
	{
		if(confirm('This location is NOT available for ordering.\n\nWould you like to be notified of openings?'))
		{
			var notifyWin = window.open('/order/notify.php?GMID=' + document.order_step2.game.value + '&DCID=' + dataCenterBackOrderArray[1], 'notifyWin', 'scrollbars=yes, menubar=no, height=500, width=500');
			notifyWin.focus();
		}
	}
}
function changeGamePrice()
{
	var thisform = document.order_step2;
	//BACKORDER
	var datacenterBackOrderPattern	= /(\d+),(backorder)$/;
	var dataCenterBackOrderArray	= thisform.DCID.value.match(datacenterBackOrderPattern);
	if(dataCenterBackOrderArray != null)
	{
		thisform.total.value="Not Available";
		return;
	}
	//INVALID LOCATION
	if(thisform.DCID.value == 0)
	{
		thisform.total.value="Choose Location";
		return;
	}
	//GAME PRICE
	var serverType	= thisform.server_type.options[thisform.server_type.selectedIndex].value;
	var price		= 1.0 * thisform.maxplayers.options[thisform.maxplayers.selectedIndex].getAttribute('price_' + serverType);
	//GAME PRICE MODIFIER
	price			= price + (thisform.DCID.options[thisform.DCID.selectedIndex].getAttribute('price_' + serverType + '_mod') * thisform.maxplayers.options[thisform.maxplayers.selectedIndex].value);

	if (thisform.DCID.options[thisform.DCID.selectedIndex].getAttribute('price_' + serverType + '_mod') > 0)
	{
		$('#surcharge_button').show();
	}
	else
	{
		$('#surcharge_button').hide();
	}

	var memSelect = $('select[name=memory]');
	if (memSelect.length > 0)
	{
		if (memSelect.val() == 512)
		{
			price += 5;
		}
		else
		{
			price += (memSelect.val()/memory_mb)*memory_cost;
		}
	}


	// VOICE PRICE
	var voice_price = thisform.voice[thisform.voice.selectedIndex].getAttribute('price');
	price = price + (voice_price * 1.0);

	//TERM
	var months = thisform.next_invoice_period.options[thisform.next_invoice_period.selectedIndex].value;
	if(months == 3)
	{
		price = price * 3 * .95;
	}
	else if (months == 6)
	{
		price = price * 6 * .90;
	}
	else if (months == 12)
	{
		price = price * 12 * .85;
	}
	//EXCHANGE RATE
	price = price.toFixed(2);
	if(exchangeRateSymbol != '$')
	{
		exchange_price = price / exchangeRate;
		exchange_price = exchange_price.toFixed(2);
		thisform.total.value="$" + price + " (approx " + exchangeRateSymbol + exchange_price + ")";
	}
	else
	{
		thisform.total.value="$" + price;
	}
}
function changeVoicePrice()
{
	// VOICE PRICE
	var price = 1 * document.order_step2.voice[document.order_step2.voice.selectedIndex].getAttribute('price');
	//TERM
	months = document.order_step2.next_invoice_period.options[document.order_step2.next_invoice_period.selectedIndex].value;
	if (months == 3)
	{
		price = price * 3 * .95;
	}
	else if (months == 6)
	{
		price = price * 6 * .90;
	}
	else if (months == 12)
	{
		price = price * 12 * .85;
	}
	//EXCHANGE RATE
	price = price.toFixed(2);
	if(exchangeRateSymbol != '$')
	{
		exchange_price = price / exchangeRate;
		exchange_price = exchange_price.toFixed(2);
		document.order_step2.total.value="$" + price + " (approx " + exchangeRateSymbol + exchange_price + ")";
	}
	else
	{
		document.order_step2.total.value="$" + price;
	}
}
function changeDedicatedPrice()
{
	//DEDICATED PRICE - THE RADIO GROUP CAN EITHER BE A nodelist (MULTIPLE OPTIONS) OR A HTMLInputElement (SINGLE OPTION)
	var price = 0.0;
	if(document.order_step2.package.length)
	{
		for(i=0; i<document.order_step2.package.length; ++i)
		{
			if (document.order_step2.package[i].checked == true)
			{
				price = 1 * document.order_step2.package[i].getAttribute('price');
				break;
			}
		}
	}
	else
	{
		price = 1 * document.order_step2.package.getAttribute('price');
	}
	//EXCHANGE RATE
	price = price.toFixed(2);
	if(exchangeRateSymbol != '$')
	{
		exchange_price = price / exchangeRate;
		exchange_price = exchange_price.toFixed(2);
		document.order_step2.total.value="$" + price + " (approx " + exchangeRateSymbol + exchange_price + ")";
	}
	else
	{
		document.order_step2.total.value="$" + price;
	}
}

function changePackagePrice()
{
	//THE RADIO GROUP CAN EITHER BE A nodelist (MULTIPLE OPTIONS) OR A HTMLInputElement (SINGLE OPTION)
	var price = 0.0;
	var selectedpackage = 0;
	if(document.order_step2.package.length)
	{
		for(i=0; i<document.order_step2.package.length; ++i)
		{
			if (document.order_step2.package[i].checked || document.order_step2.package[i].selected)
			{
				price = 1 * parseFloat(document.order_step2.package[i].getAttribute('price'));
				selectedpackage = document.order_step2.package[i].value;
				break;
			}
		}
	}
	else
	{
		price = 1 * parseFloat(document.order_step2.package.getAttribute('price'));
	}
	if ($('select[name=os] :selected').attr('charge') > 0)
	{
		price = price + parseInt($('select[name=os] :selected').attr('charge'));
	}

	if (selectedpackage == 103 && $('select[name=os]').val() == 'windows_ranked')
	{
		alert("Ranked servers are not supported on the Silver Gamer package");
		$('select[name=os]').val('windows');
	}

	if ($('select[name=os]').val() == 'windows_ranked')
	{
		$('select[name=control_panel]').attr('disabled','disabled');
		$('select[name=control_panel]').val('yes');
	}
	else
	{
		$('select[name=control_panel]').attr('disabled','');
	}

	//EXCHANGE RATE
	price = price.toFixed(2);
	if(exchangeRateSymbol != '$')
	{
		exchange_price = price / exchangeRate;
		exchange_price = exchange_price.toFixed(2);
		document.order_step2.total.value="$" + price + " (approx " + exchangeRateSymbol + exchange_price + ")";
	}
	else
	{
		document.order_step2.total.value="$" + price + "/month";
	}
}

	var backorderReserve = new Array();

function changeBlackops()
{
	var backorderReserveHTML = '';
	if (backorderReserve[document.order_step2.DCID.value] == 1){
		backorderReserveHTML = '<div style="background-color:#099fc5;padding:4px; margin-top:4px; border:1px solid #ffad12;"><B>' + backorderReserveDC[document.order_step2.DCID.value]  + '</B> is currently on backorder, but you can RESERVE your server now! <BR\><BR\>The approximate install date is on or before: <B>' + backorderReserveText[document.order_step2.DCID.value] + '</B><BR><BR><a href=# onClick=\'window.open("/order/notify.php?GMID=' + document.order_step2.game.value + '&DCID=' + document.order_step2.DCID.value + '","notifyWin", "scrollbars=yes, menubar=no, height=500, width=500")\'>If you do not wish to reserve for this date but rather be notified by email, click here!</a>		</div>';
	}
	if (document.order_step2.DCID.value == 30)
	{
		if (document.order_step2.game.value == 129)
		{
			$('#extra_pricing').html(backorderReserveHTML + '<div style="background-color:#099fc5;padding:4px; margin-top:4px; border:1px solid #ffad12;">There is an extra $0.50 per slot surcharge for servers in this location. <a href="#" onclick="document.getElementById(\'surcharge_info\').style.display = \'inline\';">(More Info)</a></div>');
		}
		else
		{
			$('#extra_pricing').html(backorderReserveHTML + '<div style="background-color:#099fc5;padding:4px; margin-top:4px; border:1px solid #ffad12;">There is an extra $10 per server surcharge in this location. <a href="#"  onclick="document.getElementById(\'surcharge_info\').style.display = \'inline\';">(More Info)</a></div>');
		}
	}
	else
	{
		$('#extra_pricing').html(backorderReserveHTML  + '');
	}
}
function updateCountry()
{
	if (document.order_step2.country.value != 'US')
	{
		document.order_step2.state.value = "";
	}
}
function showBanners(element, banner)
{
	$('.banners').hide();
	$('#' + banner).show();
	$('.tab_option').removeClass('tab_option_active');
	$(element).addClass('tab_option_active');
}
