// Pullquote
var pullquote = {
	init : function() {
	// Check that the browser supports the methods used
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;
		var oElement, oPullquote, oPullquoteP, oQuoteContent, i, j;
	// Find all span elements with a class name of pullquote
		var arrElements = document.getElementsByTagName('span');
		var oRegExp = new RegExp("(^|\\s)pullquote(\\s|$)");
		for (i=0; i<arrElements.length; i++) {
	// Save the current element
			oElement = arrElements[i];
			if (oRegExp.test(oElement.className)) {
	// Create the blockquote and p elements
				oPullquote = document.createElement('blockquote');
				oPullquote.className = oElement.className
				oPullquoteP = document.createElement('p');
	// Insert the pullquote text
				for(j=0;j<oElement.childNodes.length;j++) {
					oPullquoteP.appendChild(oElement.childNodes[j].cloneNode(true));
				}
				oPullquote.appendChild(oPullquoteP);
	// Insert the blockquote element before the span elements parent element
				oElement.parentNode.parentNode.insertBefore(oPullquote,oElement.parentNode);
			}
		}
	}
};
// addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
function addEvent(obj, type, fn) {
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}
addEvent(window, 'load', pullquote.init);


function setLastfmLinks() { 

    var lastfmpopups = glow.dom.get('.lastfm .track a');
    lastfmpopups.each(function (i) {        	
    	glow.events.addListener(
		    lastfmpopups[i],
		    'click',
		    function () { 		    
		    	window.open(this.getAttribute('href'), 'lastfmartist');
		    	return false;
		    
		    }
		);
		
    });
 
}


// Subscribe Unsubscribe show hide
function subscribeUnsubscribe(){
	glow.dom.get("#un-subscribe").css("display", "none"); 
	glow.events.addListener('.hidethis a','click',function () { 
		glow.dom.get(".unsubscribe").css("display", "block"); 
		glow.dom.get("#un-subscribe").css("display", "none"); 
	});
	glow.events.addListener('.unsubscribe a','click',function () { 
		glow.dom.get(".unsubscribe").css("display", "none");
		glow.dom.get("#un-subscribe").css("display", "block"); 
	});
	glow.events.addListener('.hidethis a','click',function (e) { e.preventDefault(); });
	glow.events.addListener('.unsubscribe a','click',function (e) { e.preventDefault(); });
}


// tear and share show hide
function tearShareShowHide(){
	glow.dom.get("#tearshare").css("display", "none"); 
	
	glow.events.addListener('#show a.expand','click',function () { 
		glow.dom.get("#tearshare").css("display", "block"); 
		glow.dom.get("#show").css("display", "none"); 
	});
	glow.events.addListener('#tearshare a.collapse','click',function () { 
		glow.dom.get("#tearshare").css("display", "none");
		glow.dom.get("#show").css("display", "block"); 
	});
	glow.events.addListener('#show a.expand','click',function (e) { e.preventDefault(); });
	glow.events.addListener('#tearshare a.collapse','click',function (e) { e.preventDefault(); });
}



//glow.onDomReady(function()
//{
//setLastfmLinks();
//
//});

function videoTooltips() { 

if (!document.getElementById("emp1")) return;

var thisTitle = "";

    var videothumbs = glow.dom.get('.video-nav ul li a');
    videothumbs.each(function (i) { 
    	glow.events.addListener(
		    videothumbs[i],
		    'mouseover',
		    function (e) { 	
				if (this.getAttribute('title') && this.getAttribute('title') != '') {
					thisTitle = this.getAttribute('title');
					this.setAttribute('title', '');
					glow.dom.get("body").append("<div id='thumbtooltip'><p>" + thisTitle + "</p></div>");	 		   	
					glow.dom.get("#thumbtooltip").css("top", (e.pageY + 5) + "px");
					glow.dom.get("#thumbtooltip").css("left", (e.pageX + 5) + "px");
					return false;		    
				}
		    }
		);
		
		
glow.events.addListener(
		    videothumbs[i],
		    'mouseout',
		    function () { 	
				this.setAttribute('title', thisTitle);
				glow.dom.get("#thumbtooltip").remove();					   
		    }
		);		
    
    });
    

}

