function show_browse(ElmId)
{
	document.getElementById(ElmId).style.display="block";
	return false;
}
//--------------------------
function hide_browse(ElmId)
{
	document.getElementById(ElmId).style.display="none";
	return false;
}
//--------------------------
function redirect(url)
{
	window.location=url;
}
//--------------------------
function add_temp_lightbox(album_id,parent_album_id)
{ 
    AjaxRequest.post(
    {
        'url':'?mod=ajax_function&fun=do_add_temp_lightbox&album_id=' + album_id + '&parent_album_id=' +parent_album_id ,
        'onSuccess':function add_album(req)
                    {
						document.getElementById('show_lightbox_td').innerHTML  =  req.responseText ;
						
					},
					'onError':function add_temp_lightbox(req){alert(req.responseText)}
	});
}
//--------------------------
function delete_temp_lightbox(album_id)
{ 
    AjaxRequest.post(
    {
        'url':'?mod=ajax_function&fun=do_delete_temp_lightbox&album_id=' + album_id ,
        'onSuccess':function delet_album(req)
                    {
						document.getElementById('show_lightbox_td').innerHTML  =  req.responseText ;
					},    
					'onError':function delete_temp_lightbox(req){alert(req.responseText)}
	});
}
//--------------------------
function add_photo_temp_lightbox(photo_id)
{ 
    AjaxRequest.post(
    {
        'url':'?mod=ajax_function&fun=do_add_photo_temp_lightbox&photo_id=' + photo_id ,
        'onSuccess':function add_photo(req)
                    {

						document.getElementById('show_lightbox_td').innerHTML  =  req.responseText ;
					},
					'onError':function add_photo_temp_lightbox(req){alert(req.responseText)}
	});
}
//--------------------------
function delete_photo_temp_lightbox(photo_id)
{ 
    AjaxRequest.post(
    {
        'url':'?mod=ajax_function&fun=do_delete_photo_temp_lightbox&photo_id=' + photo_id ,
        'onSuccess':function delete_photo(req)
                    {
						document.getElementById('show_lightbox_td').innerHTML  =  req.responseText ;
					},    
					'onError':function delete_photo_temp_lightbox(req){alert(req.responseText)}
	});
}
//----------------------------------------------------
function highlightCalendarCell(element) {
	$(element).style.border = '1px solid #999999';
}
//----------------------------------------------------
function resetCalendarCell(element) {
	$(element).style.border = '1px solid #000000';
}
//----------------------------------------------------
function startCalendar(month, year) {
	new Ajax.Updater('calendarInternal', 'index.php?mod=rpc', {method: 'post', postBody: 'action=startCalendar&month='+month+'&year='+year+''});
}
//----------------------------------------------------
function showEventForm(day) {
	$('evtDay').value = day;
	$('evtMonth').value = $F('ccMonth');
	$('evtYear').value = $F('ccYear');
	
	displayEvents(day, $F('ccMonth'), $F('ccYear'));
	
	if(Element.visible('addEventForm')) {
		// do nothing.
	} else {
		Element.show('addEventForm');
	}
}
//----------------------------------------------------
function displayEvents(day, month, year) 
{
	new Ajax.Updater('eventList', 'modules/rpc.php', {method: 'post', postBody: 'action=listEvents&&d='+day+'&m='+month+'&y='+year+''});
	if(Element.visible('eventList')) {
		// do nothing, its already visble.
	} else {
		setTimeout("Element.show('eventList')", 300);
	}
}
//----------------------------------------------------
function highlightEvent(day) 
{
	Element.hide('addEventForm');
	$('calendarDay_'+day+'').style.background = '#<?= $eventColor ?>';
}
//----------------------------------------------------
function deleteEvent(eid) 
{
	confirmation = confirm('Are you sure you wish to delete this event?\n\nOnce the event is deleted, it is gone forever!');
	if(confirmation == true) {
		new Ajax.Request('rpc.php', {method: 'post', postBody: 'action=deleteEvent&eid='+eid+'', onSuccess: Element.hide('event_'+eid+'')});
	} else {
		// Do not delete it!.
	}
}
//-------------------------------------------------

var browserName=navigator.appName; 
if (browserName=="Microsoft Internet Explorer")
{
	var offsetx = 850;
	var offsety = 315;
}
else
{
	var offsetx = 12;
	var offsety =  8;
}

function newelement(newid)
{ 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
    if(document.getElementById)
    {
        var iebody=(document.compatMode && 
        	document.compatMode != 'BackCompat') ? 
        		document.documentElement : document.body;
        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

        var lixlpixel_tooltip = document.getElementById('tooltip');
        lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
        lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
    }
}
function tooltip(tip)
{
    if(!document.getElementById('tooltip')) newelement('tooltip');
    var lixlpixel_tooltip = document.getElementById('tooltip');
    lixlpixel_tooltip.innerHTML = tip;
    lixlpixel_tooltip.style.display = 'block';
    document.onmousemove = getmouseposition;
}
function exit()
{
    document.getElementById('tooltip').style.display = 'none';
}
