// JavaScript Document
function downloadme(x){ 
    myTempWindow = window.open(x,"","left=10000, screenX=10000"); 
    myTempWindow.document.execCommand("SaveAs","null",x); 
    myTempWindow.close(); 
}

function Start(page) {
OpenWin = window.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=yes,scrollbars=no,resizable=yes");
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}

function check_form(f) { // f is the form (passed using the this keyword)
	if(f.nume.value.length < 1){
		alert("ATENTIE!!! Va rugam completati campul NUME!");
		f.nume.focus(); // put the prompt in the name field 
		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID){
			// change the color of text field
			f.nume.style.background = "yellow";
		}
		// make sure the form is not submitted	
		return false;
	}
	
	// check the first email address ( the exclamation means "not" )
	if(!check_email(f.email.value)){
		alert("ATENTIE!!! Adresa de e-mail invalida!.");
		f.email.focus(); 
		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID){
			// change the color of text field
			f.email.style.background = "yellow";
		}
		// make sure the form is not submitted
		return false;
	}

	if(f.telefon.value.length < 10){
		alert("ATENTIE!!! Numarul de telefon nu este valid!");
		f.telefon.focus(); // put the prompt in the name field 
		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID){
			// change the color of text field
			f.telefon.style.background = "yellow";
		}
		// make sure the form is not submitted	
		return false;
	}

	if(f.mesaj.value.length < 1){
		alert("ATENTIE!!! Va rugam sa scrieti mesajul!");
		f.mesaj.focus(); // put the prompt in the name field 
		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID){
			// change the color of text field
			f.mesaj.style.background = "yellow";
		}
		// make sure the form is not submitted	
		return false;
	}	
}

function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else
		cntfield.value = maxlimit - field.value.length;
}

function numere(e){
   	var unicode=e.charCode? e.charCode : e.keyCode
   	if (unicode!=8){ //daca tasta apasata nu e backspace
   		if (unicode<48||unicode>57) //si nu e nici numar
   			return false //nu se poate apasa
   	}
}
function limitarelungime(obj, length){
   	var lungime=length
    if (obj.value.length>lungime)
	    obj.value=obj.value.substring(0, lungime)
}

function downloadme(x){
myTempWindow = window.open(x,'','left=10000,screenX=10000');
myTempWindow.document.execCommand('SaveAs','null','download.pdf');
myTempWindow.close();
}