/**
* enableReflect
* Thanks to Sumit for helping me get this code working. http://sumit-gaur.blogspot.com/
* Thanks to Robert for the getElementsByClassName code. http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
* Thanks to Simon for the addLoadEvent function. http://simonwillison.net/2004/May/26/addLoadEvent/
* This code is developed for use on www.Hyd-Masti.com
* If you wish to use this code or a derivative, please keep these messages and link to www.Hyd-Masti.com
* If you improve this code, please send me a mail on divyaratnaATgmail.com...
* Cheers, Div
**/

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");	
	var oElement;
	var tmpEle;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		tmpEle = oElement;
		var parentHier = "";		
		while(tmpEle.parentNode!=null){
			parentHier = parentHier + tmpEle.className + " ";
			tmpEle = tmpEle.parentNode;
		}
		if(oRegExp.test(parentHier)){		
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements);
}

function enableReflect() 
{
	var ele = getElementsByClassName(document, "img", "post-body");	
	for(var i=0; i<ele.length; i++) {
		var img = ele[i]; 
		var p = img.parentNode;
		var newImg = img.cloneNode(true);
		newImg.className = 'reflect';	
		p.replaceChild(newImg,img);		
	}
	addReflections();
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
		if (oldonload) {
			oldonload();
		}
		func();
		}
	}
}

addLoadEvent(enableReflect);