// JavaScript Document

function addfav()
{
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel("Tzoale.ro, portal haine", "http://www.tzoale.ro","");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( "http://www.tzoale.ro", "Tzoale.ro, portal haine"); }
}

function popup_zoom (img)
{
	var tmp = '';
	if (img.indexOf ('?name=') > 0)
	{
		tmp = img.substring (img.indexOf ('?name=')+6, img.length);
		tmp = tmp.substring (0, tmp.indexOf ('&'));
	}
	else
		tmp = img;
//	thumbs.php?name=&new_w=240&new_h=270
	window.open ("zoom.php?im="+tmp,"mywindow","status=1,width=650,height=410");
}

function print_it (id)
{
	if (document.getElementById)
	{
		var content = document.getElementById (id).innerHTML;
		content = content.substring (0, content.indexOf ('<SCRIPT')) + content.substring (content.indexOf ('</SCRIPT>')+9);
		var printWin = window.open ('','', 'width=600,height=600');
//		printWin.document.open ();
		printWin.document.write ('<html><body>');
		printWin.document.write (content);
		printWin.document.write ('</body></html>');
		printWin.document.close ();
		printWin.focus ();
		printWin.print ();
//		setTimeout ('oW.close()', 5000);
	}
}

function manage (id, cls1, cls2)
{
	if (document.getElementById)
	{
		var el = document.getElementById (id);
		if (el.className == cls1)
			el.className = cls2;
		else
			el.className = cls1;
		for (var i = 3; i<arguments.length; i++)
		{
			if (arguments[i] != '')
			{
				var el = document.getElementById (arguments[i]);
				el.className = cls1;
			}
		}
	}
	return false;
}
function MM_openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}

function swap_image(titlu,imagine,descriere)
{
	document.getElementById("titlu").innerHTML = titlu;
	document.getElementById("picture").innerHTML = imagine;
/*	document.getElementById("description").innerHTML = descriere;*/
	
}
function show_newsletter()
{
	if(document.getElementById("newsletter").style.display = "block")
		document.getElementById("newsletter").style.display = "none";
	if(document.getElementById("newsletter").style.display = "none")
		document.getElementById("newsletter").style.display = "block";
}

function validare()
{
	formular = document.getElementById("form1");
	if(formular.nume.value.length ==0)
	{
		alert('Introduceti numele!');
		return false;
	}
	if(formular.prenume.value.length ==0)
	{
		alert('Introduceti prenumele!');
		return false;
	}
	if(formular.oras.value.length == 0)
	{
		alert('Introduceti e-mail!');
		return false;
	}
	if(formular.adresa.value.length == 0)
	{
		alert('Introduceti e-mail!');
		return false;
	}
	if(formular.email.value.length == 0)
	{
		alert('Introduceti e-mail!');
		return false;
	}
	if((formular.email.value.indexOf("@") == -1) || (formular.email.value.indexOf(".") == -1))
	{
		alert('Introduceti un e-mail valid!');
		formular.email.focus();
		return false;
	}
	if(formular.tel.value.length == 0)
	{
		alert('Introduce nr. de telefon!');
		return false;
	}
	
		formular.submit();
	
}

function validare_search()
{
	form = document.getElementById("search");
	if(form.keyword.value.length == 0)
	{
		alert('Insert the keyword!');
		return false;
	}
	form.submit();
}

function validare_newsletter(id)
{
	form = document.getElementById(id);
	if(form.name.value == 0)
		{
			alert('Trebuie sa completati numele dumneavoastra !');
			form.email.focus();
			return false;
		}
	if(ControllaMail(id) == false)
		{
			alert('Trebuie sa completati e-mail dumneavoastra !');
			form.email.focus();
			return false;
		}
	form.submit();
}
function ControllaMail(id)
   {
   EmailAddr = document.getElementById(id).email.value;
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (Filtro.test(EmailAddr))
      return true;
   else
      {
      document.getElementById(id).email.focus();
      return false;
      }
   }


function verify(id)
{
	var form = document.getElementById(id)
		if(form.nume.value == 0)
		{
			alert('Trebuie sa completati numele si prenumele dumneavoastra !');
			form.nume.focus();
			return false;
		}
		if(form.tel.value == 0)
		{
			alert('Trebuie sa completati telefonul dumneavoastra !');
			form.tel.focus();
			return false;
		}
		if(form.email.value == 0)
		{
			alert('Trebuie sa completati e-mail dumneavoastra !');
			form.email.focus();
			return false;
		}
		if(form.mesaj.value == 0)
		{
			alert('Trebuie sa completati mesajul dumneavoastra !');
			form.mesaj.focus();
			return false;
		}
		form.submit()	
}


function view(id)
{
		document.getElementById(id).style ;
		if(document.getElementById(id).style.display == "none")
			document.getElementById(id).style.display = 'block';
		if(document.getElementById(id).style.display == "block")
			document.getElementById(id).style.display = 'none';
}


function img_over(id)
{
	if(id == 'home')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/home_hover.jpg";
	if(id == 'despre')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/despre_hover.jpg";
	if(id == 'produse')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/produs_hover.jpg";
	if(id == 'clienti')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/acoperire.jpg";
	if(id == 'cariere')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/cariere_hover.jpg";
	if(id == 'articol')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/articol_hover.jpg";
	if(id == 'newsletter')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/newsletter_hover.jpg";
	if(id == 'forum')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/forum_hover.jpg";
	if(id == 'contact')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/contact_hover.jpg";
}
function img_out(id)
{
	if(id == 'home')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/home.jpg";
	if(id == 'despre')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/despre.jpg";	
	if(id == 'produse')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/produs.jpg";
	if(id == 'clienti')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/acoperire_hover.jpg";
	if(id == 'cariere')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/cariere.jpg";
	if(id == 'articol')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/articol.jpg";
	if(id == 'newsletter')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/newsletter.jpg";
	if(id == 'forum')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/forum.jpg";
	if(id == 'contact')
		document.getElementById(id).src = "http://www.distrifarm.w2w.ro/css/contact.jpg";
	
}