//menu
	$(function() {
		$("ul#menu span").css("opacity","0");
		$("ul#menu span").hover(function () {
			$(this).stop().animate({
				opacity: 1
			}, 'fast');
		},
		function () {
			$(this).stop().animate({
				opacity: 0
			}, 'fast');
		});
	});

	
$(document).ready( function()
{
   PEPS.rollover.init();
});

PEPS = {};
PEPS.rollover =
{
   init: function()
   {
      this.preload(); 
      $(".roll").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.roll').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_on' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_on\./, '.');
   }
}; 

 $(document).ready(
				function(){
$('ul#frontpage').innerfade({
	speed: 1000,
	timeout: 10000,
	type: 'sequence',
	containerheight: '130px'
});
			});
			
function do_imprim(val)
{
	var elem1 = document.getElementById("nr_culori");
	var elem2 = document.getElementById("grafica");
	if (val == 1) {
		elem1.disabled = '';
		elem2.disabled = '';
		}
			if (val == 0) {
		elem1.disabled = 'disabled';
		elem2.disabled = 'disabled';
		}
}

function do_persoana(val)
{
	var elem = document.getElementById("juridic");
	if (val == 1) elem.style.display = '';
	if (val == 0) elem.style.display = 'none';
}
			
function checkValid(id, msg, regula) {
	var prefix = "* ";
	var suffix = "\n";


	switch(regula) {
		case 'required':
						if (document.getElementById(id).value=="")
							return prefix+msg+suffix;
						break;
		case 'select':
						if (document.getElementById(id).options[document.getElementById(id).selectedIndex].value=="")
							return prefix+msg+suffix;
						break;
		case 'numeric':
						var validch = "0123456789.,";
						var isNumber=true;
						var ch;
						var val = document.getElementById(id).value;

						for (i=0; i<val.length && isNumber == true; i++) {
							ch = val.charAt(i);
							if (validch.indexOf(ch) == -1)
								return prefix+msg+suffix;
						}
						break;
		case 'email':
						var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
						if (!filter.test(document.getElementById(id).value.replace(new RegExp("[\\s]+$", "g"), "")))
							return prefix+msg+suffix;
						break;
		case 'integer':
						var filter=/^\d{0,9}$/;
						if (!filter.test(document.getElementById(id).value))
							return prefix+msg+suffix;
						break;
	}
	return "";
}


function checkLength(id, min, max, msg) {

	var prefix = "* ";
	var suffix = "\n";

	if (document.getElementById(id).value.length < min || document.getElementById(id).value.length > max )
	return prefix+msg+suffix
	else
	return ''

}

function checkIdentical(id1, id2, msg) {

	var prefix = "* ";
	var suffix = "\n";

	if (document.getElementById(id1).value != document.getElementById(id2).value)
	return prefix+msg+suffix
	else
	return ''

}


function checkRadio(form_name,radio_name,msg)
{

	var radio_choice = false;
	var prefix = "* ";
	var suffix = "\n";
	radio_obj = eval('document.'+form_name+'.'+radio_name);

	if (radio_obj.checked) {
		radio_choice = true;
	} else {
		for (counter = 0; counter < radio_obj.length; counter++)
		{

			if (radio_obj[counter].checked) {
				radio_choice = true;
				break;
			}
		}
	}

	if (!radio_choice) {
		return prefix+msg+suffix;
	}
	    return '';
}

function verificaFormular() {
	msg_alert = "Va rugam corectati erorile si incercati din nou:\n";
	msg_alert += "______________________________________________________\n";
	msg_alert += "\n";
	msg = "";
	msg += checkValid("produs_ambalat", "Trebuie sa specificati produsul ambalat!", "select");
	msg += checkValid("rol_ambalaj", "Trebuie sa specificati rolul ambalajului!", "select");
	msg += checkValid("tip_carton", "Trebuie sa specificati tipul de carton ondulat!", "select");
	msg += checkValid("lungime", "Trebuie sa specificati lungimea ambalajului!", "required");
	msg += checkValid("lungime", "Trebuie sa specificati lungimea ambalajului! (numar)", "numeric");
	msg += checkValid("latime", "Trebuie sa specificati latimea ambalajului!", "required");
	msg += checkValid("latime", "Trebuie sa specificati latimea ambalajului! (numar)", "numeric");
	msg += checkValid("inaltime", "Trebuie sa specificati inaltimea ambalajului!", "required");
	msg += checkValid("inaltime", "Trebuie sa specificati inaltimea ambalajului! (numar)", "numeric");
	msg += checkValid("greutate", "Trebuie sa specificati greutatea produselor ambalate!", "required");
	msg += checkValid("greutate", "Trebuie sa specificati greutatea produselor ambalate! (numar)", "numeric");
	msg += checkRadio("myform","culoare_carton", "Trebuie sa specificati culoarea cartonului!");
	msg += checkRadio("myform","imprimat", "Trebuie sa specificati imprimarea cartonului!");
	msg += checkValid("cantitate", "Trebuie sa specificati cantitatea!", "required");
	msg += checkValid("cantitate", "Trebuie sa specificati cantitatea! (numar)", "numeric");
	msg += checkRadio("myform","pret_transport", "Trebuie sa specificati daca oferta sa contina si includerea transportului!");
	msg += checkValid("termen_livrare", "Trebuie sa specificati termenul de livrare!", "required");
	msg += checkValid("adresa_livrare", "Trebuie sa specificati adresa de livrare!", "required");

	if (document.myform.pp[0].checked)
	{
	msg += checkValid("nume_companie", "Trebuie sa specificati numele companiei!", "required");
	msg += checkValid("cod_fiscal", "Trebuie sa specificati codul fiscal!", "required");
	msg += checkValid("nr_reg_com", "Trebuie sa specificati numarul de inregistrare la registrul comertului!", "required");	
	}
	
	msg += checkValid("persoana_contact", "Trebuie sa specificati numele persoanei de contact!", "required");
	msg += checkValid("email", "Trebuie sa specificati adresa de e-mail!", "email");
	msg += checkValid("telefon", "Trebuie sa specificati telefonul!", "required");
	msg += checkValid("adresa", "Trebuie sa specificati adresa!", "required");
	
	if (msg != "") {
		alert(msg_alert+msg);
		return false;
	}
	return true;
}


function verificaCV() {
	msg_alert = "Va rugam corectati erorile si incercati din nou:\n";
	msg_alert += "______________________________________________________\n";
	msg_alert += "\n";
	msg = "";
	msg += checkValid("departament", "Trebuie sa specificati departamentul!", "select");
	msg += checkValid("nume", "Trebuie sa specificati numele dvs!", "required");
	msg += checkValid("prenume", "Trebuie sa specificati prenumele dvs!", "required");
	msg += checkValid("adresa", "Trebuie sa specificati adresa!", "required");
	msg += checkValid("telefon", "Trebuie sa specificati telefonul!", "required");
	msg += checkValid("mobil", "Trebuie sa specificati telefonul mobil!", "required");
	msg += checkValid("email", "Trebuie sa specificati adresa de e-mail!", "email");
	if (document.getElementById('data_nasterii').value == 'zz/ll/aaaa')
			msg += "* Trebuie sa specificati ziua de nastere!\n";
	msg += checkRadio("myform","sex", "Trebuie sa specificati sexul!");
	msg += checkValid("stare_civila", "Trebuie sa specificati starea civila!", "select");
	msg += checkValid("nationalitate", "Trebuie sa specificati nationalitatea!", "required");
	msg += checkRadio("myform","permis_conducere", "Trebuie sa specificati daca aveti permis de conducere!");
	if (document.getElementById('perioada1').value == '' || document.getElementById('angajator1').value == '' || document.getElementById('functia1').value == '' || document.getElementById('responsabilitati1').value == '')
	msg += "* Trebuie sa specificati minim ultimul loc de munca ca si experienta profesionala!\n";
	if (document.getElementById('promotie1').value == '' || document.getElementById('institutie1').value == '' || document.getElementById('certificare1').value == '')
	msg += "* Trebuie sa specificati minim ultima diploma obtinuta/scoala urmata!\n";
	if (msg != "") {
		alert(msg_alert+msg);
		return false;
	}
	return true;
}

function verificaFormularen() {
	msg_alert = "Check for errors and try again:\n";
	msg_alert += "______________________________________________________\n";
	msg_alert += "\n";
	msg = "";
		msg += checkValid("produs_ambalat", "You must specify product type", "select");
	msg += checkValid("rol_ambalaj", "You must specify packaging role!", "select");
	msg += checkValid("tip_carton", "You must specify corrugated board type!", "select");
	msg += checkValid("lungime", "You must specify the length of the box!", "required");
	msg += checkValid("lungime", "You must specify the length of the box! (must be a number)", "numeric");
	msg += checkValid("latime", "You must specify the width of the box!", "required");
	msg += checkValid("latime", "You must specify the width of the box! (must be a number)", "numeric");
	msg += checkValid("inaltime", "You must specify depth of the box!", "required");
	msg += checkValid("inaltime", "You must specify depth of the box! (must be a number)", "numeric");
	msg += checkValid("greutate", "You must specify weight of the packed products!", "required");
	msg += checkValid("greutate", "You must specify weight of the packed products! (must be a number)", "numeric");
	msg += checkRadio("myform","culoare_carton", "You must specify cardboard color!");
	msg += checkRadio("myform","imprimat", "You must specify if the cardboard is printed or not!");
	msg += checkValid("cantitate", "You must specify a quantity!", "required");
	msg += checkValid("cantitate", "You must specify a quantity! (must be a number)", "numeric");
	msg += checkRadio("myform","pret_transport", "You must specify if offer should include transport costs!");
	msg += checkValid("termen_livrare", "You must specify term of delivery!", "required");
	msg += checkValid("adresa_livrare", "You must specify a delivery address!", "required");

	if (document.myform.pp[0].checked)
	{
	msg += checkValid("nume_companie", "You must specify company name!", "required");
	msg += checkValid("cod_fiscal", "You must specify company's tax code number!", "required");
	msg += checkValid("nr_reg_com", "You must specify a company's registration number!", "required");	
	}
	
	msg += checkValid("persoana_contact", "You must specify contact name!", "required");
	msg += checkValid("email", "You must specify an e-mail!", "email");
	msg += checkValid("telefon", "You must specify a telephone!", "required");
	msg += checkValid("adresa", "You must specify an address!", "required");
	
	if (msg != "") {
		alert(msg_alert+msg);
		return false;
	}
	return true;
}

function verificaCVen() {
	msg_alert = "Check for errors and try again:\n";
	msg_alert += "______________________________________________________\n";
	msg_alert += "\n";
	msg = "";
	msg += checkValid("departament", "You must specify a department!", "select");
	msg += checkValid("nume", "You must specify Your name!", "required");
	msg += checkValid("prenume", "You must specify Your surname!", "required");
	msg += checkValid("adresa", "You must specify Your address!", "required");
	msg += checkValid("telefon", "You must specify Your phone number!", "required");
	msg += checkValid("mobil", "You must specify Your mobile number!", "required");
	msg += checkValid("email", "You must specify Your email!", "email");
	if (document.getElementById('data_nasterii').value == 'dd/mm/yyyy')
			msg += "* You must specify Your date of birth!\n";
	msg += checkRadio("myform","sex", "You must specify Your gender!");
	msg += checkValid("stare_civila", "You must specify Your marital status!", "select");
	msg += checkValid("nationalitate", "You must specify Your nationality!", "required");
	msg += checkRadio("myform","permis_conducere", "You must specify if you got driving license!");
	if (document.getElementById('perioada1').value == '' || document.getElementById('angajator1').value == '' || document.getElementById('functia1').value == '' || document.getElementById('responsabilitati1').value == '')
	msg += "* You must specify at least Your last work experience!\n";
	if (document.getElementById('promotie1').value == '' || document.getElementById('institutie1').value == '' || document.getElementById('certificare1').value == '')
	msg += "* You must specify at least Your last education and training!\n";
	if (msg != "") {
		alert(msg_alert+msg);
		return false;
	}
	return true;
}

function verificaNewsletter() {
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (document.getElementById('newsletter_email').value=='Adresa dvs. de e-mail')
	{
	alert("Trebuie sa specificati o adresa de email");
	return false;
	}
	if (!filter.test(document.getElementById('newsletter_email').value.replace(new RegExp("[\\s]+$", "g"), "")))
	{
	alert("Trebuie sa specificati o adresa de email");
	return false;
	}
	return true;
}

function checkNewsletter() {
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (document.getElementById('newsletter_email').value=='You must enter an email')
	{
	alert("You must enter an email");
	return false;
	}
	if (!filter.test(document.getElementById('newsletter_email').value.replace(new RegExp("[\\s]+$", "g"), "")))
	{
	alert("You must enter an email");
	return false;
	}
	return true;
}

function uberprufenNewsletter() {
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (document.getElementById('newsletter_email').value=='Geben Sie eine E-Mail')
	{
	alert("Geben Sie eine E-Mail");
	return false;
	}
	if (!filter.test(document.getElementById('newsletter_email').value.replace(new RegExp("[\\s]+$", "g"), "")))
	{
	alert("Geben Sie eine E-Mail");
	return false;
	}
	return true;
}