// JavaScript Document

function imageGallery(name, imageFrame, width)
{
	this.name = name;
	this.imageFrame = imageFrame;
	this.direction = 'left';  
	this.width = width;
	this.xoffset = 0;
	
	this.speed = 2;
	
	//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);
	}
}

function randOrd(){
return (Math.round(Math.random())-0.5); }
var pictures = new Array ("<img src=\"images/h1.jpg\"  />", "<img src=\"images/h2.jpg\" />", "<img src=\"images/h3.jpg\" />", "<img src=\"images/h4.jpg\" />", "<img src=\"images/h5.jpg\" />", "<img src=\"images/h6.jpg\" />", "<img src=\"images/h7.jpg\" />", "<img src=\"images/h8.jpg\" />", "<img src=\"images/h9.jpg\" />", "<img src=\"images/h10.jpg\" />", "<img src=\"images/h11.jpg\" />", "<img src=\"images/h13.jpg\" />", "<img src=\"images/h14.jpg\" />", "<img src=\"images/h15.jpg\" />", "<img src=\"images/h16.jpg\" />", "<img src=\"images/h17.jpg\" />", "<img src=\"images/h18.jpg\" />", "<img src=\"images/h19.jpg\" />");
pictures.sort(randOrd);


      function addEvent(obj ,evt, fnc)
      {
        if (obj.addEventListener)
          obj.addEventListener(evt,fnc,false);
        else if (obj.attachEvent)
          obj.attachEvent('on'+evt,fnc);
        else
          return false;
        return true;
      }

      function removeEvent(obj ,evt, fnc)
      {
        if (obj.removeEventListener)
          obj.removeEventListener(evt,fnc,false);
        else if (obj.detachEvent)
          obj.detachEvent('on'+evt,fnc);
        else
          return false;
        return true;
      }

      //----------

      function appendElement(node,tag,id,htm)
      {
        var ne = document.createElement(tag);
        if(id) ne.id = id;
        if(htm) ne.innerHTML = htm;
        node.appendChild(ne);
      }

      //----------

      function showPopup(p)
      {
        greyout(true);
        document.getElementById(p).style.display = 'block';
      }

      function hidePopup(p)
      {
        greyout(false);
        document.getElementById(p).style.display = 'none';
      }

      //----------

      function greyout(d,z)
      {
        var obj = document.getElementById('greyout');
        if(!obj)
        {
          appendElement(document.body,'div','greyout');
          obj = document.getElementById('greyout');
          obj.style.position = 'absolute';
          obj.style.top = '0px';
          obj.style.left = '0px';
          obj.style.background = '#111';
          obj.style.opacity = '.5';
          obj.style.filter = 'alpha(opacity=50)';
        }
        if(d)
        {
          if(!z){ z - 50 }
          obj.style.zIndex = z;
          obj.style.height = Math.max(document.body.scrollHeight,document.body.clientHeight)+'px';
          obj.style.width  = Math.max(document.body.scrollWidth,document.body.clientWidth)+'px';
          obj.style.display = 'block';
          addEvent(window,'resize',greyoutResize);
        }
        else
        {
          obj.style.display = 'none';    
          removeEvent(window,'resize',greyoutResize);
        }
      }
      
      function greyoutResize()
      {
        var obj = document.getElementById('greyout');
        obj.style.height = document.body.clientHeight+'px';
        obj.style.width  = document.body.clientWidth+'px';
        obj.style.height = Math.max(document.body.scrollHeight,document.body.clientHeight)+'px';
        obj.style.width  = Math.max(document.body.scrollWidth,document.body.clientWidth)+'px';
      }

