// JavaScript Document

//-----------------------------------------------Layer kezeles--------------------------------------------------------

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}



//----------------------------------------------Eger kezeles---------------------------------------------

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;
var stempX = 0;
var stempY = 0;
var myWidth = 0, myHeight = 0;

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;


// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) 
{
	if (document.documentElement && !document.documentElement.scrollTop)
	{// IE6 +4.01 but no scrolling going on
		stempX = 0;
		stempY = 0;		
	}
	else 
	if (document.documentElement && document.documentElement.scrollTop)
	{// IE6 +4.01 and user has scrolled
    	stempX = document.documentElement.scrollLeft;
    	stempY = document.documentElement.scrollTop;
	}
	else 
	if (document.body && document.body.scrollTop)
	{// IE5 or DTD 3.2
    	stempX = document.body.scrollLeft;
    	stempY = document.body.scrollTop;
	}
	
	if(navigator.appVersion.indexOf('Chrome') != -1)//... nem Chrome ...
	{
	//alert(navigator.appVersion);
	stempX = document.body.scrollLeft;
    stempY = document.body.scrollTop;
	}
	
  	if (IE) { // grab the x-y pos.s if browser is IE
    	tempX = event.clientX;
    	tempY = event.clientY;
  	} else {  // grab the x-y pos.s if browser is NS
    	tempX = e.pageX - stempX;
    	tempY = e.pageY - stempY;
  	}  
  	// catch possible negative values in NS4
  	if (tempX < 0){tempX = 0}
  	if (tempY < 0){tempY = 0}  
  	// show the position values in the form named Show
  	// in the text fields named MouseX and MouseY

	//width = window.body.offsetWidth;
	//width = window.body.offsetWidth;
	
	//width = window.offsetWidth; undefined
	
	//height = window.body.innerHeight;

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

/*0000
  document.Show.MouseX.value = myWidth;
  document.Show.MouseY.value = myHeight;
  
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  document.Show.ScrollX.value = stempX
  document.Show.ScrollY.value = stempY
*/  

  	return true;
}
