///////// FEEDBACK FORM JS ///////////
	var COM_SAVE_HTML = '';

function com_restore_send_area(divX)
{
	document.getElementById(divX).innerHTML = COM_SAVE_HTML;
}

function com_callback_sendform(messagex)
{
	if (messagex == 'ok') {
		document.getElementById("send_form_feedback").innerHTML = '<b>THANK YOU</b><br> Your enquiry has been forwarded to the appropriate people';
	} else {
		document.getElementById("send_form_feedback").innerHTML = messagex;
		setTimeout("com_restore_send_area('send_form_feedback')",7000);
	}		
}

function com_sendform_validate()
{
	var validOK = true;

	if (!com_test_empty('fe_phone')) 	validOK = false;
	if (!com_test_empty('fe_name')) 	validOK = false;
	if (!com_test_empty('fe_offer')) 	validOK = false;

	if (!com_test_empty('fe_eml')) 	validOK = false;
	else {
		if (!com_valid_email(document.getElementById('fe_eml').value)) { 
			com_input_error('fe_eml',true); validOK = false;
		}  else com_input_error('fe_eml',false);
	}

	if (validOK) {
		COM_SAVE_HTML = document.getElementById("send_form_feedback").innerHTML;
		fw_postFormReturnText(document.form_feedback, com_callback_sendform);
		document.getElementById("send_form_feedback").innerHTML = '<img src="images/ajax-loader.gif" width="32" height="32">';
	}

}

function com_test_empty(itemName)
{
	var validOK = true;
	if (document.getElementById(itemName).value.length == 0) { 
		com_input_error(itemName,true); validOK = false;
	}  else com_input_error(itemName,false);
	return validOK;
}

/*********** OTHER SCRIPTS **********/

function com_input_error(itemName,highLight)
{
	if (highLight) { bg = '#fbb'; border = '#c55'; }
	else { bg = '#fff';  border = '#999'; }
	document.getElementById(itemName).style.background = bg;
	document.getElementById(itemName).style.border = 'solid 1px '+border;
}

	//add comas to number - usage, strX = com_addCommas(amount)
	function com_addCommas(nStr)
	{
		nStr += "";
		x = nStr.split(".");
		x1 = x[0];
		x2 = x.length > 1 ? "." + x[1] : "";
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, "$1" + "," + "$2");
		}
		return x1 + x2;
	}
		
   	// check for valid numeric strings - usage, if ( !com_isNum(amount) )
	function com_isNum(strString)
   	{
   		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;
  	}
	
	//check if group is selected - usage, if (com_radio_active(document.form1.radio1) < 1)
 	function com_radio_active(radio_group)
 	{
		//if only 1 radio
 		if (!radio_group.length)
		{
			if (radio_group.checked)
				return radio_group.value;
			else return -1;
		}
			
    	// Run through the group
     	for (counter = 0; counter < radio_group.length; counter++) 
		{
         	// When we find the activated button, return the index
         	if (radio_group[counter].checked) 
			{
             	return radio_group[counter].value;
         	}
     	}
     	// If no button is activated, return -1
     	return -1
	}

	function com_valid_url(str) 
	{
		if (str.length < 1) return false
		x = str.split(".");	
		if ((x.length < 3) || (x.length > 4)) 
			return false;
		else return true;
	}
	
	function com_valid_email(str) 
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
	
		var tested = true;
		
		if (str.indexOf(at)==-1)
		   tested = false;
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		   tested = false;
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		   tested = false;
		 if (str.indexOf(at,(lat+1))!=-1)
		   tested = false;
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		   tested = false;
		 if (str.indexOf(dot,(lat+2))==-1)
		   tested = false;
		 if (str.indexOf(" ")!=-1)
		   tested = false;
	
		if ( !tested )
			return false;
		else
			return true;
	
	}
