/*izkaznica.js*/
var tempX;
var tempY;

// 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

function getMouseXY(e){
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}  
	
	// 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
	//document.Show.MouseX.value = tempX
	//document.Show.MouseY.value = tempY
	return true
}
document.onclick = getMouseXY;

/*function getEl(){
	var ev = arguments[0] || window.event,
	origEl = ev.target || ev.srcElement;
	alert(origEl.tagName);	
}
document.onclick = getEl;*/

function izkaznica(id, tip, tOby){
		
	var ajaxRequest;  // The variable that makes Ajax possible!
		
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		
		if(ajaxRequest.readyState == 1){
						
		}		
		else if(ajaxRequest.readyState == 4){
			
			
			
			var ajaxDisplay = document.getElementById(tOby);
						
			if(ajaxRequest.responseText=="error"){				
				//ajaxDisplay.innerHTML='Napaka';							
			}else{
				
				ajaxDisplay.innerHTML=ajaxRequest.responseText;
				//alert(ajaxRequest.responseText);
				/*if(IE){
					ajaxDisplay.style.top = (tempY+30)+"px";	
					ajaxDisplay.style.left = (tempX+50)+"px";
				}else{
					ajaxDisplay.style.top = (tempY-70)+"px";	
					ajaxDisplay.style.left = (tempX+50)+"px";

				}*/
				
				
				
				/*origEl = ev.target || ev.srcElement;
				alert(origEl.tagName);*/
			}
			
			
		}
	}
	
				
	var queryString = "?a="+tip+"&id="+id+"=&r="+rand(-8000000000000,100000000000);
	
	
	ajaxRequest.open("GET", "ajax_common.php"+queryString, true);
	ajaxRequest.send(null);
	
}

function izkaznicaHide(tOby){
	
	var ajaxDisplay = document.getElementById(tOby);
	
	ajaxDisplay.innerHTML = '';
	
	/*ajaxDisplay.style.top = "-1000px";	
	ajaxDisplay.style.left = "-1000px";*/
	
}
