/*
*	content:		global functions
*	project:		animoto
*	version:		$Id: global.js 424 2007-05-31 11:44:24Z  $
*	developer:		dli
*	all rights at:	daniel.liebig@wevin.de 
*/


//-- preload rollovers
	var Img		= new Array(8);
	var imgPath	= '../../_common/img/main_menue/';
	
//-- remember currently active image
	
	var activeImg;
	
	
	for (var i = 0; i < 8; i++)
	{
		Img[i] = new Image();
	}
	Img[0].src = imgPath + 'animoto_h.gif';
	Img[1].src = imgPath + 'services_h.gif';
	Img[2].src = imgPath + 'show_h.gif';
	Img[3].src = imgPath + 'art_h.gif';
	Img[4].src = imgPath + 'contact_h.gif';
	Img[5].src = imgPath + 'home_h.gif';
	Img[6].src = imgPath + 'sitemap_h.gif';
	Img[7].src = imgPath + 'login_h.gif';

function highlight(Img)
{
	if ( Img != activeImg )
	{
		swapIn(Img);
	}
}

function highlightOff(Img)
{
//	alert(activeImg.src);

	if ( Img != activeImg )
	{
		swapOut(Img);
	}
}

function set_active(Img)		// function name: setActive seems not to work with i.e., hell knows why
{
	if ( Img == activeImg )
	{
		return;
	}
	swapOut(activeImg);
	activeImg	= Img;
	highlight(activeImg);
}

function swapIn(Img)
{
	if ( !Img )
	{
		return;
	}
	if ( Img.src.substr(Img.src.length - 6) == '_h.gif' )
	{
		return;
	}
	overImgSrc 	= Img.src.substr(0, (Img.src.length - 4) ) + '_h.gif';
	Img.src		= overImgSrc;
}

function swapOut(Img)
{
	if ( !Img )
	{
		return;
	}
	if ( Img.src.substr(Img.src.length - 6) != '_h.gif' )
	{
		return;
	}
	outImgSrc 	= Img.src.substr(0, (Img.src.length - 6) ) + '.gif';
	Img.src		= outImgSrc;
}

function set_image_source(Img, src)
{
	document.getElementById(Img).src = src;
}


/************************************** scrolling (seems to be pretty global) ********************************/

var scrolling;

function scroll(direction)
{
	i = 0;
	if ( direction == 'up')
	{
		var move = 'move_up()';
	}
	if ( direction == 'down')
	{
		var move = 'move_down()';
	}
	scrolling	= window.setInterval(move, 1);
}

function move_down()
{
	var Content	= document.getElementById('scrolling_content');
	var top		= Content.offsetTop;
	if ( top >= 0 )
	{
		stop_scrolling();
		return;
	}
	top += 5;
	Content.style.top = top + 'px';
}

function move_up()
{
	var Content	= document.getElementById('scrolling_content');
	var top		= Content.offsetTop;
	var Frame	= document.getElementById('frame');
	if ( top <= ( Frame.offsetHeight - Content.offsetHeight ) )
	{
		stop_scrolling();
		return;
	}
	top -= 5;
	Content.style.top = top + 'px';
}


function stop_scrolling()
{
	window.clearInterval(scrolling);
}


function move_to(pos)
{
	var Content	= document.getElementById('scrolling_content');
	Content.style.top = pos + 'px';
}


function emergency_break()
{
	i += 1;
	if ( i >= 100 )
	{
		stop_scrolling();
		alert('emergency break!');
	}
}



