 function toggleitem(a){
	x=document.getElementById(a);
	if(x.style.display=="block"){
		x.style.display="none"
	}else{
		x.style.display="block"
	}
}

function showcaptcha() {

	var url = 'captcha.cfm';
	var pars = '';
	
	//create the ajax request
	var myAjax = new Ajax.Request(
	        url,
	        {
	                method: 'get',
	                parameters: pars,
	                onComplete: displayCaptcha
	        }
	);      
}

//ajax callback method
function displayCaptcha(data) {
	document.getElementById('divcaptcha').innerHTML = data.responseText; 
      
}


function checkUser(strEmail, intAccountID) {

	var url = 'admin/ajax_CheckUser.cfm';
	var pars = 'strName=' + strEmail + '&intID=' + intAccountID + '&tableName=accounts&valueColumnName=strEmail&IDcolumnName=intAccountID';
	
	//create the ajax request
	var myAjax = new Ajax.Request(
	        url,
	        {
	                method: 'get',
	                parameters: pars,
	                onComplete: showResponse
	        }
	);      
}

//ajax callback method
function showResponse(data) {
	//alert(data.responseText);
      if (data.responseText == 1){
      	alert('Email is already used. Please try something else');
      	return false;
      }else{
      	if(validateForm( document.gronk, 0, 1, 0, 1, 17 )){
      		document.gronk.submit();
      	}else{
      		return false;
      	}
      	
      }
}

function displayBlock(id){
 	document.getElementById(id).style.display='block';
}
function displayNone(id){
 	document.getElementById(id).style.display='none';
}

function radio_button_checker(radioField)
{	
	
	// set var radio_choice to false
	var radio_choice = false;
	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < radioField.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (radioField[counter].checked)
		radio_choice = true; 
	}
	
	if (!radio_choice)
	{
		return (false);
	}
return (true);
}

function OpenEditWindow(strURL, strTitle, intWidth, intHeight, scrollbars)
	{
		var intWindowLeft
		var intWindowTop
		var msgWindow
		
		
		// find out the numbers to center the screen.
		intWindowLeft = (screen.width - intWidth) / 2;
		intWindowTop = (screen.height - intHeight) / 2;
		window.open(strURL,strTitle,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + scrollbars + ',resizable=0,width=' + intWidth + ',height=' + intHeight + ',left=' + intWindowLeft + ',top=' + intWindowTop);	
	}	
	
function trim(s)
{
return s.replace(/^\s+|\s+$/g, "");
}	
	
function isFloat(s)
{
var n = trim(s);
return n.length>0 && !(/[^0-9.]/).test(n) && (/\.\d/).test(n);
}	

function LTrim(str) {
	for (var i=0; str.charAt(i)==" "; i++);
	return str.substring(i,str.length);
	}
function RTrim(str) {
	for (var i=str.length-1; str.charAt(i)==" "; i--);
	return str.substring(0,i+1);
	}
function Trim(str) {
	return LTrim(RTrim(str));
	}
function toggleDisplay(x) {
if( document.getElementById(x).style.display == "none" ) {
    document.getElementById(x).style.display = "block";
  } else {
    document.getElementById(x).style.display = "none"; }
}