/*********COMPARA PAROLE***********/
function comparaParole()	
	{
		pas = document.adaugaForm.parola.value;
		pas1 = document.adaugaForm.parola1.value;
		if(pas!=pas1)
		{
			alert("Parolele nu se potrivesc!");
			document.adaugaForm.parola.focus();
			return false; 
		}
		return true;
	}
/*********END COMPARA PAROLE***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE CLIENTI***********/
function validatelogin()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "utilizator";
	w[1] = "parola";
		
		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		return true;
	}
}
/*********END VALIDARE CLIENTI***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VERIFICA EMAIL**********/
function verEmail()
{
	var re;
     	re = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.([a-zA-Z]{2,4})$/;
		
		if (re.test(document.adaugaForm.email.value) == false){	
	          	alert("Va rugam sa va introduceti corect adresa de email!");
				document.adaugaForm.email.focus();
			return false;
        }
	return true;
}
/*********END VERIFICA EMAIL**********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VERIFICA EMAIL**********/
function verEmailProprietar()
{
	var re;
     	re = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.([a-zA-Z]{2,4})$/;
		
		if (re.test(document.adaugaForm.EMAIL_PROPRIETAR.value) == false){	
	          	alert("Va rugam sa va introduceti corect adresa de email a proprietarului!");
				document.adaugaForm.EMAIL_PROPRIETAR.focus();
			return false;
        }
	return true;
}
/*********END VERIFICA EMAIL**********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VERIFICA DACA E NUMAR**********/
function blockChars(e)
{
	var key;
	var keychar;
	var reg;
	
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; 
	}
	else if(e.which) {
		// netscape
		key = e.which; 
	}
	else {
		// no event, so pass through
		return true;
	}

keychar = String.fromCharCode(key);
	reg = /[a-z]|@|#|~|!|%|&|-|=|;|:|>|<|,/;
	return !reg.test(keychar);
}

/*********END VERIFICA DACA E NUMAR*********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********FUNCTIE UCFIRST***********/
String.prototype.ucFirst=function()
	{
		if(arguments[0] == true)
	{
		var words=this.split(" ")
		for(var w in words)
	{
		words[w]=words[w].ucFirst()
	}
		return words.join(" ")
	}
		return this.charAt(0).toUpperCase()+this.substring(1,this.length)
	}
/*********END FUNCTIE UCFIRST***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE AGENTI***********/
function validare_agenti()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "pozitia";
	w[1] = "nume_agent";
	w[2] = "utilizator";
	w[3] = "tip";
	w[4] = "departamente_id";
	w[5] = "zone_id";
	w[6] = "telefon";
	w[7] = "email";
	w[8] = "parola";
	w[9] = "parola1";

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		
		if (!verEmail()) return false;
		if (!comparaParole()) return false;
		
		return true;	
	}
}
/*********END VALIDARE AGENTI***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE BANNERS***********/
function validare_banners()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "pozitia";
	w[1] = "amplasare_pagina";
	w[2] = "prezenta";
	w[3] = "tip_banner";
	w[4] = "url_address";
	w[5] = "denumire_banners";
	w[6] = "client";
	

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		return true;	
	}
}
/*********END VALIDARE BANNERS***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE AGENTI***********/
function validare_form_contact()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "user";
	w[1] = "parola";
	w[2] = "parola1";
	w[3] = "nume";
	w[4] = "prenume";
	w[5] = "telefon";
	w[6] = "email";

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		
		if (!verEmail()) return false;
		if (!comparaParole()) return false;
		
		return true;	
	}
}
/*********END VALIDARE AGENTI***********/

/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE NEWSLETTER***********/
function validare_form_news()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "nume";
	w[1] = "email";

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		
		if (!verEmail()) return false;
		if (!comparaParole()) return false;
		
		return true;	
	}
}
/*********END VALIDARE AGENTI***********//*----------------------------------------------------------------------------------------------------------------------------------------------------------*/

/*********VALIDARE PAROLA NOUA***********/
function validare_parola_noua()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "parola_veche";
	w[1] = "parola";
	w[2] = "parola1";
		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}				
		}
		if (!comparaParole()) return false;
		
		return true;	
	}
}
/*********END VALIDARE PAROLA NOUA***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE CATEGORII***********/
function masina_scateg()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "ord";
	w[1] = "denumire_masina_scateg";
		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		return true;
	}
}
/*********END VALIDARE CATEGORII***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE SUBCATEGORII***********/
function validare_subcategorii()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "ord";
	w[1] = "categorii_stanga_id";
	w[2] = "denumire[ro]";
		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		return true;
	}
}
/*********END VALIDARE SUBCATEGORII***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE ARTICOLE***********/
function validare_articole()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "ord";
	w[1] = "aux[ro][denumire]";
	w[2] = "aux[ro][descriere]";
		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}	
			
		}
		return true;
	}
}
/*********END VALIDARE ARTICOLE***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE DEPARTAMANTE***********/
function validare_departamente()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "denumire_departament";

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}				
		}
		return true;
	}
}

/*********END VALIDARE DEPARTAMANTE***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE DEPARTAMANTE***********/
function validare_write_details()
{		
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "titlu";
	w[1] = "detalii";

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}				
		}
		return true;
	}
}

/*********END VALIDARE DEPARTAMANTE***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE CONCURS***********/
function validare_concurs()
{	
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "marca_concurs";
	w[1] = "model_concurs";
	w[2] = "an_fabricatie";

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}				
		}
		return true;
	}
}

/*********END VALIDARE CONCURS***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE CONCURS***********/
function validare_concurs_step2()
{	
	with(document.adaugaForm)
	{
	var s = "Camp obligatoriu: ";
	var w = new Array();
	w[0] = "nume";
	w[1] = "prenume";
	w[2] = "email";

		for (i=0;i<w.length;i++)
		{		
			e = document.adaugaForm.elements[w[i]];
			val = e.value;
			if(val == "")
			{									
				nume_brut = e.name.replace("_", " ");				
				alert(s+nume_brut.ucFirst());
				e.focus();
				return false;
			}				
		}
		if (!verEmail()) return false;
		return true;
	}
}

/*********END VALIDARE CONCURS***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*********VALIDARE CATEGORIE***********/
function numeleCategoriei()
{
	if (!document.adaugaForm.denumire )
		return true;
	denumire_brut = document.adaugaForm.denumire.value.replace(/[^A-Za-z_ ]*/g ,"");
	document.adaugaForm.denumire.value = denumire_brut;	
}
/*********VALIDARE CATEGORIE***********/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
function blockNumbers(e)
{
var key;
var keychar;
var reg;

if(window.event) 
	{
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; 
	}
else if(e.which) 
	{
		// netscape
		key = e.which; 
	}
else 
	{
	
		// no event, so pass through
		return true;
	}
	
	keychar = String.fromCharCode(key);
	reg = /[A-Za-z]|@|#|~|!|%|&|-|=|;|:|>|<|,/;
	return !reg.test(keychar);
}



function blockChars(e)
{
	var key;
	var keychar;
	var reg;
	
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; 
	}
	else if(e.which) {
		// netscape
		key = e.which; 
	}
	else {
		// no event, so pass through
		return true;
	}

keychar = String.fromCharCode(key);
	reg = /[a-z]|@|#|~|!|%|&|-|=|;|:|>|<|,/;
	return !reg.test(keychar);
}

function chk()
{
	if(document.getElementById("picture_con_show_place"))
	{
		my_div=document.getElementById("picture_con_show_place")
		top_space=document.getElementById("picture_con_show_place").offsetTop
		bottom_space=15
		my_div.style.height=document.body.clientHeight-top_space-bottom_space
	}

}

function ceca(ss)
{
	obj=document.getElementById(ss);
	if(obj.checked==true)
	{
		obj.checked=false;
	}
	else 
	{
		obj.checked=true;
	}

}
//SHOW HIDE VIDEO//--------------------------------------------------------------
var active	= "";
function AscundeDiv(divname){		
		if(active != ""){
			eval("document.getElementById('" + active + "').style.display='none';");

		}	
		if(active == divname){
			eval("document.getElementById('" + divname + "').style.display='none';");
			active = "";
			return false;
		}else{
			eval("document.getElementById('" + divname + "').style.display='block';");
		}	
		active = divname;
		
		return false;
}
function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}
//--------------------------------------------------------------

//Das Objekt, das gerade bewegt wird.
var dragobjekt = null;

// Position, an der das Objekt angeklickt wurde.
var dragx = 0;
var dragy = 0;

// Mausposition
var posx = 0;
var posy = 0;


function draginit() {
 // Initialisierung der Überwachung der Events

  document.onmousemove = drag;
  document.onmouseup = dragstop;
}


function dragstart(element) {
   //Wird aufgerufen, wenn ein Objekt bewegt werden soll.

  dragobjekt = element;
  dragx = posx - dragobjekt.offsetLeft;
  dragy = posy - dragobjekt.offsetTop;
}


function dragstop() {
  //Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll.
  //Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll.
  if(dragobjekt != null) {
   max = dragobjekt.style.zIndex*1;
   //alert(max)
  }


  dragobjekt=null;
}


function drag(ereignis) {
  //Wird aufgerufen, wenn die Maus bewegt wird und bewegt bei Bedarf das Objekt.

  posx = document.all ? window.event.clientX : ereignis.pageX;
  posy = document.all ? window.event.clientY : ereignis.pageY;
  if(dragobjekt != null) {
    dragobjekt.style.left = (posx - dragx) + "px";
    dragobjekt.style.top = (posy - dragy) + "px";
  }
}

function D(d){ return document.getElementById(d) };
if (window != top) top.location = self.location;