
function open_view(sImage,titlu) {
	var sURL = '../view.php?img=' + String(sImage) +'&titlu='+titlu ;
	var imageWin = window.open(sURL, 'imageWin', 'height=420,width=410,scrollbars=1,resizable=1')	
}


function isEMailAddr(elem) {
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        return false;
    } else {
        return true;
    }
}

var sErrorFields = '';
var sErrorTexts = '';
function addError(errorText, errorField) {
	sErrorTexts += '   ' + errorText + '\n';
	sErrorFields += errorField + ',';
}
function addErrorDiv(errorText, errorField) {
	sErrorTexts += '   ' + errorText + '<br>';
	sErrorFields += errorField + ',';
}

function setFormFocus(f, e) {
	if(e) {
		f.elements[e].focus();
	}
}
function unhighlightErrors(f, s) {
	a = s.split(',');
	if(a.length > 0) {
		for(i = 0; i < (a.length -1); i++) {
			if(a[i].toString().length > 0) { f.elements[a[i]].style.backgroundColor = ''; f.elements[a[i]].style.borderColor = ''; }
		}
	}
}
function highlightErrors(f, s) {
	if(s.length > 0) {
		a = s.split(',');
		if(a.length > 0) {
			for(i = 0; i < (a.length -1); i++) {
				if(a[i].toString().length > 0) { f.elements[a[i]].style.backgroundColor = ''; f.elements[a[i]].style.borderColor = '#FF8083'; }
			}
			setFormFocus(f, a[0])
		}
	}
}


function checknumber(x){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(x))
		return false
	else
		return true
}

   

function emailValid(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){ return false}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false }
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false }
	if (str.indexOf(at,(lat+1))!=-1){ return false }
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false }
	if (str.indexOf(dot,(lat+2))==-1){ return false }		
	if (str.indexOf(" ")!=-1){ return false }
	return true
}

function openMenuItem2(divon) {
	if ($(divon).style.display!="none"){
		new  Effect.SlideUp($(divon), { duration:0.5 });
	} else {
	new Effect.SlideDown($(divon), { duration:0.5 });
	}

}

function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}


function validareContact_ro(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv('Va rugam sa completati numele.', 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv('Va rugam sa completati adresa de email.', 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv('Adresa dumneavoastra de email nu este valida.', 'email')
	}

	if(f.mesaj.value.length == 0) { addErrorDiv('Va rugam sa introduceti mesajul.', 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}


function validareContact_en(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv('Please complete your name.', 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv('Please complete your email.', 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv('Your mail adress is not valid.', 'email')
	}

	if(f.mesaj.value.length == 0) { addErrorDiv('Please enter your massage.', 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}


function vnw_en(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.list.selectedIndex == 0 || f.list.selectedIndex == -1) { addError('Select country!<br>', 'list') }

	if(f.email_nw.value.length < 5) {
		addErrorDiv('Please complete your email.', 'email_nw')
	}
	else if(!emailValid(f.email_nw.value)) {
		addErrorDiv('Your mail adress is not valid.', 'email_nw')
	}

	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors_nw").innerHTML = '<strong>Errors:</strong><br />' + sErrorTexts;
		document.getElementById("errors_nw").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}




function validareContact_fr(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv("S'il vous plaît remplir le nom.", 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv("S'il vous plaît remplir adresse email.", 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv("Votre adresse email n'est pas valide.", 'email')
	}

	if(f.mesaj.value.length == 0) { addErrorDiv("S'il vous plaît entrer votre message.", 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}



function validareContact_it(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv("Si prega di compilare il nome.", 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv("Si prega di compilare la tua email.", 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv("Il tuo indirizzo email non è valido.", 'email')
	}

	if(f.mesaj.value.length == 0) { addErrorDiv("Inserisci il tuo messaggio.", 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}






function validareCerereOferta_ro(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv('Va rugam sa completati numele.', 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv('Va rugam sa completati adresa de email.', 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv('Adresa dumneavoastra de email nu este valida.', 'email')
	}

	if(f.telefon.value.length == 0) { addErrorDiv('Va rugam sa introduceti un numar de telefon.', 'telefon') }
	if(f.oras.value.length == 0) { addErrorDiv('Va rugam sa introduceti numele orasului.', 'oras') }
	if(f.telefon.value.length == 0) { addErrorDiv('Va rugam sa introduceti un numar de telefon.', 'telefon') }
	if(f.mesaj.value.length == 0) { addErrorDiv('Va rugam sa introduceti mesajul.', 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}


function validareCerereOferta_en(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv('Please complete your name.', 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv('Please complete your email adress.', 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv('Your mail adress is not valid.', 'email')
	}

	if(f.telefon.value.length == 0) { addErrorDiv('Please enter a phone number.', 'telefon') }
	if(f.oras.value.length == 0) { addErrorDiv('Please enter the city name.', 'oras') }
	if(f.mesaj.value.length == 0) { addErrorDiv('Please enter your massage.', 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}


function validareCerereOferta_fr(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv("S'il vous plaît indiquez votre e-mail.", 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv("Votre adresse email n'est pas valide.", 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv("S'il vous plaît remplir adresse email.", 'email')
	}

	if(f.telefon.value.length == 0) { addErrorDiv("S'il vous plaît, entrez un numéro de téléphone.", 'telefon') }
	if(f.oras.value.length == 0) { addErrorDiv("S'il vous plaît entrer votre ville.", 'oras') }
	if(f.mesaj.value.length == 0) { addErrorDiv("S'il vous plaît entrer votre message.", 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}







function validareCerereOferta_it(f) {
	unhighlightErrors(f, sErrorFields)
	sErrorTexts = '';
	sErrorFields = '';

	if(f.nume.value.length == 0) { addErrorDiv("Si prega di compilare il nome.", 'nume') }
	
	if(f.email.value.length < 5) {
		addErrorDiv("Si prega di compilare la tua email.", 'email')
	}
	else if(!emailValid(f.email.value)) {
		addErrorDiv("Il tuo indirizzo email non è valido.", 'email')
	}

	if(f.telefon.value.length == 0) { addErrorDiv("Si prega di inserire un numero di telefono.", 'telefon') }
	if(f.oras.value.length == 0) { addErrorDiv("Inserisci la tua città.", 'oras') }
	if(f.mesaj.value.length == 0) { addErrorDiv("Inserisci il tuo messaggio.", 'mesaj') }
	
	if(sErrorTexts.length > 0) {
		highlightErrors(f, sErrorFields)
		document.getElementById("errors").innerHTML = '<strong>Errors:</strong><br /><br />' + sErrorTexts;
		document.getElementById("errors").style.display="block";
		return false
	}
	else {
		//document.contact.Submit.disabled="true";
		return true
	}
}
