function populateScreenSize(){
	eSize_Of_Screen = document.getElementById('Size_Of_Screen');
	eSize_Of_Browser = document.getElementById('Size_Of_Browser');
	
	try{
		eSize_Of_Screen.value = screen.width + 'x' + screen.height;
		eSize_Of_Browser.value = document.body.clientWidth + 'x' + document.body.clientHeight;
	}
	catch(err){}
}

function toggle(ElementID, Visibility){
	var TheElement = document.getElementById(ElementID);
	
	if(Visibility == undefined){
		TheElement.style.display = TheElement.style.display == 'none' ? 'block' : 'none';
	}
	else{
		TheElement.style.display = Visibility;
	}
}

function toggleIndustry(CategoryID){
	
	// Hide currently active category list
	if(ActiveCategoryID){
		TheSelectBox = document.getElementById('SubCatList_'+ActiveCategoryID)
		if(TheSelectBox != undefined){
			TheSelectBox.style.display = 'none';
		}		
	}
	
	// Show state list for selected country (or the text box)
	TheSelectBox = document.getElementById('SubCatList_'+CategoryID);
	
	if(TheSelectBox != undefined){
		// Show the correct select box
		TheSelectBox.style.display = 'inline';
		
		// Make the hidden textbox have the value of the selectbox that is now showing
		document.getElementById('IndustrySubID').value = TheSelectBox.value;
	}
	
	ActiveCategoryID = CategoryID;
	
}

function toggleCountry(CountryISO){

	// Hide currently active state list or textbox
	if(ActiveCountryISO){
		TheSelectBox = document.getElementById('StateList_'+ActiveCountryISO)
		if(TheSelectBox != undefined){
			// Hide the select box
			TheSelectBox.style.display = 'none';
		}		
	}
	
	// Hide the textbox
	document.getElementById('State').style.display = 'none';
	
	// Show state list for selected country (or the text box)
	TheSelectBox = document.getElementById('StateList_'+CountryISO)
	if(TheSelectBox != undefined){
		// Show the select box
		TheSelectBox.style.display = 'inline';
	}
	else{
		// Show the textbox
		document.getElementById('State').style.display = 'inline';
	}
	
	ActiveCountryISO = CountryISO;
	
}

/**
 * @author A.R.T.
 * @date June 2007
 *
 * Checks for required fields in the form
 */
function validateForm(TheForm){
	var DoContinue = true;
	var ErrorMessage = "Please provide or correct the following:\n";
	var PassedValidation = true;
	
	// Get a reference to the form
	// TheForm = document.getElementById('TrialForm');
	
	// Loop over the form elements
	for(x=0; x<TheForm.elements.length; x++){
		
		// Get a reference to the element
		TheElement = TheForm.elements[x];
		
		// See if the field is required
		if(TheElement.className.indexOf('*') >= 0){
			PassedValidation = true;
			
			// If it is a text field, see if it is empty or if it has 'Email' in the name, then make sure it has a @ sign and a period.
			if(TheElement.type == 'text' && (TheElement.value == '' || (TheElement.name.indexOf('Email') > -1 && (TheElement.value.indexOf('@') < 0 || TheElement.value.indexOf('.') < 0 || TheElement.value.indexOf(' ') > -1)))){
				PassedValidation = false;
			}
			// If it is a textarea
			if(TheElement.type == 'textarea' && TheElement.innerText == ''){
				PassedValidation = false;
			}
			// If it is a select box, see if nothing is selected
			if(TheElement.type == 'select-one' && TheElement.selectedIndex == 0){
				PassedValidation = false;
			}
			// If it is a radio or checkbox, see if nothing is selected
			if(TheElement.type == 'radio' || TheElement.type == 'checkbox'){
				
				arrBoxes = document.getElementsByName(TheElement.name);
				OneWasChecked = false;
				
				for(i=0; i<arrBoxes.length; i++){
					if(arrBoxes[i].checked){
						OneWasChecked = true;
						//break;
					}
				}
				
				if(OneWasChecked == false){
					PassedValidation = false;
				}
			}
			
			// If a field didn't pass the validation check, add to the error message
			if(PassedValidation == false){
				// Add the text from the "class" attribute of the element to the error message
				ErrorMessage += "\n " + TheElement.className;
				
				// Tell the form not to submit
				DoContinue = false;
			}
		}
	}
	
	// If there was a required field(s) that wasn't filled out, then show the error message
	if(DoContinue == false){
		alert(ErrorMessage);
	}
	
	return DoContinue;
}

// insertAdjacentHTML Prototype (So it will work in FireFox)
//
// insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement
// for Netscape 6/Mozilla by Thor Larholm me@jscript.dk
// Usage: include this code segment at the beginning of your document
// before any other Javascript contents.
// Source: http://www.faqts.com/knowledge_base/view.phtml/aid/5756
if(typeof HTMLElement!="undefined" && !
HTMLElement.prototype.insertAdjacentElement){
	HTMLElement.prototype.insertAdjacentElement = function
(where,parsedNode)
	{
		switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling) 
				this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function
(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}


	HTMLElement.prototype.insertAdjacentText = function
(where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}
