function DoPopup(Event)
{
	var ViewportWidth = window.innerWidth ? window.innerWidth : $(window).width();

	var Elem = $(Event.target);
	//alert(Elem.attr('tag'));
	var Data = jQuery.parseJSON(Elem.attr('tag'));

	$('#pop-title').html(Data.Title);
	$('#pop-img').attr('src', Data.Img);
	$('#pop-author').html('by ' + Data.User);

	var Offset = Elem.offset().left + Elem.outerWidth(true) + 30;
	if ((Offset + 240) > ViewportWidth)
		$('#popup').css('left', Elem.offset().left - 270);
	else
		$('#popup').css('left', Offset);

	$('#popup').css('top', Elem.offset().top - 30);
	$('#popup').show();
}

function ClosePopup(Event)
{
	$('#popup').hide();
}

function ShowCategory(Obj, ChildId)
{
	if (document.getElementById('Child2_' + ChildId).style.display == 'block')
	{
		document.getElementById('Child2_' + ChildId).style.display = 'none';
		Obj.src = '/img/EN/arrow-directory-small-right.png';
	}
	else
	{
		document.getElementById('Child2_' + ChildId).style.display = 'block';
		Obj.src = '/img/EN/arrow-directory-small.png';
	}
	
	SetHeight();return false;
}

function LoadTwitter()
{
	//we make the ajax call if we have the twitter div in the page
	if ($('#Twitter').is('div'))
		$.ajax({
		  url: "/ajax/LoadTwitter.php?Query=" + $('#SearchQuery').val(),
		  context: document.body,
		  success: function(Response)
		  	{
		    	$('#Twitter').html(Response.Data);
		    	SetHeight();
		  	}
		});
}
function LoadFlickr()
{
	//we make the ajax call if we have the twitter div in the page
	if ($('#FlickrHolder').is('div'))
	{
		$.ajax({
		  url: "/ajax/LoadFlickr.php?Query=" + $('#SearchQuery').val(),
		  context: document.body,
		  success: function(Response)
		  	{
		  		if (Response.Data != '')
		  		{
			    	$('#FlickrHolder').html(Response.Data);
			    	SetHeight();
		  		}
		  		else
		  		{
		  			$('#FlickrHolderParent').css('display', 'none');
		  			SetHeight();
		  		}
		  	}
		});
	}
}
$(document).click(HideTopSearches);
function ShowTopSearches()
{
	if ($('#more-menu').css('display') == 'none')
	{
		$('#more-menu').css('position', 'absolute');
		$('#more-menu').css('left', $('#menu-parent').position().left + 'px');
		$('#more-menu').css('top', ($('#menu-parent').position().top + 25) + 'px');
		$('#more-menu').css('width', '180px');
		
		$('#more-menu').css('display', 'block');
	}
	else
		$('#more-menu').css('display', 'none');
}
function HideTopSearches(e)
{
	if ((e.target.id != 'menu-parent') && (e.target.id != 'menu-parent-img'))
		$('#more-menu').css('display', 'none');
}
