/**
 * GestoriaLuis
 */

var $ = jQuery.noConflict();

$(document).ready(function(){
	// email effect
	flogin_email = $('#external_login input[name="email"]');
	text_email = 'Usuari';
	flogin_email.blur(function() { if(this.value == '') this.value = text_email; });
	flogin_email.focus(function() { if(this.value == text_email) this.value = ''; });

	// pass effect
	flogin_psw = $('#external_login input[name="psw"]');
	text_psw = 'Clau';
	flogin_psw.blur(function() { if(this.value == '') this.value = text_psw; });
	flogin_psw.focus(function() { if(this.value == text_psw) this.value = ''; });	

	// login form event
	$('#flogin').submit(function() {

		var frm = document.forms[document.flogin.desti.value];
		
		if(document.flogin.desti.value == 'f1'){
			document.f1.ctl00$ContentPlaceHolder1$Login1$UserName.value = document.flogin.email.value;
			document.f1.ctl00$ContentPlaceHolder1$Login1$Password.value = document.flogin.psw.value;
		}
		if(document.flogin.desti.value == 'f2'){
			document.f2.email.value = document.flogin.email.value;
			document.f2.psw.value = document.flogin.psw.value;
		}
		if(document.flogin.desti.value == 'f3'){
			document.f3.login.value = document.flogin.email.value;
			document.f3.pwd.value = document.flogin.psw.value;
		}

		setTimeout(function(){ frm.submit(); }, 500);
		return false;		
	});
});


