function SubScribeContest( name, mail, uid, isdate ) {
        var handlerFunc = function(t) {
        }
        var errFunc = function(t) {
                var msgDiv = $('haveparticipate');
                if (msgDiv) {
                        msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
                }
        }
        var url = document.location.href;
        var parms = 'tafUrl='+url;
        parms += '&name='+name;
        parms += '&mail='+mail;
        parms += '&uid='+uid;
        parms += '&isdate='+isdate;

        new Effect.BlindUp('paticipate', {duration: 0.40});
        new Effect.BlindDown('haveparticipate', {duration: 0.40});

        new Ajax.Updater('haveparticipate','/features/contests.php', {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});

}
function changeFontSize( size, action) {
	var divelements = new Array('testfont', 'main' );
	var last = 0;
	var x = 0;
	if ( action == 'load' && size != ''){
		var y=0;
		while (divelements[x]) {
			document.getElementById(divelements[x]).style.fontSize = size;
			x++;
		}
	}
	if ( action == 'click' ){
		alert(size);
		while (divelements[x]) {
			if (document.getElementById(divelements[x]).style.fontSize == '100%' ){
				document.getElementById(divelements[x]).style.fontSize = '120%';
			} else if ( document.getElementById(divelements[x]).style.fontSize == ''){
				document.getElementById(divelements[x]).style.fontSize = '120%';
			} else if ( document.getElementById(divelements[x]).style.fontSize == '120%'){
				document.getElementById(divelements[x]).style.fontSize = '140%';
			} else if ( document.getElementById(divelements[x]).style.fontSize == '140%'){
				document.getElementById(divelements[x]).style.fontSize = '100%';
			}
			last = document.getElementById(divelements[x]).style.fontSize;
			x++;
		}
	}
	if ( last ){
	        var handlerFunc = function(t) {
	        }
	        var errFunc = function(t) {
	                var msgDiv = $('hiddenfsize'+cid);
	                if (msgDiv) {
	                        msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
	                }
	        }
	        var url = document.location.href;
	        var parms = 'tafUrl='+url;
	        parms += '&fsize='+last;
	
	        new Ajax.Updater('hiddenfsize','/features/setfontsize.php', {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});
	}
}

function ShowAdult(dateselected, datenow){
	if ( (datenow - dateselected) >= 18 ){
		if (!Element.visible('adultcache'))
		new Effect.BlindDown('adultcache', {duration: 0.40});
	} else {
		new Effect.BlindUp('adultcache', {duration: 0.40});
	}
}

function showVoteComment( cid, add ) {

	new Effect.BlindDown('commenthavevote'+cid, {duration: 0.40});
	new Effect.BlindUp('commentvote'+cid, {duration: 0.40});
	new Effect.BlindDown('havecommentclick'+cid, {duration: 0.40});
	new Effect.BlindUp('votecommentnow'+cid, {duration: 0.40});
        var handlerFunc = function(t) {
        }
        var errFunc = function(t) {
                var msgDiv = $('commenthavevote'+cid);
                if (msgDiv) {
                        msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
                }
        }
        var url = document.location.href;
        var parms = 'tafUrl='+url;
        parms += '&cid='+cid;
        parms += '&add='+add;

        new Ajax.Updater('commenthavevote'+cid,'/features/votecomments.php', {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});

}
function ouvre_popup(page, w, h, msg) {

	if (msg !=''){
		var answer = confirm (msg);
		if (answer){
                    window.open(page,"nom_popup",'menubar=no, status=no, scrollbars=no, menubar=no, width='+w+', height='+h);
                }
        } else {
                    window.open(page,"nom_popup",'menubar=no, status=no, scrollbars=no, menubar=no, width='+w+', height='+h);
        }
}

function replySubmit( content, uid, cid ){
        var handlerFunc = function(t) {
        }
        var errFunc = function(t) {
               var msgDiv = $('replythanks'+cid);
               if (msgDiv) {
                        msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
                }
        }
        new Effect.BlindUp('replytitle'+cid, {duration: 0.40});
        new Effect.BlindUp('replyform'+cid, {duration: 0.40});
        new Effect.BlindDown('replythanks'+cid, {duration: 0.40});

        var url = document.location.href;
        var parms = 'tafUrl='+url;
	    parms += '&content='+content;
	    parms += '&uid='+uid;
	    parms += '&cid='+cid;
            new Ajax.Updater('replythanks'+cid,'/features/replytocomments.php',
	       {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});
}

function showReply(id) {
        replyid = 'replyform'+id;
        if (!Element.visible(replyid)) {
                new Effect.BlindDown(replyid, {duration: 0.40});
        } else {
                new Effect.BlindUp(replyid, {duration: 0.40});
        }
}

function ShowCommentsReplies( cid ){
            var handlerFunc = function(t) {
            }
            var errFunc = function(t) {
            	var msgDiv = $('hiddenreply'+cid);
            	if (msgDiv) {
                          msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
            	}
            }
            new Effect.BlindDown('hiddenreply'+cid);
            new Effect.BlindUp('reply'+cid);
            var url = document.location.href;
            var parms = 'tafUrl='+url;
	        parms += '&cid='+cid;
	    new Ajax.Updater('hiddenreply'+cid,'/include/commentsreplies.php',
	                    {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});
	
}
function mailstofriendsremover( email, id ){
            var handlerFunc = function(t) {
            }
            var errFunc = function(t) {
            	var msgDiv = $('email-'+id);
            	if (msgDiv) {
                          msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
            	}
            }
            new Effect.BlindUp('email-'+id, {duration: 1.40});
            var url = document.location.href;
            var parms = 'tafUrl='+url;
	        parms += '&email='+email;
	    new Ajax.Updater('email-'+id,'/features/deletemailtofriendslist.php',
	                    {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});
}

function CheckEmail(str, error) {
        var at="@";
        var dot=".";
        var lat=str.indexOf(at);
        var lstr=str.length;
        var ldot=str.indexOf(dot);
        if (lstr >= 0 ){
                if (str.indexOf(at)==-1){
			alert(error);
	                return false;
                  }
                 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert(error);
                      	return false;
                 }
                 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert(error);
                        return false;
                 }
                 if (str.indexOf(at,(lat+1))!=-1){
			alert(error);
                      	return false;
                 }
                 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert(error);
                	return false;
                 }
                 if (str.indexOf(dot,(lat+2))==-1){
			alert(error);
                     	return false;
                 }
                 if (str.indexOf(" ")!=-1){
			alert(error);
                     	return false;
                 }
         }
         return true;
}

function AddForLaunch(email, error) {
        if ( CheckEmail(email.launchemail.value,error) == true ){
               
        
                var handlerFunc = function(t) {
                }
                var errFunc = function(t) {
                var msgDiv = $('launch');
                if (msgDiv) {
                         msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
                }
         }
         var url = document.location.href;
         var parms = 'tafUrl='+url;
             parms += '&email='+email.launchemail.value;
             new Ajax.Updater('launch','../include/launch.php',
             {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});
        }
}

function AddOrDelValue(container_id){
   	var checkboxes = document.getElementById(container_id).getElementsByTagName('input');
	document.mailtofriends.hiddenmails.value = '';
   	for (var i=0;i<checkboxes.length;i++){
		if ( checkboxes[i].checked == true ){
			document.mailtofriends.hiddenmails.value = 
			document.mailtofriends.hiddenmails.value +checkboxes[i].value + ',';
		}
	}
}
function CheckAll(container_id,state){
   var checkboxes = document.getElementById(container_id).getElementsByTagName('input');
   for (var i=0;i<checkboxes.length;i++){
	if(checkboxes[i].type == 'checkbox'){
		if ( ! checkboxes[i].disabled ){
			checkboxes[i].checked = state;
		}
	}
   }
   AddOrDelValue(container_id);
   return true;
}
function showtext( id ){
	    newtext = 'hide'+id;
            new Effect.BlindUp(id, {duration: 0.40});
            if (!Element.visible(newtext)) {
                new Effect.BlindDown(newtext, {duration: 0.40});
            } else {
                new Effect.BlindUp(newtext, {duration: 0.40});
            }
}
function voteIt( pid, add ) {
        var handlerFunc = function(t) {
        }
        var errFunc = function(t) {
                var msgDiv = $('tafvote');
                if (msgDiv) {
                        msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
                }
        }
        var url = document.location.href;
        var parms = 'tafUrl='+url;
        parms += '&postid='+pid;
        parms += '&add='+add;

        new Ajax.Updater('tafvote','/features/vote.php', {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});

}
function showVoteBox( pid, add ) {
         voteIt( pid, add );
         new Effect.BlindDown(haveclick, {duration: 0.40});
         new Effect.BlindDown(aftervote, {duration: 0.40});
         new Effect.BlindUp(votenow, {duration: 0.40});
         new Effect.BlindUp(actualvote, {duration: 0.40});
}

function reporting ( rep, pid, uid, msg ){
         var type = rep.value;
         var confirmMSG = msg;
         var answer = confirm(confirmMSG);

         if ( answer ) {
                 new Effect.BlindDown('reportresult'+pid, {duration: 0.40});
                 new Effect.BlindUp('reportstart'+pid, {duration: 0.40});
                 var handlerFunc = function(t) {
                 }
                 var errFunc = function(t) {
                         var msgDiv = $('tafReport'+pid);
                         if (msgDiv) {
                                 msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
                         }
                 }
                 var url = document.location.href;
                 var parms = 'tafUrl='+url;
                 parms += '&postid='+pid;
                 parms += '&value='+rep.value;
                 parms += '&uid='+uid;

                 new Ajax.Updater('tafReport'+pid,'/features/reporting.php', {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});
	}
}
function mailstofriends( nbpossiblemails, emailchecked, email, pid, uid ){
        var emails = '';
        for ( i=0; i < nbpossiblemails; i++ ){
              if (emailchecked[i].checked){
                  emails += emailchecked[i].value + '-';
                  have = 1;
              }
        }
        if( email == '' && emails != '' ){
            email = "NULL";
        }
        if ( CheckEmail(email) == false && email != "NULL" ){
            alert("Invalid Email!");
        } else {
            var handlerFunc = function(t) {
            }
            var errFunc = function(t) {
            var msgDiv = $('tread');
            if (msgDiv) {
                msgDiv.innerHTML = 'Error ' + t.status + ' -- ' + t.statusText;
            }
        }
        var url = document.location.href;
        var parms = 'tafUrl='+url;
            parms += '&emailchecked='+emailchecked;
            parms += '&pid='+pid;
            parms += '&name='+name;
            parms += '&email='+email;
            parms += '&emailchecked='+emails;
            parms += '&uid='+uid;
            new Ajax.Updater('tread','/include/mailtofriends.php',
                {method: 'post',parameters: parms, onSuccess:handlerFunc, onFailure:errFunc});
        }
}


// Retour arrière
// backlink object initializer
function backlink() {
	this.text = 'Go Back';
	this.type = 'link';
	this.write = backlink_write;
	this.form = true;
}


// write method
function backlink_write() {
	if (! window.history) return;
	if (window.history.length == 0)return;

	this.type = this.type.toLowerCase();
	if (this.type == 'button') {
		if (this.form)
			document.write('<FORM>');
		document.write('<INPUT TYPE=BUTTON onClick="history.back(-1)" VALUE="', this.text, '"');
		if (this.otheratts) document.write(' ', this.otheratts);
		document.write('>');
		if (this.form)document.write('<\/FORM>');
	} else {
		document.write('<A HREF="javascript:history.back(-1)"');
		if (this.otheratts)
			document.write(' ', this.otheratts);
		document.write('>');
		if (this.type == 'image' || this.type == 'img') {
			document.write('<img SRC="', this.src, '" ALT="', this.text, '"');
			if (this.width) document.write(' WIDTH=', this.width);
			if (this.height) document.write(' HEIGHT=', this.height);
			if (this.otherimgatts) document.write(' ', this.otherimgatts);
			document.write(' BORDER=0 />');
		}
		else
			document.write(this.text);
		document.write('<\/A>');
	}
}

// print chronique
function goPrint(WEB_PATH)
{
	javascript:window.print();
	
	//var a = window.open('','','width=640,height=480,scrollbars=yes,toolbar=yes');
	//a.document.open("text/html");
	//a.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title></title>\n');
	//a.document.write('<link rel="stylesheet" type="text/css" href="'+WEB_PATH+'/css/2008-fc-com.css" />\n');	
	//a.document.write('<link rel="stylesheet" type="text/css" href="'+WEB_PATH+'/css/boites-animations.css" />\n');
	//a.document.write('</head><body style="background: white;">');
	//a.document.write('<style>#pubChronique {display: none}</style>');
	//a.document.write('<div id="col02popchr">');
	//a.document.write('<div align="center"><div id="sitelogo3" style="width: 505px; position: relative"><div align="left"><img src="'+WEB_PATH+'/images/logopopchr2.gif" border="0" alt="" /></div></div></div>');
	//a.document.write('La fonction imprimer est temporairement non disponible');
	//a.document.write(document.getElementById('col02popchr').innerHTML);
	//a.document.write('</div>');
	//a.document.write('<div class="clearer"></div>');
	//a.document.write('</body></html>');	
	//a.document.close();
	//a.print();
}


function VersionNavigateur(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}


function layerSetup(id,visibility){
if(document.getElementById){
this.obj = document.getElementById(id).style;
this.obj.visibility = visibility;
return this.obj;}
else if(document.all){
this.obj = document.all[id].style;
this.obj.visibility = visibility;
return this.obj;}
else if(document.layers){
this.obj = document.layers[id];
this.obj.visibility = visibility;
return this.obj;}
}
function visVisible(param){
new layerSetup(param,'visible');
}

function visHidden(param){
new layerSetup(param,'hidden');
}	
