// JavaScript Document

function imageGallery(name, imageFrame, width)
{
	this.name = name;
	this.imageFrame = imageFrame;
	this.direction = 'left';  
	this.width = width;
	this.xoffset = 0;
	
	this.speed = 4;
	
	//this.timer;

	this.init = init;  
	this.play = play;
	this.start = start;
	
	this.init();
	this.start();
	this.play();
	
	function init()
	{
		
		$('scrollright').onmouseover = function (e)
		{
			if (!e) var e = window.event;
			this.src = 'images/scrollright_over.png';
			updategallery('left',8);
		}		
		if ($('scrollright').captureEvents) $('scrollright').captureEvents(Event.ONMOUSEOVER);
		
		$('scrollright').onmouseout = function (e)
		{
			if (!e) var e = window.event;
			this.src = 'images/scrollright.png';
			updategallery('center',0);
		}		
		if ($('scrollright').captureEvents) $('scrollright').captureEvents(Event.ONMOUSEOUT);
		
		
		$('scrollleft').onmouseover = function (e)
		{
			if (!e) var e = window.event;
			this.src = 'images/scrollleft_over.png';
			updategallery('right',8);
		}		
		if ($('scrollleft').captureEvents) $('scrollleft').captureEvents(Event.ONMOUSEOVER);
		
		$('scrollleft').onmouseout = function (e)
		{
			if (!e) var e = window.event;
			this.src = 'images/scrollleft.png';
			updategallery('center',0);
		}		
		if ($('scrollleft').captureEvents) $('scrollleft').captureEvents(Event.ONMOUSEOUT);
		
		//alert(this.imageFrame.innerHTML); 
	}
	function play()
	{
		//alert('this.imageFrame.innerHTML'); 
		this.timer = setInterval(this.name+'.start()','50');
	}
	function start()
	{
		if(this.direction == 'left')
		{
			if(this.xoffset > -(this.width - 1000))
			{
				this.xoffset = this.xoffset - this.speed ;
				$('scrollright').style.display = 'block';
				$('scrollleft').style.display = 'block';
			}
			else
			{
				this.xoffset = -(this.width - 1000) ;
				$('scrollright').style.display = 'none';
			}
		}
		if(this.direction == 'right')
		{
			if(this.xoffset < 0)
			{
				this.xoffset = this.xoffset + this.speed ;
				$('scrollleft').style.display = 'block';
				$('scrollright').style.display = 'block';
			}
			else
			{
				this.xoffset = 0;
				$('scrollleft').style.display = 'none';
			}
		}
		this.imageFrame.style.left = this.xoffset + 'px';
	}	
}

function updategallery(direction, speed)
{
	imgGallery.direction = direction;
	imgGallery.speed = speed;
}

function setupsearch()
{
	if($('search'))
	{
		var searchNode = $('search');
		searchNode.onfocus = function (e)
		{
			if (!e) var e = window.event;
			if(this.value == 'Search')
			{
				this.value = '';
			}
		}		
		if (searchNode.captureEvents) searchNode.captureEvents(Event.ONFOCUS);
		
		searchNode.onblur = function (e)
		{
			if (!e) var e = window.event;
			if(this.value == '')
			{
				this.value = 'Search';
			}
		}		
		if (searchNode.captureEvents) searchNode.captureEvents(Event.ONBLUR);
		
	}
}


function setupmailinglist()
{
	if($('mailinglist'))
	{
		var mailinglistNode = $('mailinglist');
		mailinglistNode.onfocus = function (e)
		{
			if (!e) var e = window.event;
			if(this.value == 'Type your email')
			{
				this.value = '';
			}
		}		
		if (mailinglistNode.captureEvents) mailinglistNode.captureEvents(Event.ONFOCUS);
		
		mailinglistNode.onblur = function (e)
		{
			if (!e) var e = window.event;
			if(this.value == '')
			{
				this.value = 'Type your email';
			}
		}		
		if (mailinglistNode.captureEvents) mailinglistNode.captureEvents(Event.ONBLUR);
		
	}
}

function initrollovers_pressrelease()
{
	if($('next'))
	{
	$('next').onmouseover = function (e)
	{
		if (!e) var e = window.event;
		this.src = 'images/scrollright_over.png';
	}		
	if ($('next').captureEvents) $('next').captureEvents(Event.ONMOUSEOVER);
	
	$('next').onmouseout = function (e)
	{
		if (!e) var e = window.event;
		this.src = 'images/scrollright.png';
	}		
	if ($('next').captureEvents) $('next').captureEvents(Event.ONMOUSEOUT);
	}
	
	if($('prev'))
	{
	$('prev').onmouseover = function (e)
	{
		if (!e) var e = window.event;
		this.src = 'images/scrollleft_over.png';
	}		
	if ($('prev').captureEvents) $('prev').captureEvents(Event.ONMOUSEOVER);
	
	$('prev').onmouseout = function (e)
	{
		if (!e) var e = window.event;
		this.src = 'images/scrollleft.png';
	}		
	if ($('prev').captureEvents) $('prev').captureEvents(Event.ONMOUSEOUT);
	}
}


