function VCenter(url,nom,largeur,hauteur,options) {
	var haut=(screen.height-hauteur)/2;
	var Gauche=(screen.width-largeur)/2;
	fencent=window.open(url,nom,"top="+haut+",left="+Gauche+",width="+largeur+",height="+hauteur+","+options);
}

function printBlog (myId, bgColor, fgColor) {
	
	content = new String();

	//	on recuperre les data	
	var pic = document.getElementById('myPic-'+myId).innerHTML;
	var titleArticle = document.getElementById('titleArticle-'+myId).innerHTML;
	var text = document.getElementById('text-'+myId).innerHTML;

	//	on clean 
	reg = new RegExp(">(.+)\\<", "g");
	test = titleArticle.split(reg);
	titleArticleClean = test['1'];
	
	//	on reattribue a la nouvelle page :)
	var content =  window.open("", "ZoneImpr", "height=500, width=660,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10000, top=10");
	content.document.body.innerHTML += pic;
	content.document.body.innerHTML += '<h3 id="titleArticle-0" class="storytitle" style="font-size:19px;font-weight:bold;margin:0 0 15px;padding:4px 10px;height:24px;width:613px;font-family:arial,verdana,sans;background-color: '+bgColor+'; color: '+fgColor+';">'+titleArticleClean.toUpperCase()+'</h3>';
	content.document.body.innerHTML += '<div style="font-size:12px;font-family:arial,verdana,sans;padding:0 0 20px;width:633px;">'+text+'</div>';

	//	et on print ça !
	content.window.print();
	content.window.close();

}

// <![CDATA[
// Conseiller le site a un ami
function showRecommendSiteResponse(responseText, statusText) {

    jQuery("p#recommend_site_response").html("");
    

    if ("success"==statusText) {
        if ("success"==responseText) {
            jQuery("form#recommend_site_form").fadeOut('fast', function(){
                jQuery("div#recommend_site_success").fadeIn('fast');
            });
        } else {
            expr = new RegExp("^[a-zA-Z0-9_][a-zA-Z0-9_.-]*[a-zA-Z0-9_]@[a-zA-Z0-9_][a-zA-Z0-9_.-]*[a-zA-Z0-9_]\\.[a-zA-Z]{2,4}$", "i");
            
	    if ($('#rsname').val()=='') {
                //$('#rsname').addClass('emptyfield');
		document.getElementById('rsnameinput').style.color = 'red';
		document.getElementById('rsname').style.border = '1px solid red';
                $('#rsname').focus(function() { 
			//$('#rsname').removeClass('emptyfield'); 
		    	document.getElementById('rsname').style.border = '1px solid #737271';
    			document.getElementById('rsnameinput').style.color = 'black';	
		})

            }
            if ($('#rsemail').val()=='' || !expr.test($('#rsemail').val())) {
                //$('#rsemail').addClass('emptyfield');
		document.getElementById('rsemailinput').style.color = 'red';
		document.getElementById('rsemail').style.border = '1px solid red';
                $('#rsemail').focus(function() { 
			//$('#rsemail').removeClass('emptyfield'); 
			document.getElementById('rsemail').style.border = '1px solid #737271';
			document.getElementById('rsemailinput').style.color = 'black';
		})
            }
            if ($('#rsemail2').val()=='' || !expr.test($('#rsemail2').val())) {
                //$('#rsemail2').addClass('emptyfield');
		document.getElementById('rsemailinput2').style.color = 'red';
		document.getElementById('rsemail2').style.border = '1px solid red';
                $('#rsemail2').focus(function() { 
			//$('#rsemail2').removeClass('emptyfield'); 	
			document.getElementById('rsemail2').style.border = '1px solid #737271';
			document.getElementById('rsemailinput2').style.color = 'black';
		})
            }
            jQuery("p#recommend_site_response").html(responseText);
        }
    }
    else {
        jQuery("p#recommend_site_response").html("Une erreur est survenue.<br />Veuillez réessayer ultérieurement.");
    }
}

function resetRecommendSiteForm() {

    jQuery("input#recommend_site_friend_email").val("");
    document.getElementById("recommend_site_response").innerHTML = '';

    document.getElementById("recommend_site_message").value = '';
    document.getElementById('rsname').style.border = '1px solid #737271';
    document.getElementById('rsnameinput').style.color = 'black';
    document.getElementById('rsemail').style.border = '1px solid #737271';
    document.getElementById('rsemailinput').style.color = 'black';
    document.getElementById('rsemail2').style.border = '1px solid #737271';
    document.getElementById('rsemailinput2').style.color = 'black';

    document.getElementById('rsemail2').value = '';
    
    jQuery("div#recommend_site_success").fadeOut('fast', function() {
        jQuery("form#recommend_site_form").fadeIn('fast');
    });
}

//	Envoyer l'article a un ami
function showRecommendPostResponse (responseText, statusText) {

    rep = responseText.split('|'); 
    var id = rep['0'];
    var msg = rep['1'];
    if (id!='-1') {
    	suf = '_'+id;
    } else {
	suf = '';
    }
    
    jQuery("p#recommend_post_response").html("");
    if ("success"==statusText) {
        if ("success"==msg) {
            jQuery("form#recommend_post_form"+suf).fadeOut('fast', function(){
                jQuery("div#recommend_post_success"+suf).fadeIn('fast');
            });
        }
        else {

	    expr = new RegExp("^[a-zA-Z0-9_][a-zA-Z0-9_.-]*[a-zA-Z0-9_]@[a-zA-Z0-9_][a-zA-Z0-9_.-]*[a-zA-Z0-9_]\\.[a-zA-Z]{2,4}$", "i");
	    if ($('#postNameInput'+suf).val()=='') {
	    	document.getElementById('postName'+suf).style.color = 'red';  
	        document.getElementById('postNameInput'+suf).style.border = '1px solid red';
	    } else {
		document.getElementById('postName'+suf).style.color = 'black';  
	        document.getElementById('postNameInput'+suf).style.border = '1px solid black';
	    }

	    if ($('#postMailInput'+suf).val()=='' || !expr.test($('#postMailInput'+suf).val())) {
		document.getElementById('postMail'+suf).style.color = 'red';
		document.getElementById('postMailInput'+suf).style.border = '1px solid red';
	    } else {
		document.getElementById('postMail'+suf).style.color = 'black';
		document.getElementById('postMailInput'+suf).style.border = '1px solid black';
	    }		
    
	    if ($('#postMail2Input'+suf).val()=='' || !expr.test($('#postMail2Input'+suf).val())) {
		document.getElementById('postMail2'+suf).style.color = 'red';
	    	document.getElementById('postMail2Input'+suf).style.border = '1px solid red';
	    } else {
		document.getElementById('postMail2'+suf).style.color = 'black';
	    	document.getElementById('postMail2Input'+suf).style.border = '1px solid black';
	    }
	    
            jQuery("p#recommend_post_response"+suf).html(msg);
        }
    }
    else {
	
        jQuery("p#recommend_post_response"+suf).html("Une erreur est survenue.<br />Veuillez réessayer ultérieurement.");
    }

}

function resetRecommendPostForm(id) {

    if(id!='-1') {
		suf = '_'+id;
		id = suf;    
    }else {
		suf = '';
		id = suf;  
    }

    jQuery("input#recommend_post_friend_email"+id).val("");

    document.getElementById('postName'+suf).style.color = 'black';
    document.getElementById('postMail'+suf).style.color = 'black';
    document.getElementById('postMail2'+suf).style.color = 'black';
    document.getElementById('postNameInput'+suf).style.border = '1px solid black';
    document.getElementById('postMailInput'+suf).style.border = '1px solid black';
    document.getElementById('postMail2Input'+suf).style.border = '1px solid black';
    document.getElementById('postMail2Input'+suf).value = '';

    jQuery("p#recommend_post_response"+suf).html('');
    document.getElementById("recommend_post_message"+id).value = '';

    jQuery("div#recommend_post_success"+id).fadeOut('fast', function(){
        jQuery("form#recommend_post_form"+id).fadeIn('fast');
    });

}

//	initialisation
jQuery(document).ready(function() {

    jQuery("form#recommend_site_form").ajaxForm({
        success:showRecommendSiteResponse,
        error:showRecommendSiteResponse
    });
    if (0 < jQuery("form#recommend_post_form").size()) jQuery("form#recommend_post_form").ajaxForm({
        success:showRecommendPostResponse,
        error:showRecommendPostResponse
    });

	/* *************************************************************************************************************** */
    if (0 < jQuery("form#recommend_post_form_0").size()) jQuery("form#recommend_post_form_0").ajaxForm({
        success:showRecommendPostResponse,
        error:showRecommendPostResponse
    });
    if (0 < jQuery("form#recommend_post_form_1").size()) jQuery("form#recommend_post_form_1").ajaxForm({
        success:showRecommendPostResponse,
        error:showRecommendPostResponse
    });
    if (0 < jQuery("form#recommend_post_form_2").size()) jQuery("form#recommend_post_form_2").ajaxForm({
        success:showRecommendPostResponse,
        error:showRecommendPostResponse
    }); 
	/* *************************************************************************************************************** */

    jQuery(".comments_link").click(function() {updCommentsPage(jQuery(this))});
    
    
    /*
    jQuery(".tooltip").hover(function() {
    	jQuery(this).attr("title_tmp", jQuery(this).attr("title")); //On stock la valeur du title dans un attribut temporaire
    	jQuery(this).attr("title",""); //On vide le contenu du title
        jQuery(this).prepend("<div style=\"position:relative; display:none;\"><div style=\"position:absolute;right:0;*right:-22px;top:27px;z-index:10000000\"><span style=\"background:#000000; color:#FFFFFF; padding:2px; white-space:nowrap;font-weight:normal;font-size:11px;\">&nbsp;"+jQuery(this).attr("title_tmp")+"</span></div></div>");
        jQuery(this).children("div").fadeIn("normal");
    }, function() {
        jQuery(this).children("div").fadeOut("normal").remove();
        jQuery(this).attr("title", jQuery(this).attr("title_tmp")); //On repositionne le title initial
        jQuery(this).attr("title_tmp",""); //On vide le contenu de l'attribut temporaire 
    });
    */
    jQuery(".tooltip").hover(function() {
		    
	jQuery(this).attr("title_tmp", jQuery(this).attr("title")); //On stock la valeur du title dans un attribut temporaire
    	jQuery(this).attr("title",""); //On vide le contenu du title
		    
        jQuery(this).prepend("<div style=\"position:absolute; display:none; width:0;\"><div style=\"position:relative;left:0;top:22px;\"><span style=\"background:#000000; color:#FFFFFF; padding:2px; white-space:nowrap;font-weight:bold;font-size:15px;\">&nbsp;"+jQuery(this).attr("title_tmp")+"</span></div></div>");
        jQuery(this).children("div").fadeIn("normal");
    }, function() {
        jQuery(this).children("div").fadeOut("normal").remove();
	
	jQuery(this).attr("title", jQuery(this).attr("title_tmp")); //On repositionne le title initial
        jQuery(this).attr("title_tmp",""); //On vide le contenu de l'attribut temporaire 
	
    });

    
});
// ]]>

//	hiddenModalRecommendPostPS
function cleanMe () {

	//	pour ne aps avoir d'erreurs JS
	if(document.getElementById("myAnswer").innerHTML != null) {
		document.getElementById("myAnswer").innerHTML = "&nbsp;";
	}
	if(	document.getElementById("myTarget").innerHTML != null) {
		document.getElementById("myTarget").innerHTML = "&nbsp;";
	}
	if (document.getElementById("useremail").value !=null) {
		document.getElementById("useremail").value = "";
	}

	//	sert a eviter le multi-envoi de mail	
	var btn = document.getElementById('butValider');
	var myFnctn = btn.getAttribute("history");

	btn.setAttribute("onClick", myFnctn);
	
}

function checkMe (id) {
	
	parse = document.getElementById('myUrl').value.split('=');
	url = parse['0']+'=';
	
	
	if (id!=0) {
		
		//	si on selectionne le blog on grise les autres rubriques
		if (id.length>3) {
			
			//	on ajoute le-blog dans l' url, sinon on ne recuperre pas les articles dans le flux rss :)
			urlArray = url.split('feed');
			
			//	l'id n'est pas dans l' url
			if (document.getElementById('myUrl').value.search(id) == -1) {
								
				url = urlArray['0']+'le-blog/feed/?cat=';
				url = url+id;
				
				jQuery("input").each(function(){
						if( jQuery(this).attr("name") == "categories_mag") {
							jQuery(this).attr("disabled","disabled");
						}
				});
				
			} else {
				
				//	on nettoye l' url dans l' input
				url = urlArray['0'].substr(0, (urlArray['0'].length-8))+'feed/?cat=';
				//	url = url;
				jQuery("input").each(function(){
					if( jQuery(this).attr("name") == "categories_mag") {
						jQuery(this).removeAttr("disabled");
					}
				});			
			}
			
		} else {
			
			count = 0;
			jQuery("input").each(function(){
				if( jQuery(this).attr("name") == "categories_blog") {
					jQuery(this).attr("disabled","disabled");
				}
			});
			
			
			jQuery("input").each(function(){
					
				if( jQuery(this).attr("checked") == true) {
					count++
				}
			
			
				if (count==1) {
					if( jQuery(this).attr("name") == "categories_blog") {
						jQuery(this).removeAttr("disabled");
					}
				}
				
			});
			
			mesIDS = parse['1'];
				
			//	au moins un element dans la liste
			if (mesIDS.length != 0) {
				
				mesIDSA = mesIDS.split(',');
				jointArray = false;
				removeArray = false;
				
				//	1 element
				if (mesIDSA.length == '1') {
					
					if (mesIDSA['0'] != id) {
						url = url+mesIDS+','+id;
					} else {
						url = parse['0']+'=';					
					}
				} else {
				
					urlTMP = '';
					for (i=0;i<mesIDSA.length;i++) {
						
						//	on enleve cet id car deja present
						if (mesIDSA[i] == id) {
							
							mesIDSA.splice(i,1); 
							removeArray = true;
												
						} else {
							//	on ajoute a l' url
							jointArray = true;
						}
						
					}
					
					if (jointArray==true) {
						url = url+mesIDSA.join(',')+','+id;
					}
					if (removeArray==true) {
						url = parse['0']+'='+mesIDSA.join(',');
					}
				
				}			

			} else {
			
				if(parse['1']=='') {
					url = url+id;
				} else {
					url = url+parse['1']+','+id;
				}
			}
				
		}
				
	} else {
		
		//	on reinitialise tout les input(s)
		jQuery("input").each(function(){
			if( (jQuery(this).attr("name") == "categories_mag") || (jQuery(this).attr("name") == "categories_blog") ){
				jQuery(this).removeAttr("disabled");
				jQuery(this).removeAttr("checked");
			}
		});	
	
	}
	
	document.getElementById('myUrl').value = url;
	
	if (document.getElementById('default').checked == true) {
		document.getElementById('myUrl').style.display = 'block';
		document.getElementById('myInputTxt').style.display = 'block';
	} else {
		document.getElementById('myUrl').style.display = 'none';
		document.getElementById('myInputTxt').style.display = 'none';
	}

}

function monoprixAddVote(postId, target) {
    jQuery.ajax({
        type: "POST",
        url: "<?php bloginfo('wpurl'); ?>/wp-content/plugins/monoprix-vote/monoprix-vote.php",
        data: "vote_post_id="+postId,
        success: function(msg) {
            jQuery(target).parent().append("<div id=\"monoprix-vote-msg\" style=\"position:absolute; display:none;\"><div style=\"border:5px solid red; position:relative; top:-2px; left:-212px; width:250px; background:white;\"><p align=\"right\" style=\"margin:0;padding:0\"><a href=\"javascript:void(0);\" onclick=\"jQuery(this).parent().parent().parent().fadeOut('fast', function() { jQuery(this).remove(); });\" style=\"display:block; width:1em; margin:2px; background:#FF0000; color:#FFFFFF; text-align:center; font-weight:bold;\">x</a></p><p style=\"color:red;\">"+msg+"</p></div></div>");
            jQuery(target).siblings("#monoprix-vote-msg").fadeIn('fast');
        },
        error: function(msg) {
            jQuery(target).parent().append("<div id=\"monoprix-vote-msg\" style=\"position:absolute; display:none;\"><div style=\"border:5px solid red; position:relative; top:-2px; left:-212px; width:250px; background:white;\"><p style=\"color:red;\">Une erreur est survenue.<br />Veuillez réessayer ultérieurement.</p><p align=\"right\" style=\"margin:0;padding:0\"><a href=\"javascript:void(0);\" onclick=\"jQuery(this).parent().parent().parent().fadeOut('fast', function() { jQuery(this).remove(); });\">Fermer</a></p></div></div>");
            jQuery(target).siblings("#monoprix-vote-msg").fadeIn('fast');
        }
    });
}


function monoprixRssSubmit(formId) {
	var aggregator = jQuery("#"+formId+" input:radio[name=aggregator]:checked").val();
	var categories = new Array();
	var catCpt = 0;
	jQuery("input").each(function(){
			if( (jQuery(this).attr("name") == "categories_mag") || (jQuery(this).attr("name") == "categories_blog") ) {
				if( jQuery(this).attr("checked") == true )  {
					categories[catCpt]=jQuery(this).val();
					catCpt++;
				}
			}
	});
	if (0 >= categories.length) {alert("Veuillez sélectionner au moins une rubrique."); return false};

	rssUrl = document.getElementById("myUrl").value;
	switch (aggregator) {
		case "netvibes":
			open("http://www.netvibes.com/subscribe.php?type=rss&url="+escape(rssUrl),"_blank");
		break;
		case "google":
			open("http://fusion.google.com/add?source=atgs&feedurl="+escape(rssUrl),"_blank");
		break;
		case "yahoo":
			open("http://add.my.yahoo.com/rss?url="+escape(rssUrl),"_blank");
		break;
		case "live":
			open("http://www.live.com/?add="+escape(rssUrl),"_blank");
		break;
		default:
			open(rssUrl,"_blank");
		break;
	}
	tb_remove();
	return false;
}


// ajax_login_widget settings
var alw_timeout = 0;
var alw_redirectOnLogin = '';

// constants

var alw_success = 1;
var alw_failure = 0;
