//************************************************************************************
// Copyright (C) 2006, Massimo Beatini
//
// This software is provided "as-is", without any express or implied warranty. In 
// no event will the authors be held liable for any damages arising from the use 
// of this software.
//
// Permission is granted to anyone to use this software for any purpose, including 
// commercial applications, and to alter it and redistribute it freely, subject to 
// the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not claim 
//    that you wrote the original software. If you use this software in a product, 
//    an acknowledgment in the product documentation would be appreciated but is 
//    not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be 
//    misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
//************************************************************************************
// This copy of the dimmingdiv.js file has been adjusted and reduced by Noveos.com

var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";
var over = false;

function displayFloatingDiv(divId, title, left, top, minimise) 
{
	DivID = divId;
	var d = document.getElementById(divId);
	
	d.style.left = left + 'px';
	d.style.top = top + 'px';
	
	var addHeader;
	
	if (originalDivHTML == "") {originalDivHTML = d.innerHTML;}
	
	if(minimise) {
		addHeader = '<p class="heading" ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;">' + title + '</p>';
		d.innerHTML = addHeader;
	}
	else {
		addHeader = '<p class="heading" ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;">' + title + '</p>';
		d.innerHTML = addHeader + originalDivHTML;    	
	}
	d.className = 'dimming';
	d.style.visibility = "visible";
}

function hideFloatingDiv(divId) 
{
	var d = document.getElementById(divId);
	if(d)
	{
		d.style.width = '0px';
		d.style.height = '0px';
		d.style.left = '0px';
		d.style.top = '0px';
		d.className = 'dimming';
		d.style.visibility = "hidden";
	}
}

function moveSearchPanel() {displaySearchPanel(false);}

function displaySearchPanel(minimise)
{
	var w, h, l, t;
	w = 400;
	if(minimise) {
		h = 23;
	}
	else {
		h = 740;
	}
	whiteSpace = (document.body.scrollWidth - 1142) / 2;
	l = whiteSpace + 340;
	t = 195;
	displayFloatingDiv('s_refine_panel', 'Services and Activities Filter', l, t, minimise);
}

function maximiseFloatingDiv() {displaySearchPanel(false);}

function minimiseFloatingDiv() {displaySearchPanel(true);}

function hiddenFloatingDiv(divId) 
{
	var d = document.getElementById(divId);
	d.innerHTML = originalDivHTML;
	d.style.visibility='hidden';
	DivID = "";
}

function MouseDown(e) 
{
	if (over)
	{
		if (isMozilla) {
			objDiv = document.getElementById(DivID);
			X = e.layerX;
			Y = e.layerY;
			return false;
		}
		else {
			objDiv = document.getElementById(DivID);
			objDiv = objDiv.style;
			X = event.offsetX;
			Y = event.offsetY;
		}
	}
}

function MouseMove(e){
	if (objDiv) {
		if (isMozilla) {
			objDiv.style.top = (e.pageY-Y) + 'px';
			objDiv.style.left = (e.pageX-X) + 'px';
			return false;
		}
		else {
			objDiv.pixelLeft = event.clientX-X + document.body.scrollLeft;
			objDiv.pixelTop = event.clientY-Y + document.body.scrollTop;
			return false;
		}
	}
}

function MouseUp(){objDiv = null;}

function init(){
	isMozilla = (document.all) ? 0 : 1;
	if (isMozilla){document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);}
	document.onmousedown = MouseDown;
	document.onmousemove = MouseMove;
	document.onmouseup = MouseUp;
}
init();