			
function loggerMove(a) {
	
	new Ajax.Request('/log/move/', 
		{method:'post',
		onSuccess:loggerEnd, onFailure:errFunc	,
		postBody:
		'body='+(URLEncode(a))
		});
		
	
}

var loggerEnd = function(t) {	
	
 	window.open(t.responseText,"forstats2");
 
} 
			

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}

var handlerFunc2 = function(t) {
	$('loading').style.display='';
	new Ajax.Request('/ajax/reload/', 
		{method:'post',
		onSuccess:handlerFunc3, onFailure:errFunc	
		});
		
		return false;
	 
} 

var handlerFunc3 = function(t) {
	$('rss').innerHTML=t.responseText;
	Effect.Fade('loading');
	var x=$('formenu').getElementsBySelector("a");
	x[0].className='see';
	for (var i = 1, length = x.length; i < length; i++) {
		x[i].className='';	
	}
		
	
	
	 
} 

var errFunc = function(t) {
    alert('Error ' + t.status + ' -- ' + t.statusText);
}
 
function add(a) { 
		new Ajax.Request('/ajax/add/', 
		{method:'post',
		onSuccess:handlerFunc2, onFailure:errFunc,
		postBody:
		'rss='+a		
		});
		
		return false;
}

var handlerFunc4 = function(t) {		
 $(hidid).innerHTML=t.responseText;
} 

var hidid='';
function hodnot(hid,id,value) {
		hidid=hid;
		new Ajax.Request('/hodnoceni/', 
		{method:'post',
		onSuccess:handlerFunc4, onFailure:errFunc,
		postBody:
		'id='+id
		+'&value='+value
		});
		
		return false;
}
var favor='';
function fav(a) { 
		favor=a;
		new Ajax.Request('/ajax/fav/', 
		{method:'post',
		onSuccess:handlerFunc5, onFailure:errFunc,
		postBody:
		'id='+a		
		});
		
		return false;
}

var handlerFunc5 = function(t) {		
 $('fav'+favor).innerHTML=t.responseText;
} 


function checkone() { 
		$('checksome').innerHTML='Kontroluji nové zprávy';
		$('checksome').style.bottom='0px';
		Effect.Appear('checksome');
		new Ajax.Request('/ajax/checksome/', 
		{method:'post',
		onSuccess:handlerFunc6, onFailure:errFunc
		});		
		return false;
}

var handlerFunc6 = function(t) {		
 $('checksome').innerHTML=t.responseText;
 setTimeout('checkone()',40000);
 setTimeout('hideinfo()',2000);
 handlerFunc2();
 
}
function hideinfo() {
	Effect.Fade('checksome');
}

function hidelast() {
	Effect.Fade('last');
}

function showload() {
	$('loading').style.display='';
}

function hideload() {
	$('loading').style.display='none';
}

var tagged;
function tagit(a) { 
	if (tagged==a) {
		hidetagit();
	} else {
			tagged=a;
			showload();
			Effect.Appear("tagit");
			//$("tagit").style.display="";
			var myAjax2 = new Ajax.Updater(
				'tagit', 
				'/tagit/?id='+a, 
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ 
						
						handlerFunctagit();}
				});
				return false;
	}
}

function hidetagit() {
	tagged='';
	Effect.Fade("tagit");
}


var handlerFunctagit = function(t) {	
	
	setMousePos();
	//Effect.Appear("tagit");
	hideload();
	
 
}

function savetag(a,tag) { 
	
		var myAjax2 = new Ajax.Updater(
				'tagit', 
				'/tagit/save/?id='+a+'&tag='+tag, 
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ hideload();}
				});
				return false;
				
		return false;
}

function discussit(a) { 		
	
			showload();
			Effect.Appear("tagit");
			var myAjax2 = new Ajax.Updater(
				'tagit', 
				'/diskuse/?id='+a, 
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ hideload();}
				});
				return false;
}

function deleteit(a) { 		
	
			showload();
			
			var myAjax2 = new Ajax.Updater(
				'tagit', 
				'/deleteme/?id='+a, 
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ Effect.Fade("delete"+a);alert("Váš hlas byl uložen. Děkujeme");hideload();}
				});
				return false;
}

function hideTag() {
	if ($("tagit").style.display=="") {
		
	} else {
		Effect.Fade("tagit");
	}
}

function zipit(a) { 		
	
			showload();
			var myAjax2 = new Ajax.Updater(
				'kosik', 
				'/ajaxkos/?url='+a, 
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ Effect.Fade("zipit"+a);hideload();}
				});
				return false;
}

function zipme(x,y) { 		
	
			showload();
			var myAjax2 = new Ajax.Updater(
				'ziped', 
				'/zipme/'+x+"/"+y, 
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ handlerFunctagit();}
				});
				return false;
}



function savediscuss(a,jmeno,email,titulek,text) { 
	
		var myAjax2 = new Ajax.Updater(
				'tagit', 
				'/diskuse/save/?id='+a+'&jmeno='+jmeno
				+'&email='+email
				+'&titulek='+titulek
				+'&text='+text, 
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ handlerFunctagit();}
				});
				return false;
				
		return false;
}

			var mx;
			var my;
			
			
			// 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
			
			// If NS -- that is, !IE -- then set up for mouse capture
			if (!IE) document.captureEvents(Event.MOUSEMOVE)
			
			// Set-up to use getMouseXY function onMouseMove
			document.onmousemove = getMouseXY;
			
			// Temporary variables to hold mouse x-y pos.s
			var tempX = 0
			var tempY = 0
			
			// Main function to retrieve mouse x-y pos.s
			
			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
			  mx = tempX
			  my = tempY
			  $("helper").style.top=(my+10)+'px';;
			
			
			  $("helper").style.left=(mx+30)+'px';
			  
			 
			  
			 
			  return true
			}
			
			function setMousePos() {
			frameWidth = self.innerWidth;
			frameHeight = self.innerHeight;
			var pulka=frameWidth/2;
			$("tagit").style.top=(my+10)+'px';;
			
			
			$("tagit").style.left=(mx+30)+'px';
			
			
			}
			
			
//writeCookie();

function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2010");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
}

function checkname(a) { 
		new Ajax.Request('/ajax/checkname/', 
		{method:'post',
		onSuccess:handlerFuncx, onFailure:errFunc,
		postBody:
		'name='+a		
		});
		
		return false;
}

var handlerFuncx = function(t) {	
	if (t.responseText=='') {
		$("sbmt").style.display='';
		$("nameid").style.display='none';
	} else {
		$("sbmt").style.display='none';
		$("nameid").style.display='';
	}
 	$("nameid").innerHTML=t.responseText;
} 
