function switchSelection(maxFactor){
	var list = document.getElementById('listaselectie');
	var crtIndex = list.value;
	resetPrevDisplays(maxFactor);
	document.getElementById('selectie'+crtIndex).style.display = 'block';
	document.getElementById('blmain').innerHTML = list.options[list.selectedIndex].innerHTML;
	if(document.getElementById('programare')!=null){
		document.getElementById('programare').action = 'programare.php?sect='+crtIndex;
	}
	if(document.getElementById('extra'+crtIndex)!=null){
		document.getElementById('extra'+crtIndex).style.display = 'block';
	}
	if(document.getElementById('detalii'+crtIndex)!=null){
		document.getElementById('detalii'+crtIndex).style.display = 'block';
	}
	if(document.getElementById('lnkmedici')!=null){
		document.getElementById('lnkmedici').href = 'lista_medici-'+crtIndex+'.htm';
	}
	if(document.getElementById('lnksectie')!=null){
		document.getElementById('lnksectie').href = 'sectii_clinici-'+crtIndex+'.htm';
	}
}

function resetPrevDisplays(maxFactor){
	for(var i=1; i<=maxFactor; i++){
		document.getElementById('selectie'+i).style.display = 'none';
		if(document.getElementById('extra'+i)!=null){
			document.getElementById('extra'+i).style.display = 'none';
		}
		if(document.getElementById('detalii'+i)!=null){
			document.getElementById('detalii'+i).style.display = 'none';
		}
	}
}

function showComMembers(cid){
	showScreenCastBlocker("comisie.php?id="+cid,50,280,450)
}

function showContactForm(){
	showScreenCastBlocker("contact.php",50,230,500);
}

function showMap(){
	showScreenCastBlocker("harta.php",50,500,440);
}

function isEmail(str) { 
	// are regular expressions supported? 
	var supported = 0; 
	if (window.RegExp) 
	{ 
	  var tempStr = "a"; 
	  var tempReg = new RegExp(tempStr); 
	  if (tempReg.test(tempStr)) supported = 1; 
	} 
	if (!supported)  
	  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); 
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"); 
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); 
	return (!r1.test(str) && r2.test(str)); 
}

function sendMsg(){
	var test = document.getElementById('txtNume');
	if(test.value.length < 5){
		alert('Trebuie sa completati numele Dvs.');
		test.focus();
		return;
	}
	test = document.getElementById('txtEmail');
	if(!isEmail(test.value)){
		alert('Adresa de e-mail este invalida');
		test.focus();
		return;
	}
	test = document.getElementById('userConfirm');
	if(test.value.length != 6){
		alert('Trebuie sa introduceti codul din imagine');
		test.focus();
		return;
	}
	test = document.getElementById('frmContact');
	test.action = "contact.php";
	test.submit();
}