var mouse_x = 0;
var mouse_y = 0;

var activeBtn;	

/* NAVIGATION */

var activeLang;
var mouseOverLang;
var mouseOutLang;
var langImg;

if(activeLang == "")
{
	activeLang = "nl";
}	

/* VIDEO PLAYER CODE */
var movieName = "trapo";

function thisMovie(movieName)
{
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1)
	{
    return window[movieName]
  }
	else
	{
    return document[movieName]
  }
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie)
{
  if (typeof(theMovie) != "undefined")
	{
    return theMovie.PercentLoaded() == 100;
  }
	else
	{
    return false;
  }
}



function mouseOverLanguage(lang ,path)
{
	if(lang != activeLang)
	{
		langImg = document.getElementById(lang);
		langImg.style.marginTop= "-3px";
		langImg.style.marginLeft= "-3px";
		langImg.src = root_path + "image/vlaggen/" + lang + "_active.gif";
	}
}	

function resetActiveLanguage(lang, path)
{
	if(lang != activeLang)
	{
		langImg = document.getElementById(lang);
		langImg.style.marginTop= "0px";
		langImg.style.marginLeft= "0px";
		langImg.src = root_path + "image/vlaggen/" + lang + "_inactive.gif";
	}
}

function setActiveLanguage(lang)
{
	//reset current
	langImg = document.getElementById('nl');
	langImg.style.marginTop= "0px";
	langImg.style.marginLeft= "0px";
	langImg.src = root_path + "image/vlaggen/nl_inactive.gif";
	
	langImg = document.getElementById('uk');
	langImg.style.marginTop= "0px";
	langImg.style.marginLeft= "0px";
	langImg.src = root_path + "image/vlaggen/uk_inactive.gif";
	
	langImg = document.getElementById('de');
	langImg.style.marginTop= "0px";
	langImg.style.marginLeft= "0px";
	langImg.src = root_path + "image/vlaggen/de_inactive.gif";
	
	langImg = document.getElementById('fr');
	langImg.style.marginTop= "0px";
	langImg.style.marginLeft= "0px";
	langImg.src = root_path + "image/vlaggen/fr_inactive.gif";
		
	//set new language
	activeLang = lang;	
			
	//set new language		
	langImg = document.getElementById(lang);
	langImg.style.marginTop= "-3px";
	langImg.style.marginLeft= "-3px";
	langImg.src = root_path + "image/vlaggen/" + lang + "_active.gif";
}

function clearActiveLang(lang, path)
{		
	if(lang != mouseOutLang)
	{	
		//langDiv = document.getElementById(lang);
		//langDiv.innerHTML = "<img src=\""+ path +"image/vlaggen/" + lang + "_inactive.gif\" alt=\"\" />";
	}
	
	mouseOutLang = lang;
}	

/*
*/
function goTo(url)
{
	document.location.href = url;
}

/*
*/
function refreshWindow()
{
	document.location.href = document.location.href;
}

/*
*/
function submitForm(form_id, action)
{
	document.getElementById(form_id + "_action").value = action;
	document.getElementById(form_id).submit();
}


/* GUI */

/*
*/
function rescaleWindow(window_obj, document_obj, id)
{
	var height = document_obj.body.clientHeight + 100;
	
	//make window not to high
	if(height > screen.height)
		height = screen.height;
	
	window_obj.resizeTo((window.screen.width / 2), height);
}

/*
*/
function selectOption(object_id, select_value)
{
	var select_obj        = document.getElementById(object_id);
	
	var available_options = select_obj.options;
	
	for(var o = 0; o < available_options.length; o++)
	{
		if(available_options[o].value == select_value)
		{
			select_obj.selectedIndex = o;
			break;
		}
	}
}

/*
*/
function showElement(id)
{
	(document.getElementById(id)).style.display = "block";
}

/*
*/
function hideElement(id)
{
	(document.getElementById(id)).style.display = "none";
}


/* POSITIONING */

/*
*/
function getElementPosition(obj) 
{
	if(obj != null)
	{
		var curleft = curtop = 0;
		
		if (obj.offsetParent) 
		{
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			
			while (obj = obj.offsetParent) 
			{
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		
		return [curleft,curtop];
	}
	else
	{
		return [mouse_x, mouse_y];
	}
}

/*
*/
function getMousePosition(e) 
{
	e = e ? e : window.event;

	return [e.clientX, e.clientY];
}

/*
*/
function setMouseCoordinates(e) 
{
	e = e ? e : window.event;
	
	mouse_x = e.clientX;
	mouse_y = e.clientY;
}


/* WINDOW */

var window_clean_params  = ",directories=0,location=0,menubar=0,minimizable=0,personalbar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0";
var window_normal_params = ",directories=0,location=1,menubar=0,minimizable=0,personalbar=0,resizable=1,scrollbars=1,status=1,titlebar=0,toolbar=0";

/*
*/
function openStandardNewWindow(url, clean)
{
	openNewWindow(url, 480, 640, clean);
}

/*
*/
function openNewWindow(url, width, height, clean)
{
	if(width == "0" || height == "0")
		openNewWindowFullScreen(url, false);
	else
		window.open(url, "", "width=" + width + ",height=" + height + (clean ? window_clean_params : window_normal_params));
}

/*
*/
function openNewWindowCentered(url, width, height, clean)
{
	var left = parseInt(((screen.width)  - width)  / 2);
	var top  = parseInt(((screen.height) - height) / 2);
	
	window.open(url, "", "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + (clean ? window_clean_params : window_normal_params));
}

/*
*/
function openNewWindowFullScreen(url, clean)
{
	var left   = 0;
	var top    = 0;
	var width  = screen.width;
	var height = screen.height;
	
	window.open(url, "", "width=" + width + "px,height=" + height + "px,left=" + left + "px,top=" + top + "px" + (clean ? window_clean_params : window_normal_params));
}

/*
*/
function openANewWindow(url, params)
{
	window.open(url, "", params);
}


/* EFFECT(S) */

/*
*/
var current_opacity = -1;
var fade_element;
var fade_from;
var fade_to;
var fade_delay = 100;
var fade_step;

function fadeElement(element, from, to, total_time)
{
	fade_element    = element;
	fade_from       = from;
	fade_to         = to;
	fade_step       = parseInt((fade_to - fade_from) / (total_time / fade_delay));
	current_opacity = from;
	
	current_opacity += fade_step;

	element.style.filter  = "alpha(opacity=" + current_opacity + ")";
	
	element.style.opacity = (current_opacity / 100);

	fade();
}

/*
*/
function fade()
{
	current_opacity += fade_step;

	fade_element.style.filter  = "alpha(opacity=" + current_opacity + ")";
	
	fade_element.style.opacity = (current_opacity / 100);

	if(current_opacity > 0 && current_opacity < 100)
		setTimeout("fade();", fade_delay);
}

if(activeBtn == "")
{
	activeBtn = "home";
}	

function setActiveBtn(elementId, lang)
{		
	elementObject = document.getElementById(elementId);
	elementObject.src = root_path + "image/menu/" + lang  + "/"+ elementObject.id +"_active.gif";
	
	activeBtn = elementObject.id;
	//alert('set active btn');
	
}

function navItem(status, elementId, lang)
{
	var elementObject;

	if(status == "over")
	{
		elementObject = document.getElementById(elementId);
		elementObject.src = root_path + "image/menu/" + lang + "/"+ elementObject.id +"_active.gif";
	}
	
	if(status == "out")
	{
		elementObject = document.getElementById(elementId);
		if(activeBtn != elementObject.id)
		{			
			elementObject.src = root_path + "image/menu/" + lang + "/"+ elementObject.id +"_inactive.gif";
		}
	}
	
}


var movieName = "trapo";

function thisMovie(movieName)
{
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1)
	{
    return window[movieName]
  }
	else
	{
    return document[movieName]
  }
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie)
{
  if (typeof(theMovie) != "undefined")
	{
    return theMovie.PercentLoaded() == 100;
  }
	else
	{
    return false;
  }
}

function golabel(lab)
{
	
  if (movieIsLoaded(thisMovie(movieName)))
	{
    thisMovie(movieName).TGotoLabel("_level0/",lab);
  }		
		
	// flip the script		
	var elem = document.getElementById('clickSlide');
	
	if(lab == "slideUp")
	{
		var newLab = "slideDown";
	}
	else
	{
		var newLab = "slideUp";
	}
		
	elem.onclick = new Function("golabel('"+newLab+"')");

	
}