/******************************************************************************* Package: AFFIRMA XHTML/CSS Framework 1.0 Title: Global JS Functions File: global.js.php Version: 1.0 Date/Time: 2008-08-29 15:16 Author name: Adal Hernandez Fraile Author organisation: AFFIRMA Author URI: www.affirma.nu Author contact details: Copyright: (c) 2008 Adal Hernandez Fraile // AFFIRMA License: Released under the MIT License: http://www.opensource.org/licenses/mit-license.php Acknowledgements: none Description: Global JS functions for use at BobvanderVlist.com Dependencies: none Change history: change.log To-do list: todo.txt *******************************************************************************/ greenHomeImgs = new Array(); blueHomeImgs = new Array(); prevGreenRndImgNum = null; prevBlueRndImgNum = null; blueHomeImgs[0] = 'Match-10.jpg'; blueHomeImgs[1] = '12.jpg'; blueHomeImgs[2] = '_MG_0369.jpg'; blueHomeImgs[3] = 'weekendschool-1.jpg'; blueHomeImgs[4] = 'Match-08.jpg'; blueHomeImgs[5] = 'De-Rode-Leeuw-1.jpg'; blueHomeImgs[6] = '2695-001.jpg'; blueHomeImgs[7] = 'ABCD-1.jpg'; blueHomeImgs[8] = '11.jpg'; blueHomeImgs[9] = 'Albeda-2.jpg'; greenHomeImgs[0] = '2710-003.jpg'; greenHomeImgs[1] = 'J.frerichs.jpg'; greenHomeImgs[2] = 'Match-04.jpg'; greenHomeImgs[3] = 'zoektocht.jpg'; greenHomeImgs[4] = 'Turks-supermarkt.jpg'; greenHomeImgs[5] = 'Postbode.jpg'; greenHomeImgs[6] = '9.jpg'; greenHomeImgs[7] = '5.jpg'; greenHomeImgs[8] = 'Match-05.jpg'; function swapRndImg(srcImg, targetImgType) { switch(targetImgType){ case 'green':rndNum = Math.ceil(Math.random()*greenHomeImgs.length-1); if(rndNum==prevGreenRndImgNum) { rndNum = (rndNum+1<=greenHomeImgs.length-1)?rndNum+1:(rndNum-1>=0)?rndNum-1:0; } srcImg.src = 'http://www.bobvandervlist.com/dev/img/home/green/'+greenHomeImgs[rndNum]; prevGreenRndImgNum = rndNum; break; case 'blue':rndNum = Math.ceil(Math.random()*blueHomeImgs.length-1); if(rndNum==prevBlueRndImgNum) { rndNum = (rndNum+1<=blueHomeImgs.length-1)?rndNum+1:(rndNum-1>=0)?rndNum-1:0; } srcImg.src = 'http://www.bobvandervlist.com/dev/img/home/blue/'+blueHomeImgs[rndNum]; prevBlueRndImgNum = rndNum; break; } } function restoreImg(srcImg, targetImgSrc) { srcImg.src = targetImgSrc; } function showPostComments(postId, uri, containerId, numOfComments) { document.getElementById(containerId).innerHTML = '
'+numOfComments+'
'; document.getElementById(containerId).style.height = (document.getElementById('post-'+postId).offsetHeight*0.8)+'px'; return false; } function showCommentForm(postId, actionUri, redirectUri, authorName, authorEmail) { if(!document.getElementById('comment_form_wrapper')){ var commentFormWrapper = document.createElement('div'); commentFormWrapper.id = 'comment_form_wrapper'; document.body.appendChild(commentFormWrapper); } else { commentFormWrapper = document.getElementById('comment_form_wrapper'); } commentFormWrapper.innerHTML = ''; commentFormWrapper.innerHTML += '
afsluiten
Plaats een reactie

 

 




'; commentFormWrapper.style.top = findPos(document.getElementById('post_'+postId+'_comments_wrapper'))[1]-15+'px'; commentFormWrapper.style.display = 'block'; return false; } function makeMask(){ if(!document.getElementById('mask')){ var mask = document.createElement('div'); mask.id = 'mask'; var heights = [window.innerHeight, document.body.clientHeight, document.documentElement.offsetHeight]; heights.sort(function(a, b){return b - a;}); var h = heights[0]; mask.style['height'] = h + 'px'; document.body.appendChild(mask); } else { mask = document.getElementById('mask'); } mask.style.display = 'block'; } function closeCommentForm(){ if(document.getElementById('comment_form_wrapper')){ document.getElementById('comment_form_wrapper').style.display='none'; } if(document.getElementById('mask')){ document.getElementById('mask').style.display = 'none'; } return false; } function validateCommentForm() { var commentForm = document.forms['comment_form']; if(commentForm.elements['author'].value == '') { alert('Vul je naam in a.u.b.'); return false; } if(commentForm.elements['email'].value == '') { alert('Vul je email in a.u.b.'); return false; } if(commentForm.elements['comment'].value == '') { alert('Vul een bericht in a.u.b.'); return false; } if(typeof(commentForm)!="undefined") commentForm.submit(); } function findPos(obj) { var x = y = 0; var coordinates = new Array(); if (obj.offsetParent) { do { x += obj.offsetLeft; y += obj.offsetTop; } while (obj = obj.offsetParent); } coordinates[0] = x; coordinates[1] = y; return coordinates; } function findDim(obj) { var w = h = 0; var dimensions = new Array(); if (obj.offsetParent) { do { w += obj.offsetWidth; h += obj.offsetHeight; } while (obj = obj.offsetParent); } dimensions[0] = w; dimensions[1] = h; return dimensions; } /******************************************************************************* General Purpose Functions *******************************************************************************/ /* Function to capitalize the first letter of each word in a string Parameters: none Returns: modified version of string Remarks: Adapted from: http://www.andyfowler.com/journal/2005/07/javascript-ucwords-replacement/ */ String.prototype.ucWords = function(){ return this.toLowerCase().replace(/\w+/g,function(s){ return s.charAt(0).toUpperCase() + s.substr(1); }) }; /* Function to display an obfuscated mailto link to guard against spam robots Parameters: @addrCharCodes: string of comma-separated char codes to convert to human readable chars @subject: e-mail subject, for use by e-mail client @title: string value for title property of mailto link @className: string value for class property of mailto link @innerHTML: string to display as maillink (innerHTML of a element) Returns: nothing */ function writeObfuscatedEmailLink(addrCharCodes, subject, title, className, innerHTML){ addrCharCodes2 = addrCharCodes.split(','); emailAddr = ''; for(i=0; i'+((innerHTML!='')?innerHTML:emailAddr)+''); }