function getMousePosition (mouse_event)
{
    if (document.all && !window.opera) {
    	var x = 0;
     	var x = 0;
        x = window.event.offsetX;
        y = window.event.offsetY;
    } else {
    	var x = 0;
    	var y = 0;
        x = mouse_event.pageX;
        y = mouse_event.pageY;
    }
    document.getElementById('x_pos').value = x;
    document.getElementById('y_pos').value = y;
}

function showImage (image, image_height, image_width , use_design_end, design_width, design_height, x_add, y_add)
{
	//if (document.getElementById(image).style.visibility == 'hidden') {
    	x = document.getElementById('x_pos').value;
    	y = document.getElementById('y_pos').value;
      var version = navigator.appVersion;
      var found = version.search(/MSIE 8.0.+/);
      if (document.all && !window.opera && found == -1) {
        	var y2 = parseInt(y) + getPageTopBeginnig (design_height) - 48 + y_add;
      	var x2 = parseInt(x) + getPageLeftBeginnig (design_width) + x_add;
      	if (use_design_end == true) {
      		var right_end = getRightEnd (design_end);
      		var border = getLeftBorder(design_width);
      	} else {
      		var right_end = getWindowWidth ();
      		var border = getLeftBorder(design_width);
      	}

        if (x2 + border + image_width > right_end + border) {
        	x2 = x2 - image_width;
        }
      } else {
        var y2 = parseInt(y) - image_height;
        var x2 = parseInt(x);
        if (use_design_end == true) {
        	var right_end = getRightEnd (design_width);
        } else {
        	var right_end = getWindowWidth ();
        }
        if (x2 + image_width > right_end) {
        	x2 = x2 - image_width;
        }
      }
		document.getElementById(image).style.top = y2 + 'px';
		document.getElementById(image).style.left = x2 + 'px';
		document.getElementById(image).style.visibility='visible';
	//}
}

function getPageTopBeginnig (design_height)
{
	var beginning = 0;
	var window_height = getWindowHeight();
	var borders = window_height - design_height;
	var border = borders / 2;
	beginning = border;
	return beginning;
}

function getPageLeftBeginnig (design_width)
{
	var beginning = 0;
	var window_width = getWindowWidth();
	var borders = window_width - design_width;
	var border = borders / 2;
	beginning = border;
	return beginning;
}

function getLeftBorder (design_width)
{
	var left_border = 0;
	var window_width = getWindowWidth();
	var borders = window_width - design_width;
	var border = borders / 2;
	left_border = border;
	return left_border;
}

function getRightEnd (design_width)
{
	var right_end = 0;
	var window_width = getWindowWidth();
	var borders = window_width - design_width;
	var border = borders / 2;
	right_end = design_width + border;
	return right_end;
}

function getWindowWidth () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function getWindowHeight () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function hideImage (image)
{
	if (document.getElementById(image).style.visibility == 'visible') {
		document.getElementById(image).style.visibility='hidden';
	}
}

function setBackgroundTopPosition ()
{
  var from_top = getPageTopBeginnig(600);
  from_top = from_top + 254;
  document.getElementById('body').style.backgroundPosition = '0 ' + from_top + 'px';
}

function setBackgroundTopPositionStartsite ()
{
  var from_top = getPageTopBeginnig(450);
  from_top = from_top + 104;
  document.getElementById('body').style.backgroundPosition = '0 ' + from_top + 'px';
}

