function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function set_required_short() {
	var required_fields = new Array();
	
	required_fields[0] = "idaccount_mail";
	array_count = 1;
	for (i=0; i<array_count; i++) {
		el = returnObjById(required_fields[i]);
		if (focus(el)) alert ("focuus");
		if (el.value == "" ) {
			el.style.cssText="background: url(images/oa_rq_field_short.gif) no-repeat ;";
		} else {
			el.style.cssText="background: url(images/oa_field_short.gif) no-repeat ;";
		}
	}
	return true;
}
function set_required_big() {
	var required_fields = new Array();
	
	required_fields[0] = "idaccount_name";
	required_fields[1] = "idaccount_phone";
	array_count = 2;
	for (i=0; i<array_count; i++) {
		el = returnObjById(required_fields[i]);
		if (focus(el)) alert ("focuus");
		temp_value = el.value;
		if (el.value == "" ) {
			el.style.cssText="background: url(images/oa_rq_field_long.gif) no-repeat ;";
		} else {
			el.style.cssText="background: url(images/oa_field_long.gif) no-repeat ;";
		}
	}
	return true;
}
var myrules = {
	'.change_background_long' : function(el){
		el.onfocus = function(){
				this.style.cssText="background: url(images/oa_field_long.gif) no-repeat ;";
			return true;
		}
		el.onblur = function(){
			if (this.value == "" ) {
				this.style.cssText="background: url(images/oa_rq_field_long.gif) no-repeat ;";
			} else {
				this.style.cssText="background: url(images/oa_field_long.gif) no-repeat ;";
			}
			return true;
		}
	},
	'.change_background_short' : function(el){
		el.onfocus = function(){
				this.style.cssText="background: url(images/oa_field_short.gif) no-repeat ;";
			return true;
		}
		el.onblur = function(){
			if (this.value == "" ) {
				this.style.cssText="background: url(images/oa_rq_field_short.gif) no-repeat ;";
			} else {
				this.style.cssText="background: url(images/oa_field_short.gif) no-repeat ;";
			}
			return true;
		}
	}
};

Behaviour.register(myrules);
addLoadEvent(set_required_big);
addLoadEvent(set_required_short);
