function check_email(email)
{
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(email) && r2.test(email));
}

function daysInFebruary (year){
   return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function check_date(day,month,year)
{
	var daysInMonth = DaysArray(12)
	if ( (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
	{
		return false;
	}
	else
	{
		return true;
	}
}
		
function newwin(location,name,w,h)
{
var scrw=(screen.width/2)-(w/2);
var scrh=(screen.height/2)-(h/2);
window.open(location,name,'scrollbars="no",left='+scrw+',top='+scrh+',width='+w+',height='+h);
}

function newwin1(location,name,w,h)
{
window.open(location,name,'scrollbars="no",left=10,top=10,width='+w+',height='+h);
}

function openwinwithtarget(link,target)
{
window.open(link,target);
}


function openwin(link)
{
window.open(link,"_self");
}

function send2an(obj)
{
var err=0;
if ((obj.title.value.length<1)&&(err==0)) { err=1;alert("Nu ati introdus nici un titlu pentru anunt !");obj.title.focus();}
if ((obj.descr.value.length<1)&&(err==0)) { err=1;alert("Nu ati introdus nici o descriere a anuntului !");obj.descr.focus();}
if ((obj.idc.value==0)&&(err==0)) { err=1;alert("Nu ati selectat o categorie !");obj.idc.focus();}
if ((obj.city.value.length<1)&&(err==0)) { err=1;alert("Nu ati introdus un judet valid !");obj.city.focus();}
if ((obj.country.value==0)&&(err==0)) { err=1;alert("Nu ati selectat o tara !");obj.country.focus();}
if ( !check_email(obj.email.value) && (err==0) ) { err=1;alert("Adresa de email este invalida !");obj.email.focus();}
if ( !check_date(obj.day.value,obj.month.value,obj.year.value) && (err==0) ) { err=1;alert("Ati introdus o data incorecta !");obj.day.focus();}
if (err==0) obj.submit();
}

function send2contact(obj)
{
var err=0;
if ((obj.name.value.length<1)&&(err==0)) { err=1;alert("ERROR!!");obj.name.focus();}
if ((obj.email.value.length<1)&&(err==0)) { err=1;alert("ERROR!!");obj.email.focus();}
if ((obj.comments.value.length<1)&&(err==0)) { err=1;alert("ERROR!!");obj.comments.focus();}

if (err==0) obj.submit();
}

function getKey() {
   var keyCode = event.keyCode;
return keyCode;
}


function send2key(obj)
{
var key=getKey();
//alert("dsakjda");
if (key==13) send2(obj);
}

function send2(obj)
{
obj.submit();
}

function checkgb(obj)
{
var err=0;
if ((err==0)&&(obj.name.value.length<3)) { obj.name.focus(); err=1;}
if ((err==0)&&(obj.email.value.length<3)) { obj.email.focus(); err=1;}

if (err==1) alert("ERROR!!!");
if (err==0) obj.submit();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function check()
{
im=document.faddan.imgfile;
img=document.faddan.img;
if ((im.value!=oldimg)&&(im.value.length>0)) { oldimg=im.value; 
						img.src=oldimg;
						}
setTimeout("check()",1000);
}

//menu
function SOL_menu( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#69c';
				break;
			default:
				if ( document.getElementsByTagName ) {
					//tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#036';
				break;
			default:
				if ( document.getElementsByTagName ) {
					//tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}

function SOL_menuClick( tableCellRef, navStyle, url ) {
	SOL_menu( tableCellRef, 0, navStyle );
	SOL_goTo( url );
}

function SOL_goTo(url)
{
window.location=url;
}

//end menu
