var pret_total = 0;
var multiple = 0;
var rb_value="";
var nrps = new Array();
var nrpa = new Array();
var nrpart = new Array();
nrpart[0]=0;
var is_cod = false;

function loadplayer()
{
var flashvars = {};
var params = {};
params.play = "false";
params.loop = "false";
params.menu = "false";
params.quality = "autohigh";
params.scale = "showall";
params.salign = "t";
params.wmode = "direct";
params.devicefont = "false";
params.seamlesstabbing = "true";
params.swliveconnect = "true";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.allownetworking = "all";
var attributes = {};
attributes.id = "player";
// callback swfObject
function alertStatus(e) {
	checkLoad = setTimeout(loadMovie,10);
}
// functie care verifica daca s-a incarcat swf-ul
function loadMovie() {
	try 
		{ 
		var percent = document.getElementById("player").PercentLoaded();
		if (percent<100) checkLoad = setTimeout(loadMovie,10);
		else {
			checkLoad = null;
			document.getElementById("player").loadCover("images/demo.jpg");
			document.getElementById("player").decryptAndConnect(currentApp, currentVid, 0);
		}
	}
	catch (e)
	{
		checkLoad = setTimeout(loadMovie,10);
	}
}


swfobject.embedSWF("flash/player_prima_pagina.swf", "myAlternativeContent", "640", "390", "10.0.22", "flash/expressInstall.swf", flashvars, params, attributes, alertStatus);

jQuery.extend(
  jQuery.expr[ ":" ], 
  { realyvisible : function (a) { return !(jQuery(a).is(':hidden') || jQuery(a).parents(':hidden').length); }}
);


}

function loadplayer_trailerSD()
{
var flashvars = {};
var params = {};
params.play = "false";
params.loop = "false";
params.menu = "false";
params.quality = "autohigh";
params.scale = "showall";
params.salign = "t";
params.wmode = "direct";
params.devicefont = "false";
params.seamlesstabbing = "true";
params.swliveconnect = "true";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.allownetworking = "all";
var attributes = {};
attributes.id = "player";
// callback swfObject
function alertStatus(e) {
	checkLoad = setTimeout(loadMovie,10);
}
// functie care verifica daca s-a incarcat swf-ul
function loadMovie() {
	try 
		{ 
		var percent = document.getElementById("player").PercentLoaded();
		if (percent<100) checkLoad = setTimeout(loadMovie,10);
		else {
			checkLoad = null;
			document.getElementById("player").decryptAndConnect(currentApp, currentVid, 1);
		}
	}
	catch (e)
	{
		checkLoad = setTimeout(loadMovie,10);
	}
}


swfobject.embedSWF("flash/player_trailer_sd.swf", "myAlternativeContent2", "640", "390", "10.0.22", "flash/expressInstall.swf", flashvars, params, attributes, alertStatus);


}


function loadplayer_videoSD()
{
var flashvars = {};
var params = {};
params.play = "false";
params.loop = "false";
params.menu = "false";
params.quality = "autohigh";
params.scale = "showall";
params.salign = "t";
params.wmode = "direct";
params.devicefont = "false";
params.seamlesstabbing = "true";
params.swliveconnect = "true";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.allownetworking = "all";
var attributes = {};
attributes.id = "player";
// callback swfObject
function alertStatus(e) {
	checkLoad = setTimeout(loadMovie,10);
}
// functie care verifica daca s-a incarcat swf-ul
function loadMovie() {
	try 
		{ 
		var percent = document.getElementById("player").PercentLoaded();
		if (percent<100) checkLoad = setTimeout(loadMovie,10);
		else {
			checkLoad = null;
			document.getElementById("player").decryptAndConnect(currentApp, currentVid, 1);
		}
	}
	catch (e)
	{
		checkLoad = setTimeout(loadMovie,10);
	}
}


swfobject.embedSWF("flash/player_trailer_sd.swf", "videoContentSD", "640", "390", "10.0.22", "flash/expressInstall.swf", flashvars, params, attributes, alertStatus);


}


function playDemoVideo()
{

	$("#demoVideoLink").hide();
	$("#divOver").hide();
	$("#demoVideoContent").show();
	$("#divDemoVideo").css("border","none");
	loadplayer_315p();
}


function loadplayer_315p()
{
var flashvars = {};
var params = {};
params.play = "false";
params.loop = "false";
params.menu = "false";
params.width = "560";
params.quality = "autohigh";
params.scale = "showall";
params.salign = "t";
params.wmode = "direct";
params.devicefont = "false";
params.seamlesstabbing = "true";
params.swliveconnect = "true";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.allownetworking = "all";
var attributes = {};
attributes.id = "player";
// callback swfObject
function alertStatus(e) {
	checkLoad = setTimeout(loadMovie,10);
}
// functie care verifica daca s-a incarcat swf-ul
function loadMovie() {
	try 
		{ 
		var percent = document.getElementById("player").PercentLoaded();
		if (percent<100) checkLoad = setTimeout(loadMovie,10);
		else {
			checkLoad = null;
			document.getElementById("player").decryptAndConnect(currentApp, currentVid, 1);
		}
	}
	catch (e)
	{
		checkLoad = setTimeout(loadMovie,10);
	}
}


swfobject.embedSWF("flash/player_trailer_sd.swf", "demoVideoContent", "560", "345", "10.0.22", "flash/expressInstall.swf", flashvars, params, attributes, alertStatus);


}


function showAllArchive()
{
	$('.noshow').fadeIn("slow");
	$('.plinkinscriere').hide();

}

function showArchiveSem(id)
{
	$('#div_arhiva_list_'+id).show();
}

function nextSong ()
{
	if (currentVid_id < (parseInt(firstVid)+parseInt(totalVids))-1)
		location.href = "video.php?seminar_id="+seminar_id+"&video_id="+(parseInt(currentVid_id)+1);
	else
		location.href = "video.php?seminar_id="+seminar_id+"&video_id="+(parseInt(firstVid));
}

function prevSong ()
{
	if (currentVid_id > parseInt(firstVid))
		location.href = "video.php?seminar_id="+seminar_id+"&video_id="+(parseInt(currentVid_id)-1);
	else
		location.href = "video.php?seminar_id="+seminar_id+"&video_id="+(parseInt(firstVid) + parseInt(totalVids) -1);

}


function showTab(id)
{
	if (id!=idselected)
	{
		$('#tab'+idselected).hide();
		$('#atab'+idselected).removeClass("liselected");
		$('#atab'+idselected).addClass("notselected");
		$('#tab'+id).fadeIn("1000");
		$('#atab'+id).toggleClass("liselected");
		idselected = id;
	}
}


function is_empty(id)
{
	var value=$("input#"+id).val();
	var label="label#"+id+"_error";
	if (value=="")
	{
		$(label).html("Acest câmp este obligatoriu!");
		$(label).show();
		return true;
	}
	return false;
}

function verifica(id)
{
	
	var value = $("#"+id).val();
	if ((value == ' ')||(value == ''))
		{
			 $("label#"+id+"_error").html("Acest câmp este obligatoriu!");
			 $("label#"+id+"_error").show();
			 return true;
		}
	return false;
}

function verifica_date(id)
{
	var newid = "label#"+id.substring(0,id.length-3)+"_error";
	var value = $("#"+id).val();
	if ((value == ' ')||(value == ''))
		{
			 $(newid).html("Acest câmp este obligatoriu!");
			 $(newid).show();
			 return true;
		}
	return false;
}

function verifica2(id)
{
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var email = $("#"+id).val();
	if (email == ' ') 
		{
			$("label#email_error").html("Acest câmp este obligatoriu!");
	 		$("label#email_error").show();
	 		return true;
	 	}
	else if(!emailReg.test(email)) 
		{
	 		$("label#email_error").html("Adresa de e-mail nu este validă!");
	 		$("label#email_error").show();
	 		return true;
		}
	return false
}


function not_valid(value)
{
	var userReg = ["/","!",".","@","#","$","%","^","&","*","(",")","_","+","{","}","[","]",";",":","<",">",",",".","/","?","=","-","§","±","`","~"];
	for (i=0; i<userReg.length; i++)
		if ((value.indexOf(userReg[i]))!=-1)
			return true;

	return false;
}


function sterge(tabel, row, id)
{
	var conf = confirm("Esti sigur ca vrei sa stergi aceasta inregistrare?")
	if (conf)
		{
		var post_vars="table="+tabel+"&row="+row+"&id="+id;
		$.ajax({ type: "POST", url: "include/sterge_inreg.php", data: post_vars, success: function() {
								  alert ("s-a sters!"); }
								});
		
		}
}

function login_multiple()
  {
	multiple = 1;
  }
  
  

function nl_button_click()
  {
  		$('.error').hide();
  		$("#spinner").hide();
   		var error = false;
   		var email = $("input#postemail").val();
   		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
   		
   		if (email == ' ')
   			{
   				$("label#email_error").html("Acest câmp nu poate fi gol!");
				$("label#email_error").show();
				error = true;
   			}
   		
   		else if(!emailReg.test(email))
   			{
				 $("label#email_error").html("Adresa de e-mail nu este validă!");
				 $("label#email_error").show();
				 error = true;
			}
		
		if (error == false)
			{
				$.post("include/testduplicate.php?email="+email, {}, function(data) {
					if (data=="0")
						{
						$("#nl_button").hide();
  						$("#spinner").show();
						var form = document.getElementById("frmnewsletter");
						form.action = "/include/addemail.php";
						form.submit();
						}
					else
						{
						$("label#email_error").html("Adresa de e-mail există în baza de date!");
				 		$("label#email_error").show();
						}
					});
				
			}
  }


function ct_button_click()
  {
		var username = $("#login_username").val();
		var password = $("#login_password").val();
		var post_vars = "postusername="+username+"&postpassword="+password;
		$.post("checklogin.php?"+post_vars, {}, function(data) {
			if (data=="ok")
				{
				if (multiple==1) location.href="index.php";
				else location.reload(true);
				}
			else 
				{
					var loginError = document.getElementById("login_error")
					loginError.innerHTML = "Datele introduse sunt greşite.<br/> Încercaţi din nou!";
					$("#login_error").show();
					$("#login_hidden").html("Aţi uitat parola?");
					$("#login_hidden").show();
				}
		});
  }

function ct_out_button_click()
  {
		$.post("logout.php", {}, function(data) {
			location.reload(true);
		});
  }
  
 
function ct_out_button_click_ins()
  {
		$.post("logout2.php", {}, function(data) {
			location.reload(true);
		});
  }


function pas2_click() {
	$('.error').hide();
	$("#pas2_button").hide();
  	$("#spinner").show();
	var error_seminarii = false;
	var post_vars="";
		
	if (!($("input:checkbox:checked").size()))
		{
			$("label#check_error").show();
			error_seminarii=true;
		}
						 
	var nrchk = 0;
	var nrchked = 0;
	var post_seminarii ='';
	var formselect = document.getElementById("formselect");
	
	if (formselect.seminar)
		{						 	 
			if (!(formselect.seminar.length)) 
				{
					if (formselect.seminar.checked)
						{
							nrchked = 1;
							var ch = document.getElementById(formselect.seminar.id);
							var obj_titlu = document.getElementById("titlu_seminar"+formselect.seminar.id);
							titlu = obj_titlu.innerHTML;
							post_seminarii += '&seminar_id0='+formselect.seminar.id+'&pret_0='+ch.value+'&titlu_0='+titlu;
						}
				}
			else 
				{ 
					nrchk = formselect.seminar.length;
					for (i=0; i<nrchk; i++)
						{
							if (formselect.seminar[i].checked == true)
								{
								 	var ch = document.getElementById(formselect.seminar[i].id);
								 	var obj_titlu = document.getElementById("titlu_seminar"+formselect.seminar[i].id);
								 	titlu = obj_titlu.innerHTML;
								 	post_seminarii += '&seminar_id'+nrchked+'='+formselect.seminar[i].id;
								 	nrchked++;
								 }
						}
				}
							 		
			post_seminarii2 = '&nr_seminarii='+nrchked
			post_seminarii = post_seminarii2+post_seminarii;
		}
						 	
	var nrchk = 0;
	var nrchked = 0;
	var post_arhiva ='';
	var formarhiva = document.getElementById("formarhiva");
	if (formarhiva.seminar)
		{
			if (!(formarhiva.seminar.length))
				{
					if (formarhiva.seminar.checked)
						{
					 		nrchked = 1;
							var ch = document.getElementById(formarhiva.seminar.id);
					 		var obj_titlu = document.getElementById("titlu_arhiva"+formarhiva.seminar.id);
					 		titlu = obj_titlu.innerHTML;
					 		post_arhiva += '&arhiva_id0='+formarhiva.seminar.id+'&pret_0='+ch.value+'&titlu_0='+titlu;
					 	}
				}
			else
				{
					nrchk = formarhiva.seminar.length;
					for (i=0; i<nrchk; i++)
						{
							if (formarhiva.seminar[i].checked == true)
								{
									var ch = document.getElementById(formarhiva.seminar[i].id);
									var obj_titlu = document.getElementById("titlu_arhiva"+formarhiva.seminar[i].id);
									titlu = obj_titlu.innerHTML;
									post_arhiva += '&arhiva_id'+nrchked+'='+formarhiva.seminar[i].id;
									nrchked++;
								}
						}
				}
						 		
		 	post_arhiva2 = '&nr_arhiva='+nrchked
			post_arhiva = post_arhiva2+post_arhiva;
		}
			 				
	var error = error_seminarii;
	
	if(error == false) 
		{
			var label = document.getElementById("label_pret");
			total = label.innerHTML;
			post_vars = post_seminarii + post_arhiva +"&nrpart="+nrpart;
						
			$.post("include/pas2.php?"+post_vars, {}, function(data){
				if (data=="ok")
				location.href="inscriere.php?page=2";
			});
			 
		}
	else
		{
				$("#pas2_button").show();
  				$("#spinner").hide();
		}			 
		
	return false;
 
}  
  
  
function pas3_click(NrSem, NrArh)
{
	$('.error').hide();
	$("#pas3_button").hide();
  	$("#spinner").show();
	
	var error = false;					   
	
	/* VALIDARE PARTICIPANTI */
	
	var errorpart = false;
	var participants = new Array();
	var participanta = new Array();
	var participantis = "";
	var participantia = "";
	
	for (var i=0; i<NrSem; i++)
		{
			for (var j=1; j<=nrps[i]; j++)
			{
				var input = document.getElementById("nume"+i+"_"+j);
				var nume = input.value;
				var name = input.name;
				var seminarid = name.substr(name.lastIndexOf("_")+1,name.length-1);
				if ((nume=="Nume")||(nume==" "))
					{
						$("div_eroare_numar_"+i+"_"+j).show();
						$("label#error_nume_"+i+"_"+j).show();
						errorpart = true;
					}
							
				var prenume = document.getElementById("prenume"+i+"_"+j).value;
				if ((prenume=="Prenume")||(prenume==" "))
					{
						$("div_eroare_numar_"+i+"_"+j).show();
						$("label#error_prenume_"+i+"_"+j).show();
						errorpart = true;
					}
					
				var email = document.getElementById("email"+i+"_"+j).value;
				if ((email=="Email")||(email==" "))
					{
						$("div_eroare_numar_"+i+"_"+j).show();
						$("label#error_email_"+i+"_"+j).show();
						errorpart = true;
					}
					
				if (!(errorpart))
					{	
						participants[i] = nume+","+prenume+","+email+","+seminarid;
						participantis = participantis+";"+participants[i];
					}	
			}			
		}

	for (var i=0; i<NrArh; i++)
		{
			for (var j=1; j<=nrpa[i]; j++)
			{
				var input = document.getElementById("nume_arh_"+i+"_"+j);
				var nume = input.value;
				var name = input.name;
				var arhivaid = name.substr(name.lastIndexOf("_")+1,name.length-1);
				if ((nume=="Nume")||(nume==" "))
					{
						$("div_eroare_numar_arh_"+i+"_"+j).show();
						$("label#error_nume_arh_"+i+"_"+j).show();
						errorpart = true;
					}
							
				var prenume = document.getElementById("prenume_arh_"+i+"_"+j).value;
				if ((prenume=="Prenume")||(prenume==" "))
					{
						$("div_eroare_numar_arh_"+i+"_"+j).show();
						$("label#error_prenume_arh_"+i+"_"+j).show();
						errorpart = true;
					}
				
				var email = document.getElementById("email_arh_"+i+"_"+j).value;
				if ((email=="Email")||(email==" "))
					{
						$("div_eroare_numar_arh_"+i+"_"+j).show();
						$("label#error_email_arh_"+i+"_"+j).show();
						errorpart = true;
					}

				if (!(errorpart))
					{	
						participanta[i] = nume+","+prenume+","+email+","+arhivaid;
						participantia = participantia+";"+participanta[i];
					}	
			}			
		}
		
	if (!(errorpart))
			{
				participantis = participantis.substring(1, participantis.length+1);
				participantia = participantia.substring(1, participantia.length+1);
			}


	if (is_cod == false)
	{
			
	/* VALIDARE NUME + PRENUME + EMAIL */

	var errordatepers = false;
		
	var nume = $("input#nume").val();
	if (nume == "")
		 {
		 $("label#nume_error").show();
		 errordatepers=true;
		 }

	var prenume = $("input#prenume").val();
	if (prenume == "")
		 {
		 $("label#prenume_error").show();
		 errordatepers=true;
		 }

	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var email = $("input#email").val();
	if (email == '') 
		{
			$("label#email_error").html("Acest câmp este obligatoriu!");
	 		$("label#email_error").show();
	 		errordatepers=true;
		} 
	else if(!emailReg.test(email)) 
		{
			$("label#email_error").html("Adresa de e-mail nu este validă!");
	 		$("label#email_error").show();
	 		errordatepers=true;
		}					
						
	
	/* VALIDARE DATE FACTURARE */
	
	var errordatefact = false;
	
	var error_persoana = false;
	if (!($("input:radio:checked").size()))
		 {
		 $("label#persoana_error").show();
		 error_persoana=true;
		 }
		 					 
	if (!(error_persoana))
		 {
			 var persoana = ($("input:radio:checked").val());
			 var postpersoana = "&persoana="+persoana;
			  	 
			 if (persoana == "fizica") 
			 	{
				 	var cnp = $("input#cnp").val();
				 	if (cnp == "") 
						{
					 	$("label#cnp_error").show();
					 	errordatefact=true;
					 	}
					 else postpersoana = postpersoana +"&cnp="+cnp;
				 }
			 
			 if (persoana == "juridica")
			 	{
				 	var firma = $("input#firma").val();
				 	firma = firma.replace("&"," %26 ");
				 	if (firma == "") 
						{
					 	$("label#firma_error").show();
					 	errordatefact=true;
					 	}
				 	else postpersoana = postpersoana + "&numefirma="+firma;
				 	
				 	var cui = $("input#cui").val();
				 	if (cui == "") 
						{
					 	$("label#cui_error").show();
					 	errordatefact=true;
					 	}
					 else postpersoana = postpersoana + "&cui="+cui;
					 	
					var nrj = $("input#nrj").val();
					var cont = $("input#cont").val();
					var banca = $("input#banca").val();
					postpersoana = postpersoana + "&nrj="+nrj+"&cont="+cont+"&banca="+banca;
				}
			 	 								 
			 var adresa = $("textarea#adresa").val();
			 if (adresa == "") 
				 {
				 $("label#adresa_error").show();
				 errordatefact=true;
				 }
				 
			 var oras = $("input#oras").val();
			 if (oras == "") 
				 {
				 $("label#oras_error").show();
				 errordatefact=true;
				 }
			
			 var judet = $("select#judet").val();
			 var tara = $("select#tari").val();
			 				 
			 var telefon = $("input#telefon").val();
			 if (telefon == "") 
				 {
				 $("label#telefon_error").show();
				 errordatefact=true;
				 }
	 
		}

	   
	   error = errorpart||errordatefact||errordatepers||error_persoana;
	   					   
					   				   
	   if (error==false)
			   {
  				   var valuecaptcha = $("input#inputcaptcha").val();
  			       $.post("include/test.php?captcha="+valuecaptcha, {}, function(data){
			       
				   if (data=="nu")
				   		  {
				   		  	$("label#captcha_error").html("Caracterele introduse nu corespund cu cele din imagine. Încearcaţi din nou!");
				   		  	$("label#captcha_error").show();
				   		  	document.getElementById('imgcaptcha').src = 'securimage/securimage_show.php?' + Math.random();
				   		  	error = true;
				   		  	$("#pas3_button").show();
  							$("#spinner").hide();
				   		  }
				   
				   if (!(error)) 
				   		  {
				   		  	var post_vars="nr_participanti_s="+nrps+"&participanti_s="+participantis+"&nr_participanti_a="+nrpa+"&participanti_a="+participantia+"&nume="+nume+"&prenume="+prenume+"&email="+email+"&adresa="+adresa+"&oras="+oras+"&judet="+judet+"&tara="+tara+"&telefon="+telefon;
				   		  	post_vars=post_vars+postpersoana;
				   		    $.post("include/pas3.php?"+post_vars, {}, function(data){
					     	   	location.href="inscriere.php?page=3";
					     	})
						  }
				   });
			   }
		
		else
			{
					$("#pas3_button").show();
  					$("#spinner").hide();
			}
	}
		
		
	else
		{
			error = errorpart;
	   	
		if (error==false)
			   {
					var post_vars="nr_participanti_s="+nrps+"&participanti_s="+participantis+"&nr_participanti_a="+nrpa+"&participanti_a="+participantia;
					$.post("include/pas3.php?"+post_vars, {}, function(data){
					    location.href="inscriere.php?page=3";
					})
				}
		
		else
				{
					$("#pas3_button").show();
  					$("#spinner").hide();
				}
		}
	return false;	

}


function pas3_auth_click()
{
	$('.error').hide();
	$("#pas3_button").hide();
  	$("#spinner").show();
	var errordate=false;
	var queryFields="";
	var queryData="";
		
		if ($("#ch_nume").is(':checked'))
			{
				if (verifica_date("nume_tb"))
					errordate = true;
				else 
					{
						queryFields += "nume, ";
						queryData += "'"+$("#nume_tb").val()+"', ";
					}
						
			}
		
		if ($("#ch_prenume").is(':checked'))
			{
				if (verifica_date("prenume_tb"))
					errordate = true;
				else 
					{
						queryFields += "prenume, ";
						queryData += "'"+$("#prenume_tb").val()+"', ";
					}
				
			}
		
		if ($("#ch_email").is(':checked'))
			{
				if (verifica2("email_tb"))
					errordate = true;
				else 
					{
						queryFields += "email, ";
						queryData += "'"+$("#email_tb").val()+"', ";
					}
				
			}
		
		if ($("#ch_adresa").is(':checked'))
			{
				if (verifica_date("adresa_tb"))
					errordate = true;
				else 
					{
						queryFields += "adresa, ";
						queryData += "'"+$("#adresa_tb").val()+"', ";
					}
				
			}
		
		if ($("#ch_oras").is(':checked'))
			{
				if (verifica_date("oras_tb"))
					errordate = true;
				else 
					{
						queryFields += "oras, ";
						queryData += "'"+$("#oras_tb").val()+"', ";
					}
			}
		
		if ($("#ch_judet").is(':checked'))
			{
					queryFields += "judet, ";
					queryData += "'"+$("#judet_tb").val()+"', ";
				
			}
		
		if ($("#ch_tara").is(':checked'))
			{
					queryFields += "tara, ";
					queryData += "'"+$("#tara_tb").val()+"', ";
			}
		
		if ($("#ch_telefon").is(':checked'))
			{
				if (verifica_date("telefon_tb"))
					errordate = true;
				else 
					{
						queryFields += "telefon, ";
						queryData += "'"+$("#telefon_tb").val()+"', ";
					}				
			}
		
		var error_nou = false;
		
		var rb_value_nou = ($("input:radio:checked").val());
		
		if (rb_value_nou!=rb_value)
			{
				if (rb_value_nou=="fizica")
				{
					queryFields += "persoana, ";
					queryData += "'fizica'', ";
					
					var cnp = $("input#cnp").val();	
					if ((cnp=="")||(cnp==" "))
						{
							$("label#cnp_nou_error").show();
							error_nou = true;
						}
					else 
						{
							queryFields += "cui_cnp, ";
							queryData += "'"+cnp+"', ";
						}
				
				}
			
				if (rb_value_nou=="juridica")
				{
					queryFields += "persoana, ";
					queryData += "'juridica', ";
					
					var nume_firma = $("input#nume_firma").val();	
					if ((nume_firma=="")||(nume_firma==" "))
						{
							$("label#nume_firma_nou_error").show();
							error_nou = true;
						}
					else 
						{
							queryFields += "nume_firma, ";
							queryData += "'"+nume_firma+"', ";
						} 
				
					var cui = $("input#cui").val();	
					if ((cui=="")||(cui==" "))
						{
							$("label#cui_nou_error").show();
							error_nou = true;
						}
					else 
						{
							queryFields += "cui_cnp, ";
							queryData += "'"+cui+"', ";
						}
					
					var nrj = $("input#nrj").val();
					var cont_bancar = $("input#cont_bancar").val();
					var banca = $("input#banca").val();
					queryFields += "nrj, cont_bancar, banca, ";
					queryData += "'"+nrj+"', '"+cont_bancar+"', '"+banca+"', "; 

				
				}			
			}
		
		else
			{
				if (rb_value=="fizica")
				{
					if ($("#ch_cnp").is(':checked'))
						{
							if (verifica_date("cnp_tb"))
								errordate = true;
							else 
								{
									queryFields += "cui_cnp, ";
									queryData += "'"+$("#cnp_tb").val()+"', ";
								}
						}
				}		
				
				
				if (rb_value=="juridica")
				{
					if ($("#ch_nume_firma").is(':checked'))
						{
							if (verifica_date("nume_firma_tb"))
								errordate = true;
							else 
								{
									queryFields += "nume_firma, ";
									queryData += "'"+$("#nume_firma_tb").val()+"', ";
								}
						}
					
					if ($("#ch_cui").is(':checked'))
						{
							if (verifica_date("cui_tb"))
								errordate = true;
							else 
								{
									queryFields += "cui_cnp, ";
									queryData += "'"+$("#cui_tb").val()+"', ";
								}
						}
					
					if ($("#ch_nrj").is(':checked'))
					{
							queryFields += "nrj, ";
							queryData += "'"+$("#nrj_tb").val()+"', ";
						
					}
		
					if ($("#ch_cont_bancar").is(':checked'))
					{
							queryFields += "cont_bancar, ";
							queryData += "'"+$("#cont_bancar_tb").val()+"', ";
						
					}
					
					if ($("#ch_banca").is(':checked'))
					{
							queryFields += "banca, ";
							queryData += "'"+$("#banca_tb").val()+"', ";
						
					}
				}		
			}
		
		var error = errordate||error_nou;
		if (!(error))
			{	
				queryFields = queryFields.substring(0, queryFields.length-2);
				queryData = queryData.substring(0, queryData.length-2);
				
				if (queryFields!="")
				{	
					$.post("include/pas3_auth.php?queryfields="+queryFields+"&querydata="+queryData, {}, function(data){
							location.href="inscriere.php?page=3";
					});
				}
				else
					{
						location.href="inscriere.php?page=3";
					}	
			}
	
		else
			{
					$("#pas3_button").show();
  					$("#spinner").hide();
			}
					
		return false;		
		
}


function btn_cod_click()
{
	$("label#cod_error").hide();
	var errorcod = false;
	
	var cod = $("input#cod_client").val();
	if (cod=="")
		{
			errorcod = true;
			$("label#cod_error").html("Vă rugăm să introduceţi un cod!");
	 		$("label#cod_error").show();
		}
	
	if (errorcod == false)
		{
			$.post("include/checkcodclient.php?codclient="+cod, {}, function(data){
			
				if (data==0)
					{
						$("label#cod_error").html("Codul introdus nu este valid!");
	 					$("label#cod_error").show();
					}
				
				else
					{
						is_cod = true;
						$("div#div_datefacturare").hide();
						$("div#div_codclient").show();
						var pcod = document.getElementById("p_codclient");
						pcod.innerHTML = "Codul introdus de dvs. este valid şi corespunde clientului cu numele: "+data+"<br/>Dacă aţi completat şi numele participanţilor, puteţi trece la pasul 3 <br/>pentru a vizualiza sumarul comenzii şi a selecta metoda de plată.<br/><span class='pcategorie' style='font-size:1.1em; margin-left:0;'><a href='javascript:btn_cod_out_click();'>Revenire la date noi de facturare sau alt cod de client...</a></span>";
					}
			
			});
		
		}

	
}


function btn_cod_out_click()
{
	$.post("include/checkoutcodclient.php", {}, function(data){
			
				is_cod = false;
				$("div#div_datefacturare").show();
				$("div#div_codclient").hide();
	});
}


function btn_transfer_click()
{
	var termeni = document.getElementById("termeni");
	if (termeni.checked)
		{
			$("#div_plati").hide();
			$("#spinner_plati").show();
			location.href="include/transfer.php";
		}
	else alert ("Va rugam sa cititi cu atentie termenii si conditiile de inscriere si participare la seminariile online, si sa bifati daca sunteti de acord.");
	


}

function btn_card_click()
{
	var termeni = document.getElementById("termeni");
	if (termeni.checked)
		{
			location.href="include/card.php";
		}
	else alert ("Va rugam sa cititi cu atentie termenii si conditiile de inscriere si participare la seminariile online, si sa bifati daca sunteti de acord.");
}		

function pas1_click_atPas2()
{
	$('#spinner_left').show();
	$('#pas1_button').hide();
	
	$.post ("include/pas1.php", {}, function(data)
		{
			location.href="inscriere.php";
		});
	

}

function isRegisteredUser(nume, prenume)
{
	is_cod = true;
	$("div#div_datefacturare").hide();
	$("div#div_codclient").show();
	var pcod = document.getElementById("p_codclient");
	pcod.innerHTML = "Codul de client introdus corespunde clientului cu numele: "+nume+" "+prenume+"<br/>Dacă aţi completat şi numele participanţilor, puteţi trece la pasul 3 <br/>pentru a vizualiza sumarul comenzii şi a selecta metoda de plată.<br/><span class='pcategorie' style='font-size:1.1em; margin-left:0;'><a href='javascript:btn_cod_out_click();'>Revenire la date noi de facturare sau alt cod de client...</a></span>";
}

function hideFlash()
  {
  	   var target = document.getElementById("player");
  	   
  	   var div = document.createElement("div");
       target.parentNode.insertBefore(div, target);
  	   swfobject.removeSWF("player"); 
	   div.setAttribute("id", "myAlternativeContent");
   
	   $("#divDemo").show();
  } 


function playDemo ()
{
	$("#divDemo").hide();
			$("#myAlternativeContent").show();
			loadplayer_trailerSD();

}


function playVideoSD ()
{
	
	loadplayer_videoSD();

}



/* MAIN FUNCTION */

$(function() {


  $(".demoSampleLink").click(function()
	{

		swfobject.removeSWF("player");
		$("#divOver").show();
		$("#demoVideoLink").show();
		var div = document.createElement("div");
		div.id = "demoVideoContent";
		var upperdiv = document.getElementById("divDemoVideo");
		upperdiv.appendChild(div);

	});


  $('.error').hide();
  if (is_cod==false) $("div#div_codclient").hide();
  
  if (document.body.id=="pageinscriere")
  {
    $("select[@name='listNumar']").change(function(){
    	var val = this.value;
    	var id = this.id;
    	id = id.slice(10);
    	aux = nrpart[id];
    	nrpart[id] = val;
 		
 		var ch = document.getElementById(id);
		var label_pret=document.getElementById("label_pret");
		var pret_nou = ch.value*nrpart[id];
		pret_total = pret_total - (parseInt(ch.value)*aux) + pret_nou;
		label_pret.innerHTML="TOTAL: "+pret_total+" lei (+TVA)"; 
  });
       
    
    
    
  }
  
  if ((document.body.id=="pageadmin"))
  {
  	$("#btn_platit").hide();
  	$("#btn_platit_arh").hide();
  
  	$("select[@name='selectseminar']").click (function()
  	{
  		if (this.value>0)
  		{
	  		if (document.getElementById("div_admin_sem"))
	  			{
					div_admin_sem = document.getElementById("div_admin_sem");
					div_admin_sem.parentNode.removeChild(div_admin_sem);
				}
	  		
	  		var post_vars = "seminar_id="+this.value;
			$.post("include/admin_sem.php?"+post_vars, {}, function(data){
			
			var content = document.getElementById("div_main_admin");
			var div = document.createElement("div");
			div.id = "div_admin_sem";
			div.innerHTML = "<p class='pus'>"+data+"</p>";
			content.appendChild (div);
			$("#btn_platit").show();
			document.getElementById("btn_platit").value = "Vezi doar cei care au platit";
			});
		}
		else
		{
			if (document.getElementById("div_admin_sem"))
	  			{
					div_admin_sem = document.getElementById("div_admin_sem");
					div_admin_sem.parentNode.removeChild(div_admin_sem);
					$("#btn_platit").hide();
				}
		}
	});
		
	$("select[@name='selectarhiva']").click (function()
  	{
  		if (this.value>0)
  		{
	  		if (document.getElementById("div_admin_arh"))
	  			{
					div_admin_arh = document.getElementById("div_admin_arh");
					div_admin_arh.parentNode.removeChild(div_admin_arh);
				}
	  		
	  		var post_vars = "seminar_id="+this.value;
			$.post("include/admin_arh.php?"+post_vars, {}, function(data){
			
			var content = document.getElementById("div_arhiva_admin");
			var div = document.createElement("div");
			div.id = "div_admin_arh";
			div.innerHTML = "<p class='pus'>"+data+"</p>";
			content.appendChild (div);
			$("#btn_platit_arh").show();
			document.getElementById("btn_platit_arh").value = "Vezi doar cei care au platit";
			});
		}
		else
		{
			if (document.getElementById("div_admin_arh"))
	  			{
					div_admin_arh = document.getElementById("div_admin_arh");
					div_admin_arh.parentNode.removeChild(div_admin_arh);
					$("#btn_platit_arh").hide();
				}
		}
	});
	
	
	$("select[@name='selecttabel']").click (function()
  	{
  		if (this.value!="none")
  		{
	  		if (document.getElementById("div_admin_table"))
	  			{
					div_admin_table = document.getElementById("div_admin_table");
					div_admin_table.parentNode.removeChild(div_admin_table);
				}
	  		
	  		var post_vars = "table="+this.value;
			$.post("include/admin_table.php?"+post_vars, {}, function(data){
			
			var content = document.getElementById("div_table_admin");
			var div = document.createElement("div");
			div.id = "div_admin_table";
			div.innerHTML = "<p class='pus'>"+data+"</p>";
			content.appendChild (div);
			});
		}
		else
		{
			if (document.getElementById("div_admin_table"))
	  			{
					div_admin_table = document.getElementById("div_admin_table");
					div_admin_table.parentNode.removeChild(div_admin_table);
				}
		}
	});
	
	
	$("#btn_platit").click (function()
	{
	
		if (this.value=="Vezi pe toti")
		{
			this.value="Incarca...";
			var parent = document.getElementById("div_main_admin");
			var tr = parent.getElementsByTagName("tr");
			for (var i=1; i<tr.length; i++)
					$("#"+tr[i].id).show();
			this.value="Vezi doar cei care au platit";	
		}
		
		else
		{
			this.value="Incarca...";
			var parent = document.getElementById("div_main_admin");
			var td = parent.getElementsByTagName("td");

			var usr = 0;
				for (var i=4; i<td.length; i++)
					{
						if (i%4==3)
							{
							usr = td[i-3].innerHTML;
							if (td[i].innerHTML!="conf")
								{
									$("#"+usr+"usr").hide();
								}
							}
					}
			this.value="Vezi pe toti";
		}
	});
	
	$("#btn_platit_arh").click (function()
	{
	
		if (this.value=="Vezi pe toti")
		{
			this.value="Incarca...";
			var parent = document.getElementById("div_arhiva_admin");
			var tr = parent.getElementsByTagName("tr");
			for (var i=1; i<tr.length; i++)
				$("#"+tr[i].id).show();
			this.value="Vezi doar cei care au platit";	
		}
		
		else
		{
			this.value="Incarca...";
			var parent = document.getElementById("div_arhiva_admin");
			var td = parent.getElementsByTagName("td");
			var usr = 0;
				for (var i=4; i<td.length; i++)
					{
						if (i%4==3)
							{
							usr = td[i-3].innerHTML;
							if (td[i].innerHTML!="conf")
								{
									$("#"+usr+"arh").hide();
								}
							}
					}
			this.value="Vezi pe toti";
		}
	});
	  
  }


  
  
    if (multiple == 1)
	{
		$("#login_error").html("Aţi fost autentificat pe alt calculator. Încercaţi din nou!");
		$("#login_error").show();
	}
  $('#spinner').hide();
  $('#spinner_left').hide();
  
  $('.div_input_fizica').hide();
  $('.div_input_juridica').hide();
  $('.div_input').hide();
  $('#modif_parola').hide();
  $('.div_cont_input_fizica').hide();
  $('.div_cont_input_juridica').hide();
  
  
   
  if (document.body.id=="pagecont")
  {
   
  	rb_value = ($("input:radio:checked").val());
  	var rb_value_nou = rb_value;
  	if (rb_value=="juridica")
  		$('.div_cont_input_juridica').show();
  	else
  		$('.div_cont_input_fizica').show();
  		
  	$("input[@name='cont_persoana']").click (function ()
  	{
  		rb_value_nou = ($("input:radio:checked").val());
  		if (rb_value=="fizica")
  			{
	  			if (rb_value_nou=="juridica")
	  			{
		  		  	$('.div_cont_input_juridica').show();
		  			$('.div_cont_input_fizica').hide();
		  			
		  			var obj_firma = document.getElementById("firma");
		  			obj_firma.disabled=false;
		  			$("input#ch_firma").hide();
		  			var obj_cui = document.getElementById("cui");
		  			obj_cui.disabled=false;
		  			obj_cui.value=" ";
		  			$("input#ch_cui").hide();
		  			var obj_nrj = document.getElementById("nrj");
		  			obj_nrj.disabled=false;
		  			$("input#ch_nrj").hide();
	  			}
	  			else
	  			{
	  				$('.div_cont_input_fizica').show();
	  				$('.div_cont_input_juridica').hide();
	  			}
			}
		  		
  		if (rb_value=="juridica")
  			{
	  			if (rb_value_nou=="fizica")
	  			{
		  			$('.div_cont_input_fizica').show();
		  			$('.div_cont_input_juridica').hide();
		  			
		  			var obj_cnp = document.getElementById("cnp");
		  			obj_cnp.disabled=false;
		  			obj_cnp.value=" ";
		  			$("input#ch_cnp").hide();
		 		}
		 		else
		 		{
		 			$('.div_cont_input_juridica').show();
		 			$('.div_cont_input_fizica').hide();
		 		}
		 	}
	  
	  });
  }
  
  

  
 
  
  $("#btn_intrebare").click(function() {
  
  		  var input = document.getElementById("intrebare");
  		  nume = input.name;
  		  text = input.value;
  		  input.value="";
  		addintrebare(nume, text);
  
    });
  
  
  
  $("#btn_tehnic").click(function() {
  
  		  var input = document.getElementById("tehnic");
  		  nume = input.name;
  		  text = input.value;
  		  input.value="";
  		addtehnic(nume, text);
  
    });
 
  $("input[@name='ch_modifica']").click (function()
  {
  	var ch = document.getElementById(this.id);
  	var textbox_id = (ch.id).substr(3);
  	var textbox = document.getElementById(textbox_id);
  	
  	if (ch.checked)
  		{
  		textbox.disabled=false;
  		ch.disabled=true;
  		}
   		
  });
  
  $("input[@name='checkbox_password']").click (function()
  {
  	var ch = document.getElementById(this.id);
  	if (ch.checked)
  		$('#modif_parola').show();
  	else
  		$('#modif_parola').hide();
  });
  
  // Daca se selecteaza un seminar;
    
  $("input[@name='seminar']").click (function()
									  {
									  var ch = document.getElementById(this.id);
									  var label_pret=document.getElementById("label_pret");
									  if (ch.checked)
									  {
									  	pret_total+=(parseInt(ch.value)*parseInt(nrpart[ch.id]));
									  	label_pret.innerHTML="TOTAL: "+pret_total+" lei (+TVA)"; 
									  	$("#div_input_numar_"+ch.id).show();
									  }
									  else 
									  {
									  	pret_total-=(parseInt(ch.value)*parseInt(nrpart[ch.id]));
									  	label_pret.innerHTML="TOTAL: "+pret_total+" lei (+TVA)"; 
									  	$("#div_input_numar_"+ch.id).hide();
									  }
									  
									  });
		
  $('.input_tb_date').hide();
  $('.selecthidden').hide();							  
   
  $("input[@name='ch_date']").click (function()
  {
  	var ch = document.getElementById(this.id);
  	id = (ch.id).substr(3);
  	
   	if (ch.checked)
  		{
  			$("#"+id+"_p").hide();
  			$("#"+id+"_tb").show();
  		}
  	else
  		{
  			$("#"+id+"_error").hide();
			$("#"+id+"_p").show();
  			$("#"+id+"_tb").hide();
  		}
  });
  
 
  if (document.body.id=="pageinscriere")
  {
  
  	$('.div_juridica').hide();
  	$('.div_input_juridica').hide();
   	$('.div_fizica').hide();
   	$('.div_input_fizica').hide();
  
    rb_value = ($("input:radio:checked").val());
  	if (rb_value=="juridica")
  		$('.div_juridica').show();
  	else
  		$('.div_fizica').show();
  	  
  }
 
  $("#radio1_date").click(function() {
  		$('.error').hide();
  	 	$('.div_input_juridica').hide();
  		$('.div_juridica').hide();	
  		
  		if (rb_value=="fizica")
  			$('.div_fizica').show();
  		else
  			$('.div_input_fizica').show();
  });
  
  $("#radio2_date").click(function() {
  		$('.error').hide();	
  		$('.div_fizica').hide();
  		$('.div_input_fizica').hide();
		
		if (rb_value=="juridica")
  			$('.div_juridica').show();
  		else
  			$('.div_input_juridica').show();
  });
 
    
  
  $("#btn_pas2").click(function() {
					   
					   $('.error').hide();
					   
					   var error = false;					   
					   var erroruser = false;
					   var errorpass = false;
					   var errorpass2 = false;
					   
					   if (is_empty("usernamenou"))
						   erroruser = true;
					   
					   if (!(erroruser))
					   {
						   var value = $("input#usernamenou").val();
						   if (value.length<6)
						   {
							   $("label#usernamenou_error").html("Username-ul trebuie sa aiba minim 6 caractere!");
							   $("label#usernamenou_error").show();
							   erroruser = true;
						   }
						
						   else if (not_valid(value))
						   {
							   $("label#usernamenou_error").html("Unele caracterere introduse nu sunt permise!");
							   $("label#usernamenou_error").show();
							   erroruser = true;
						   }
					   }
					   
					   if (is_empty("passwordnou"))
							errorpass = true;
					   					   
					   if (!(errorpass))
					   {
						   var value = $("input#passwordnou").val();
						   if (value.length<6)
						   {
							   $("label#passwordnou_error").html("Parola trebuie sa aiba minim 6 caractere!");
							   $("label#passwordnou_error").show();
							   errorpass = true;
						   }
						   else if (not_valid(value))
						   {
							   $("label#passwordnou_error").html("Unele caracterere introduse nu sunt permise!");
							   $("label#passwordnou_error").show();
							   errorpass = true;
						   }
					   }
					   
					   if (is_empty("passwordnou2"))
						   errorpass2 = true;
					   			   
					   if ((!(errorpass))&&(!(errorpass2)))
					   {
						   var value = $("input#passwordnou").val();
						   var value2 = $("input#passwordnou2").val();
						   if (value!=value2)
							   {
							   errorpass2 = true;
							   $("label#passwordnou2_error").html("Parolele nu corespund!");
							   $("label#passwordnou2_error").show();
							   }
					   }
					   
					   error = erroruser||errorpass||errorpass2;
					   
					   				   
					   if (!(error))
					   {
					       var valueuser = $("input#usernamenou").val();
					       var valuecaptcha = $("input#inputcaptcha").val();
					       $.post("include/test.php?captcha="+valuecaptcha+"&usernamenou='"+valueuser+"'", {}, function(data){
						   if (data=="e") 
								  {
									  $("label#usernamenou_error").html("Acest user este deja inscris!");
									  $("label#usernamenou_error").show();
									  error = true;
								  }
								 
						   if (data=="captchanu")
						   		  {
						   		  	$("label#captcha_error").html("Caracterele introduse nu corespund cu cele din imagine. Încearcă din nou!");
						   		  	$("label#captcha_error").show();
						   		  	error = true;
						   		  }
						   
						   if (data=="ecaptchanu")
						   		  {
						   		  	$("label#usernamenou_error").html("Acest user este deja inscris!");
									$("label#usernamenou_error").show();
									$("label#captcha_error").html("Caracterele introduse nu corespund cu cele din imagine. Încearcă din nou!");
						   		  	$("label#captcha_error").show();
						   		  	document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random();
						   		  	error = true;						   		  
						   		  }
								 
						   if (!(error)) 
							     $("form#frmiu").submit();
								 
						   });
					   }
					   		   
					   				   
   return true;
   });	


  $("#radio1").click(function() {
  		$("label#persoana_error").hide();
   		$('.error').hide();
  		$('.div_input_fizica').show();
  		$('.div_input_juridica').hide();
  		$('.div_input').show();  
  });
  
  $("#radio2").click(function() {
   		$("label#persoana_error").hide();
  		$('.div_input_fizica').hide();
  		$('.div_input_juridica').show();
  		$('.div_input').show();  
  });
  
   
  $("#btn_pas3").click(function() {
  
  						  
						 $('.error').hide();
						 
						 var error_persoana = false;
						 var error_seminarii = false;
						 
						 if (!($("input:radio:checked").size()))
						 {
						 $("label#persoana_error").show();
						 error_persoana=true;
						 }
						 
						 if (!($("input:checkbox:checked").size()))
						 {
						 $("label#check_error").show();
						 error_seminarii=true;
						 }
						 
						 {
						 	var nrchk = 0;
						 	var nrchked = 0;
						 	var post_seminarii ='';
						 	var formselect = document.getElementById("formselect");
						 	if (formselect.seminar)
						 	{						 	 
							 	if (!(formselect.seminar.length)) 
							 		{
								 		if (formselect.seminar.checked)
								 		{
								 			nrchked = 1;
								 			var ch = document.getElementById(formselect.seminar.id);
								 			var obj_titlu = document.getElementById("titlu_seminar"+formselect.seminar.id);
								 			titlu = obj_titlu.innerHTML;
								 			post_seminarii += '&seminar_id0='+formselect.seminar.id+'&pret_0='+ch.value+'&titlu_0='+titlu;
								 		}
							 		}
							 		else 
							 		{ 
								 		nrchk = formselect.seminar.length;
								 	 	for (i=0; i<nrchk; i++)
								 		{
								 			if (formselect.seminar[i].checked == true)
								 			{
								 				var ch = document.getElementById(formselect.seminar[i].id);
								 				var obj_titlu = document.getElementById("titlu_seminar"+formselect.seminar[i].id);
								 				titlu = obj_titlu.innerHTML;
								 				post_seminarii += '&seminar_id'+nrchked+'='+formselect.seminar[i].id+'&pret_'+nrchked+'='+ch.value+'&titlu_'+nrchked+'='+titlu;
								 				nrchked++;
								 			}
								 		}
							 		}
							 		
							 	post_seminarii2 = '&nr_seminarii='+nrchked
							 	post_seminarii = post_seminarii2+post_seminarii;
						 	
						 	}
						 	
						 	var nrchk = 0;
						 	var nrchked = 0;
						 	var post_arhiva ='';
						 	var formarhiva = document.getElementById("formarhiva");
						 	if (formarhiva.seminar)
						 	{
						 		if (!(formarhiva.seminar.length))
						 		{
						 			if (formarhiva.seminar.checked)
						 			{
						 				nrchked = 1;
						 				var ch = document.getElementById(formarhiva.seminar.id);
						 				var obj_titlu = document.getElementById("titlu_arhiva"+formarhiva.seminar.id);
						 				titlu = obj_titlu.innerHTML;
						 				post_arhiva += '&arhiva_id0='+formarhiva.seminar.id+'&pret_0='+ch.value+'&titlu_0='+titlu;
						 			}
						 		}
							 	else
							 	{
								 	nrchk = formarhiva.seminar.length;
								 	for (i=0; i<nrchk; i++)
								 		{
								 			if (formarhiva.seminar[i].checked == true)
								 				{
								 				var ch = document.getElementById(formarhiva.seminar[i].id);
								 				var obj_titlu = document.getElementById("titlu_arhiva"+formarhiva.seminar[i].id);
								 				titlu = obj_titlu.innerHTML;
								 				post_arhiva += '&arhiva_id'+nrchked+'='+formarhiva.seminar[i].id+'&pret_a_'+nrchked+'='+ch.value+'&titlu_a_'+nrchked+'='+titlu;
								 				nrchked++;
								 				}
								 		}
							 	}
							 		
							 	post_arhiva2 = '&nr_arhiva='+nrchked
							 	post_arhiva = post_arhiva2+post_arhiva;
			 				}
			 				
						 }
						 						 
						 var error = true;
						 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
						 
						 if (!(error_persoana))
						 {
							 error = false;	
							 
							 var persoana = ($("input:radio:checked").val());
							 						 			 
							 var email = $("input#email").val();
							 if (email == '') 
							 {
								 $("label#email_error").html("Acest câmp este obligatoriu!");
								 $("label#email_error").show();
								 error = true;
							 } 
							 else if(!emailReg.test(email)) 
							 {
								 $("label#email_error").html("Adresa de e-mail nu este validă!");
								 $("label#email_error").show();
								 error = true;
							 }
							 
							 var nume = $("input#nume").val();
							 if (nume == "")
							 	 {
							 	 $("label#nume_error").show();
							 	 error=true;
							 	 }
							 	 
							 if (persoana == "fizica") 
							 	{
							 	var cnp = $("input#cnp").val();
							 	if (cnp == "") 
									{
								 	$("label#cnp_error").show();
								 	error=true;
								 	}
								 }
							 
							 if (persoana == "juridica")
							 	{
							 	var firma = $("input#firma").val();
							 	if (firma == "") 
									{
								 	$("label#firma_error").show();
								 	error=true;
								 	}
							 	
							 	var cui = $("input#cui").val();
							 	if (cui == "") 
									{
								 	$("label#cui_error").show();
								 	error=true;
								 	}
								 	
								var nrj = $("input#nrj").val();
							 	if (nrj == "") 
									{
								 	$("label#nrj_error").show();
								 	error=true;
								 	}
								}
							 	 								 
							 var adresa = $("textarea#adresa").val();
							 if (adresa == "") 
								 {
								 $("label#adresa_error").show();
								 error=true;
								 }
								 
							 var oras = $("input#oras").val();
							 if (oras == "") 
								 {
								 $("label#oras_error").show();
								 error=true;
								 }
								 
							 var telefon = $("input#telefon").val();
							 if (telefon == "") 
								 {
								 $("label#telefon_error").show();
								 error=true;
								 }
					 
						}
							
												 						 
						 error = error_seminarii||error_persoana||error;
						 
						 
						 if(error == false) {
						 
						 $("#btn_pas3").hide();
  						 $("#spinner").show();
						 
						 var label = document.getElementById("label_pret");
						 total = label.innerHTML;
						 
						 if (persoana == "fizica")
						 	var post_vars = 'persoana=' + persoana + '&nume='+ nume + '&email=' + email + '&cnp=' + cnp + '&adresa=' + adresa + '&oras=' + oras + '&telefon=' + telefon;
						 	
						 if (persoana == "juridica")
						 	var post_vars = 'persoana=' + persoana + '&nume='+ nume + '&firma=' + firma + '&email=' + email + '&cui=' + cui + '&nrj=' + nrj + '&adresa=' + adresa + '&oras=' + oras + '&telefon=' + telefon;
						 	
					 
						 post_vars = post_vars + post_seminarii + post_arhiva + '&total='+ total;
						 
					 $.ajax({ type: "POST", url: "include/post.php", data: post_vars, success: function() {
								  location.href="confirm.php"; }
								});
										
						 }
						 
						 
		 return false;
		 });



  $("#btn_pas3_user").click(function() {	
  		
  		$('.error').hide();
  		
  		var error_seminarii=false;
  
  		if (!($("input:checkbox:checked").size()))
						 {
						 $("label#check_error").show();
						 error_seminarii=true;
						 }
						 
						 if (!(error_seminarii))
						 {
						 	var nrchk = 0;
						 	var nrchked = 0;
						 	var post_seminarii ='';
						 	var formselect = document.getElementById("formselect");
						 	if (formselect.seminar)
						 	{						 	 
							 	if (!(formselect.seminar.length)) 
							 		{
								 		if (formselect.seminar.checked)
								 		{
								 			nrchked = 1;
								 			var ch = document.getElementById(formselect.seminar.id);
								 			var obj_titlu = document.getElementById("titlu_seminar"+formselect.seminar.id);
								 			titlu = obj_titlu.innerHTML;
								 			post_seminarii += '&seminar_id0='+formselect.seminar.id+'&pret_0='+ch.value+'&titlu_0='+titlu;
								 		}
							 		}
							 		else 
							 		{ 
								 		nrchk = formselect.seminar.length;
								 	 	for (i=0; i<nrchk; i++)
								 		{
								 			if (formselect.seminar[i].checked == true)
								 			{
								 				var ch = document.getElementById(formselect.seminar[i].id);
								 				var obj_titlu = document.getElementById("titlu_seminar"+formselect.seminar[i].id);
								 				titlu = obj_titlu.innerHTML;
								 				post_seminarii += '&seminar_id'+nrchked+'='+formselect.seminar[i].id+'&pret_'+nrchked+'='+ch.value+'&titlu_'+nrchked+'='+titlu;
								 				nrchked++;
								 			}
								 		}
							 		}
							 		
							 	post_seminarii2 = '&nr_seminarii='+nrchked
							 	post_seminarii = post_seminarii2+post_seminarii;
						 	
						 	}
						 	
						 	var nrchk = 0;
						 	var nrchked = 0;
						 	var post_arhiva ='';
						 	var formarhiva = document.getElementById("formarhiva");
						 	if (formarhiva.seminar)
						 	{
						 		if (!(formarhiva.seminar.length))
						 		{
						 			if (formarhiva.seminar.checked)
						 			{
						 				nrchked = 1;
						 				var ch = document.getElementById(formarhiva.seminar.id);
						 				var obj_titlu = document.getElementById("titlu_arhiva"+formarhiva.seminar.id);
						 				titlu = obj_titlu.innerHTML;
						 				post_arhiva += '&arhiva_id0='+formarhiva.seminar.id+'&pret_0='+ch.value+'&titlu_0='+titlu;
						 			}
						 		}
							 	else
							 	{
								 	nrchk = formarhiva.seminar.length;
								 	for (i=0; i<nrchk; i++)
								 		{
								 			if (formarhiva.seminar[i].checked == true)
								 				{
								 				var ch = document.getElementById(formarhiva.seminar[i].id);
								 				var obj_titlu = document.getElementById("titlu_arhiva"+formarhiva.seminar[i].id);
								 				titlu = obj_titlu.innerHTML;
								 				post_arhiva += '&arhiva_id'+nrchked+'='+formarhiva.seminar[i].id+'&pret_a_'+nrchked+'='+ch.value+'&titlu_a_'+nrchked+'='+titlu;
								 				nrchked++;
								 				}
								 		}
							 	}
							 		
							 	post_arhiva2 = '&nr_arhiva='+nrchked
							 	post_arhiva = post_arhiva2+post_arhiva;
			 				}
			 				
						 }
						 
						 if(error_seminarii == false) {
						 						 
						 $("#btn_pas3_user").hide();
  						 $("#spinner").show();

						 
						 var label = document.getElementById("label_pret");
						 total = label.innerHTML;
						 
						 
						 post_vars = 'total='+ total + post_seminarii + post_arhiva; 
						 
				 
						$.ajax({ type: "POST", url: "include/post2.php", data: post_vars, success: function() {
								  location.href="confirm.php"; }
								}); 
					
						}
  			return false;		
  			});
  
  
  $("input#btn_recov").click(function()
  {
		$('.error').hide();  

 		var error = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
						 
		var email = $("input#email").val();
				if (email == '') 
					 {
						 $("label#email_error").html("Acest câmp este obligatoriu!");
						 $("label#email_error").show();
						 error = true;
					 } 
				else if(!emailReg.test(email)) 
					 {
						 $("label#email_error").html("Adresa de e-mail nu este validă!");
						 $("label#email_error").show();
						 error = true;
					 }
							 
		var username = $("input#username").val();
			if (username == "")
				 	 {
				 	 $("label#username_error").show();
				 	 error=true;
				 	 }
		
		if (error==false)
			{
				 $.post("include/usernametest.php?username="+username+"&email="+email, {}, function(data){
				 	if (data==1) {
				 		var form = document.getElementById("formpassrecov");
				 		form.action = "passwordgen.php?username="+username+"&email="+email;
				 		$("form#formpassrecov").submit();
				  	}
				 		
				 	else {
				 		$("label#form_error").html("Datele introduse nu corespund în baza de date!<br/> Încercați din nou!");
				 		$("label#form_error").show();
				 	}
				 });
			}

  });
  
  
  $("#btn_propunere").click(function()
  {
  		$('.error').hide();
  		var error = false;
  		
  		var email_error = false;
   		var email = $("input#propunere_email").val();
   		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
   		
   		if (email == '')
   			{
   				$("label#propunere_email_error").html("Introduceți adresa dvs. de e-mail!");
				$("label#propunere_email_error").show();
				email_error = true;
   			}
   		
   		else if(!emailReg.test(email))
   			{
				 $("label#propunere_email_error").html("Adresa de e-mail nu este validă!");
				 $("label#propunere_email_error").show();
				 email_error = true;
			}

		var ta_error = false;
		var ta = $("textarea#propunere_mesaj").val();
				
		if (ta == '')
			{
				$("label#propunere_mesaj_error").show();
				ta_error = true;
			}
		
		error = ta_error||email_error;
		
		if (!(error))
			{
				$("form#frmpropunere").submit();
			}
  
  });
  
  $("#btn_contactsend").click(function()
  {
  		$('.error').hide();
  		var error = false;
   		
   		var email_error = false;
   		var email = $("input#contact_email").val();
   		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
   		
   		if (email == '')
   			{
   				$("label#contact_email_error").html("Introduceti adresa dvs. de e-mail!");
				$("label#contact_email_error").show();
				email_error = true;
   			}
   		
   		else if(!emailReg.test(email))
   			{
				 $("label#contact_email_error").html("Adresa de e-mail nu este validă!");
				 $("label#contact_email_error").show();
				 email_error = true;
			}
			
		var ta_error = false;
		var ta = $("textarea#contact_mesaj").val();
				
		if (ta == '')
			{
				$("label#contact_mesaj_error").show();
				ta_error = true;
			}
		
		error = ta_error||email_error;
		
		if (!(error))
		  {	
		    var valuecaptcha = $("input#inputcaptcha").val();
		    	       
		    $.post("include/test2.php?captcha="+valuecaptcha, {}, function(data){
		    	
		   	if (data=="captchanu")
			   		  {
			   		  	$("label#captcha_error").html("Caracterele introduse nu corespund cu cele din imagine. Încearcă din nou!");
			   		  	$("label#captcha_error").show();
			   		  	document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random();
			   		  	error = true;
			   		  }
			
			if (!error)
				{
					$("form#frmcontact").submit();
				}
			   		  
			});
  
		}
  });
  
  $("#btn_commentsend").click(function()
  {
  		$('.error').hide();
  		var error = false;
   		
   		var email_error = false;
   		var email = $("input#comment_email").val();
   		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
   		
   		var nume_error = false;
   		var nume = $("input#comment_nume").val();
   		if (nume == '')
   			{
   				$("label#comment_nume_error").html("Introduceți numele dvs.!");
				$("label#comment_nume_error").show();
				nume_error = true;
   			}
   		
   		if (email == '')
   			{
   				$("label#comment_email_error").html("Introduceți adresa dvs. de e-mail!");
				$("label#comment_email_error").show();
				email_error = true;
   			}
   		
   		else if(!emailReg.test(email))
   			{
				 $("label#comment_email_error").html("Adresa de e-mail nu este validă!");
				 $("label#comment_email_error").show();
				 email_error = true;
			}
			
		var ta_error = false;
		var ta = $("textarea#comment_mesaj").val();
				
		if (ta == '')
			{
				$("label#comment_mesaj_error").show();
				ta_error = true;
			}
		
		error = ta_error||email_error||nume_error;
		
		  
			if (!error)
				{
					$("form#frmcomentariu").submit();
				}
			   		  

  
		
  });

  
  
  $("input#btn_contactsend_l").click(function()
  {
  	$('.error').hide();
  	var ta_error = false;
	var ta = $("textarea#contact_mesaj").val();

	if (ta == '')
			{
				$("label#contact_mesaj_error").show();
				ta_error = true;
			}
	
	if (!(ta_error))
	{
		$("form#frmcontact_l").submit();
	}
  
  });
  
  
    	
  $("input#btn_modifica").click(function()
  {
  		
  		$('.error').hide();
  		
  		//validare date
  		var post_vars = '';
  		var errordate = false;
  		var errorpass = false;
 		
 		if (rb_value == rb_value_nou)
 		{
 			post_vars = 'persoana='+rb_value;
			
			if ($("#ch_nume").is(':checked'))
				{
					if (verifica("nume"))
						errordate = true;
					else post_vars += '&nume='+($("#nume").val());
				}
			if ($("#ch_email").is(':checked'))
				{
					if (verifica2("email"))
						errordate = true;
					else post_vars += '&email='+($("#email").val());
				}
			
			if ($("#ch_adresa").is(':checked'))
				{
					if (verifica("adresa"))
						errordate = true;
					else post_vars += '&adresa='+($("#adresa").val());
				}
			if ($("#ch_oras_judet").is(':checked'))
				{
					if (verifica("oras_judet"))
						errordate = true;
					else post_vars += '&oras_jude='+($("#oras_jude").val());
				}
			if ($("#ch_telefon").is(':checked'))
				{
					if (verifica("telefon"))
						errordate = true;
					else post_vars += '&telefon='+($("#telefon").val());
				}
	
			if (rb_value == "fizica")
			{
				if ($("#ch_cnp").is(':checked'))
					if (verifica("cnp"))
							errordate = true;
						else post_vars += '&cui_cnp='+($("#cnp").val());
			}
			
			if (rb_value == "juridica")
			{
				if ($("#ch_cui").is(':checked'))
					if (verifica("cui"))
						errordate = true;
					else post_vars += '&cui_cnp='+($("#cui").val());
				
				if ($("#ch_nrj").is(':checked'))				
					if (verifica("nrj"))
						errordate = true;
					else post_vars += '&nrj='+($("#nrj").val());
				
				if ($("#ch_nume_firma").is(':checked'))
					if (verifica("nume_firma"))
						errordate = true;
					else post_vars += '&nume_firma='+($("#nume_firma").val());
			}	

 		}
 		
 		else if (rb_value != rb_value_nou)
 		{
 			post_vars = 'persoana='+rb_value_nou;
 			
			if ($("#ch_nume").is(':checked'))
				{
					if (verifica("nume"))
						errordate = true;
					else post_vars += '&nume='+($("#nume").val());
				}
			if ($("#ch_email").is(':checked'))
				{
					if (verifica2("email"))
						errordate = true;
					else post_vars += '&email='+($("#email").val());
				}
			
			if ($("#ch_adresa").is(':checked'))
				{
					if (verifica("adresa"))
						errordate = true;
					else post_vars += '&adresa='+($("#adresa").val());
				}
			if ($("#ch_oras_judet").is(':checked'))
				{
					if (verifica("oras_judet"))
						errordate = true;
					else post_vars += '&oras_jude='+($("#oras_jude").val());
				}
			if ($("#ch_telefon").is(':checked'))
				{
					if (verifica("telefon"))
						errordate = true;
					else post_vars += '&telefon='+($("#telefon").val());
				}
	
			if (rb_value_nou == "fizica")
			{
				if (verifica("cnp"))
					{
					errordate = true;
					}
				else post_vars += '&cui_cnp='+($("#cnp").val());
			}
			
			if (rb_value_nou == "juridica")
			{
				if (verifica("cui"))
					errordate = true;
				else post_vars += '&cui_cnp='+($("#cui").val());
				
				if (verifica("nrj"))
					errordate = true;
				else post_vars += '&nrj='+($("#nrj").val());
				
				if (verifica("nume_firma"))
					errordate = true;
				else post_vars += '&nume_firma='+($("#nume_firma").val());
			}	
 		}
 		  		
  		//modificare parola
  		
  		var ch_modpass = document.getElementById("checkbox_password");
  		if (ch_modpass.checked)
  			{
  				
				if (is_empty("passwordold")) errorpass = true;
				if (is_empty("passwordnew")) errorpass = true;
				if (is_empty("passwordnew2")) errorpass = true;
				
				
									   
				if (!(errorpass))
				{
					var value = $("input#passwordnew").val();
					if (value.length<6)
					{
						$("label#passwordnew_error").html("Parola trebuie sa aiba minim 6 caractere!");
						$("label#passwordnew_error").show();
						errorpass = true;
					}
					else if (not_valid(value))
					{
						$("label#passwordnew_error").html("Unele caracterere introduse nu sunt permise!");
						$("label#passwordnew_error").show();
						errorpass = true;
					}
				
					var value2 = $("input#passwordnew2").val();
					if (value!=value2)
					{
						errorpass = true;
						$("label#passwordnew2_error").html("Parolele nu corespund!");
						$("label#passwordnew2_error").show();
					}
				}
				
				var error = errordate || errorpass;
				
				
				if (!(error))
					{
						
						var errorpasstest=false;
						var valueold = $("input#passwordold").val();
						   $.get("include/testpass.php?password='"+valueold+"'", {}, function(data){
						   
  					       if (data=="e") 
								  {
									  $("label#passwordold_error").html("Parola veche introdusa nu este corecta!");
									  $("label#passwordold_error").show();
									  errorpasstest = true;
								  }
								 
						   if (!(errorpasstest)) 
							      {
						      	  	  post_vars += "&password="+value;
						      	  	  $.ajax({ type: "POST", url: "include/post3.php", data: post_vars, success: function() {
								 			 
								 			 if (typeof(window['seminarid']) != "undefined")
								 			 	location.href="confirm.php?seminar_id="+seminarid;
								 			 else
								 			 	location.href="confirm.php?redirect=home";
								 			  }
											}); 
							      }
						});
					}

  			}
  			
  		else 
  			{
  				if (errordate == false)
  					if (!((post_vars == "persoana=juridica") || (post_vars == "persoana=fizica")))
  						{
  							
  							$.ajax({ type: "POST", url: "include/post3.php", data: post_vars, success: function() {
								  if (typeof(window['seminarid']) != "undefined")
								 			 	location.href="confirm.php?seminar_id="+seminarid;
								 			 else
								 			 	location.href="confirm.php?redirect=home";
									 }
								}); 
  						}
  					else
  						{
  						if (typeof(window['seminarid']) != "undefined")
  												location.href="inscriere.php?seminar_id="+seminarid;
								 			 else
								 			 	location.href="index.php";
  						}
  			}
  });
  

});

runOnLoad(function(){
		  $("input#username_nou").select().focus();
		  });



function check (id, pret)
{
	$(document).ready(function() {
					  
					  var checkbox=document.getElementById(id);
					  checkbox.checked=true; 
					  $("#div_input_numar_"+checkbox.id).show();
					  
					  pret_total+=pret;
					  var label_pret=document.getElementById("label_pret");
					  label_pret.innerHTML="TOTAL: "+pret_total+" lei (+TVA)";
					  
					  });
	
}

function checkSemPart (id, pret, sessionNr)
{
	$(document).ready(function() {
					  
					     
					  var checkbox=document.getElementById(id);
					  checkbox.checked=true; 
					  $("#div_input_numar_"+checkbox.id).show();
					  
					  var partSelect = document.getElementById("listnumar_"+id);
					  partSelect.value = parseInt(sessionNr);
					  nrpart[id] = parseInt(sessionNr);					  
					  
					  pret = pret * nrpart[id];
					  pret_total+=pret;
					  var label_pret=document.getElementById("label_pret");
					  label_pret.innerHTML="TOTAL: "+pret_total+" lei (+TVA)";
					  
					  });
	
}








$(document).ready(function() { 
				  
				  $('input[type="text"]').focus(function() {  
												if (this.value == this.defaultValue){  
												this.value = '';  
												}  
												if(this.value != this.defaultValue){  
												this.select();  
												}  
												});  
				  $('input[type="text"]').blur(function() {  
											   if (this.value == ''){  
											   this.value = (this.defaultValue ? this.defaultValue : '');  
											   }  
											   });  
				  
				  $('input[type="password"]').focus(function() {  
													if (this.value == this.defaultValue){  
													this.value = '';  
													}  
													if(this.value != this.defaultValue){  
													this.select();  
													}  
													});  
				  $('input[type="password"]').blur(function() {  
												   if (this.value == ''){  
												   this.value = (this.defaultValue ? this.defaultValue : '');  
												   }  
												   });  
												   
				  /* if (document.body.id=="pagehome")
				  	{
				  		var div = document.getElementById("divOferta2");
				  		var div1 = document.getElementById("divNou1");
				  		var div2 = document.getElementById("divNou2");
				  		var divs = document.getElementById("div_nou_sep");
				  		var h1 = div1.offsetHeight;
				  		var h2 = div2.offsetHeight;
				  						  					  		
				  		if (h1>h2)
				  			{
				  				div.style.height = h1-h2+4+"px";
				  				divs.style.height = h1+15+"px";
				  			}	
				  					  		
				  	}
				  */
				  });  

