function poga_act(id)
   { 
   set_login_value();	
   if (document.getElementById('cust_no').value > 0)
	   document.getElementById(id).disabled = false;
	else
	   document.getElementById(id).disabled = true;
   }

function login()
	{
	var email = $("#email").val();
	var password = $("#password").val();
	var palikt_ielogojies = $("#palikt_ielogojies_t").val();
	if ((email == '') || (password == ''))
		{
//    	$("#info").html('');
    	$("#warning").html("<font color=red>Lai autoriz&#275;tos, ir j&#257;ievada e-pasta adresi un paroli!</font>");
		} 
	else
		{
 		$.ajax({
   		type: "GET",
   		url: "login_check.php",
   		data: "email="+email+"&password="+password,
   		success: function(rc){ 
		  if (rc == 0)
		  	{
			$("#warning").html("<font color=red>E-pasta adrese un / vai parole nepareiza</font>");
//			$("#info").html('');
			}
	      else if (rc > 0)
			{
//			$("#info").html('');
			$("#warning").html("<font color=green>Autoriz&#257;cija veiksm&#299;ga</font>");
			setTimeout("tb_remove()",3000);
		    document.getElementById('cust_no').value = rc;
			if (document.getElementById('poga')!= null) document.getElementById('poga').disabled = false;
			if (palikt_ielogojies=='X')
				{
				var Jetzt = new Date();
				var cookie_jetzt = Jetzt.toGMTString();
				var pirmais_kols = cookie_jetzt.search(':');
				var cookie_end = cookie_jetzt.substr(0,pirmais_kols-2)+'21:00:00'+cookie_jetzt.substr(pirmais_kols+6,4);
				document.cookie = 'cookie_login='+rc+";expires=" + cookie_end; 
				}
			else document.cookie = 'cookie_login='+rc; 
			set_loginlink_gaita_login();
			}
	      else if (rc == -1)
			{
//			$("#info").html('');
			$("#warning").html("<font color=red>Jums e-past&#257; tika nos&#363;t&#299;ta re&#291;istr&#275;&#353;an&#257;s apstiprin&#257;juma saite</font>");
			setTimeout("tb_remove()",10000);
			}
	      else if (rc == -2)
			{
//			$("#info").html('');
			$("#warning").html("<font color=red>Jums ir ierobe&#382;ota foruma lieto&#353;ana!</font>");
			setTimeout("tb_remove()",10000);
			}
   							 }
			   });
		}
	return false;
	}

function logout()
	{
    document.getElementById('cust_no').value = 0;
	if (document.getElementById('poga')!= null) document.getElementById('poga').disabled = true;
	document.cookie = 'cookie_login=0;'+' expires=Thu, 01-Jan-70 00:00:01 GMT;';
	set_loginlink_gaita_logout();
	}	
	
function register()
	{
	var email = $("#email").val();
	var password1 = $("#password1").val();
	var password2 = $("#password2").val();
	var year = $("#year").val();
	var sex = $("#sexk").val();
	var reg_error=false;
	if ((email == '') || (password1 == '') || (password2 == ''))
		{
    	$("#warning").html("<font color=red>Aizpildiet ar * atz&#299;m&#275;tos lauci&#326;us!</font>");
    	reg_error=true;
		} 
	if ((reg_error==false)&&( ! checkEmail(email, true)))
		{
    	$("#warning").html("<font color=red>E-pasta adreses sintakse nepareiza</font>");
    	reg_error=true;
		} 
	if ((reg_error==false)&&(password1 != password2))
		{
    	$("#warning").html("<font color=red>Parole un paroles atk&#257;rtojums nesakr&#299;t</font>");
    	reg_error=true;
		} 
	if ((reg_error==false)&&(password1.length <6 ))
		{
    	$("#warning").html("<font color=red>Parolei j&#257;b&#363;t min. 6 z&#299;mes garai</font>");
    	reg_error=true;
		} 

 if (reg_error==false)
		{
 		$.ajax({
   		type: "GET",
   		url: "reg_check.php",
   		data: "email="+email+"&password="+password1+"&year="+year+"&sex="+sex,
   		success: function(rc){ 
		  if ((rc.length>1)&&(rc.length<10))
		  	{
			$("#warning").html("<font color=red>E-pasta adrese port&#257;l&#257; jau re&#291;istr&#275;ta</font>");
	    	reg_error=true;
			}
	      else if (rc.length==32)
			{
			$("#info").html("<b>Jums e-past&#257; tika nos&#363;t&#299;ta re&#291;istr&#275;&#353;an&#257;s apstiprin&#257;juma saite.</b>");
			$("#warning").html("<font color=green>Re&#291;istr&#257;cija veiksm&#299;ga</font>");
			setTimeout("tb_remove()",20000);
			}
   							 }
			   });
		}
	return false;
	}
	
