/* --------------------------------------------------------------
   $Id: general.js.php,v 1.1.1.1 2008/10/27 07:55:57 cvs Exp $   

   XT-Commerce - community made shopping
   http://www.xt-commerce.com

   Copyright (c) 2003 XT-Commerce
   --------------------------------------------------------------
   based on: 
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
   (c) 2002-2003 osCommerce(general.js,v 1.2 2001/05/20); www.oscommerce.com 
   (c) 2003	 nextcommerce (general.js,v 1.4 2003/08/13); www.nextcommerce.org

   Released under the GNU General Public License 
   --------------------------------------------------------------*/

function SetFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i=0; i<field.length; i++) {
      if ( (field.elements[i].type != "image") && 
           (field.elements[i].type != "hidden") && 
           (field.elements[i].type != "reset") && 
           (field.elements[i].type != "submit") ) {

        document.forms[0].elements[i].focus();

        if ( (field.elements[i].type == "text") || 
             (field.elements[i].type == "password") )
          document.forms[0].elements[i].select();
        
        break;
      }
    }
  }
}

function validate_form(formname){
	alert_str = '';
	dom = document.forms[formname];
	validate_fields = checkfields.length;
	for(i=0;i<validate_fields;i++){
		el = dom.elements[ checkfields[i]['field'] ];
		min = checkfields[i]['min'];
		title = checkfields[i]['title'];
		if(el.value.length < min){
			alert_str = alert_str+title+"\r\n";
		}
	}
	if(alert_str != '')
		alert('<?php echo JS_REQUIRED_FIELDS; ?>\r\n'+alert_str);
	return false;
}
