// JavaScript Document
function openBrWindow(theURL,winName,features){
  window.open(theURL,winName,features);
}

function checkfield(theForm){
	//sorting out required fields
	for(x = 0; x < requiredFields.length; x++){
		if(theForm.elements[requiredFields[x]]){
			theElement = theForm.elements[requiredFields[x]];
				//getting the type of element
			if(theElement.type == 'select-one'){ //selection list one value
				if(theElement.options[theElement.selectedIndex].value.length == 0){
					theElement.focus();
					alert(standardMsg);
					return false;
				}
			}else if(theElement.type =='select-multiple'){ //selection list multiple values
				//alert('Required: '+theElement.name+' option selected: '+theElement.selectedIndex);
				if(theElement.selectedIndex == -1){
					theElement.focus();
					alert(standardMsg);
					return false;
				}
			}else if(theElement.type == 'text' || theElement.type == 'password' || theElement.type == 'textarea' || theElement.type == 'file'){ //text
				//alert(theElement.name+": "+theElement.value.length);
				if(theElement.value.length == 0){
					theElement.focus();
					alert(standardMsg);
					return false;
				}
			}else if(theElement.type == 'checkbox'){
				//alert(theElement.name+": "+theElement.value.length);
				if(theElement.checked != true){
					theElement.focus();
					alert(standardMsg);
					return false;
				}
			}else if(theElement[0].type == 'radio'){
				//alert(theElement.name+": "+theElement.value.length);
				radioChecked = false;
				for(z = 0; z < theElement.length; z++){
					if(theElement[z].checked == true){
						radioChecked = true;
						break;
					}
				}
				if(!radioChecked){
					theElement[0].focus();
					alert(standardMsg);
					return false;
				}
			}
		}
	}
	 
 	return true;
} // end checkfield()

function hideShowLayer(layerId){
	layerRef = document.getElementById(layerId);
	if(layerRef.style.visibility == 'hidden'){
		layerRef.style.visibility = 'visible';
	}else{
		layerRef.style.visibility = 'hidden';
	}
}

winRef = null;
winIsOpen = false;
function openWin(theURL,winName,features,winWidth,winHeight) {
  if(winWidth > 0 && winHeight > 0){
  	monitorWidth = screen.width;
	monitorHeight = screen.height;
	xPos = Math.round(monitorWidth - winWidth) / 2;	
	yPos = Math.round(monitorHeight - winHeight) / 2;
	features += ',left='+xPos+',top='+yPos;	
  }
  winRef = window.open(theURL,winName,features);
  winIsOpen = true;
}
