//// PREFILLED INPUTS //////
function prefilledField(id,j,strcolor){
	this.j = j;
	this.id = id;
	this.strdefaultval = this.j.val();
	this.strdefaultcolor = this.j.css("color");
	this.origType = this.j.attr("type")?this.j.attr("type"):'text';
	this.onclick = function(){
		if(this.j.val()==this.strdefaultval)
			this.j.val('').css('color',strcolor);
		if(this.origType=='password') 
			this.j.attr("type","password");
	}
	this.onblur = function(){
		if(this.j.val()==''){
			this.j.val(this.strdefaultval).css('color',this.strdefaultcolor);
			if(this.origType=='password') this.j.attr("type","text");
		}
	}
	this.onsubmit = function(){
		if(this.j.val()==this.strdefaultval)
			this.j.val('');
	}
	//if(this.origType=='password') this.j.attr('type','text');
	eval('this.j.bind("focus",function(){arrprefilledfields['+this.id+'].onclick();});');
	eval('this.j.bind("blur",function(){arrprefilledfields['+this.id+'].onblur();});');
	eval('this.j.parents("form").bind("submit",function(){arrprefilledfields['+this.id+'].onsubmit();});');
}
var arrprefilledfields = [];
$(function(){
	$(":input.prefilled").each(function(){
		var id = arrprefilledfields.length;
		arrprefilledfields[id] = new prefilledField(id,$(this),'#000');
		$(this).bind("clear",function(){
			arrprefilledfields[id].onsubmit();
		}).bind("repopulate",function(){
			arrprefilledfields[id].onblur();
		});
	});
});
