//************** LOGIN *****************
function findElementById(id){
	return ( document.all+'' != 'undefined' ? document.all[id] : document.getElementById(id) );
}

function txt2pwd(obj,pwd){
	obj.style.visibility = 'hidden';
	document.getElementById('loginTopBar').j_password.style.display = 'block';
	document.getElementById('txt').style.display = 'none';
	document.getElementById('loginTopBar').j_password.focus();	
}

function pwd2txt(obj,txt){	
	if(obj.value.length==0){
		findElementById(txt).style.visibility = 'visible';
		document.getElementById('loginTopBar').j_password.style.display = 'none';
		document.getElementById('txt').style.display = 'block';
				
	}
}


function validatelogin(){
	var alertvalidate="";
	if ((document.loginTopBar.j_username.value =='')||(document.loginTopBar.j_password.value =='')||(document.loginTopBar.j_username.value =='Username')||(document.loginTopBar.j_password.value =='Password'))
	{
		alertvalidate="The login and password fields are required\n";
		if (alertvalidate!="")
		{
			alert (alertvalidate);
			return false;
		}
	}
}

//************** SEARCH *****************
function searchsite(){
	var siteform = document.getElementById('fsearchsite')

	if ((siteform.as_epq.value == "") || (siteform.as_epq.value == "Search in the site")){
		alert("You have not provided any arguments for research");
		return false;
	}else{
		return true;
	}
}

function searchtitle(){
	var searchform = document.getElementById('fsearchtitle')

	if ((searchform.param.value == "") || (searchform.param.value == "Quotes search")){
		alert("You have not provided any arguments for research");
		return false;
	}else{
		var isin = searchform.param.value;
		var checkIsin = isIsin(isin);
		if (checkIsin==true)
			searchform.grp.value="motore";
			searchform.submit();
	}
}

//************** CONTROLLO SU ISIN *****************

function isIsin(stringToTest){
	var beginpattern = /[a-z,A-Z]{2}/;
	var endpattern = /[a-z,A-Z,0-9]{10}/;
	begin=stringToTest.substring(0,2);
	end=stringToTest.substring(2,stringToTest.length);
	if(stringToTest.length==12 && (beginpattern.test(begin)==true) && (endpattern.test(end)==true) )
		return true;
	return false;
}

//********** gotoToUrl **********
function gotoToUrl(selectObj){
	if (selectObj.value != ""){
		window.open(selectObj.value,'','');
	}
}

//********** switchLanguage ******
function switchLanguage(selectObj){
	if (selectObj.value != ""){
		location.href = selectObj.value;
	}
}