
function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;} 

	
function changePop(sel) {
  if (sel.value==1)
  {
  	//showdiv('pop_table_1');
	//hidediv('pop_table_2');
	$("#pop_table_2").slideUp("slow",function(){
  		$("#pop_table_1").slideDown("slow");
	});
  }
  if (sel.value==2)
  {
  	//showdiv('pop_table_2');
	//hidediv('pop_table_1');
  	$("#pop_table_1").slideUp("slow",function(){
  		$("#pop_table_2").slideDown("slow");
	});
  }
};

function finPop(elem) {
	//alert (document.getElementById(elem));
	if (elem=="fin")
  	{
		$("#fin_pop").slideUp("slow",function(){
			$("#msg_fin").slideDown("slow");
		});
	}
	if (elem=="close")
  	{
		$("#msg_fin").slideUp("slow",function(){
			$("#fin_pop").slideDown("slow");
		});
	}
}

function hidediv(id) {
//safe function to hide an element with a specified id
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}


function showdiv(id) {
//safe function to show an element with a specified id
	try {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
	else { // IE 4
		document.all.id.style.display = 'block';
		}
	}
	} catch(e){ }
}

function hiddenall(title,cnt) {
	for(i=1;i<=cnt;i++) {
		try {
			hidediv(title + i);
		} catch(e) {}
	};
}
function firstclasset(title,cnt) {
	for(i=1;i<=cnt;i++) {
		if(document.getElementById('c'+i).className != "menu_elem_sell")
		{ 
			try {
					document.getElementById('c'+i).className=title;
			} catch(e) {}
		}
//		else{ alert(document.getElementById('c'+i).className);}
	};
}

function firstclasunset(cnt) {
	for(i=1;i<=cnt;i++) {
		document.getElementById('c'+i).className="menu_elem";
	};
}

function checkout(elem) {
	if(elem.className == "menu_elem_sell") {
		//alert(1);
	} else {
		elem.className='menu_elem';
//		alert(elem.className);
	}
}


function hov (id)
	{
	document.getElementById(id).className=id+'_hov';
	}

function out (id)
	{
	document.getElementById(id).className=id;
	}


function fhover(elem) {
	if(elem.className != "menu_elem_sell" ) {		
		elem.className='menu_elem_hov';		
	}
}


function fclick(elem, submeniu) {
	firstclasunset(6);
	firstclasset('menu_elem',6);
	elem.className='menu_elem_sell';
}


function tab_hov(id)
{
	if((document.getElementById(id).className != 'ro_sell') && (document.getElementById(id).className != 'en_sell'))
	{
		document.getElementById(id).className=id+'_hov';
	}
}

function tab_out(id)
{
	if((document.getElementById(id).className != 'ro_sell') && (document.getElementById(id).className != 'en_sell'))
	{
		document.getElementById(id).className=id;
	}
}
	
function hide_show_login(id){
	if(id == 1){
		document.getElementById('tab_ro').className='tab_ro_sell';
		document.getElementById('tab_en').className='tab_en';
		document.getElementById('login_en').style.display='none';
		document.getElementById('login_ro').style.display='block';
	}else{
		document.getElementById('tab_ro').className='tab_ro';
		document.getElementById('tab_en').className='tab_en_sell';
		document.getElementById('login_ro').style.display='none';
		document.getElementById('login_en').style.display='block';
	}
}

function submitForm(){
	var errorStart = "Va rugam sa completati urmatoarele campuri:";
	var error = errorStart;
	
	if(document.getElementById("pop_select").value == 1){
		if(document.getElementById("nume_prenume").value.length < 2){
			error = error + "nume prenume, ";
		}
		if(document.getElementById("utilizator1").value.length < 2){
			error+="utilizator, ";
		}
		
		var cnp = parseInt(document.getElementById("cnp").value);
		if(String(cnp).length != 13){
			error = "Introduceti un CNP valid! \n"+error;
		}
		
		var emailValid = checkEmail(document.getElementById("email1").value);
		
		if(document.getElementById("email1").value.length > 0 && !emailValid){
			error = "Introduceti un email valid! \n"+error;
		}
	
		if(document.getElementById("telefon1").value.length < 5 && !emailValid){
			error+=" telefon sau email, ";
		}
		if(error != errorStart){
			alert(error);
		}else{
			document.formPassword.submit();
		}
		
	}else{
		if(document.getElementById("denumire").value.length < 2){
			error+="denumire, ";
		}
		if(document.getElementById("utilizator2").value.length < 2){
			error+="utilizator, ";
		}
		if(document.getElementById("cui").value.length < 5){
			error+="cui, ";
		}
	
		var emailValid = checkEmail(document.getElementById("email2").value);
		
		if(document.getElementById("email2").value.length > 0 && !emailValid){
			error = "Introduceti un email valid! \n"+error;
		}
		
		if(document.getElementById("telefon2").value.length < 5 && !emailValid){
			error+=" telefon sau email, ";
		}
		if(error != errorStart){
			alert(error);
		}else{
			document.formPassword.submit();
		}
		
	}
}

function checkEmail(email) {
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email)) {
		return false;
	}else{
		return true;
	}
}

function open_win(id){
	if(id == 1){
	//	'ai_uitat_parola.php', 'Recuperare parola', '402', '577'
		window.open("ai_uitat_parola.php","","width=402,height=624,menubar=no,status=yes,location=no,toolbar=no,scrollbars=no");	
	}
	if(id == 2){
	//	'suport_tehnic.php', 'Suport tehnic', '402', '534'
		window.open("suport_tehnic.php", "", "width=402,height=574,menubar=no,status=yes,location=no,toolbar=no,scrollbars=no");
	}
}


function openUrlId(){
	closeAllQid();
	var url = document.location.href;
	if(url.indexOf("#")==-1) {
		return -1;
	}
	var params = url.split("#");
	qid = params[1];
	if(qid.length == 0){
		return -1;
	}
	
	if(convertDivToID(qid) > 0){
		id = convertDivToID(qid);
		document.getElementById('qidA'+id).className = 'green_minus';
		document.getElementById('qidA'+id).innerHTML = 'inchide';
		document.getElementById('qidP'+id).style.display = 'block';		
	}
}

function openCloseQid(id){
	if(document.getElementById('qidA'+id).className == 'green_minus'){//inchide
		document.getElementById('qidA'+id).className = 'green_plus';
		document.getElementById('qidA'+id).innerHTML = 'detalii';
		document.getElementById('qidP'+id).style.display = 'none';
	}else
	if(document.getElementById('qidA'+id).className == 'green_plus'){
		//closeAllQid();
		document.getElementById('qidA'+id).className = 'green_minus';
		document.getElementById('qidA'+id).innerHTML = 'inchide';
		document.getElementById('qidP'+id).style.display = 'block';
	}
}


function convertDivToID(div){
	var qidItems = new Array();
	qidItems['internet-banking-gratuit'] = '1';
	qidItems['comisioane-mai-mici'] = '2';
	qidItems['vizualizare-sold-conturi'] = '3';
	qidItems['plati-si-conversii-valutare'] = '4';
	qidItems['constituire-si-spargere-depozite'] = '5';
	qidItems['vizualizare-istoric-tranzactii'] = '6';
	qidItems['extrase-cont-si-alerte-de-notificare'] = '7';
	qidItems['monitorizare-ordine'] = '8';
	qidItems['evolutie-cotatii-valutare'] = '9';
	
	return qidItems[div];
}


function closeAllQid(){
	var id = 0;
	while(true){
		id++;
		var obj = document.getElementById('qidA'+id);
		if(obj == null){
			return -1;
		}
		document.getElementById('qidA'+id).className = 'green_plus';
		document.getElementById('qidA'+id).innerHTML = 'detalii';
		document.getElementById('qidP'+id).style.display = 'none';	
	}
}