
function check_form(form){
	var msg='';

  if(self.check_form_custom){
    msg=check_form_custom(form);
  }

	var pmin=check_price(form.elements['pmin'].value);
	var pmax=check_price(form.elements['pmax'].value);
	
	if(pmin===false){
		msg=msg+"\n- Minimal price is in improper format";
	}
	
	if(pmax===false){
		msg=msg+"\n- Maximal price is in improper format";
	}
	
	if((pmin!==true) && (pmin!==false) && (pmax!==false) && (pmax!==true) && (pmin>pmax)){
		msg=msg+"\n- Minimal price should be smaller than maximal price";
	}
	
	if(msg!=''){
		alert('Invalid information entered.'+msg);
		return false;
	}
	return true;

}

function check_price(price){
	if(!price || price=='min' || price=='max') return true;
	var regex=/^\$?((?:\d+)(?:\.\d{2})?)$/;
	var matches=regex.exec(price);
	if(!matches) return false;
	return (+matches[1]);
}

function openHelp(){
  window.open('help.html','cghelp','menubar=no,location=no,toolbar=no,resizable=yes,scrollbars=yes,status=no,width=400,height=600');
}

