var active_image;
var tot_images;
var imagini=new Array();
var title=new Array();

var sub_title=new Array();
var play;

/*function swap_image(i, x,y,autoplay){
	document.getElementById('f').innerHTML='<img src="images/galery/'+imagini[i]+'" width="'+x+'" height="'+y+'" />';
	document.getElementById('subtitlu').innerHTML=sub_title[i];
	i++;
	//alert(document.getElementById('f').innerHTML+"       "+autoplay+"  "+i);
	if(autoplay){
		
		//alert(document.getElementById('f').innerHTML+"       "+autoplay+"  "+i);
		//setTimeout("swap_image(i,x,y,true)", 3000);
	}
}

function swap_buton(tot){
	if (play){
		document.getElementById('but').innerHTML='<input type="submit" name="pause" class="butoane_galerie" value="Pause" onclick="play=false;swap_buton('+tot+');slideshow(0,'+tot+',400,300);"/>';
	}else{
		document.getElementById('but').innerHTML='<input type="submit" name="play" class="butoane_galerie" value="Play" onclick="play=true;swap_buton('+tot+');slideshow(0,'+tot+',400,300);"/>';
	}
}


function slideshow(im,tot,x,y){
	 if (play){
	 	if(im>tot-1){ 
	 		im=0;
			document.getElementById('f').innerHTML='<img src="images/galery/'+imagini[im]+'" width="'+x+'" height="'+y+'" title="'+title[im]+'" />';
			document.getElementById('subtitlu').innerHTML=sub_title[im];
			im++;
			//alert(im+" of total:"+tot);
			setTimeout("slideshow("+im+","+tot+","+x+","+y+")",6000);
				//alert(document.getElementById('f').innerHTML);
			//return (im * slideshow (im+1,tot,x,y) );
	 	}
	 	else{
			
			document.getElementById('f').innerHTML='<img src="images/galery/'+imagini[im]+'" width="'+x+'" height="'+y+'" title="'+title[im]+'"/>';
			document.getElementById('subtitlu').innerHTML=sub_title[im];
			im++;
			//alert(im+" of total:"+tot);
			setTimeout("slideshow("+im+","+tot+","+x+","+y+")",6000);
				//alert(document.getElementById('f').innerHTML);
			//return (im * slideshow (im+1,tot,x,y) );
		}
	 }else{
	return 1;	 
	}
	 
}

function init(imagine,x,y){
		active_image=0;
		//tot_images=0;
		stoped=false;
		play=true;
		//alert(i);
		slideshow(0,i,400,300)
}*/

function validare_service() {

	if((document.form1.titlu.value=='')||(document.form1.continut.value=='')||(document.form1.foto.value=='')||(document.form1.limba.value=='Chose a language')){
		alert('Fill all fields on the form');
		return false;
	}
	
	else{
		return true;
	}
}

function validare_foto() {

	if((document.form1.titlu.value=='')||(document.form1.foto.value=='')){
		alert('Fill all fields on the form');
		return false;
	}
	
	else{
		return true;
	}
}


function validare_blog_coment() {
	//alert('document.form1.nume.value')
	if(ValidBotBoot()){
		if(echeck(document.form1.mail.value)){
			if((document.form1.nume.value=='')||(document.form1.mail.value=='')||(document.form1.continut.value=='')){
				alert('Fill all fields on the form');
				return false;
			}else{
				return true;
			}
		}else{
			return false;	
		}
	}else{
		alert('Fill all fields on the form');
		return false;	
	}
}

function validare_mail_form() {
	//alert('document.form1.nume.value')
	if(echeck(document.form1.mail.value)){
	if((document.form1.nume.value=='')||(document.form1.mail.value=='')||(document.form1.telefon.value=='')||(document.form1.mesaj.value=='')){
		alert('Fill all fields on the form');
		return false;
	}
	
	else{
		return true;
	}
	}else{
		return false;	
	}
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

//------------------------------------kaptcha------------------
var a = Math.ceil(Math.random() * 10);
var b = Math.ceil(Math.random() * 10);       
var c = a + b
function DrawBotBoot()
{
	document.write(a + " + " + b +"=");
	document.write("<input id='BotBootInput' type='text' value='' maxlength='2' size='2'/>");
}    
function ValidBotBoot(){
	var d = document.getElementById('BotBootInput').value;
	if (d == c) return true;        
	return false;
	
}

$(function(){
	$("a.lbox").lightBox();
});