function AddAds(){
	document.forms[0].action='addactivity.php';
	document.forms[0].submit();
}

function ShowCommentBox(ads_id){
	if (! document.getElementById) {
		alert("Your browser is too old too support this feature. Please try installing a more recent one.");
	}
	else {
		eval("document.getElementById('dv_cmt_"     + ads_id + "').style.display=''");
		eval("document.getElementById('btn_addCmt_" + ads_id + "').style.display='none'");
		eval("document.getElementById('btn_submit_" + ads_id + "').style.display=''");
		eval("document.getElementById('btn_cancel_" + ads_id + "').style.display=''");
		eval("document.getElementById('cmt_lib_"    + ads_id + "').focus()");
	}
}

function HideCommentBox(ads_id){
		if (! document.getElementById) {
		alert("Your browser is too old too support this feature. Please try installing a more recent one.");
	}
	else {
		eval("document.getElementById('dv_cmt_"     + ads_id + "').style.display='none'");
		eval("document.getElementById('btn_addCmt_" + ads_id + "').style.display=''");
		eval("document.getElementById('btn_submit_" + ads_id + "').style.display='none'");
		eval("document.getElementById('btn_cancel_" + ads_id + "').style.display='none'");
	}
}

function AddComment(ads_id){
	document.forms[0].action = "addcomment.php";
	document.forms[0].ads_id.value = ads_id;
	document.forms[0].url_from.value = document.forms[0].url_from.value + "#" + ads_id;
	document.forms[0].submit();
}		

function DelComment(cmt_id, ads_id){
	if( confirm("Voulez-vous supprimer définitivement ce commentaire ?") ){
		document.forms[0].action = "delcomment.php";
		document.forms[0].cmt_id.value = cmt_id;
		document.forms[0].ads_id.value = ads_id;
		document.forms[0].submit();
	}
}	

function AddToFavorite(usr_id, ads_id){
	if( confirm("Voulez-vous ajouter cet Ego à vos favoris ?") ){
		document.forms[0].action = "addfavorite.php";
		document.forms[0].usr_id.value = usr_id;
		document.forms[0].ads_id.value = ads_id;
		document.forms[0].url_from.value = document.forms[0].url_from.value + "#" + ads_id;
		document.forms[0].submit();
	}
}

function DelFavorite(ads_id){
	if( confirm("Voulez-vous supprimer définitivement cet Ego de vos favoris ?") ){
		document.forms[0].action = "delfavorite.php?ads_id=" + ads_id;
		document.forms[0].submit();
	}
}			

function DelActivity(ads_id, tle){
	if( confirm("Voulez-vous supprimer définitivement l'annonce intitulée \"" + tle + "\" ?") ){
		document.forms[0].action = "delactivity.php";
		document.forms[0].ads_id.value = ads_id;
		document.forms[0].url_from.value = document.forms[0].url_from.value + "#" + ads_id;
		document.forms[0].submit();
	}
}		

function ShowEmailBox(ads_id){
	if (! document.getElementById) {
		alert("Your browser is too old too support this feature. Please try installing a more recent one.");
	}
	else {
		eval("document.getElementById('dv_cmt_box_"   + ads_id + "').style.display='none'");
		eval("document.getElementById('dv_email_box_" + ads_id + "').style.display=''");
		eval("document.getElementById('email_txt_"    + ads_id + "').focus()");
	}
}

function HideMailBox(ads_id){
	if (! document.getElementById) {
		alert("Your browser is too old too support this feature. Please try installing a more recent one.");
	}
	else {
		eval("document.getElementById('dv_cmt_box_"   + ads_id + "').style.display=''");
		eval("document.getElementById('dv_email_box_" + ads_id + "').style.display='none'");
	}
}

function SendUserMail(ads_id, usr_eml_to){
	if( eval("document.forms[0].email_txt_" + ads_id).value == "" ){
		alert("Veuillez saisir un contenu au message");
		return false;
	}
	else{
		if( confirm("Confirmez-vous l\'envoi de cet email?") ){
			document.forms[0].usr_eml_to.value = usr_eml_to;
			document.forms[0].ads_id.value     = ads_id;
			document.forms[0].action = "sendUserMail.php";
			document.forms[0].submit();
		}
	}
}

function ShowAvailibilities(ads_id){
	if (! document.getElementById) {
		alert("Your browser is too old too support this feature. Please try installing a more recent one.");
	}
	else {
		for(var i=1; i<=35; i++){
			eval("document.getElementById('week_" + ads_id + "_chk" + i + "').style.display=''");
		}
		//display the input's background in white
		eval("document.getElementById('tle_"  + ads_id + "').className = 'visible'");
		eval("document.getElementById('lvl_"  + ads_id + "').className = 'visible'");
		eval("document.getElementById('cmnt_" + ads_id + "').className = 'visible'");
		
		//set the inputs editable
		eval("document.getElementById('tle_"  + ads_id + "').readOnly = false");
		eval("document.getElementById('lvl_"  + ads_id + "').disabled = false");
		eval("document.getElementById('cmnt_" + ads_id + "').readOnly = false");
		
		eval("document.getElementById('dv_actions_box_"        + ads_id + "').style.display='none'");	
		eval("document.getElementById('dv_availabilities_box_" + ads_id + "').style.display=''");
	}
}

function HideAvailibilities(ads_id){
	if (! document.getElementById) {
		alert("Your browser is too old too support this feature. Please try installing a more recent one.");
	}
	else {
		for(var i=1; i<=35; i++){
			eval("document.getElementById('week_" + ads_id + "_chk" + i + "').style.display='none'");
		}
		
		//hide the input's background
		eval("document.getElementById('tle_"  + ads_id + "').className = 'hidden'");
		eval("document.getElementById('lvl_"  + ads_id + "').className = 'hidden'");
		eval("document.getElementById('cmnt_" + ads_id + "').className = 'hidden'");
		
		//set the inputs editable
		eval("document.getElementById('tle_"  + ads_id + "').readOnly = true");
		eval("document.getElementById('lvl_"  + ads_id + "').disabled = true");
		eval("document.getElementById('cmnt_" + ads_id + "').readOnly = true");	
			
		eval("document.getElementById('dv_actions_box_"        + ads_id + "').style.display=''");	
		eval("document.getElementById('dv_availabilities_box_" + ads_id + "').style.display='none'");	
	}
}	

function UpdateAvailibilities(ads_id){
	if( confirm("Confirmez-vous la modification de votre annonce ?") ){
		document.forms[0].action = "updavailabilities.php";
		document.forms[0].ads_id.value = ads_id;
		document.forms[0].url_from.value = document.forms[0].url_from.value + "#" + ads_id;
		document.forms[0].submit();
	}
}	

function ShowAllComments(ads_id){
	document.forms[0].ads_id.value = ads_id;
	document.forms[0].action = "editcomments.php";
	document.forms[0].submit();
}
