/* DO NOT EDIT. THIS IS A CACHE FILE AND WILL GET OVERWRITTEN RANDOMLY.
INSTEAD EDIT THE TEMPLATE FROM WITHIN THE ADMIN ZONE, OR BY MANUALLY EDITING A TEMPLATES_CUSTOM OVERRIDE. */

function scriptLoadStuffStaff()
{
	var map,elements,i,j;
	for (i=0;i<document.images.length;i++)
	{
		map=document.images[i].getAttribute('usemap');
		if (map)
		{
			elements=document.getElementsByTagName('area');
			for (j=0;j<elements.length;j++)
			{
				if (!elements[j].onclick)
				{
					elements[j].src=document.images[i].src;
					elements[j].onclick=handleImageClick;
				}
			}
		}
		if (!document.images[i].onmouseover)
		{
			document.images[i].onmouseover=handleImageMouseOver;
		}
		if (!document.images[i].onmouseout)
		{
			document.images[i].onmouseout=handleImageMouseOut;
		}
		if (!document.images[i].onclick)
		{
			document.images[i].onclick=handleImageClick;
		} else
		if (!document.images[i].oldOnClick)
		{
			document.images[i].oldOnClick=document.images[i].onclick;
			document.images[i].onclick=function (event) { handleImageClick(event); this.oldOnClick(event); }
		}
	}
}

function handleImageMouseOver(event)
{
	window.old_status_img=window.status;
	window.status='Hold down the \'Alt\'/\'Shift\'/\'Ctrl\' keys together and click to edit this.';
}

function handleImageMouseOut(event)
{
	if (typeof window.old_status_img=='undefined') window.old_status_img='';
	window.status=window.old_status_img;
}

function handleImageClick(event)
{
	if (!event) event=window.event;

	var src=this.origsrc?this.origsrc:this.src;
	if ((src) && (magicKeypress(event)))
	{
		// Bubbling needs to be stopped because shift+click will open a new window on some lower event handler (in firefox anyway)
		if (typeof event.stopPropagation!='undefined') event.stopPropagation();
		event.cancelBubble=true;

		if (src.indexOf('/ocportal/themes/')!=-1)
			window.location.href='http://localhost/ocportal/adminzone/index.php?page=admin_themes&type=edit_image&url='+window.encodeURIComponent(src)+keep_stub();
		else window.alert('The image you clicked is not a theme image, and thus must be edited by some alternative means.');

		return false;
	}

	return true;
}

function handleZoneClick(src,event,zone_name)
{
	if (magicKeypress(event))
	{
		zone_name=zone_name.replace(/:.*$/,'');
		
		// Bubbling needs to be stopped because shift+click will open a new window on some lower event handler (in firefox anyway)
		if (typeof event.stopPropagation!='undefined') event.stopPropagation();
		event.cancelBubble=true;

		window.location.href='http://localhost/ocportal/adminzone/index.php?page=admin_zones&type=_edit&id='+window.encodeURIComponent(zone_name)+'&redirect='+window.encodeURIComponent(window.location.href)+keep_stub();

		return false;
	}

	return true;
}

function load_management_menu(type)
{
	if (!type) type='management';

	var on_url,off_url;

	if (type=='management')
	{
		on_url="http://localhost/ocportal/themes/default/images/bottom/managementmenu.png";
		off_url="http://localhost/ocportal/themes/default/images/bottom/managementmenu.png";
	} else
	{
		on_url="http://localhost/ocportal/themes/default/images/bottom/bookmarksmenu.png";
		off_url="http://localhost/ocportal/themes/default/images/bottom/bookmarksmenu.png";
	}

	var tmp_element,img;
	var management_menu_box=document.getElementById(type+'_menu_box');
	if (management_menu_box)
	{
		img=document.getElementById(type+'_menu_img');
		if (management_menu_box.style.display=='none')
		{
			management_menu_box.style.display='block';
			img.src=off_url;
		} else
		{
			management_menu_box.style.display='none';
			img.src=on_url;
		}
		fixImage(img);
		return false;
	}

	if ((!window.popUpMenu) || (!window.ajax_supported))
	{
		if (document.getElementById(type+'_menu_img_loader'))
		{
			window.setTimeout('load_management_menu(\''+type+'\');',200);
			return false;
		}

		img=document.getElementById(type+'_menu_img');
		setOpacity(img,0.4);
		tmp_element=document.createElement('img');
		tmp_element.style.position='absolute';
		tmp_element.style.left=findPosX(img)+'px';
		//tmp_element.style.top=findPosY(img)+'px'; Doesn't apply because the bottom is absolutely positioned itself (and hence, the reference point)
		tmp_element.style.top='9px';
		tmp_element.id=type+'_menu_img_loader';
		tmp_element.src="http://localhost/ocportal/themes/default/images/bottom/loading.gif";
		img.parentNode.appendChild(tmp_element);
		fixImage(img);

		require_javascript("javascript_ajax");
		require_javascript("javascript_menu_popup");
		window.setTimeout('load_management_menu(\''+type+'\');',200);

		return false;
	}
	if ((window.ajax_supported) && (ajax_supported()))
	{
		if (!confirm_session()) return false;

		addEventListenerAbstract(document,'click',function (e) { if (!e) e=window.event; var el=e.target; if (!el) el=e.srcElement; if (el.id!=type+'_menu_img') { document.getElementById(type+'_menu_img').src=on_url; document.getElementById(type+'_menu_box').style.display='none'; } },false);

		var img=document.getElementById(type+'_menu_img');
		img.src=off_url;
		fixImage(img);

		tmp_element=document.getElementById(type+'_menu_img_loader');
		if (tmp_element) tmp_element.parentNode.removeChild(tmp_element);
		setOpacity(img,1.0);
		var e=document.createElement('div');
		e.setAttribute('id',type+'_menu_box');
		e.style.zIndex=200;
		var b=document.getElementById(type+'_menu_rel');
		e.style.position='absolute';
		e.style.bottom='10px';
		setInnerHTML(e,load_snippet(type+'_menu'));
		b.appendChild(e);

		return false; // No need to load link now, because we've done an overlay
	}
	window.location.href=document.getElementById(type+'_menu_button').href;
	return false;
}


