var mouseX, mouseY, windowW;
function getWindowWidth() {
var myWidth;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth ) ) {
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    myWidth = document.body.clientWidth;
   }
  windowW = myWidth / 4;
  return windowW;
}

function getMousePos(event){
	var e = window.event||window.Event;

	if(!e.clientX) {
		//mouseX = event.pageX;
		mouseY = event.pageY;
	}
	else {
		//mouseX = e.clientX + document.documentElement.scrollLeft;
		mouseY = e.clientY + document.documentElement.scrollTop;
	}
//fix pos	
	mouseX = getWindowWidth();
	mouseY -= 200;
}

//listen
if(window.Event && document.captureEvents)
 	document.captureEvents(Event.MOUSEMOVE);
//assign
document.onmousemove = getMousePos;

//the real thing
function DOMpopup(wat) {
var target = document.getElementById(wat);

target.style.position='absolute';
target.style.display='block';
target.style.top=mouseY+'px';
target.style.left=mouseX+'px';

//return false;
//alert('mouseX = '+mouseX+' | mouseY = '+mouseY);
}

function addurl() {
var rvmsg;
var urlcode = "";
var cmsg = document.getElementById("urltarget").value;
	thisURL = prompt("URL:", "http://");
if (thisURL) {
	if (thisURL.length>7)
	{
 	var thisTitle = prompt("A link neve:", "");
	}
	urlcode = "[url="+thisURL+"]"+thisTitle+"[/url]";
	rvmsg = cmsg+urlcode;
	if (thisURL.length>8 && thisTitle.length>1)
	{
	document.getElementById('urltarget').value=rvmsg;
	}
	document.getElementById('urltarget').focus();
	return;
	}
}


function addurl2() {
var rvmsg;
var urlcode = "";
var cmsg = document.getElementById("urltarget").value;
	thisURL = prompt("URL:", "http://");
if (thisURL) {
	if (thisURL.length>7)
	{
 	var thisTitle = prompt("A link neve:", "");
	}
	
var pos=thisURL.indexOf("http")
if (pos>=0) {	
	urlcode = '<a href="'+thisURL+'" target="_blank">'+thisTitle+'</a>';
}
else {
	urlcode = '<a href="'+thisURL+'">'+thisTitle+'</a>';
}
	
	rvmsg = cmsg+urlcode;
	if (thisURL.length>8 && thisTitle.length>1)
	{
	document.getElementById('urltarget').value=rvmsg;
	}
	document.getElementById('urltarget').focus();
	return;
	}
}


function preloadImages(items) {
var imageSrc = new Array(items);
var imageItem = new Array();
	for(var i=0;i<imageSrc.length;i++) {
		imageItem[i] = new Image();
		imageItem[i].src = "http://www.sbmx.hu/"+imageSrc[i];
	}
}