function validateFirm ( form ) {

	if ( form.firmname.value == '' ) {
		alert ( "Va rugam completati numele numele firmei!" ) ;
		form.firmname.focus();
		return false;
	}

	if ( form.description.value == '' ) {
		alert ( "Va rugam introduceti descrierea activitatii firmei!" ) ;
		form.description.focus();
		return false;
	}

	if ( form.description.value.length > 500 ) {
		alert ( "Descrierea activitatii firmei nu trebuie sa depaseasca 500 caractere!" ) ;
		form.description.focus();
		return false;
	}
	
	checked = false;
	for ( i = 0 ; i < form.elements.length; i++ ) {
		if ( form.elements[i].type == "checkbox" && form.elements[i].name != "accord" ) {
			if ( form.elements[i].checked ) {
				checked = true;
				break;
			}
		}
	}
	
	if ( !checked ) {
		alert ( "Va rugam selectati domeniile de activitate ale firmei!" );
		return false;
	}
	
	
	if ( form.address.value.length == 0 ) {
		alert ( "Va rugam completati adresa!" ) ;
		form.address.focus();
		return false;
	}
	
	if ( form.city.value.length == 0 && form.sector.selectedIndex == 0) {
		alert ( "Va rugam introduceti localitatea sau (in cazul Bucurestiului) alegeti sectorul!" ) ;
		form.city.focus();
		return false;
	}
	
	if ( form.countyid.selectedIndex == 0) {
		alert ( "Va rugam alegeti judetul!" ) ;
		form.countyid.focus();
		return false;
	}
	

	if ( form.phone.value.length == 0 && form.cellphone.value.length == 0 && form.fax.value.length == 0 && form.email.value.length == 0 && (form.site.value.length == 0 || form.site.value == "http://")) {
		alert ( "Va rugam inserati cel putin modalitate de contact!" ) ;
		form.phone.focus();
		return false;
	}

	if ( form.email.value.length > 0 && ! isMail( form.email ) ){
		alert ( "Adresa e-mail introdusa nu este corecta!" ) ;
		form.email.focus();
		return false;
	}
	

	if ( !form.accord.checked ){
		alert ( "Pentru a va putea inscrie pe site trebuie sa fiti de acord cu Termenii si conditiile de utilizare a www.AnuntGratis.ro!" ) ;
		form.email.focus();
		return false;
	}

	return true;
}


function changeSectorCounty ( form , selected) {


	if ( selected + "" == "sector" ) {

//selectez Bucuresti ca judet daca cineva incearca sa puna un sector
		if ( form.sector.selectedIndex > 0 ) {

			form.countyid.selectedIndex = 10 ;

		}

	}
	else{
			
		if ( selected + "" == "countyid" ) {
		
//daca se selecteaza altceva decat Bucuresti in campul de judete, atunci deselectez sectorul
			if ( form.countyid.selectedIndex != 10 ) {
			
				form.sector.selectedIndex = 0 ;
		
			}
		}
	}

}

function show_hide_subDomains2 ( tr, exp, a, title1, title2) {

	if ( tr.style.display + "" == "none" ) {
		tr.style.display = "";
		exp.src='images/unexpand.gif';
		a.title = title2;
	}
	else{
		tr.style.display = "none";
		exp.src='images/expand.gif';
		a.title = title1;
	}
}

function show_hide_subDomains ( tr) {

	if ( tr.style.display + "" == "none" ) {
		tr.style.display = "";
	}
	else{
		tr.style.display = "none";
	}
}
