<!--
//afiseaza o imagine aleatoare
intImg_ = 20; // numarul de imagini
arrImg_ =["slideshow2","slideshow3","slideshow4","slideshow6","slideshow8","slideshow9","slideshow10","slideshow11","slideshow12","slideshow14","slideshow15","slideshow16","slideshow17","slideshow18","slideshow19","slideshow20","slideshow22","slideshow23","slideshow24","slideshow25"]; // lista cu imaginile

function randomNumber_(limit){
  return Math.floor(Math.random()*limit);
}

function randomImage_()
{
 i = randomNumber_(intImg_);
 document.write('<IMG height=125 width=688 src="res/'+arrImg_[i]+'.jpg">');
}

//---
//schimba imaginea din intTime in intTime sec


var intTime = 25000;
var oldnum;
var arrImg = ["slideshow2","slideshow3","slideshow4","slideshow6","slideshow8","slideshow9","slideshow10","slideshow11","slideshow12","slideshow14","slideshow15","slideshow16","slideshow17","slideshow18","slideshow19","slideshow20","slideshow22","slideshow23","slideshow24","slideshow25"]; // lista cu imaginile
var intImg = arrImg.length;

function rand(min,max,except) {
	res = (Math.floor(Math.random()*max))+min;
	if(res == except) rand(min,max,except);
	return res;
}

function startSrc() {
	if(document.imgHeader) setInterval('setSrc()',intTime);
}

function setSrc() {
	var ratio = rand(0,5);
	var num = (ratio == 0 && oldnum != 0)? 0 : rand(0,intImg,oldnum);
	//document.imgHeader.src='res/'+arrImg[num]+'.jpg';
	blendimage('spanid', 'imgHeader', 'res/'+arrImg[num]+'.jpg', 600);
	oldnum = num;
}

window.onload = startSrc

function randomImage(default_)
{
document.write("<img height=125 width=688 src='res/"+default_+".jpg' name='imgHeader' id='imgHeader' style='FILTER: progid:DXImageTransform.Microsoft.Fade(Overlap=1); '>");
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function blendimage(spanid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(spanid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
}

function randomImageEffect(default_)
{
document.write("<span id='spanid' style='background-image: url(res/"+default_+".jpg); background-repeat: no-repeat; background-position:top;'><img height=125 width=688 src='res/"+default_+".jpg' name='imgHeader' id='imgHeader'></span>");
}
//---
//functii pentru validari de formuri

function emptystr(theElement) {
	if  ((theElement==null) || (theElement.length == 0))
		return true;
	else
		return false;
}

function isEmail(theElement, theElementName) {
  str = theElement.value;
  if (!(result = ((str != "") && (str.indexOf("@") != -1) && (str.indexOf(".") != -1)))) {
    alert( theElementName + " trebuie sa fie de forma:\nex: nume@domeniu.tld" );
    theElement.focus();
  } 
  return result;
}

function isString(theElement, theElementName) {
   var newValue = theElement.value;
   var newLength = newValue.length;
   var extraChars=new String(",.- ");
   var search;
   for(var i = 0; i != newLength; i++) {
      aChar = newValue.substring(i,i+1);
      search = extraChars.indexOf(aChar);
      aChar = aChar.toUpperCase();
      if(search == -1 && (aChar < "A" || aChar > "Z") ) {
        alert( "ATENTIE!\n" + theElementName +  " trebuie sa contina doar litere!" );
	    theElement.focus(); 
	 	return false;
      }
   }
   return true;
}

function isNumber(theElement, theElementName)
{
  s = theElement.value;
  if ( (s == "") || (isNaN(Math.abs(s)) && (s.charAt(0) != '#')))
  {
      if ( isNumber.arguments.length  == 1 ) 
         alert( " Valoarea trebuie sa fie un numar." );
      else  
         alert( theElementName +  " trebuie sa contina doar cifre!" );
    theElement.focus(); 
    return false;
  }
  return true;
}

//----
//text counter 
function textCounter(field, cntfield, maxlimit)
{	
	if (field.value.length > maxlimit)
	{
	field.value = field.value.substring(0, maxlimit);
	}
	else
	{
	cntfield.value = maxlimit - field.value.length;
	}
}

//----
//

function verifycontactform(){
	if (emptystr(document.newform.nume.value)){
		alert('Va rugam sa va introduceti numele!');
		document.newform.nume.focus();
		return false;
	}
	else 
	if(!isString(document.newform.nume,'Numele')) return false;	
	
	if (emptystr(document.newform.email2.value)){
		alert('Va rugam  sa va introduceti adresa de e-mail!');
		document.newform.email2.focus();
		return false;
	}
	else 
	if(!isEmail(document.newform.email2, 'E-mail'))	return false;
	
	if (emptystr(document.newform.telefon.value)){
		alert('Va rugam  sa va introduceti numarul de telefon!');
		document.newform.telefon.focus();
		return false;
	}
	else 
	if(!isNumber(document.newform.telefon, 'Telefonul')) return false;

	if (emptystr(document.newform.subiect.value)){
		alert('Va rugam sa introduceti subiectul mesajului!');
		document.newform.subiect.focus();
		return false;
	}

			
	if (emptystr(document.newform.mesaj.value)){
		alert('Va rugam  sa va introduceti mesajul!');
		document.newform.mesaj.focus();
		return false;
	}
	
	return true;
}


function verifynewsletter(){
	if (emptystr(document.newsletter.email.value)){
		alert('Va rugam sa introduceti e-mail-ul!');
		document.newsletter.email.focus();
		return false;
	}
	else 
	if(!isEmail(document.newsletter.email, 'E-mail')) return false;
	
	document.newsletter.submit();
} 

//-->
