//	fixSelected defaults the selected country option to the
//  first set of countries when more than 1 is selected
//	jsainz@ea.com 03.01.2007	   
ct='';
function fixSelected() {
	var opts = document.forms['regSignupform'].country.getElementsByTagName('option');
	//first we loop through to find the selected country
	for(var i = 0; i < opts.length; i++){
		if(opts[i].selected){
			opts[i].selected = false;
			ct=opts[i].value;
		}
	}
	//then we loop through the top 5 to reset the selected country
	for(var i = 0; i < 5; i++){
		if(opts[i].value == ct){
			opts[i].selected = true;
		}
	}
}

function setAlt(id)
{
    document.regSignupform.screenname.value=id;
	document.regSignupform.screenname.innertext=id;
}


function maybeSwitchCountry(countrySelect) {
	if (countrySelect.selectedIndex >= 0
		&& countrySelect.options[countrySelect.selectedIndex].value == "US") {

		swapVisible(true);
	}
}

function switchCountry() {

	if (!swapVisible(false)) {
		// DHTML trickery did not work

		document.regSignupform.switchCtry.value="1";
		document.regSignupform.signmeup.click();
	}
}

function getElementReference(elementName) {
		return document.getElementById(elementName);
}


	//return true;
//}
function spamFlagCheckClicked(visibleCheck, hiddenValue) {
	if (visibleCheck.checked) {
		hiddenValue.value = "on";
	} else {
		hiddenValue.value = "";
	}

	return true;
}

function getNewImage()
{
	document.regSignupform.lightreg_newword.value="1";
	document.regSignupform.submit();
}



//	to use imgOvers()...
//	<img src="path/to/image.gif" class="imgover" />
//	make sure your hover image is named image-over.gif
//	jsainz@ea.com 2007-03-02
function imgOvers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	
	var aInputs = document.getElementsByTagName("input");
	var aImg = document.getElementsByTagName('img');
	var aImages = new Array();

	for(var i = 0; i < aInputs.length; i++) {
		aImages[i] = aInputs.item(i);
	}
	
	for(var i = 0; i < aImg.length; i++) {
		aImages[i + aInputs.length] = aImg.item(i);
	}

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '-over'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-over'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}
window.onload = imgOvers;
