var stats_icon = 'images/sys_icon_stats.png';
var stats_icon_over = 'images/sys_icon_stats.gif';
var active_tab = "tab3";
function enterValue(id, value){
	document.getElementById(id).value=value; 	
}

function tabActive(id){
	if(active_tab!=""){ document.getElementById(active_tab).className="regular"; }
	document.getElementById(id).className="active"; 	
	active_tab = id;
}


function getInfo(counter, period){
	var xmlhttp;
	var sep1 = ';'
	var sep2 = '#####';
	var loading_img = '<div style="height:65px"><img src="images/sys_loading1.gif"></div>';
//	id = 'detailed_stats';
	id = 'data_hits';
	//element1 = document.getElementById('data_hits');
	//element2 = document.getElementById('data_uniqs');
	//element3 = document.getElementById('data_pos');	
	element_summary = document.getElementById('data_summary');	
	element_countries = document.getElementById('data_countries');
	element_browsers = document.getElementById('data_browsers');
	element_keywords = document.getElementById('data_keywords');
	element_refs  = document.getElementById('data_refs');
	element_ips  = document.getElementById('data_ips');
	
	//element1.innerHTML = loading_img;
	//element2.innerHTML = loading_img;	
	//element3.innerHTML = loading_img;
	element_summary.innerHTML = loading_img;
	element_countries.innerHTML = loading_img;
	element_browsers.innerHTML = loading_img;
	element_keywords.innerHTML = loading_img;
	element_refs.innerHTML = loading_img;
	element_ips.innerHTML = loading_img;

	if (window.XMLHttpRequest)
	  {	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {	  // code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
			{
			if(xmlhttp.readyState==4)
			  {	
			  if(xmlhttp.status == 200){				  
				  data = xmlhttp.responseText;
				  //datas = data.split("####END####");
				  datas = data.split(sep2);

				  //ELEMENT 3 
				  //element3.innerHTML = "?";
				  element_summary.innerHTML = datas[0];
				  element_countries.innerHTML = datas[1];
				  element_browsers.innerHTML = datas[2];
				  element_keywords.innerHTML = datas[3];
				  element_refs.innerHTML = datas[4];
				  element_ips.innerHTML = datas[5];

			 }else alert('Klaida. Bandykite dar kartą');			  
			  }
			}	
	var funct = "detailed_stats";
	var url = "request.php";
	url = url + "?function="+funct+"&data1="+counter+"&data2="+period+"&user=logged";
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
	
	/*document.getElementById(id).style.visibility="visible";*/
}
function getData(funct){	
	
}
function statsOver(id){
	document.getElementById(id).src=stats_icon_over; 
}
function statsOut(id){
	document.getElementById(id).src=stats_icon; 
}
function selectAll(id){
	document.getElementById(id).focus(); 
	document.getElementById(id).select(); 
}
function focusOn(id){
	document.getElementById(id).focus(); 
}
function showCounter(name, type, stype){
	var img_root = 'counter/counters/';
	var filename = 'cnt'+type+'_'+stype+'.png';
	document.getElementById(name).src = img_root+filename;		
}
function selectCounter(type, stype, img_id){
	var field_type = 'type';
	var field_stype = 'stype';
	var img_root = 'counter/counters/';
	var filename = 'cnt'+type+'_'+stype+'.png';

	document.getElementById(field_type).value = type;		
	document.getElementById(field_stype).value = stype;	
	if(img_id!="")
	document.getElementById(img_id).src = img_root+filename;	
}
function formstepback(form_id, step_id){
	var step = document.getElementById(step_id).value;		
	document.getElementById(step_id).value=step-2;
	document.getElementById(form_id).submit();
}
function doNav(url){
	document.location.href = url;
}
function validate() { 
	var string = document.registration.rname.value;
   	var iChars = "*|,\":<>[]{}`\';()@&$#%";
  	for (var i = 0; i < string.length; i++) {
      	if (iChars.indexOf(string.charAt(i)) != -1){
	  alert ("Neteisingas įrašas: Prašome naudoti tik raides arba skaičius"); 
	  document.registration.rname.focus(); 
         return false;
   		}
   }
   string = document.registration.rlastname.value;
     	for (var i = 0; i < string.length; i++) {
      	if (iChars.indexOf(string.charAt(i)) != -1){
	  alert ("Neteisingas įrašas: Prašome naudoti tik raides arba skaičius"); 
	  document.registration.rlastname.focus(); 
         return false;
   		}
   }

  
	   	iChars = "*|,\":<>[]{}`\';()&$#%";
        string = document.registration.remail.value;
     	for (var i = 0; i < string.length; i++) {
      	if (iChars.indexOf(string.charAt(i)) != -1){
	  alert ("Neteisingas El-pašto formatas"); 
	  document.registration.remail.focus(); 
         return false;
   		}
   }
   
   document.registration.submit();
   return true;
} 
function status(str){
	/*window.status = str;*/
}
