var documentReady = function(){
	
	f.maskFields();
	f.language = idioma;
	
	/* efeito para retirar os valores default dos campos input e textarea ao dar foto*/
	$('input[type=text],input[type=password],textarea').each(function(){
		var input = $(this);
		if(input.attr('testDV') == 'true'){
			$(this).focus(function(){
				if(this.value === this.defaultValue){
					if((this.type == 'text') && (this.id.indexOf('_PW') > -1)){
						input.css('display','none');
						var elms = document.getElementsByName(this.name.substr(0,this.name.length-1));
						if(elms.length == 1){
							$(elms[0]).css('display','').focus();
						}
					} else {
						this.value = '';
					}
				}
			});
			$(this).blur(function(){
				if(this.value == ''){
					if((this.type == 'password') && (this.id.indexOf('_PW') > -1)){
						input.css('display','none');
						var elms = document.getElementsByName(this.name+'2');
						if(elms.length == 1){
							$(elms[0]).css('display','');
						}
					} else {
						this.value = this.defaultValue;
					}
				}
			});
		}
	});
	$('select').each(function(){
		var atual = $(this);
		var atualDiv = $('#'+atual.attr('id')+'_div');
		if(atualDiv.length == 1){
			atual.removeClass('aberto').addClass('fechado');
			atual.css('z-index','10');

			atual.click(function(){
				atual.removeClass('fechado').addClass('aberto');
			}).focus(function(){
				atual.removeClass('fechado').addClass('aberto');
			}).change(function(){
				atual.css('z-index','10');
				atual.removeClass('aberto').addClass('fechado');
				atualDiv.html(this.options[this.selectedIndex].text+'<span class="sbaixo"><span></span></span>');
			});
		}
	});
};
$(document).ready(function(){
	documentReady();
});

function parseScript(_source)
{
		var source = _source;
		var scripts = new Array();

		// Strip out tags
		while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) {
			var s = source.indexOf("<script");
			var s_e = source.indexOf(">", s);
			var e = source.indexOf("</script", s);
			var e_e = source.indexOf(">", e);

			// Add to scripts array
			scripts.push(source.substring(s_e+1, e));
			// Strip from source
			source = source.substring(0, s) + source.substring(e_e+1);
		}

		// Loop through every script collected and eval it
		for(var i=0; i<scripts.length; i++) {
			try {

				eval(scripts[i]);
			}
			catch(ex) {
				// do what you want here when a script fails
			}
		}
		// Return the cleaned source
		return source;
}
