function ValidateSecurityCode()
{
	var err=0;
	if (Get_Cookie('ool_ev_img_content')!= null) {
		var inp_ck=document.getElementById('img_check');
		if (hex_md5(inp_ck.value)!=Get_Cookie('ool_ev_img_content')) {
			err=5;
			alert('Nu ati citit bine textul din imagine!\nReincercati!');
			inp_ck.value='';
			inp_ck.focus();
		}
	}
	else err=2;
	
	if (err>0) {
		document.getElementById('tag_img_check').src="pic.php?"+Math.random();
		if (err==2) alert('Browserul dvs. respinge cookie-urile!');
	}
	if (err!=0) document.returnValue=false;
}





function Get_Cookie(name) { 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
}







function MakeDisabledFields(data,status)
{
 if (status==1){
    data.value="";
    data.disabled=true;
 }
 else data.disabled=false;
}

function EnableDataFinala(a,z)
{
 x=a.value;
 if (x==5) MakeDisabledFields(z.data2,0);
 else MakeDisabledFields(z.data2,1);
}
















function ValidLocatia(a)
{
var b,ret=1,c;
var str1="Locul evenimentului gresit completat", str2="\n\nUrmeaza exemplul:   Oradea, Stadionul Municipal";
x=a.value;
b=x.search(",");

if (b==-1){
    ret=0;
	alert(str1 + '!!!' + str2);
}
else {
   c=x.split(",");
   loc1=c[0].replace(/^\s*|\s*$/g,"");
   loc2=c[1].replace(/^\s*|\s*$/g,"");
   if (loc1=="") {
       ret=0;
	   alert(str1 + '!\nLipseste localitatea!' + str2);
   }
   if (loc2=="") {
       ret=0;
	   alert(str1 + '!\nLipseste locatia!' + str2);
   }
}
if (ret==0) a.value='Oradea, ';
else a.value=loc1+', '+loc2;
return ret;
}
///////////////////// for grow image//////////////////
function gow(bimage) {
	window.open('enlarge.php?q='+bimage,'Images','width=500,height=400,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no')
}

///////////////////////// for delete confirmation ////////////////
function confirmdelete(url,mesaj){ 
if(confirm(mesaj)==true){
self.location.href=url;
}
} 



///////////////// bara de avertizare nr caractere la textarea//////////////
function MakeProcent(textOgj,maxChars,alerttext) {
	var procent;
	if(textOgj.value.length<=maxChars) {
		procent=(textOgj.value.length*100)/maxChars;
		document.getElementById('longplay').style.width=procent+'%';
	} else {
		textOgj.value = textOgj.value.substring(0,maxChars);
		alert(alerttext);
	}
}




///////////////////////////////////////////////////////////////
////////////////// funtions for validate form //////////////////

function findObj(n, d) { //v4.01
  var p,i,x=0;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
	n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n);
  return x;
}

function validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
  var pass='';
  for (i=0; i<(args.length-2); i+=3) {
	test=args[i+2]; 
	val=findObj(args[i]);
    if (val) { 
	  if(val.id) nm=val.id; else nm=val.name; 
	  if ((val=val.value)!="" || test.indexOf('Pass')!=-1) {
		if (test.indexOf('isEmail')!=-1) { 
		  p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' trebuie sa contina o adresa de email.\n';
		}  else if (test!='R') { 
		  num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' trebuie sa contina un numar.\n';
          if (test.indexOf('inRange') != -1) { 
		    p=test.indexOf(':');
            min=test.substring(8,p); 
			max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' trebuie sa contina un numar '+min+' intre '+max+'.\n';
		  }
		  if (test.indexOf('notnull') != -1) { 
			if(val==0) errors+='- '+nm+': selectati o optiune.\n';
		  }
		} 
	  } else if (test.charAt(0) == 'R') errors += '- '+nm+' \n'; // ininte de \n' se pune is required  
	} else errors += '- '+args[i]+' is required.\n If is not defined, please define '+args[i]+'s\n';
  } if (errors) alert('Urmatoarele campuri trebuie completate:\n\n'+errors);
  document.returnValue = (errors == '');
}