function ValidateSecurityCode()
{
	var err=0;
	if (Get_Cookie('ool_firme_img_content')!= null) {
		var inp_ck=document.getElementById('img_check');
		if (hex_md5(inp_ck.value)!=Get_Cookie('ool_firme_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.MM_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 ShowTextarea(a)
{
    if (a>1) {         
        document.getElementById('c_text_t').innerHTML='Mesaj';
        document.getElementById('c_text').style.display='block';
    }    
    else {         
        document.getElementById('c_text_t').innerHTML='';
        document.getElementById('c_text').style.display='none';
    }
}

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')
}
function confirmdelete(url,mesaj){ 
if(confirm(mesaj)==true){
self.location.href=url;
}
} 


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


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);
	}
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}



///////////////////////////////////////////////////////////////////
/////////////////////// make disable inputbox if listing /////////

function DisableInput(olist) {

if(olist.selectedIndex==0) 
   {
     document.inscriere.telefon2.value='';
     document.inscriere.telefon3.value='';
    
     document.inscriere.telefon2.disabled=true;
     document.inscriere.telefon3.disabled=true;
     
     document.inscriere.file.disabled=true;
     
   } 
else 
   {
      document.inscriere.telefon2.disabled=false;
      document.inscriere.telefon3.disabled=false;
      document.inscriere.file.disabled=false;
   };
   
}



//////////////////////////////////////////////////////////////
/////////////////////////// restrict java formular //////////////


function ValidFormular(olist2,olist3){
	if (olist2.selectedIndex>0){
		if (olist3.selectedIndex>0){
			MM_validateForm('numefirma','','R','codfiscal','','R','strada','','R','oras','','R','email','','NisEmail','telefon1','','R','descriere','','R');
			if (document.MM_returnValue==true) ValidateSecurityCode();
			
		} else {
			alert('Selectati functia detinuta!');
			document.MM_returnValue=false;
		}
	} else {
		alert('Selectati o categorie!');
		document.MM_returnValue=false;          
	} 
}

function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
} 

function verif_pass(t1,t2) {
		if(t1.value!=t2.value) {
			alert("Please confirm your password.");
			t1.value="";
			t2.value="";
			t1.focus();
		}
		/*else if(t1.value.length<2) { 
			alert('Your password must be at least 3 characters long');
			t1.value="";
			t2.value="";
			t1.focus();
		}*/
	}
