//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Client_text Selector
//-------------------------------------------------------------------------------------------------------
//	track what Client_text is highlighted in the sponsor a Client_text selector
currentClient_text	= 0;

function showClient_text(what)
{
	Client_textId			= "Client_text" + what;
	
	if(document.getElementById)
	{
		if ( !document.getElementById(Client_textId) )
		{
			return;
		}

		document.getElementById(Client_textId).style.visibility	= "visible";
		if (currentClient_text != what)
		{
			previousClient_textId		= "Client_text" + currentClient_text;
			document.getElementById(previousClient_textId).style.visibility	= "hidden";
		}
	}

	currentClient_text	= what;
}

//-------------------------------------------------------------------------------------------------------
//	Client_image Selector
//-------------------------------------------------------------------------------------------------------
//	track what Client_image is highlighted in the sponsor a Client_image selector
currentClient_image	= 0;

function showClient_image(what)
{
	Client_imageId			= "Client_image" + what;
	
	if(document.getElementById)
	{
		if ( !document.getElementById(Client_imageId) )
		{
			return;
		}

		document.getElementById(Client_imageId).style.visibility	= "visible";
		if (currentClient_image != what)
		{
			previousClient_imageId		= "Client_image" + currentClient_image;
			document.getElementById(previousClient_imageId).style.visibility	= "hidden";
		}
	}

	currentClient_image	= what;
}

//-------------------------------------------------------------------------------------------------------
//	Redirect
//-------------------------------------------------------------------------------------------------------
function redirectTo( nav )
{
	//	Selected a url?
	dropdown	= nav.options;
	value		= dropdown[dropdown.selectedIndex].value;

	if ( value )
	{
		window.location.href = value;	
	}
}

//-------------------------------------------------------------------------------------------------------
//	Gallery functionality
//-------------------------------------------------------------------------------------------------------
function gallerySwap(id)
{
	detailsImage	= document.getElementById('detailsgraphic');
	detailsImage.setAttribute( 'src', gallery[id] );
	
	textElement		= document.getElementById('detailstitle');
	textElement.innerHTML	= gallerytitle[id];
	
	textElement		= document.getElementById('detailstext');
	textElement.innerHTML	= gallerytext[id];
}

//*********************************************************************************************************
//	Positioning Tools
//*********************************************************************************************************
var positionShown  = false;

//-------------------------------------------------------------------------------------------------------
//	Turn position reporting On/Off
//-------------------------------------------------------------------------------------------------------
function togglePositionReporting()
{
	//	What ctrl key combination was hit
	if ( event.ctrlKey && (event.keyCode == 71) )
	{
		if (!document.getElementById('grid') || !document.getElementById('poslabel'))
		{
			return;
		}
		
		//	Get the tool objects
		gridObj  = document.getElementById('grid');
		labelObj = document.getElementById('poslabel');
		
		//	Turn the monitoring off
		if (positionShown)
		{
			//	Hide the grid
			gridObj.style.display = 'none';
			
			//	Show the position label
			labelObj.style.display = 'none';
			
			//	Stop monitoring
			document.onmousemove = '';
		}

		//	Turn the monitoring on
		else
		{
			//	Show the label
			labelObj.style.display = 'block';
			
			//	Show the grid
			gridObj.style.display	= 'block';
			gridObj.style.height	= document.body.clientHeight + 'px';

			//	Start monitoring
			document.onmousemove = showMousePosition;
		}

		//	Reset the state
		positionShown = positionShown ? false : true;
	}
}

//-------------------------------------------------------------------------------------------------------
//	Show the mouse position
//-------------------------------------------------------------------------------------------------------
function showMousePosition()
{
	//	Get the label
	labelObj = document.getElementById('poslabel');
	
	//	Get the scroll position
	if (document.compatMode && document.compatMode != "BackCompat")
	{
		scroll_left = document.documentElement.scrollLeft;
		scroll_top  = document.documentElement.scrollTop;
	}
	else
	{
		scroll_left = document.body.scrollLeft;
		scroll_top  = document.body.scrollTop;
	}

	//	Get the mouse position
	xMousePos	 = window.event.x + scroll_left - 2;
	yMousePos	 = window.event.y + scroll_top  - 3;
	xMousePosMax = document.body.clientWidth +  scroll_left;
	yMousePosMax = document.body.clientHeight + scroll_top;

	//	Reposition the label in the correct position
	labelObj.style.top  = yMousePos + 5;
	labelObj.style.left = xMousePos + 15;
	
	//	Update the label
	labelObj.innerText = xMousePos + ", " + yMousePos;
}



//-------------------------------------------------------------------------------------------------------
// Original:  Ernst Straka (ernst.straka@central-europe.basf.org) //
// Web Site:  http://www.rs-systems.at/straka -->
//-------------------------------------------------------------------------------------------------------

// Begin
var l1 =	30;		// left of ticker in pixel, or 0 to position relative
var t1 =	120;	// top of ticker in pixel, or 0 to position relative
var w1 =	400;	// width of ticker in pixel
var ie = document.all ? true : false;
var first = true;
var l2 = l1 + w1;
var l3 = l1 - l2;
var l = l2;
function tickinit() {
if (ie) {
if (l1 == 0 && t1 == 0) {
pos = document.all['tickpos'];
l1 = getLeft(pos);
t1 = getTop(pos);
}
ticktext.style.posTop = t1;
}
else {
if (l1 == 0 && t1 == 0) {
pos = document.anchors['tickpos'];
l1 = pos.x;
t1 = pos.y;
}
document.ticktext.pageY = t1;
}
l2 = l1 + w1;
l3 = l1 - l2;
l = l2;
setInterval('tick()', 20); // Higher number = slower speed
}
function getLeft(ll) {
if (ll.offsetParent)
return (ll.offsetLeft + getLeft(ll.offsetParent));
else 
return (ll.offsetLeft);
}
function getTop(ll) {
if (ll.offsetParent)
return (ll.offsetTop + getTop(ll.offsetParent));
else
return (ll.offsetTop);
}
function tick() {
l = l - 0.5;
if (l < l3) l = l2;
cl = l1 - l;
cr = l2 - l;
if (ie) {
ticktext.style.posLeft = l;
ticktext.style.posTop = t1;
ticktext.style.clip = "rect(auto "+cr+"px auto "+cl+"px)";
if (first) ticktext.style.visibility = "visible";
}
else {
document.ticktext.pageX = l;
document.ticktext.clip.left = cl;
document.ticktext.clip.right = cr;
if (first) document.ticktext.visibility = "show";
}
first = false;
}



//----------------------------------//
//  Javascript - Mouseovers		 	//	
//----------------------------------//

//  Home Navigation  //

/*
demo0					= new Image();
demo0.src				= "/images/demo_nav_0.jpg";
demo1					= new Image();
demo1.src				= "/images/demo_nav_1.jpg";

print0					= new Image();
print0.src				= "/images/print_0.gif";
print1					= new Image();
print1.src				= "/images/print_1.gif";

spotlight0				= new Image();
spotlight0.src			= "/images/spotlight_0.gif";
spotlight1				= new Image();
spotlight1.src			= "/images/spotlight_1.gif";

compliance0					= new Image();
compliance0.src				= "/images/compliance_0.jpg";
compliance1					= new Image();
compliance1.src				= "/images/compliance_1.jpg";

information0					= new Image();
information0.src				= "/images/information_0.jpg";
information1					= new Image();
information1.src				= "/images/information_1.jpg";
*/

function mOver(what,num)
{
	
	if(num == '1')
	{
		if(document.images)	
		{
			document[what].src	= eval(what + "1.src");
		}
	}

}

function mOut(what,num)
{
	
	if(num == '0')
	{
		if(document.images)	
		{
			document[what].src	= eval(what + "0.src");
		}
	}
}


// preloader //
function MM_preloadImages() 
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


//  End //