function show_photo(text,file,width,height){
	no=window.open("", "zoom", "left=5, top=5, width="+width+", height="+height+", toolbar=no, location=no, status=no, scrollbars=auto");
	with (no.document)
	{
		open();
		writeln('<body style="margin: 0px;"><a href="javascript:void window.close();"><img src="'+file+'" style="border: 0px;" /></a></body>');
		close();
		no.focus();
	}
}

function openWindow(text,file,width,height,type){
	if (type=='img'){
		no=window.open("", "zoom", "left=5, top=5, width="+width+", height="+height+", toolbar=no, location=no, status=no, scrollbars=auto");
		with (no.document)
		{
			open();
			writeln('<body style="margin: 0px;"><a href="javascript:void window.close();"><img src="'+file+'" alt="'+text+'"style="border: 0px;" /></a></body>');
			close();
			no.focus();
		}
	}
	if (type=='file'){
		window.open(file, "zoom", "left=5, top=5, resizable,toolbar=no, location=no, status=no, scrollbars=yes");
		
		
	}
	return false;
}

function changeImage (url,foto) {
	if (document.getElementById) {
    	//window.alert(foto);    
                document.getElementById('mainphoto').src = url;
                document.getElementById('largephoto').href = foto;
               // photo_id = fotka_id;
        }
        return false;
}

function showLargeImage(url,width,height,type) {
	if (screen.height) {
		screenY = screen.height
		screenX = screen.width
	}
	var top = ((screenY/2)-(height/2));
	var left = ((screenX/2)-(width/2));
	window.open(url,'','resizable=no,status=no,scrollbars=no,width='+width+',height='+height+',top=50,left=50');
	return false;
}

function newWindow(url){
	x = window.open(url, "new_win", "");
	if (x) return false;
}

function kontrola_predvyber(oElement,value,url){
	oForm = oElement.form;
	oElement = oForm.elements[oElement.name]; 
	if(oElement.length){
		for(i = 0; i < oElement.length; i++){
			if (oElement[i].value != value)
				oElement[i].checked = false;
		}
	}
	location.replace(url);
}

function ajax(url,idElement){
	if (url != 0){
		if (window.ActiveXObject){
    		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
        else{
			httpRequest = new XMLHttpRequest();
		}
    	httpRequest.open("GET", url+'&popisek='+idElement, true);
        httpRequest.onreadystatechange= function () {processRequest(idElement); } ;
        httpRequest.send(null);
	}
	else{
		document.getElementById(idElement).innerHTML = "";
	}
	//setTimeout("alert('"+idElement+"')",10);
}

function processRequest(element){
	if (httpRequest.readyState == 4){
		if(httpRequest.status == 200){
			var vystup = document.getElementById(element);
			vystup.innerHTML = httpRequest.responseText;
		}
		else{
			alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}

// vlozime id prvku jako parametr, pokud je viditelny, skryje se a naopak
function ShowORhidden(prvek){
	if (document.getElementById(prvek).style.display == 'none')
		document.getElementById(prvek).style.display='block';
	else
		document.getElementById(prvek).style.display='none'
}

function changePrice(id,next_id){
	//window.alert(id);
	//window.setTimeout("ajax('/index.php?pg=processdata&save_form=ajax_changePrice&id_original='+id,'changePrice'+id)", 1000);
	//data = new Array();
	//data[0]=1149164;
	//data[1]=1149203;
	//data[2]=1149133;
	
	ajax('/index.php?pg=processdata&save_form='+save_form+'&next_id='+nex_id,'changePrice'+id);
	//ajax('/index.php?pg=processdata&save_form='+save_form+'2','changePrice'+1149203);
	//ajax('/index.php?pg=processdata&save_form='+save_form+'3','changePrice'+1149133);
	
	//for (var i=0; i<data.length; i++) {
		//window.alert(data[i]);
		//ajax('/index.php?pg=processdata&save_form='+save_form,'changePrice'+(data[i]));
		//for (var x=0; x<10000000; x++) {}
	//}

	//ajax('/index.php?pg=processdata&save_form='+save_form,'changePrice'+id);
	
}

function setZero(n){
	if (n <= 9){ return '0'+n; } else { return n; }
}

function Odpocet(){
	time = --stav.innerHTML;
		
	if(time){
		hod = setZero(Math.floor(time/3600));
		min = setZero(Math.floor((time-(hod*3600))/60));
		sec = setZero(Math.floor((time-(hod*3600)-(min*60))));
		cas.innerHTML = hod+':'+min+':'+sec;
		setTimeout(Odpocet,1000);
		
	}
	else cas.innerHTML = "AUKCE ZAČALA!";
}
