

var DHTML = (document.getElementById || document.all || document.layers);

function showMenu(menuItem) {
	if (!DHTML) {
		return;
	}
	if (document.getElementById){
		var m = document.getElementById(menuItem);
	}	
	else if (document.all){
		var m = document.all[menuItem];
	}
	else if (document.layers){
   		var m = document.layers[menuItem];
	}
	m.style.display = 'inline';
}

function hideMenu(menuItem) {
	if (!DHTML) {
		return;
	}
	if (document.getElementById){
		var m = document.getElementById(menuItem);
	}	
	else if (document.all){
		var m = document.all[menuItem];
	}
	else if (document.layers){
   		var m = document.layers[menuItem];
	}
	m.style.display = 'none';
}



function show(instr, id) {
	if (!DHTML) {
		return;
	}
	if (document.getElementById){
		var tbl = document.getElementById(instr);
	}	
	else if (document.all){
		var tbl = document.all[instr];
	}
	else if (document.layers){
   		var tbl = document.layers[instr];
	}
	
	var rows = tbl.getElementsByTagName('tr');
	for (var row=0; row<rows.length;row++) {
		var cells = rows[row].getElementsByTagName('td');
		for (var cell=0; cell < cells.length; cell++) {
			if(cells[cell].id == 'state_usa'){
				cells[cell].style.display = 'none';
			}
			if(cells[cell].id == 'state_canada'){
				cells[cell].style.display = 'none';
			}
		}
	}
	if(id == 'CANADA'){
		var rows = tbl.getElementsByTagName('tr');
		for (var row=0; row<rows.length;row++) {
			var cells = rows[row].getElementsByTagName('td');
			for (var cell=0; cell < cells.length; cell++) {
				if(cells[cell].id == 'state_canada'){
					cells[cell].style.display = 'inline';
				}
			}
		}
	}
	if(id == 'USA' ){
		var rows = tbl.getElementsByTagName('tr');
		for (var row=0; row<rows.length;row++) {
			var cells = rows[row].getElementsByTagName('td');
			for (var cell=0; cell < cells.length; cell++) {
				if(cells[cell].id == 'state_usa'){
					cells[cell].style.display = 'inline';
				}
			}
		}
	}
} 
function isset(id){
	if(id.value == ""){
		alert('You have missed to fill out obligatoric fields');
		return false;
	}
	else {
		return true;
	}
}

function isOK(mess){
	alert(mess);
}


function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


function invi(flag)
{
	if (!DHTML) return;
	var x = new getObj('infoText');
	x.style.display = (flag) ? 'none' : 'inline';
}

function fields(){
	
	var tmp = document.getElementById('agency');
	if( tmp != null){
		if(document.information.agency.value == ""){
			alert('You have missed to fill out the Agency Name');
			return false;
		}
	}

	var strValidChars = "0123456789 ";
	var strString = document.information.dateOfBirthMonth.value;
	//  test strString consists of valid characters listed above
   	for (i = 0; i < strString.length; i++)
    {
    	strChar = strString.charAt(i);
      	if (strValidChars.indexOf(strChar) == -1)
        {
        	alert('Date fields can only contain numeric values');
        	return false;
        }
   	}
	var strString = document.information.dateOfBirthDay.value;
	//  test strString consists of valid characters listed above
   	for (i = 0; i < strString.length; i++)
    {
    	strChar = strString.charAt(i);
      	if (strValidChars.indexOf(strChar) == -1)
        {
        	alert('Date fields can only contain numeric values');
        	return false;
        }
   	}
	var strString = document.information.dateOfBirthYear.value;
	//  test strString consists of valid characters listed above
   	for (i = 0; i < strString.length; i++)
    {
    	strChar = strString.charAt(i);
      	if (strValidChars.indexOf(strChar) == -1)
        {
        	alert('Date fields can only contain numeric values');
        	return false;
        }
   	}
   

	if(document.information.firstName.value == ""){
		alert('You have missed to fill out your first name');
		return false;
	}
	if(document.information.lastName.value == ""){
		alert('You have missed to fill out your last name');
		return false;
	}
	if(document.information.email.value == ""){
		alert('You have missed to fill out your email');
		return false;
	}
	if(document.information.gender.value == 2){
		if(document.information.maleLetter.value == ""){
			alert('If you are a male you need to fill out the letter of intent.');
			return false;
		}
	}	
	
	
	if(document.information.address.value == ""){
		alert('You have missed to fill out your address');
		return false;
	}
	

	if(document.information.city.value == ""){
		alert('You have missed to fill out your city');
		return false;
	}
	if(document.information.zip.value == ""){
		alert('You have missed to fill out your zip-code');
		return false;
	}	
	
	
	
	return true;
}

function fields_1(){
	if(document.information.product.value == -1){
		alert('Have to choose the level of Sponsorship.');
			return false;
	}
	return true;
}



// Functions for controlling pages
function addMember(checkArr){

	if(!fields()){
		return false;
	}
	if(!checkDate(checkArr)){
		return false;
	}
	return true; 
}

function checkSigned(){
	if(document.information.signed.checked == false){
		alert("You must agree with the AWSDA Values");
		return false;
	}
	return true;
}


