var browser 		= navigator.userAgent.toLowerCase();
var isIE 				= ((browser.indexOf( "msie" ) != -1) && (browser.indexOf( "opera" ) == -1) && (browser.indexOf( "webtv" ) == -1));

/* INTEGRATION FLASH */
function flash(url, taille, alttext){
	if(!isIE){
			document.write('<object type="application/x-shockwave-flash"');
			document.write('  data="'+url+'" '+taille+'>');
	}else{
			document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
			document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '+taille+'>');
			document.write('  <param name="movie" value="'+url+'" />');
	}
	document.write('<param name="loop" value="true" />');
	document.write('<param name="menu" value="false" />');
  document.write('<param name="wmode" value="transparent" />');
  document.write('<param name="allowFullScreen" value="true" />');
	document.write('<p>'+alttext+'</p>');
	document.write('</object>');
}


function flashVariable(url, cont, taille, alttext){
	if(!isIE){
			document.write('<object type="application/x-shockwave-flash"');
			document.write('  data="'+url+'" '+taille+'>');
	}else{
			document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
			document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '+taille+'>');
			document.write('  <param name="movie" value="'+url+'" />');
	}
	document.write('<param name="flashvars" value="'+cont+'" />');
	document.write('<param name="loop" value="true" />');
	document.write('<param name="menu" value="false" />');
  document.write('<param name="wmode" value="transparent" />');
  document.write('<param name="allowFullScreen" value="true" />');
	document.write('<p>'+alttext+'</p>');
	document.write('</object>');
}

function openSendDocument(document_id)
{
	var url;
	if (navigator.appName=="Microsoft Internet Explorer")
	{
  		url = 'plugins/document/SendDocument.jsp?document_id='+document_id
	}
	else 
	{
		url = 'jsp/site/plugins/document/SendDocument.jsp?document_id='+document_id
	}
	
	window.open(url,'_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=1, copyhistory=0, menuBar=0, width=950, height=800');
	
}


$(document).ready(function(){	
	if ( $("#AjaxNote").length ) affichNote($("#AjaxNote").attr('rel'));
	$("span.rater").click(function () { 
		$(this).parent().parent().remove();
		//alert(' \n'+$(this).attr('title'));
		submitNote($(this).attr('rel'),$(this).attr('title'));
    });

});


function affichNote(rel) {
	var note = 0;
	$("#AjaxNote").hide();
	$.get("jsp/site/ajaxVote.jsp", {action: "affichNote" , idvideo: rel},
		function(data){
			if(data != "") note = data;
			$("#AjaxNote").attr('style','width:'+note+'px');
			$("#AjaxNote").show("slow");
		}
	);
	
	
}

function submitNote(id,Submitnote){
	var note = 0;
	$("#AjaxNote").hide();
	$.get("jsp/site/ajaxVote.jsp", {action: "submitVote" , idvideo: id , notevalue: Submitnote},
		function(data){
			if(data != "") note = data;
			$("#AjaxNote").attr('style','width:'+note+'px');
			$("#AjaxNote").show("slow");			
			$(".voteElement").replaceWith('<a href="javascript:;" class="lienBleu voteElement" style="display: block; float: left;">> Vote comptabilis\351 !</a>');
		}
	);
}










