
//<!--
function _CF_askFormOnError(form_object, input_object, object_value, error_message) {
	alert(error_message);
       	return false;	
}

function _CF_askFormhasValue(obj, obj_type) {
    if (obj_type == "TEXT" || obj_type == "PASSWORD") {
    	if (obj.value.length == 0) {
      		return false;
    	} 
      	return true;
    } else if (obj_type == "SELECT") {
        for (i=0; i < obj.length; i++) {
			if (obj.options[i].selected && obj.options[i].value != "")
				return true;
		}
       	return false;	
	} else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX") {
		if (obj.checked)
			return true;
		else
       		return false;	
	} else if (obj_type == "RADIO" || obj_type == "CHECKBOX") {
        for (i=0; i < obj.length; i++) {
			if (obj[i].checked)
				return true;
		}
       	return false;	
	}
}

function  _checkaskform(_CF_this) {

    if  (!_CF_askFormhasValue(_CF_this.UserName, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.UserName, _CF_this.UserName.value, "Please enter your name")) {
			_CF_this.UserName.focus();
            return false; 
        }
	}
	if  (!_CF_askFormhasValue(_CF_this.topicid, "SELECT" )) {
		if  (!_CF_askFormOnError(_CF_this, _CF_this.topicid, _CF_this.topicid.value, "Choose a category")) {
		    return false; 
		}
	}
    if  (!_CF_askFormhasValue(_CF_this.EmailID, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.EmailID, _CF_this.EmailID.value, "Enter your email address")) {
            return false; 
        }
	}
	if (!f_EmailCheck(_CF_this.EmailID.value)) {
		alert('Please enter a valid email address');
		return false;
	}
    return true;
}

function  _check_pps_ask1form(_CF_this) {
    if  (!_CF_askFormhasValue(_CF_this.query, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.query, _CF_this.query.value, "Please enter your query first")) {
			_CF_this.query.focus();
            return false; 
        }
	} 
	else if (_CF_this.query.value == 'Please enter the details of your query here...') {
			alert('Please enter the details of your query first');
			_CF_this.query.focus();
			return false;
	}
	if  (!_CF_askFormhasValue(_CF_this.subject, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.subject, _CF_this.subject.value, "Please enter a few words describing your query first")) {
			_CF_this.subject.focus();
            return false; 
        }
	} 
	else if (_CF_this.subject.value == 'A few words describing your query') {
			alert('Please enter a few words describing your query first');
			_CF_this.subject.focus();
			return false;
	}
	else if (_CF_this.subject.value == 'Enter the subject of your question here...') {
			alert('Please enter a subject first');
			_CF_this.subject.focus();
			return false;
	}	
	else if (_CF_this.subject.value == 'What do you need to know? Enter here...') {
			alert('Please briefly enter what your question is first');
			_CF_this.subject.focus();
			return false;
	}		
	else if (_CF_this.subject.value == 'Enter your query here... earn AA$ for good questions!') {
			alert('Please briefly enter what your question is first');
			_CF_this.subject.focus();
			return false;
	}	
	else if (_CF_this.query.value.length > 6000) {
			alert('Your query must be less than 6000 characters');
			return false;
	}
	/*if  (!_CF_askFormhasValue(_CF_this.topicid, "SELECT" ) || _CF_this.topicid.value == 0) {
		if  (!_CF_askFormOnError(_CF_this, _CF_this.topicid, _CF_this.topicid.value, "Select a category for the query")) {
			_CF_this.topicid.focus();
		    return false; 
		}
	}
	if  (!_CF_askFormhasValue(_CF_this.supreme_price, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.supreme_price, _CF_this.query.value, "Please enter an amount for your supreme query(AA$100+)")) {
			_CF_this.supreme_price.focus();
            return false; 
        }
	} 
	else if (IsNumeric(_CF_this.supreme_price.value) == false) {
			alert('The amount you entered for your supreme query is invalid, it must to be all numbers');
			return false;
	}	
	else if (_CF_this.supreme_price.value < 100) {
			alert('The price for a supreme query has to be over AA$100');
			return false;
	}*/
	
    return true;
}

function sup_select(showhide) {
  obj=(document.all) ? document.all['supreme_tr'] : document.getElementById('supreme_tr');
  if(showhide=='show') {   obj.style.display='inline'; }
  else {   obj.style.display='none'; }
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function  _check_pps_ask2loginform(_CF_this) {
    if  (!_CF_askFormhasValue(_CF_this.emailid, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.emailid, _CF_this.emailid.value, "Enter your email address")) {
            return false; 
        }
	}
	if (!f_EmailCheck(_CF_this.emailid.value)) {
		alert('Please enter a valid email address');
		return false;
	}
    if  (!_CF_askFormhasValue(_CF_this.password, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.password, _CF_this.password.value, "Enter your password")) {
            return false; 
        }
	}
    return true;
}


function  _check_pps_ask2registerform(_CF_this) {
	if (!f_EmailCheck(_CF_this.emailid.value)) {
		alert('Please enter a valid email address');
		return false;
	}
    if  (!_CF_askFormhasValue(_CF_this.password, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.password, _CF_this.password.value, "Enter your password")) {
            return false; 
        }
	}
    if  (!_CF_askFormhasValue(_CF_this.password, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.password, _CF_this.password.value, "Enter a password")) {
            return false; 
        }
	}
    if  (!_CF_askFormhasValue(_CF_this.password_again, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.password_again, _CF_this.password_again.value, "Confirm password")) {
            return false; 
        }
	}
	if  (_CF_this.password.value != _CF_this.password_again.value) {
		alert('Both password field entries should match.');
		return false; 
	}

    if  (!_CF_askFormhasValue(_CF_this.username, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.username, _CF_this.username.value, "Enter your name")) {
            return false; 
        }
	}
    if  (!_CF_askFormhasValue(_CF_this.location, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.location, _CF_this.location.value, "Enter your location (e.g., New York, USA)")) {
            return false; 
        }
	}

	
    return true;
}

function checkquerylen(textArea,boxText,maxlength){
   var queryvalue = textArea.value;
   var queryvaluelength = textArea.value.length;
   var value = maxlength - queryvaluelength;
   if (value < 0)
   	{
		var queryvalue= textArea.value;
		//alert(' You have entered ' + (maxlength-value) + ' characters. ' + maxlength +' is the limit.');
		alert('Please provide your query in no more than ' + maxlength +' characters.');
		textArea.value = queryvalue.substr(0,maxlength)
	}
	value = maxlength - textArea.value.length;
	boxText.value = value;
}


function clear_field(_obj) {
	if (_obj.value == 'Enter your query here.' || _obj.value =='A few words describing your query' || _obj.value == 'Enter the subject of your question here...' || _obj.value == 'Enter your query here...' || _obj.value == 'Please enter the details of your query here...' || _obj.value == 'Enter your query here...It\'s free!' || _obj.value == 'Enter your query here... earn AA$ for good questions!') {
		_obj.value = '';
	}
}
function  _checksubject(_CF_this) {
	if  (!_CF_askFormhasValue(_CF_this.subject, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.subject, _CF_this.subject.value, "Please enter a few words describing your query first.")) {
			_CF_this.subject.focus();
            return false; 
        }
	} 
	return true;
}	
function  _checkhomepagesubmit(_CF_this) {
  if (_CF_this.subject.value == '') {
		  alert('Please briefly enter what your question is first.');
		  _CF_this.subject.focus();
		  return false;
  }
  else if (_CF_this.subject.value == 'Enter your query here...It\'s free!') {
		  alert('Please briefly enter what your question is first.');
		  _CF_this.subject.focus();
		  return false;
  }
  if (_CF_this.submitButton.name == 'connectb')
    _CF_this.action = "http://www.ammas.com/ar/home.cfm?r=connectadvisor&keywords=" + _CF_this.subject.value;
  if (_CF_this.submitButton.name == 'searchb')
    _CF_this.action = "http://www.ammas.com/ar/home.cfm?r=se&gtype=3&SearchType=6&keywords=" + _CF_this.subject.value + "&q=" + _CF_this.subject.value + "&client=pub-6075632374842532&forid=1&channel=2155818690&sitesearch=www.ammas.com&ie=ISO-8859-1&oe=ISO-8859-1&safe=active&flav=0000&sig=AuEqNyEketNTPeTL&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A11&hl=en&sa.x=60&sa.y=54";
	
  return true;
}
function  _checkheadersubmit(_CF_this) {
  if (_CF_this.subject.value == '') {
		  alert('Please briefly enter what your question is first.');
		  _CF_this.subject.focus();
		  return false;
  }
  else if (_CF_this.subject.value == 'Enter your query here...It\'s free!') {
		  alert('Please briefly enter what your question is first.');
		  _CF_this.subject.focus();
		  return false;
  }
  var radioLength = _CF_this.gtype.length;
  var selectedvalue = 1;
	if(radioLength == undefined)
		selectedvalue = 1;
	for(var i = 0; i < radioLength; i++) {
		if(_CF_this.gtype[i].checked) {
			selectedvalue= _CF_this.gtype[i].value;
		}
	}
  if (selectedvalue == '2')
    _CF_this.action = "http://www.ammas.com/ar/home.cfm?r=connectadvisor&keywords=" + _CF_this.subject.value;
  if (selectedvalue == '3')
    _CF_this.action = "http://www.ammas.com/ar/home.cfm?r=se&gtype=3&SearchType=6&keywords=" + _CF_this.subject.value+ "&q=" + _CF_this.subject.value + "&client=pub-6075632374842532&forid=1&channel=2155818690&sitesearch=www.ammas.com&ie=ISO-8859-1&oe=ISO-8859-1&safe=active&flav=0000&sig=AuEqNyEketNTPeTL&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A11&hl=en&sa.x=60&sa.y=54";
  if (selectedvalue == '4')
    _CF_this.action = "http://www.ammas.com/aa/ask/ask1.cfm?askmynetwork=1";	
	
  return true;
}
function  _checksearchform(_CF_this) {
    if  (!_CF_askFormhasValue(_CF_this.keywords, "TEXT" )) {
        if  (!_CF_askFormOnError(_CF_this, _CF_this.keywords, _CF_this.keywords.value, "Please enter the keywords to search first.")) {
			_CF_this.keywords.focus();
            return false; 
        }
	} 
}	
var ie4 = document.all;
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all; 
