function checkThisSurveyForm() {
	fm = document.forms['theSurveyForm'];
	
	var radioFlag = false;
	for (x = 0; x < fm.questionAnswer.length; x++) {
		if (fm.questionAnswer[x].checked)
			radioFlag = true; 
	}
	if (!radioFlag) {
		alert("You must select an answer to the survey");
		return false;
	}		
	return true;
}

function PopupWin(var1) {
	window.open(var1,'agreement','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=600,height=550');
}

function checkEmail(fm) {	
	var missing = "";
	fm.newuser_emailaddress.value = fm.newuser_emailaddress.value.replace(/^ */g, '').replace(/ *$/g, '');	
	if (fm.newuser_emailaddress.value == "")
		missing = "Please enter your e-mail address.";
	else {
		temp = fm.newuser_emailaddress.value + " ";
		found = temp.search(/[\w\.-]+@([\w-]+\.){1,3}[a-zA-Z]{2,}\s{1}/);
		if (found != 0)
			missing = "Your e-mail must be in the form username@domain.com";
	}		
	if (missing != "") {
		alert(missing);
		return false;
	}
	return true;
}

function positionInfo(object) {
	
  var p_elm = object;

  this.getElementLeft = getElementLeft;
  function getElementLeft() {
    var x = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
  }

  this.getElementWidth = getElementWidth;
  function getElementWidth(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetWidth);
  }

  this.getElementRight = getElementRight;
  function getElementRight(){
    return getElementLeft(p_elm) + getElementWidth(p_elm);
  }

  this.getElementTop = getElementTop;
  function getElementTop() {
    var y = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      y+= elm.offsetTop;
      elm = elm.offsetParent;
    }
    return parseInt(y);
  }

  this.getElementHeight = getElementHeight;
  function getElementHeight(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetHeight);
  }

  this.getElementBottom = getElementBottom;
  function getElementBottom(){
    return getElementTop(p_elm) + getElementHeight(p_elm);
  }
}

function voteBOTY(selection,couple) {
	fm = document.forms['botyForm'];
	
	if (confirm("You are about to vote for " + couple + ". Are you sure?")) {
		fm.voteSelection.value = selection;
		fm.submit();
	}	
}

function voteDressMakeover(selection,designer) {
	fm = document.forms['makeoverForm'];
	
	if (confirm("You are about to vote for " + designer + ". Are you sure?")) {
		fm.voteSelection.value = selection;
		fm.submit();
	}	
}