function SendToAFriend(Video)
{
	window.open('envoyer-a-un-ami-' + Video + '.html', 'popup', 'location=1,directories=1,scrollbars=1,resizable=1,menuBar=1,width=500,height=300');
}

function ajax(url)
{
    var xhr=null;

    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhr.open("GET", url, false);
    xhr.send(null);

   return xhr.responseText;
}

function changePhoto(id, number)
{
	var obj = document.getElementById('photoSlider');
	obj.innerHTML = ajax('index.php?page=video&id=' + id + '&action=changephoto&number=' + number);
}

function showComment(id)
{
	var comment = document.getElementById('comment' + id);
	var comments = document.getElementsByName('comment');
	var i;
	
	for(i = 0; i < comments.length; i++)
	{
		comments[i].className = "comment";
	}
	
	comment.className = "comment active";
	
	var pagecomment = document.getElementById('commentPage' + id);
	var pagecomments = document.getElementsByName('commentPage');
	var i;
	
	for(i = 0; i < comments.length; i++)
	{
		pagecomments[i].className = "";
	}
	
	pagecomment.className = "active";
}

function addVideoFile()
{
	var videoFileListObj = document.getElementById('VideoFileList');
	var newdiv = document.createElement('div');
	newdiv.innerHTML = '<input type="file" name="VideoFile[]" class="edit" />';
	videoFileListObj.appendChild(newdiv);
}

function addTag(Id, Tag)
{
	var control = document.getElementById(Id);
	
	var BeginTag = "[" + Tag + "]";
	var EndTag = "[/" + Tag + "]";

	if(Tag == 'url')
	{
		var url = prompt("Saisissez une URL");
		if(url != null)
			 BeginTag = "[" + Tag + "=" + url + "]";
	}	

	if(navigator.appName.indexOf('Internet Explorer') != -1)
	{
		// IE
		control.focus();
		selectedText = document.selection.createRange();
		selectedText.text = BeginTag + selectedText.text + EndTag;
	}
	else if(control.selectionStart != undefined)
	{
		// Firefox, Safari
		Before = control.value.substring(0, control.selectionStart);
		After = control.value.substring(control.selectionEnd, control.value.length);
		Selection = control.value.substring(control.selectionStart, control.selectionEnd);
		control.value = Before + BeginTag + Selection + EndTag + After;
	}
	else if(document.getSelection)
	{
		// Safari sans slection
		control.value += BeginTag + EndTag;
	}
}

