﻿var algor = 0;
var mousex = 0;
var mousey = 0;
var offsetx = -200; // vzdálenost preview okna od kurzoru myši na ose X
var offsety = -40; // vzdálenost preview okna od kurzoru myši na ose Y
var ns6 = document.getElementById && !document.all; // pro kontrolu zda jse o FF,NS6 nebo o IE
var vis = 0;
var mx = 0;
var my = 0;
var desc_x = 0;
var desc_y = 0;
var noInfo = "<a href=\"javascript:hide_n();hide_i();\" title=\"zavřít popis\">X</a><span>Požadovaná informace není momentálně dostupná</span>";
var casti = new Array("HLAVA A KRK","PRSA","PAŽE","BŘÍŠKO A ZADEK","STEHNA A INTIMNÍ PARTIE","NOHY");
//var cast_n_0 = "<a href=\"javascript:show_desc_n('n/vlasy.htm')\" title=\"Vlasy\">Vlasy</a><a href=\"\" title=\"Řasy\">Řasy</a><a href=\"\" title=\"Permanentní nalíčení\">Permanentní nalíčení</a><a href=\"\" title=\"Čelo\">Čelo</a><a href=\"\" title=\"Vrásky\">Vrásky</a><a href=\"\" title=\"Zuby\">Zuby</a><a href=\"\" title=\"Podbradek\">Podbradek</a>";
var cast_n_1 = new Array();
var cast_n_2 = new Array();
var cast_n_3 = new Array();
var cast_n_4 = new Array();
var cast_n_5 = new Array();
//var cast_i_0 = "<a href=\"javascript:show_desc_i('i/vlasy.htm')\" title=\"Vlasy\">Vlasy</a><a href=\"\" title=\"Řasy\">Řasy</a><a href=\"\" title=\"Permanentní nalíčení\">Permanentní nalíčení</a><a href=\"\" title=\"Čelo\">Čelo</a><a href=\"\" title=\"Vrásky\">Vrásky</a><a href=\"\" title=\"Zuby\">Zuby</a><a href=\"\" title=\"Podbradek\">Podbradek</a>";
var cast_i_1 = new Array();
var cast_i_2 = new Array();
var cast_i_3 = new Array();
var cast_i_4 = new Array();
var cast_i_5 = new Array();


function init()
{
 {window.document.onmousemove = update;}
//  update();
}

function calculate_desc() {
	desc_x = (document.body.clientWidth/2)-250;
	desc_y = (document.body.clientHeight/2)-150;
	}


	function getXY(e) {
	    if (!e) e = window.event;

	    if (e) {
	        if (e.pageX || e.pageY) {
	            mousex = e.pageX + offsetx;
	            mousey = e.pageY + offsety;
	            algor = '[e.pageX]';
//	            if (e.clientX || e.clientY) algor += ' [e.clientX] '
	        }
	        else if (e.clientX || e.clientY) {
	            mousex = e.clientX + document.documentElement.scrollLeft + offsetx;
	            mousey = e.clientY + document.documentElement.scrollTop + offsety;
	            algor = '[e.clientX]';
//	            if (e.pageX || e.pageY) algor += ' [e.pageX] '
	        }
	    }
	}


function update(e)
{
  getXY(e); 
if (vis == 0){
if (ns6)
  	{
		window.document.getElementById("choice").style.left = mousex.toString(10) + 'px';
		window.document.getElementById("choice").style.top = mousey.toString(10) + 'px';
	}
	else
		{
			window.document.getElementById("choice").style.posLeft = mousex;
			window.document.getElementById("choice").style.posTop = mousey;
		}
	}
 }

function makeimg(source){
		window.document.getElementById("women").src = "mapa/images/w"+source+".jpg";
	}

function show_choice(what) // tady se mění text který je třeba zobrazit v okně... Proměnná "what" je jaký obrázek se má zobrazit, proměnná "code" je kód tapety, vidletu atd...
 {
		hide();
			if (vis == 0) {
			mx = mousex;
			my = mousey;}
		vis = 1;
		window.document.getElementById("choice").innerHTML="<span>"+casti[what]+"</span><br /><a href=\"javascript:choices_i('cast_i_"+what+".htm',"+what+")\" title=\"invazivní metody\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a><a href=\"javascript:choices_n('cast_n_"+what+".htm',"+what+")\" title=\"neinvazivní metody\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>";

		window.document.getElementById("choice").style.visibility="visible";
		window.document.getElementById("choice").style.display="block";

if (ns6)
  	{
		window.document.getElementById("choice").style.left = mx.toString(10) + 'px';
		window.document.getElementById("choice").style.top = my.toString(10) + 'px';
	}
	else
		{
			window.document.getElementById("choice").style.posLeft = mx;
			window.document.getElementById("choice").style.posTop = my;
		}
	
 }

function choices_n(which,what) {
	hide();
window.document.getElementById("choices_n").innerHTML = casti[what] + "<br/><br/>" + getFile("mapa/c/" + which);
if (ns6)
  	{
		window.document.getElementById("choices_n").style.left = mx.toString(10) + 'px';
		window.document.getElementById("choices_n").style.top = my.toString(10) + 'px';
	}
	else
		{
			window.document.getElementById("choices_n").style.posLeft = mx;
			window.document.getElementById("choices_n").style.posTop = my;
		}
		window.document.getElementById("choices_n").style.visibility="visible";
		window.document.getElementById("choices_n").style.display="block";

//	alert("neinvazivni "+which+""+casti[what]+"");
	}

function choices_i(which,what) {
	hide();
window.document.getElementById("choices_i").innerHTML = casti[what] + "<br/><br/>" + getFile("mapa/c/" + which);
if (ns6)
  	{
		window.document.getElementById("choices_i").style.left = mx.toString(10) + 'px';
		window.document.getElementById("choices_i").style.top = my.toString(10) + 'px';
	}
	else
		{
			window.document.getElementById("choices_i").style.posLeft = mx;
			window.document.getElementById("choices_i").style.posTop = my;
		}
		window.document.getElementById("choices_i").style.visibility="visible";
		window.document.getElementById("choices_i").style.display="block";

//	alert("neinvazivni "+which+""+casti[what]+"");
	}

function hide()
 {
		vis = 0;
		window.document.getElementById("choice").style.visibility="hidden";
		window.document.getElementById("choice").style.display="none";
 }
 
function hide_n()
 {
		window.document.getElementById("choices_n").style.visibility="hidden";
		window.document.getElementById("choices_n").style.display="none";
 }
 
function hide_i()
 {
		window.document.getElementById("choices_i").style.visibility="hidden";
		window.document.getElementById("choices_i").style.display="none";
 }

function hide_desc_n()
 {
		window.document.getElementById("desc_n").style.visibility="hidden";
		window.document.getElementById("desc_n").style.display="none";
 }

function hide_desc_i()
 {
		window.document.getElementById("desc_i").style.visibility="hidden";
		window.document.getElementById("desc_i").style.display="none";
 }

function show_desc_n(filename){
	hide();
	vis = 1;
	calculate_desc();
	hide_n();
if (ns6)
  	{
		window.document.getElementById("desc_n").style.left = desc_x.toString(10) + 'px';
		window.document.getElementById("desc_n").style.top = desc_y.toString(10) + 'px';
	}
	else
		{
			window.document.getElementById("desc_n").style.posLeft = desc_x;
			window.document.getElementById("desc_n").style.posTop = desc_y;
		}
	window.document.getElementById("desc_n").style.visibility="visible";
	window.document.getElementById("desc_n").style.display="block";
	window.document.getElementById("desc_n").innerHTML = getFile(filename);
	}

function show_desc_i(filename){
	hide();
	vis = 1;
	calculate_desc();
	hide_i();
if (ns6)
  	{
		window.document.getElementById("desc_i").style.left = desc_x.toString(10) + 'px';
		window.document.getElementById("desc_i").style.top = desc_y.toString(10) + 'px';
	}
	else
		{
			window.document.getElementById("desc_i").style.posLeft = desc_x;
			window.document.getElementById("desc_i").style.posTop = desc_y;
		}
	window.document.getElementById("desc_i").style.visibility="visible";
	window.document.getElementById("desc_i").style.display="block";
	window.document.getElementById("desc_i").innerHTML = getFile(filename);
	}

function getFile(fileName){
    var oxmlhttp = null;
    try{
        oxmlhttp = new XMLHttpRequest();
        oxmlhttp.overrideMimeType("text/xml");
    }
    catch(e){
        try{
            oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){
            return null;
        }
    }
    if(!oxmlhttp) return null;
    try{
       oxmlhttp.open("GET",fileName,false);
       oxmlhttp.send(null);
    }
    catch(e){
       return null;
    }
    if (oxmlhttp.status == 404) {return noInfo;} else {return oxmlhttp.responseText;}
}

