var setToggle;

$(document).ready(function(){
	if (setToggle == null){
		//setToggle = true;
		$('#login').click(function() {
			$('#sfondo_box_login').toggle();
			$(this).toggleClass("login_active");
			return false;
		});
	}
 
	$('input.reg').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});

	$('input.reg2').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
	
	// Ricava il nome del sito
        var host = location.href;
        host = host.substring(host.indexOf('//')+2);
        host = host.substring(0,host.indexOf('/'));

	if ((host == 'www.eni.it') || (host == 'www.eni.com')) {
		if (setToggle == null){
			setToggle = true;
			setTimeout("importJS('https://www.auth.eni.it/portal/jsp/recuperaInfo.jsp')",100);
		}
		//setTimeout("importJS('https://www.auth.eni.it/portal/jsp/requestAttributes.jsp')",150);
	}
	else if ((host == 'st-eni.eni.it') || (host == 'st-eni.eni.com')) {
		if (setToggle == null){
			setToggle = true;
			setTimeout("importJS('https://st-auth.eni.it/portal/jsp/recuperaInfo.jsp')",100);
		}
		//setTimeout("importJS('https://st-auth.eni.it/portal/jsp/requestAttributes.jsp')",150);
	} 
});

function importJS(link){
	var headID = document.getElementsByTagName("head")[0];         
	var infoScript = document.createElement('script');
	infoScript.type = 'text/javascript';
	infoScript.src = link;
	headID.appendChild(infoScript);
}
