// JavaScript Document
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

var xmlHttp

function setStats(scope, cat, lig){ 
var url="../app/_statistika.php?token="+Math.floor(Math.random()*10000);

if(scope) url=url+"&scope="+scope;
if(cat)   url=url+"&cat="+cat;
if(lig)   url=url+"&lig="+lig;

xmlHttp=GetXmlHttpObject(stateChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null); 
/// message
} /// end function;

function setIDtext(id, txtValue){
	var field=document.getElementById(id);
	if(field){ field.innerHTML=txtValue; }
	return true;
}

function stateChanged() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
document.getElementById("statistika").innerHTML=xmlHttp.responseText; 
}} 

function GetXmlHttpObject(handler){ 
var objXmlHttp=null;
if (navigator.userAgent.indexOf("Opera")>=0){
           alert("This example doesn't work in Opera");
           return 
} 
if (navigator.userAgent.indexOf("MSIE")>=0){ 
var strName="Msxml2.XMLHTTP";
  if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
      strName="Microsoft.XMLHTTP";
  } 
try { 
    objXmlHttp=new ActiveXObject(strName)
    objXmlHttp.onreadystatechange=handler 
    return objXmlHttp;
} 
catch(e){ 
alert("Error. Scripting for ActiveX might be disabled") 
return;
}} 

if (navigator.userAgent.indexOf("Mozilla")>=0){
objXmlHttp=new XMLHttpRequest();
objXmlHttp.onload=handler;
objXmlHttp.onerror=handler; 
return objXmlHttp;
}

} 


function print_stats(){
 var w,b,theURL,winName,features,stat;
 
 theURL="blank.html";
 winName="";
 
 sw=screen.width;
 sh=screen.height;
 
 pw=290;
 ph=450;
 
 tt=(sw-pw)/2;
 ll=(sh-ph)/2;

 features='width=20, height=20, status=yes, scrollbars=no';

 if(!w){
 w=window.open(theURL,winName,features);
 w.moveTo(tt,ll);
 w.document.write('<html><head><title>VK PULA | Statistika | Print</title>');
 w.document.write('<head>'); 
 w.document.write('<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />');
 w.document.write('<link href=\"../css/stats.css\" rel=\"stylesheet\" type=\"text/css\" />');
 w.document.write('<style type=\"text/css\"> #tablice { border: 2px solid #333333; } </style>');
 w.document.write('<script type=\"text/javascript\">');
 w.document.write('function set_print(){ var p=document.getElementById(\"print\"); if(p){ p.href=\"javascript:this.window.print();\"; } }');
 w.document.write('</script>');
 w.document.write('</head>');
 w.document.write('<body style=\"margin: 5px; padding: 5px;\" onload=\"set_print();\">');
 w.document.write('<div id=\"statistika\" align=\"center\">');
 w.document.write(this.document.getElementById('statistika').innerHTML);
 w.document.write('</div>');
 w.document.write('</body></html>');
 w.resizeTo(pw,ph);
 w.document.close();
 } else {
 w.focus();  
 }
}
