var globalScope = new Array();

function initPage(){
	var blocks = document.getElementsByTagName("li");
	if(blocks){
		for(var k=0; k<blocks.length; k++){
			if(blocks[k].className.indexOf("photo-box") != -1){
				var links = blocks[k].getElementsByTagName("a");
				for(var i=0; i<links.length; i++){
					links[i].onmouseover = function(e) {
						var _id = this.href.substr(this.href.indexOf("#") + 1);
						if(_id) {
							var _divs = document.getElementsByTagName("div");
							for(var z=0; z<_divs.length; z++){
								if (_divs[z].className.indexOf("popup") != -1) {
									_divs[z].style.display = 'none';
								}
							}
							
							var top = getAbsoluteTop(this);
							var left = getAbsoluteLeft(this);
							var _popup = document.getElementById(_id);
							_popup.style.display = 'block';
							var _height = _popup.offsetHeight;
							_popup.style.top = top-_height+10+'px';
							_popup.style.left = left+220+'px';
							_popup.onmouseover = function() {
								this.style.display = "block";
							}
							_popup.onmouseout = function() {
								this.style.display = "none";
							}							

							if(window.event)
							{
								window.event.cancelBubble = true;
								window.event.returnValue = false;
							}
							if(e && e.stopPropagation && e.preventDefault)
							{
								e.stopPropagation();
								e.preventDefault();
							}
							return false;
						}	
					}
					links[i].onmouseout = function(e) {
						var _id = this.href.substr(this.href.indexOf("#") + 1);
						if(_id) {						
							//WBM_hidePopup.init(_id);							

							if(window.event)
							{
								window.event.cancelBubble = true;
								window.event.returnValue = false;
							}
							if(e && e.stopPropagation && e.preventDefault)
							{
								e.stopPropagation();
								e.preventDefault();
							}
	
							return false;
						}	
					}
				}
			}
		}
	}
	var _divs = document.getElementsByTagName("div");
	if (_divs){
		for(var k=0; k<_divs.length; k++){
			var _close = _divs[k].getElementsByTagName("a");
			for(var i=0; i<_close.length; i++){
				if (_close[i].className.indexOf("close") != -1) {
					_close[i].onclick = function(){
						this.parentNode.style.display = 'none';
						return false;
					}
				}
			}
		}
	}
}

var WBM_hidePopup = 
{
	init: function(_id)
	{
		this.uniqueId = _id;
		this.popup = document.getElementById(_id);
		
		if(document.all)
		{
			globalScope[ this.uniqueId ] = this;
			window.setTimeout( 'ieIntervalHandler("' + this.uniqueId + '","hide")', 30000 );

		}
		else
		{
			window.setTimeout ( function( that ) { that.hide(); }, 30000, this );

		}
	}, 
	hide: function()
	{
		if(this.popup)
		{
			this.popup.style.display = "none";
		}
	}
}

function ieIntervalHandler( id, strFunc )
{
	var scope = globalScope[id];
	eval( "scope." + strFunc + "()" );
}


function getAbsoluteTop(obj) {
	var posTop = 0;
	while (obj.offsetParent) {posTop += obj.offsetTop; obj = obj.offsetParent;}
	return posTop;
}
function getAbsoluteLeft(obj) {
	var posLeft = 0;
	while (obj.offsetParent) {posLeft += obj.offsetLeft; obj = obj.offsetParent;}
	return posLeft;
}

if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);



function search_form_validation(){
	if(document.getElementById('search_text').value == "" || document.getElementById('search_text').value == "Search for a Speaker")
		{
		 alert("Please insert a text for search !");
		 return false;
		}else return true;
}