
//$(document).ready(function(){
	//$("span.root_path a").click(function (){
        //set loader
        //$("div#urls").html("<img src='loader.gif' alt='loader' />");
        //load url   
	    //$("div#diypage").load($(this).attr("href"));
        //return false - link is not clickable
        //set title value
        //$("div#title").html( $(this).attr("title") );
        //simple animation :-)
        //$("div#title").animate({ letterSpacing : 5 }).animate({ letterSpacing : 0 });
        //strike link
        //$(this).css("text-decoration", "line-through");
        //return false
		//return false;
	//}); 
//}


function change(type, name, dest) {
  if (window.XMLHttpRequest){
    httpRequest = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (eror) {
      httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
    httpRequest.open("GET", "index.php?"+type+"="+name+"&ajax=true", true);
    httpRequest.onreadystatechange = function () {processRequest(type, name, dest); };
    httpRequest.send(null);
  }

  function processRequest(type, name, dest) {
    if (httpRequest.readyState == 4) {
      if(httpRequest.status == 200){
        document.getElementById(dest).innerHTML = httpRequest.responseText;
        document.location.href="#"+type+"&"+name;
      } else {
        //window.location.href = "errors/ajax_error.html";
      }
    }
  }



// LOGIN FUNCTIONS
function login() {  
  login_to_get(document.getElementById("nick").value,document.getElementById("heslo").value);
}
function login_to_get(nick,heslo) {
  login_ajax_init("?nick="+nick+"&heslo="+heslo);
}

function login_ajax_init(get_value){
    if (window.XMLHttpRequest){
      httpRequest = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
      try {
        httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (eror) {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    httpRequest.open("GET", "php/login.php"+get_value, true);
    httpRequest.onreadystatechange = function () {login_processRequest(); };
    httpRequest.send(null);
  }
function login_processRequest(){
    if (httpRequest.readyState == 4) {
      if(httpRequest.status == 200){
        if(httpRequest.responseText=="uspesne"){
          success_login();
        } else {
          bad_login();
        }
      } else {
        document.write("neco tu nefunguje");
      }
    }
  }

function success_login(){
  document.getElementById("login_status").src = 'design/prihlasen.gif';
  document.getElementById("bad_login").style.visibility = 'hidden';
  document.location.href = "?part=loged";
}

function bad_login(){
  document.getElementById("login_status").src = 'design/neprihlasen.gif';
  document.getElementById("bad_login").style.visibility = 'visible';    
}

function hidden_validation(){
  document.getElementById("bad_login").style.visibility = 'hidden';
}
