/**
 * Magento Enterprise Edition
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition License
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magentocommerce.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     enterprise_default
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://www.magentocommerce.com/license/enterprise-edition
 */

/*	
	IMP field labels
*/
Imp = {};
Imp.fieldLabel = Class.create();
Imp.fieldLabel.prototype = {
    initialize : function(form, field, emptyText, pass){
	    this.form   = $(form);
        this.field  = $(field);
        this.field.addClassName('haslabel');
        this.emptyText = emptyText;
		this.pass = pass?true:false;
		if(this.pass){
			this.textField  = $(field+'_text');
	        Event.observe(this.textField, 'focus', this.focus.bind(this));
	        Event.observe(this.field, 'blur', this.blur.bind(this));
		}else{				
			Event.observe(this.field, 'focus', this.focus.bind(this));
        	Event.observe(this.field, 'blur', this.blur.bind(this));
		}
        Event.observe(this.form,  'submit', this.submit.bind(this));
        this.blur();
    },
    focus : function(event){
		this.field.removeClassName('haslabel');
        if(this.field.value==this.emptyText) { 
			this.field.value='';
		}
		if(this.pass){
			//this.field.disabled = false;
			this.field.style.display = 'inline';
			this.field.focus();
			this.textField.hide();
			//this.textField.disabled = true;
		}
    },
    blur : function(event){
        if(this.field.value==''){
			if(this.pass){
				//this.field.disabled = true;
				this.field.hide();
				this.textField.show();
				this.field.value='';
				//this.textField.disabled = false;
			}else{
				this.field.value=this.emptyText;
			}
			this.field.addClassName('haslabel');
		}else{
			if(this.pass){
				//this.field.disabled = false;
				this.field.show();
				this.textField.hide();
				//this.textField.disabled = true;
			}
		}
    },
	submit : function(event){
    	
        if (this.field.value == this.emptyText || this.field.value == ''){
            Event.stop(event);            
            return false;
        }
        return true;
    }
	
}
Validation.add('required-imp', 'This is a required field.', function(v, el) {
	return !Validation.get('IsEmpty').test(v) && el.value!=el.title;
});

