// JavaScript Document /* ============= useful Functions ============= */ function countChar() { // Removes the character entered as the maximum has been reached if (commentTextarea.value.length > maxChar) { commentTextarea.value = commentTextarea.value.substring(0, maxChar); } // Handles the display of the number of remaining characters if (commentTextarea.value.length > (maxChar - offSet)) { // Calculates the number of characters left var count = maxChar - commentTextarea.value.length; // Processes message if (count == 0) { var string = "Stop !! Vous avez atteint la limite en nombre de caractères !"; } else if (count == 1) { var string = "Il vous reste 1 caractère"; } else { var string = "Il vous reste " + count + " caractères"; } countHandle.setHTML(string); } else { countHandle.setHTML('La zone de commentaire est limitée à ' + maxChar + ' caractères').injectAfter(commentTextarea); } } function facebook(e) { var myEvent = new Event(e); u=location.href; t=document.title; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436'); myEvent.stop(); } function frameBuster(){ if(($$('#content div.bloghead')[0])||($$('#topleftcol div.blogCarHead')[0])) return; // css rules in order to test if this is a blog page - index, post or cat if ( top != self ){ top.location.href = unescape(window.location.pathname); } } function toggleMain(e) { // toggling function - using the href attribute of the source of the event - and bonus : switch class from none to "selected" var myEvent = new Event(e); var myTarget = myEvent.target; var divToShow = $(myTarget.href.split("#")[1]); // get the closest parent 'div' tag var elemParent = myTarget.getParent(); while(elemParent.getTag() != 'div') { elemParent = $(elemParent).getParent(); } if(divToShow.getStyle('display')=='none') { // hide every divs var everyDivs = $$(elemParent.getElementsByTagName('a')).getProperty('href'); // #nameoftheid $each(everyDivs, function(singleDiv){ divToHide = singleDiv.split('#')[1]; $(divToHide).setStyle('display', 'none'); }); // remove class to the links $each($(elemParent).getElementsByTagName('a'), function(singleLink){ singleLink.toggleClass('selected'); }); //show a single div and add 'selected' class to the clicked link divToShow.setStyle('display', 'block'); } myEvent.stop(); } function selectText(e) { var event = new Event(e); var target = event.target; target.select(); } function diggThis(e) { var event = new Event(e); var voteFx = new Fx.Style($('btvote'), 'opacity', { duration: 200, transition: Fx.Transitions.quartInOut }); voteFx.start(1,0).chain( voteFx.start.pass([0,1], voteFx) ).chain( voteFx.start.pass([1,0], voteFx) ).chain ( voteFx.start.pass([0,1], voteFx) ).chain ( voteFx.start.pass([1,0], voteFx) ).chain ( voteFx.start.pass([0,1], voteFx) ) // stop propagation event.stop(); } function smoothScroll(e) { var event = new Event(e); var target = (!event.target.href) ? event.target.parentNode : event.target; var divToScrollTo = target.href.split('#')[1]; new Fx.Scroll(window).toElement(divToScrollTo); // stop propagation event.stop(); } function toggleServices(e) { var event = new Event(e); var target = (!event.target.href) ? event.target.parentNode : event.target; var divToShow = target.href.split('#')[1]; var myElement = $(divToShow); var divHeight = divsHeight[divToShow]; var currentHeight = myElement.getStyle('height').toInt(); // toggle if(!currentHeight) { myElement.effects({ duration: 1000, transition: Fx.Transitions.quadOut }).start({ 'opacity':[0,100], 'height':[0,divHeight] }); } else { myElement.effects({ duration: 1000, transition: Fx.Transitions.quadOut }).start({ 'opacity':[100,0], 'height':[divHeight,0] }); } // stop propagation event.stop(); } function toggleInline(e) { var myEvent = new Event(e); var myTarget = myEvent.target; var myDiv = myTarget.href.split('#')[1]; if($(myDiv).getStyle('display') == 'none') { $(myDiv).setStyle('display', 'inline'); } else { $(myDiv).setStyle('display', 'none'); } // stop propagation myEvent.stop(); } function toggleBlock(e) { var myEvent = new Event(e); var myTarget = myEvent.target; var myDiv = myTarget.href.split('#')[1]; if($(myDiv).getStyle('display') == 'none') { $(myDiv).setStyle('display', 'block'); } else { $(myDiv).setStyle('display', 'none'); } // stop propagation myEvent.stop(); } function removeEvents() { $each($$('*'), function(myElem) { Garbage.collect(myElem); }); } function bookmarksite(title, url){ ATTR_RE= /^http:\/\//gi; if (ATTR_RE.test(url)) url = url; else url = 'http://' +location.host + url; if (document.all) { window.external.AddFavorite(url, title); } else if (window.sidebar) { window.sidebar.addPanel(title, url, "") } } var xmlHttp function displayPoll() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("list_poll").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var objXMLHttp=null if (window.XMLHttpRequest) { objXMLHttp=new XMLHttpRequest() } else if (window.ActiveXObject) { objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") } return objXMLHttp } function submitPoll() { var count = 0; var parameter = ""; xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { return } for (var i = 0; i < document.zdpoll.elements.length; i++) { var value = ""; if (document.zdpoll.elements[i].type == 'hidden') { count++; value = document.zdpoll.elements[i].value; } if(value != "") { if(count == 1) parameter = document.zdpoll.elements[i].name + "=" + value; else parameter = parameter + "&" + document.zdpoll.elements[i].name + "=" + encodeURI(document.zdpoll.elements[i].value); } } var rlen = document.zdpoll.OPTION_ID.length; for(var j=0; j