function help(a) {
Effect.Appear(a,
	{ duration: 0.3});
}

function helpoff(a) {
Effect.Fade(a,
	{ duration: 0.3});
}



function down() {
Effect.SlideDown('form',
		{ duration: 0.7});	
}

var tempX = 0
var tempY = 0
dat = new Date();
var datum=dat.getFullYear()+'-'+dat.getMonth()+'-'+dat.getDate()+'-'+dat.getHours()+'-'+dat.getMinutes()+'-'+dat.getSeconds();

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
  }  
  return true
}

function save() {
	
	var handlerFunc = function(t) {
	//	alert(t.responseText);
	}

	var errFunc = function(t) {
		    alert('Error ' + t.status + ' -- ' + t.statusText);
	}
	
	new Ajax.Request('/mouselog/log.php',{method:'post', postBody:'x='+tempX+'&y='+tempY+'&date='+datum+'&page='+document.location,onSuccess:handlerFunc, onFailure:errFunc});
return false; 
}


var IE = document.all?true:false

function mouselog() {

if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=getMouseXY;
setInterval("save()",50);
}


	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
			
			
			// 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 showhide(x) {
	a=document.getElementById(x).style.display;
	if ((a=='block') || (a=='')) {
	 Effect.Fade(x);
	} else {
	 Effect.Appear(x);
	}		
	}	
	function str_replace ( search, replace, subject ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
 
    if(!(replace instanceof Array)){
        replace=new Array(replace);
        if(search instanceof Array){//If search    is an array and replace    is a string, then this replacement string is used for every value of search
            while(search.length>replace.length){
                replace[replace.length]=replace[0];
            }
        }
    }
 
    if(!(search instanceof Array))search=new Array(search);
    while(search.length>replace.length){//If replace    has fewer values than search , then an empty string is used for the rest of replacement values
        replace[replace.length]='';
    }
 
    if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
        for(k in subject){
            subject[k]=str_replace(search,replace,subject[k]);
        }
        return subject;
    }
 
    for(var k=0; k<search.length; k++){
        var i = subject.indexOf(search[k]);
        while(i>-1){
            subject = subject.replace(search[k], replace[k]);
            i = subject.indexOf(search[k],i);
        }
    }
 
    return subject;
 
}
	
	function saveKosik(id,pocet) {
		Effect.Appear("ajaxload");
		new Ajax.Updater(
				'kosik', 
				'/tobin/'+id+'/'+pocet+'/',
				{
					method: 'get', 
					evalScripts:true,
					onComplete:function(){ 
					Effect.Fade("ajaxload");	
					if (pocet=='') {
						$('tr'+id).className="";
					} else {
						$('tr'+id).className="selected";
					}
					}
				});
	}
	
	
	function cele(idname,num) {
		val=$(idname).value;
		val=str_replace(",",".",val);
		//alert(val);
		if (val%num==0) {
			
		} else {
			val=Math.ceil((val/num))*num;	
			
			alert("Tento výrobek můžete objednat pouze v množství "+num+" ks. Počet bude upraven.");
		}
		$(idname).value=Math.round(val);

			
	}
	
	function checkenter(e,num,idname){
			var key=e.keyCode || e.which;
			
			
			
			if ((key==13)) {
				var x=parseFloat(num);
				var id='text'+(x+1);
				if ($(id)) {
					$(id).focus();
				} else {
					var id='text'+(x);
					$(id).blur();
				}
			}
	
		
	
	}
	