/*	ADD THE HOLDER AROUND BLOG IMAGES TO GIVE THE ROUNDED CORNERS	*/

window.addEvent('domready', function() {

	if($('content')){
		var blogContent 	= $('content');
		var theBlogPosts 	= blogContent.getElementsByClassName('post');
		
		
		
		var theBlogImages = new Array();
		var parent;
		var thisImage;
		var imageHolder;
		var topMask;
		var bottomMask;	
	
		for(var i=0; i<theBlogPosts.length; i++){
			theBlogImages 	= theBlogPosts[i].getElementsByTagName('img');
			for(var j=0; j<theBlogImages.length; j++){
				if(theBlogImages[j].offsetWidth == 493){
					//theBlogImages[j].setAttribute('id', 'img_'+j);
					theBlogImages[j].id = 'img_'+j;
					// get this image
					thisImage = $(theBlogImages[j].id);
					// get this image's parent
					thisParent = theBlogImages[j].getParent();
					// create the wrapper div element
					imageHolder = document.createElement('div');
					// add a class to the new element
					//imageHolder.addClass('imgHolder');
					//imageHolder.setAttribute('class', 'imgHolder');
					imageHolder.className += 'imgHolder';
					// create the top mask div
					topMask = document.createElement('div');
					//topMask.setAttribute('class', 'topImageMask');
					topMask.className += 'topImageMask';
					
					// append the image to the new div
					imageHolder.appendChild(topMask);
			
					// create the bottom mask div
					bottomMask = document.createElement('div');
					//bottomMask.setAttribute('class','bottomImageMask');
					bottomMask.className += 'bottomImageMask';
					// append the image to the new div
					imageHolder.appendChild(bottomMask);	
			
					// append the image to the new div
					imageHolder.appendChild(thisImage);
					// finally apend the new div to the original parent
					thisParent.appendChild(imageHolder);
				}
			}
		}
	}
});

/*	Styles the headings for accordion pages	*/
	
function stylesHeadings(theTargetList){
	if($(theTargetList)){
		var theList = $(theTargetList);
		var theListLinks = theList.getElementsByTagName('h3');
	
		for(var i=0; i < theListLinks.length; i++){
			if(theListLinks[i].id !== 'saveTo'){
				theListLinks[i].onmouseover = function(){
					if(this.className.search('activeTitle')==-1){
						this.setStyle('background-position', '-493px 0');
						this.setStyle('cursor', 'pointer');
					}
				}			
				theListLinks[i].onmouseout = function(){
					//this.setStyle('background-position', '0 0');
					//this.setStyle('cursor', 'default');											
				}
				if(theListLinks[i].className.indexOf('toggler')){
					//alert(theListLinks[i].id)
				}
				theListLinks[i].onclick = function(){
					this.setStyle('background-position', '0 0');
					hideErrors();													
				}				
			}								
		}		
	}
}	
window.addEvent('domready', function() {
	if($('togglePanels')){
		stylesHeadings('togglePanels');
	}		
});		

function hideErrors(){
	var theErrorBubbles = getElementsByClassName('errorBubble');
	var theInputs       = getElementsByClassName('fc-field-error');
	for(var i=0; i<theErrorBubbles.length; i++){
		theErrorBubbles[i].style.display = "none";
	}
	for(var j=0; j<theInputs.length; j++){
		theInputs[j].className = theInputs[j].className.replace(/fc-field-error/g,"");
	}	
}