
function form_submit(frm){
	$.id(frm).submit();	
}

function nospam(url,a){
	window.location='mailto:'+a+'@'+url+'?subject=enquiry';	
}

dd=new Object();

function wheel_scroll(delta,e){

	var d=(delta>0)?-15:15;
	click_scroll(d,e);
}

function add_mouse_wheel(){
	
	var wheel=function(e){
		
        var delta = 0;

		if(e.wheelDelta)
			{
			delta=e.wheelDelta/120;

			if(window.opera)
				delta=-delta;
	        }
		else if(e.detail)
			{
			delta=-e.detail/3;
			}

		if(delta)
			wheel_scroll(delta,e);

		if(e.preventDefault)
			e.preventDefault();
	}

	if(typeof isIE=='undefined')
		isIE=false;

	var b=$.id('right');

	if(isIE)
		EventUtils.addEventListener(b,'mousewheel',wheel);
	else
		EventUtils.addEventListener(b,'DOMMouseScroll',wheel);
}

function drag(box,container,scale) {

	dd[box] = new DragDrop(box, {onMouseMove:

		function(left,top) {

			if(!this.scrollStyle) this.scrollStyle = $.id(container).style;
			this.scrollStyle.top = - top*scale + 'px';
	
		}
	});

	var b=$.id(box);
	var scroller=$.id('scroller');

	dd[box].holdX();
	dd[box].limit({top: 0, bottom: (scroller.offsetHeight-b.offsetHeight)-4});
	dd[box].useRelative();
}

function click_scroll(pos,evt){
	
	var box=$.id('box');
	var right=$.id('right');
	var inner=$.id('inner');
	var scroller=$.id('scroller');

	H=inner.offsetHeight-right.offsetHeight;

	if(pos==false)
		{
		mouse=EventUtils.mouse(evt);
		var y=mouse.y-67;
		}
	else
		{
		var scale=scroller.offsetHeight/(scroller.offsetHeight-(box.offsetHeight+4))

		var y=(pos+box.offsetTop)*scale;
		var m=scroller.offsetHeight;

		if(y<0)
			y=0;

		if(y>m)
			y=m;
		}
	
	var factor=y/scroller.offsetHeight;

	var p=-H*factor;

	inner.style.top=p+'px';

	box.style.top=(y/scroller.offsetHeight)*(scroller.offsetHeight-(box.offsetHeight+4))+'px';

	var targ=EventUtils.targetElement(evt);

	if(targ.id!='box' && pos==false)
		dd['box'].onMouseDown(evt);
}

function init(){

	var box=$.id('box');
	var right=$.id('right');
	var inner=$.id('inner');
	var scroller=$.id('scroller');

	if(right.offsetHeight<inner.offsetHeight)
		{
		scroller.style.visibility='visible';
		
		var box_height=(right.offsetHeight/inner.offsetHeight)*scroller.offsetHeight;
		box.style.height=box_height+'px';
		drag('box','inner',(inner.offsetHeight-right.offsetHeight)/(scroller.offsetHeight-(box_height+4)));
		add_mouse_wheel();
		}
}