
<!-- Original author:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
<!-- old Source on http://www.jsmadeeasy.com/javascripts/Forms/Email%20Address%20Validation/template.htm -->

<!-- The above address bounces and no current valid address  -->
<!-- can be found. This version has changes by Craig Cockburn -->
<!-- to accommodate top level domains .museum and .name      -->
<!-- plus various other minor corrections and changes -->

/* 1.1.3: Amended error messages and allowed script to deal with new TLDs
   1.1.2: Fixed a bug where trailing . in e-mail address was passing
            (the bug is actually in the weak regexp engine of the browser; I
            simplified the regexps to make it work).
   1.1.1: Removed restriction that countries must be preceded by a domain,
            so abc@host.uk is now legal.  
     1.1: Rewrote most of the function to conform more closely to RFC 822.
     1.0: Original  */

<!-- Begin
function checkCautare()
{
	x= document.forms.cautare;
	stringEroare = "";
    Rexp = /^(\d{1,2})(\/\d{1,2})(\/\d{4})$/
// pentru data inceput
	if (x.per_inceput.value == 0 || x.per_inceput.value.match(Rexp)==null)
	{
		okdatainceput = false
		alert('Cautare simpla - data start invalida')
	}
	else 
	{
		okdatainceput=true
	}

// pentru data final	
	if (x.per_final.value == 0 || x.per_final.value.match(Rexp)==null)
	{
		okdatafinal = false
		alert('Cautare simpla - data final invalida')
		
	}
	else 
	{
		okdatafinal=true
		
	}
	
	if (okdatainceput && okdatafinal)
	{
		x.submit();
		
	}
	else			
	{
		
	}
}


function checkCautareA()
{
	x= document.forms.cautarea;
	stringEroare = "";
    Rexp = /^(\d{1,2})(\/\d{1,2})(\/\d{4})$/
	Rexppret = /^(\d{1,7})$/ 
// pentru data inceput
	if (x.per_inceputa.value == 0 || x.per_inceputa.value.match(Rexp)==null)
	{
		okdatainceput = false
		alert('data start invalida')
	}
	else 
	{
		okdatainceput=true
	}

// pentru data final	
	if (x.per_finala.value == 0 || x.per_finala.value.match(Rexp)==null)
	{
		okdatafinal = false
		alert('data final invalida')
	}
	else 
	{
		okdatafinal=true
	}
	
// pentru pret
/*
    if (x.pret_min.value != 0 || x.pret_max.value != 0)
	{	
		if (x.pret_min.value.match(Rexppret)==null || x.pret_max.value.match(Rexppret)==null)
		{
			okpret = false
			alert('pret incorect')
		}
		else
		{
			okpret = true
		}
	}
*/
	
	if (okdatainceput && okdatafinal)
	{
		//if (x.pret_min.value != 0 || x.pret_max.value != 0)	
		//{
			//if (okpret)
			x.cautare1.value='save';
			   x.submit();
		/* }
		else
		{
			x.cautare1.value='save';
			x.submit();
		} */
	}
	else			
	{
		
	}

}




function emailCheck (emailStr) 
{
	/*
	ok1 = true
	ok2 = true
    ok3 = true
	ok4 = true
	ok5 = true
	ok6 = true
	*/
	/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
	var emailPat=/^(.+)@(.+)$/
	/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < @ , ; : \ " . [ ]    */
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]"
	/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")"
	/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* The following string represents an atom (basically a series of
   non-special characters.) */
	var atom=validChars + '+'
	/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")"
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	/* Finally, let's start trying to figure out if the supplied address is
   valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
	{
	  	/* Too many/few @'s or something; basically, this address doesn't
     	even fit the general mould of a valid e-mail address. */
		alert("Adresa de e-mail invalida!")
		return false
		//ok1=false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	// See if "user" is valid 
	if (user.match(userPat)==null) 
	{
    	// user is not valid
    	alert("Adresa de e-mail invalida!")
    	return false
		//ok2=false
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) 
	{
    	// this is an IP address
		  for (var i=1;i<=4;i++) 
		  {
	    	if (IPArray[i]>255) 
			{
	        	alert("Adresa de e-mail invalida!")
				return false
				//ok3=false
	    	}			
	     }
    	return true
		//ok3=true
	}

	// Domain is symbolic name

	var domainArray=domain.match(domainPat)
	if (domainArray==null) 
	{
		alert("Adresa de e-mail invalida!")
    	return false
		//ok4=false
	}

	/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

	/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>6) 
	{
   		// the address must end in a two letter or other TLD including museum
   		alert("Adresa de e-mail invalida!")
   		return false
		//ok5=false
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) 
	{
   		var errStr="Adresa de e-mail invalida!"
	    alert(errStr)
   		return false
		//ok6=false
	}
   
	
	// If we've got this far, everything's valid!
	return true;
	
}
//  End -->

//**********************
function checkSolicita()
{
	
	var x=document.solicita;
	
 	var stringEroare = "";
	okn = true;
	okp = true;
	okt = true;
	oko = true;
	oke = true;
	emailStr = document.solicita.email.value;
	
	if (emailCheck (emailStr) == false)
	{
		 stringEroare += "-e-mail<br>"
		 oke=false
	} 
	
	//nume
	if (x.nume.value == 0 ||  !/\S/.test(x.nume.value)) 
	{
		 stringEroare += "-nume<br>"
		 okn=false
	}
	//prenume
	if (x.prenume.value == 0 ||  !/\S/.test(x.prenume.value)) 
	{
		 stringEroare += "-prenume<br>"
		 okp=false
	}
	//telefon
	if (x.telefon.value == 0 ||  !/^[0-9()+ -]*$/.test(x.telefon.value)) 
	{
		 stringEroare += "-telefon<br>"
		 okt=false
	}
	//observatii
	if (x.observatii.value == 0 ||  !/\S/.test(x.observatii.value)) 
	{
		 stringEroare += "-observatii<br>"
		 oko=false
	}
	if (okn && okp && okt && oko && oke)
	{
		document.getElementById('eroare').innerHTML = '';
		x.submit();
		
	}
	else			
	{
		document.getElementById('eroare').innerHTML = 'Urmatoarele rubrici sunt incomplete sau completate incorect:<br> <div style="color:red">' + stringEroare + '</div>';
	}
	
}


//************************************


//**********************
function checkSugestii()
{

	var x=document.sugestii;
	
 	var stringEroare = "";
	okn = true;
	okp = true;
	okt = true;
	oko = true;
	oke = true;
	okadr = true;
	emailStr = document.sugestii.email.value;

	if (emailCheck (emailStr) == false)
	{
		 stringEroare += "-e-mail<br>"
		 oke=false
	}

	//nume
	if (x.nume.value == 0 ||  !/\S/.test(x.nume.value))
	{
		 stringEroare += "-nume<br>"
		 okn=false
	}
	//prenume
	if (x.prenume.value == 0 ||  !/\S/.test(x.prenume.value)) 
	{
		 stringEroare += "-prenume<br>"
		 okp=false
	}
	//adresa
	if (x.adresa.value == 0 ||  !/\S/.test(x.adresa.value)) 
	{
		 stringEroare += "-adresa<br>"
		 okadr=false
	}
	//telefon
	if (x.telefon.value == 0 ||  !/^[0-9()+ -]*$/.test(x.telefon.value)) 
	{
		 stringEroare += "-telefon<br>"
		 okt=false
	}
	//observatii
	if (x.observatii.value == 0 ||  !/\S/.test(x.observatii.value)) 
	{
		 stringEroare += "-observatii<br>"
		 oko=false
	}
	if (okn && okp && okt && oko && oke && okadr)
	{
		document.getElementById('eroare').innerHTML = '';
		x.submit();

	}
	else
	{
		document.getElementById('eroare').innerHTML = 'Urmatoarele rubrici sunt incomplete sau completate incorect:<br> <div style="color:red">' + stringEroare + '</div>';
	}

}
//**********************
function checkRezervari()
{

    var x=document.form_rez;

     var stringEroare = "";
    oktpl = true;
    okcl = true;
    okdp = true;
    okds = true;
    okz = true;
    okp = true;
    oks = true;
    oktp = true;
    oknp = true;
    okn = true;
    oke = true;
    emailStr = document.form_rez.email.value;

    if (emailCheck (emailStr) == false)
    {
         stringEroare += "-e-mail<br>"
         oke=false
    }
    //tipul calatoriei
    if (x.tip.value == 0)
    {
         stringEroare += "-tipul_calatoriei<br>"
         oktpl=false
    }
    //clasa de servici
    if (x.clasa.value == 0 )
    {
         stringEroare += "-clasa_de_servici<br>"
         okcl=false
    }
    //data plecare
    if (x.data_plecare.value == 0 ||  !/\S/.test(x.data_plecare.value))
    {
         stringEroare += "-data_plecare<br>"
         okdp=false
    }
    //data sosire
    if (x.data_sosire.value == 0 ||  !/\S/.test(x.data_sosire.value))
    {
         stringEroare += "-data_sosire<br>"
         okds=false
    }
    //plecare din
    if (x.plecare.value == 0 ||  !/\S/.test(x.plecare.value))
    {
         stringEroare += "-plecare<br>"
         okp=false
    }
    //sosire la
    if (x.sosire.value == 0 ||  !/\S/.test(x.sosire.value))
    {
         stringEroare += "-sosire<br>"
         oks=false
    }
    //Tipul de pasageri
    if (x.pasager1.value == 0 )
    {
         stringEroare += "-tipul_de_pasageri<br>"
         oktp=false
    }
    //Numarul de pasageri
    if (x.nr1.value == 0 )
    {
         stringEroare += "-numarul_de_pasageri<br>"
         oknp=false
    }
    //Tipul zborului
    if (x.zbor.value == 0 ||  !/\S/.test(x.zbor.value))
    {
         stringEroare += "-tipul_zborului<br>"
         okz=false
    }

     //nume
    if (x.nume.value == 0 ||  !/\S/.test(x.nume.value))
    {
         stringEroare += "-nume<br>"
         okn=false
    }

    if (okp && oks && okn && oke && oktpl && okcl &&okdp && okds && okz && oktp && oknp)
    {
        document.getElementById('eroare').innerHTML = '';
        x.submit();

    }
    else
    {
        document.getElementById('eroare').innerHTML = '<font class="text">Urmatoarele rubrici sunt incomplete sau completate incorect:</font><br> <div style="color:red">' + stringEroare + '</div>';
    }

}

//************************************



function checkAplicaCV()
{

	var x=document.aplica;
	
 	var stringEroare = "";
	okn = true;
	okp = true;
	okt = true;
	oka = true;
	okcpc = true;
	okcar = true;
	oke = true;
	oksal = true;
	okdata = true;

	emailStr = document.aplica.email.value;
	
	if (emailCheck (emailStr) == false)
	{
		 stringEroare += "-e-mail<br>"
		 oke=false
	} 
	
	//nume
	if (x.nume.value == 0 ||  !/\S/.test(x.nume.value)) 
	{
		 stringEroare += "-nume<br>"
		 okn=false
	}
	//prenume
	if (x.prenume.value == 0 ||  !/\S/.test(x.prenume.value)) 
	{
		 stringEroare += "-prenume<br>"
		 okp=false
	}
	//adresa
	if (x.adresa.value == 0 ||  !/\S/.test(x.adresa.value)) 
	{
		 stringEroare += "-adresa<br>"
		 oka=false
	}
	 Rexp = /^(\d{1,2})(\/\d{1,2})(\/\d{4})$/
	
	// pentru data nasterii
	if (x.datan.value == 0 || x.datan.value.match(Rexp)==null)
	{
		stringEroare += "-data invalida<br>"
		okdata = false
	}
	
	//telefon
	if (x.telefon.value == 0 ||  !/^[0-9()+ -]*$/.test(x.telefon.value)) 
	{
		 stringEroare += "-telefon<br>"
		 okt=false
	}
	//cunostinte PC
	if (x.cunostintepc.value == 0 ||  !/\S/.test(x.cunostintepc.value)) 
	{
		 stringEroare += "-cunostinte PC<br>"
		 okcpc=false
	}
	//caracterizare
	if (x.caracterizare.value == 0 ||  !/\S/.test(x.caracterizare.value)) 
	{
		 stringEroare += "-autocaracerizare<br>"
		 okcar=false
	}
	//salariu
	if (x.salariu.value == 0 ||  !/\S/.test(x.salariu.value)) 
	{
		 stringEroare += "-salariu<br>"
		 oksal=false
	}
	if (okn && okp && okt && oka && oke && oksal && okcpc && okcar && okdata)
	{
		document.getElementById('eroare').innerHTML = '';
		document.aplica.submit();
	}
	else			
	{
		document.getElementById('eroare').innerHTML = 'Urmatoarele rubrici sunt incomplete sau completate incorect:<br> <div style="color:red">' + stringEroare + '</div>';
	}
	
}


//***********************************
// JavaScript Document


     /***********************************************
     * JavaScript Sound effect- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
     * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
     * This notice must stay intact for legal use
     ***********************************************/

     var soundfile="sidebar.wav" //path to sound file, or pass in filename directly into playsound()

     function playsound(soundfile)
     {
        if (document.all && document.getElementById)
        {
            document.getElementById("soundeffect").src="" //reset first in case of problems
            document.getElementById("soundeffect").src=soundfile
        }
     }

     function bindsound(tag, soundfile, masterElement)
     {
        if (!window.event) return
        var source=event.srcElement
        while (source!=masterElement && source.tagName!="HTML")
        {
            if (source.tagName==tag.toUpperCase())
            {
                playsound(soundfile)
                break
            }
        source=source.parentElement
        }
        }

//*********************************************************************************************************************

function open_win(page)
{

window.open(page,"_blank","left=300, top=300, toolbar=no, location=no, directories=no, status=no, menubar=no, titlebar=no, scrollbars=no, resizable=yes, width=315, height=300")

}

function open_win_gr1(page)
{

window.open(page,"_blank","left=300, top=300, toolbar=no, location=no, directories=no, status=no, menubar=no, titlebar=no, scrollbars=no, resizable=yes, width=365, height=280")

}
 function open_win_gr(page)
{

window.open(page,"_blank","left=300, top=300, toolbar=no, location=no, directories=no, status=no, menubar=no, titlebar=no, scrollbars=no, resizable=yes, width=615, height=480")

}

//************************************************************


function open_win2(page)
{

window.open(page,"_blank","left=300, top=300, toolbar=no, location=no, directories=no, status=no, menubar=no, titlebar=no, scrollbars=yes, resizable=yes, width=650, height=500")

}


