var image_step = 0;

function jump(myform)
{
        var target = myform.to.options[myform.to.selectedIndex].value;

	if (!target)
		return;
        parent.location.href = target;
}

function toggle(entryid)
{
	var obj = document.getElementById(entryid);

	if (!obj)
		return;
	if (obj.style.display == "none") {
	        obj.style.visibility = "visible";
	        obj.style.overflow = "visible";
	        obj.style.display = "block";
	} else {
	        obj.style.visibility = "hidden";
	        obj.style.overflow = "hidden";
	        obj.style.display = "none";
	}
}

function launch(count)
{
	var nname = "spl";
	var n;
	var entryid;
	var obj;

	if (navigator.userAgent.indexOf('iPhone') != -1) {
		setTimeout("window.scrollTo(0, 1)", 0);
	}

	if (document.getElementById("splashy")) {
		/* Delay initialization of the content */
		setTimeout(function(e) {
			splashimage();
		}, 0);
	}

	try {
		n = Math.ceil(Math.random() * count);
		entryid = nname.concat(String(n));
		obj = document.getElementById(entryid);
	} catch(e) {
		return;
	}

	if (obj) {
		obj.style.visibility = "visible";
		obj.style.overflow = "visible";
		obj.style.display = "block";
	}
}

function unloadpage()
{
	return true;
}

var	opacity = 110;
var	dir = 1;
var	step = 0;
var	myimg = new Array("ZL1", "C1", "C2", "HA1", "XL1");
var	timeo;

function set_opacity(obj, level)
{
        if (level == 100)
                level = 99.999;
        obj.style.filter = "alpha(opacity:" + level + ")";
        obj.style.KHTMLOpacity = level / 100;
        obj.style.MozOpacity = level / 100;
        obj.style.opacity = level / 100;
}

function splashstep(image_step)
{
	var nname = "/pix/vtFW-" + myimg[image_step] + "-frame.png";
	var obj;

	try {
		obj = document.getElementById("splashy");
	} catch (e) {
		return (null);
	}

	obj.src = nname;
	obj.alt = document.getElementById("splashtitle").innerHTML =
	    ".vtFW-" + myimg[image_step];
	obj.onload = function(e) {
		document.getElementById("splashtitle").innerHTML =
		    this.alt;
	}
	document.getElementById("splasha").href =
	    "http://www.vantronix.com/products/vtfw/" +
	    myimg[image_step].toLowerCase();

	return (obj);
}

function splashfade(obj)
{
        var     delay = 40;

	if (timeo)
		clearTimeout(timeo);

        if (opacity > 100) {
                dir = 1;
                delay = 4000;
        }

        set_opacity(obj, opacity);
        opacity -= (10 * dir);

        if (opacity < 0) {
                dir *= -1;
                if (++step >= myimg.length)
                        step = 0;
		splashstep(step);

                obj.onload = function() {
			timeo = setTimeout(function(e) { splashfade(obj) }, delay);
                }
                return;
        }

	timeo = setTimeout(function(e) { splashfade(obj) }, delay);
}

function splashimage()
{
	obj = splashstep(step);
	if (!obj)
		return;

	timeo = setTimeout(function(e) { splashfade(obj) }, 0);
}

function highlight(obj, enable)
{
	if (!obj)
		return;
	if (enable) {
		obj.style.backgroundColor = '#c0c0c0';
	} else {
		obj.style.backgroundColor = '#ffffff';
	}
}

function togglelang(lang)
{
	var url = parent.location.href;
	var repl;
	var url1;

	if (!lang) {
		if (url.match(/www2.vantronix.com/gi))
			repl = "vantronix.net";
		else if (url.match(/www2.vantronix.net/gi))
			repl = "vantronix.com";
		else if (url.match(/vantronix\.(com|net)/gi))
			repl = "vantronix.de";
		else
			repl = "vantronix.com";
	} else if (lang == "en") {
		repl = "vantronix.com";
	} else if (lang == "de") {
		repl = "vantronix.de";
	}

	if (repl)
		url1 = url.replace(/vantronix\.[a-zA-Z]+/gi, repl);
	if (!url1)
		url1 = url;

	parent.location.href = url1;
}

