function addThisURL() {
	var com1=document.getElementById('daId').value;
	//alert(''+com1);
	var ajax = new XHR();
	ajax.appendData('url',''+com1);
	ajax.appendData('action','addThisURL');
	Categ=document.getElementById('Categ').value;
ssCateg=document.getElementById('categorie').value;
langue=document.getElementById('lang').value;
textATaper= document.getElementById('textATaper').value;
newTitle=  document.getElementById('newTitle').value;

//alert(''+textATaper+' '+newTitle);
ajax.appendData('textATaper',''+textATaper);
ajax.appendData('newTitle',''+newTitle);
ajax.appendData('ssCateg',''+ssCateg);
ajax.appendData('Categ',''+Categ);
ajax.appendData('lang',''+langue);
nCateg=document.getElementById('ncat').value;
nsCateg=document.getElementById('nscat').value;
nsCateg2=document.getElementById('nscat2').value;
ajax.appendData('nCateg',''+nCateg);
ajax.appendData('nsCateg',''+nsCateg);
ajax.appendData('nsCateg2',''+nsCateg2);

ajax.send("../fonctionAjax.php");
       ajax.complete = function (xhr) 
        {
			document.getElementById('resulatAddVid').innerHTML = xhr.responseText;
		}
		
		if (nsCateg!='') {
			//alert("reloadsubcat");
			document.getElementById('nscat').value='';
			loadSubCat();
		}
		
}


function showURL() {
	//alert("add comment");
	var com1=document.getElementById('daId').value;
	
	document.getElementById('searchResultsVideoColumn2').src=com1;
		
			
			//document.getElementById('addCom').style.display="none";
		
}
function showURL2() {
	//alert("add comment");
	//var com1=document.getElementById('daId2').value;
	var com2=document.getElementById('daId').value;
	var ajax = new XHR();
	
	//ajax.appendData('querry',''+com1);
	ajax.appendData('urlVideo',''+com2);
	
	ajax.appendData('action','showInfoAllocine');
	ajax.send("../fonctionAjax.php");
    ajax.complete = function (xhr) 
        {
		
		
		/*
		var r=xhr.responseText.substring(0,2);
		if (r=='<d') {
		//alert ("red");
			document.getElementById('commentForm').style.display="none";
		}
		*/
			document.getElementById('searchResultsVideoColumn2').innerHTML = xhr.responseText;
			
		}
	//document.getElementById('infoAllocine').src=com1;
		
			
			//document.getElementById('addCom').style.display="none";
		
}

function showDaVid(id) {
	var ajax = new XHR();
	
	ajax.appendData('id',''+id);
	
	ajax.appendData('action','showDaVid');
	ajax.send("../fonctionAjax.php");
    ajax.complete = function (xhr) 
        {
		
		
		/*
		var r=xhr.responseText.substring(0,2);
		if (r=='<d') {
		//alert ("red");
			document.getElementById('commentForm').style.display="none";
		}
		*/
			document.getElementById('searchResultsVideoColumn').innerHTML = xhr.responseText;
			
		}
	
}

function addComment() {
		
			document.getElementById('addCom').style.display="none";
			document.getElementById('commentForm').style.display="block";
		
}

function addComment1() {
		
			document.getElementById('addCom1').style.display="none";
			document.getElementById('commentForm1').style.display="block";
		
}

function saveComment() {
	//alert("add comment");
	
	var ajax = new XHR();
	
	var com1=document.getElementById('com1').value;
	var com2=document.getElementById('com2').value;
	var com3=document.getElementById('com3').value;
	var com4=document.getElementById('com4').value;
	//document.getElementById('newComment').innerHTML = ''+com1;
	ajax.appendData('com1',''+com1);
	ajax.appendData('com2',''+com2);
	ajax.appendData('com3',''+com3);
	ajax.appendData('com4',''+com4);
	
	ajax.appendData('action','saveComment');
	ajax.send("fonctionAjax.php");
    ajax.complete = function (xhr) 
        {
		
		var r=xhr.responseText.substring(0,2);
		
		if (r=='<d') {
		//alert ("red");
			document.getElementById('commentForm').style.display="none";
		}
		
			document.getElementById('newComment').innerHTML = xhr.responseText;
			//document.getElementById('addCom').style.display="none";
		}
}


function addVideoTut() {
var ajax = new XHR();

Categ=document.getElementById('Categ').value;
ssCateg=document.getElementById('categorie').value;
langue=document.getElementById('lang').value;
textATaper= document.getElementById('textATaper').value;
newTitle=  document.getElementById('newTitle').value;

//alert(''+textATaper+' '+newTitle);
ajax.appendData('textATaper',''+textATaper);
ajax.appendData('newTitle',''+newTitle);
ajax.appendData('action','apiAddVid');
ajax.appendData('ssCateg',''+ssCateg);
ajax.appendData('Categ',''+Categ);
ajax.appendData('lang',''+langue);
nCateg=document.getElementById('ncat').value;
nsCateg=document.getElementById('nscat').value;
nsCateg2=document.getElementById('nscat2').value;
ajax.appendData('nCateg',''+nCateg);
ajax.appendData('nsCateg',''+nsCateg);
ajax.appendData('nsCateg2',''+nsCateg2);

ajax.send("../fonctionAjax.php");
       ajax.complete = function (xhr) 
        {
			document.getElementById('resulatAddVid').innerHTML = xhr.responseText;
		}
		if (nsCateg!='') {
			//alert("reloadsubcat");
			document.getElementById('nscat').value='';
			loadSubCat();
		}
		
}

function loadSubCat() {
//alert('Loading'); 
cat1=document.getElementById('Categ').value;


var ajax = new XHR();
ajax.appendData('famID',''+cat1);
ajax.appendData('action','loadSubCat');

ajax.send("../fonctionAjax.php");
       ajax.complete = function (xhr) 
        {
			//alert(''+xhr.responseText);
			document.getElementById('categorie').innerHTML = xhr.responseText;
		}
}
 

function processTutoSubmition() {
document.getElementById('messageOut').innerHTML = "<img src=images/loading.gif>";

	nom=document.getElementById('Nom').value;
	lien=document.getElementById('lien').value;
	categ=document.getElementById('Categ').value;
	nCateg=document.getElementById('ncat').value;
	ssCateg=document.getElementById('categorie').value;
	nsCateg=document.getElementById('nscat').value;
	minutes=document.getElementById('minutes').value;
	secondes=document.getElementById('secondes').value;
	usefulURL=document.getElementById('usefulURL').value;
	userName1=document.getElementById('userName1').value;
	userEmail=document.getElementById('userEmail').value;
	captcha= document.getElementById('captchac').value;
	info= document.getElementById('info').value;
	
	var ajax = new XHR();
	
	ajax.appendData('nom',''+nom);
	ajax.appendData('lien',''+lien);
	ajax.appendData('categ',''+categ);
	ajax.appendData('nCateg',''+nCateg);
	ajax.appendData('ssCateg',''+ssCateg);
	ajax.appendData('nsCateg',''+nsCateg);
	ajax.appendData('minutes',''+minutes);
	ajax.appendData('secondes',''+secondes);
	ajax.appendData('usefulURL',''+usefulURL);
	ajax.appendData('userName1',''+userName1);
	ajax.appendData('userEmail',''+userEmail);
	ajax.appendData('captcha',''+captcha);
	ajax.appendData('info',''+info);
	ajax.appendData('action','submitTuto');
	ajax.send("fonctionAjax.php");
       ajax.complete = function (xhr) 
        {
		// Pas oublier de changer la couleur du fond
		var r=xhr.responseText.substring(0,1);
		var toPrint=xhr.responseText.substring(1,xhr.responseText.length);
		//alert(''+r);
		if (r=='r') {
		//alert ("red");
			document.getElementById('messageOut').style.background="#dd0000";
		}
		else {
		document.getElementById('messageOut').style.background="#37f706";
		
		document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random();
		
		document.getElementById('captchac').value='';
		document.getElementById('Nom').value='';
	    document.getElementById('lien').value='';
		document.getElementById('ncat').value='';
		document.getElementById('nscat').value='';
		document.getElementById('minutes').value='';
		document.getElementById('secondes').value='';
		document.getElementById('usefulURL').value='';
		document.getElementById('info').value='';
		}
		
		document.getElementById('messageOut').innerHTML = toPrint;
		}			
} 

function processMessageSubmition() {
document.getElementById('messageOut').innerHTML = "<img src=images/loading.gif>";

	nom=document.getElementById('Nom').value;
	lien=document.getElementById('lien').value;
	nCateg=document.getElementById('ncat').value;
	captcha= document.getElementById('captchac').value;
	info= document.getElementById('info').value;
	 
	var ajax = new XHR();
	
	ajax.appendData('nom',''+nom);
	ajax.appendData('lien',''+lien);
	ajax.appendData('nCateg',''+nCateg);
	ajax.appendData('captcha',''+captcha);
	ajax.appendData('info',''+info);
	ajax.appendData('action','submitMessage');
	ajax.send("fonctionAjax.php");
       ajax.complete = function (xhr) 
        {
		// Pas oublier de changer la couleur du fond
		var r=xhr.responseText.substring(0,1);
		var toPrint=xhr.responseText.substring(1,xhr.responseText.length);
		//alert(''+r);
		if (r=='r') {
		//alert ("red");
			document.getElementById('messageOut').style.background="#dd0000";
		}
		else {
		document.getElementById('messageOut').style.background="#37f706";
		
		document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random();
		
		document.getElementById('captchac').value='';
		document.getElementById('Nom').value='';
	    document.getElementById('lien').value='';
		document.getElementById('ncat').value='';
		document.getElementById('info').value='';
		}
		
		document.getElementById('messageOut').innerHTML = toPrint;
		}			
		
}

function handleKeyPress(e){
var key=e.keyCode || e.which;
if (key==13){
valider();
}
}
function valider() {
 recherche=document.getElementById('search').value;
 recherche = recherche.replace(/ /g, '-');
 recherche = recherche.replace(/é/g, 'e');
 recherche = recherche.replace(/è/g, 'e');
 recherche = recherche.replace(/à/g, 'a');
 recherche = recherche.replace(/ç/g, 'c');
 
 window.location.href='http://video-tuto.com/_'+recherche;
  // si la valeur du champ prenom est non vide

 //   alert("Saisissez le prénom");
  }
function savepic() {
nom=document.getElementById('nom').value;
url=document.getElementById('url').value;
//alert(''+nom+' '+url); 
var ajax = new XHR();
	
	ajax.appendData('nom',''+nom);
	ajax.appendData('url',''+url);
	ajax.appendData('action','savepic');
	ajax.send("fonctionAjax.php");
	 ajax.complete = function (xhr) 
        {
			alert(''+xhr.responseText);
			//document.getElementById('categorie').innerHTML = xhr.responseText;
		}
}
