function $(id)
{
	return document.getElementById(id);
}

function isNumber(obj) {
	reg = new RegExp('[^0-9]+', 'g');
	if(reg.test(obj.value))
		obj.value = obj.value.replace(/[^0-9]+/, '');
	
	return true;
}

function intervalColor(obj, color1, color2)
{
    $(obj).style.color = ($(obj).style.color == color1)?color2:color1;
}
 
function over_menu(img,name,pref)
{
	img.src = 'image/bouton/bt_'+pref+'_'+name+'_over.png';
}

function out_menu(img,name,pref)
{
	img.src = 'image/bouton/bt_'+pref+'_'+name+'.png';
}

function photo_popup(url_photo)
{
	titre="Photo Gallerie"; 
	w=open("",'_blank','width=400,height=400,channelmode=no,directories=no,location=no,menubar=no,scrollbars=no,status=no,resizable=no'); 
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>"); 
	w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>"); 
	w.document.write("<BODY onload='checksize()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
	w.document.write("<TD valign='middle' align='center'><IMG src='"+url_photo+"' border=0 alt='Mon image'>"); 
	w.document.write("</TD></TR></TABLE>");
	w.document.write("</BODY></HTML>"); 
	w.document.close();

}

function calcul_prix_saut()
{
	var total =0;
	if($('type_saut').value == 'Tandem')
	{
		total = 210;
		$('bloc_prix_type').innerHTML = total;
	}
	else
	{
		total = 250;
		$('bloc_prix_type').innerHTML = total;
	}
	if($('video_saut').checked)
	{
		total = total+70;
		$('bloc_prix_video').innerHTML = '70 &euro;';
		$('bloc_prix_video').style.display = 'block';
	}
	else
		$('bloc_prix_video').style.display = 'none';
	$('total_saut').value = total;
}

function test_type_saut(sel)
{
	if(sel.value == 'Tandem')
	{
		$("bloc_moment_td").style.display = 'block';
		$("bloc_moment_pac").style.display = 'none';
	}
	else
	{
		$("bloc_moment_td").style.display = 'none';
		$("bloc_moment_pac").style.display = 'block';
	}
}

function open_choose_image(id_bloc,prefix)
{
	window.open('page/admin/popup_image.php?id_bloc='+id_bloc+'&prefix='+prefix,'_blank','width=500,height=350,channelmode=no,directories=no,location=no,menubar=no,scrollbars=no,status=no,resizable=no'); 
}

function delete_news(id_news)
{
	if(confirm('Voulez vous supprimer cette news ?'))
		window.location.href = 'cadre.php?inc=page/home/index.php&confirm=delete_news&ne_id='+id_news;
}

function delete_staffs(id_staffs)
{
	if(confirm('Voulez vous supprimer cet staff ?'))
		window.location.href = 'cadre.php?inc=page/club/index.php&confirm=delete_staffs&st_id='+id_staffs;
}

function delete_livre(id_livre)
{
	if(confirm('Voulez vous supprimer ce message ?'))
		window.location.href = 'cadre.php?inc=page/livre/index.php&confirm=delete_livre&li_id='+id_livre;
}

function delete_video(id_video)
{
	if(confirm('Voulez vous supprimer cette video ?'))
		window.location.href = 'cadre.php?inc=page/gallery/index.php&confirm=delete_video&vi_id='+id_video;
}

function delete_document(id_document,url_document)
{
	if(confirm('Voulez vous supprimer ce document ?'))
		window.location.href = 'cadre.php?inc=page/document/index.php&confirm=delete_document&do_id='+id_document+'&do_url='+url_document;
}

function change_manage_img()
{
	if($("manage_img").value == 'add')
	{
		$("admin_insert_image").style.display = 'block';
		$("admin_delete_image").style.display = 'none';
	}
	else
	{
		$("admin_insert_image").style.display = 'none';
		$("admin_delete_image").style.display = 'block';
	}
}

function change_manage_video()
{
	if($("manage_video").value == 'add')
	{
		$("admin_insert_video").style.display = 'block';
		$("admin_delete_video").style.display = 'none';
	}
	else
	{
		$("admin_insert_video").style.display = 'none';
		$("admin_delete_video").style.display = 'block';
	}
}

function star_mouse(id,type)
{
	val = $("li_note").value;
	for(var i=1; i<=id && val<id && type == 'over'; i++)
	{
		$("img_note_"+i).src = 'image/star.png';
	}
	if(type == 'out')
		star_color(val);
	
}

function star_color(id)
{
	for(var i=1; i<=5; i++)
	{
		if(i<=id)
			$("img_note_"+i).src = 'image/star.png';
		else
			$("img_note_"+i).src = 'image/star off.png';
	}
	$("li_note").value = id;
	
}