// JavaScript Document
function addFavorite(){
  if (document.all){
    window.external.AddFavorite(location.href, document.title);
  }else if (window.sidebar){
    window.sidebar.addPanel(document.title, location.href, "");
  }
  return false;
}

function openForm(){
  var hght = document.body.clientHeight;
  var wdth = document.body.clientWidth;
  var frm = document.getElementById('topLayer');
  
//  alert(hght +'-'+ wdth +'-'+ winH() +'-'+ winW());
  
  var lft =  Math.round((wdth - frm.clientWidth)/2);
  
  
  
  frm.style.top = '0';
  frm.style.left = lft;
  
  frm.style.display = 'block';
  return false;

}

function closeForm(){
  document.getElementById('topLayer').style.display = 'none';
  return false;
}




function winH() {
	if (window.innerHeight) return window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight)
		return document.body.clientHeight;
	else return null;
}

function winW() {
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
	else if (document.body && document.body.clientWidth)
		return document.body.clientWidth;
	else return null;
}

function juliUrl(){
  document.write('<p class="zdroj">Zdroj: <a href="http://www.juli.sk" rel="nofollow" target="_blank">juli.sk</a></p>');
}

function odaz(par){
  document.write('<a href="http://www.e-horoskopy.sk" target="_blank">e-horoskopy.sk</a>');
}


////////////////ajaxovina///////////////////////////////////////////////////////
function createHttpConnection() {
	var http_request;
	if (window.XMLHttpRequest) {// Mozilla, Safari, ...
		try {
			http_request = new XMLHttpRequest();
		} catch (e) {
			http_request = false;
		}
	} else {
		if (window.ActiveXObject) {// IE
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				http_request = false;
			}
		} else {
			http_request = false;
		}
	}
	return http_request;
}


function hlasuj(idVtipu, hodnotenie) {

  sendRequest = createHttpConnection();
  jsRank = createHttpConnection();
  if (jsRank.readyState == 4 || jsRank.readyState === 0) {
    jsRank.open("GET",rankUrl+'vtipy-hodnotenie.php?id_vtipu='+ idVtipu + '&rank='+hodnotenie+'&rand='+ Math.floor(Math.random() * 1000000), true);
    jsRank.send(null);
    jsRank.onreadystatechange = function() { receivedData(idVtipu); };
  }

}
function receivedData(idVtipu) {
	if (jsRank.readyState == 4) {
		var serverData = jsRank.responseText.split("\n");
		var responseLength = serverData.length;
		if (jsRank.status != 200) {
			responseLength = 0;
		}

		jsRank = null;

    document.getElementById('all_rnk_'+idVtipu).innerHTML = serverData[0];
    document.getElementById('my_rnk_'+idVtipu).innerHTML = serverData[1];

	}
}

function openMail(typ, id){
  window.open(mainUrl +"/unit/posli-mail.php?typ="+typ+"&id="+id,"mail" + Math.floor(Math.random() * 1000000),"top=50,left=50,width=500,height=400,buttons=No,scrollbars=Yes,location=No,menubar=No,resizable=No,status=No,directories=No,toolbar=No,copyhistory=No");

}


