var tm_height=null

function getobj(id) {
   	if(Boolean(document.getElementById)) {
    	return document.getElementById(id);
   	} else if(Boolean(document.all)) {
      	return eval('document.all.'+id);
	}
}

function pic(img,x,y) { 
	window.open('index.php?action=picture&image='+img,'picture','toolbar=no,status=no,width='+x+',height='+y);
}

function pic_admin(img,x,y) { 
	window.open('admin.php?action=picture&image='+img,'picture','toolbar=no,status=no,width='+x+',height='+y);
}

function detail_print(id,x,y) { 
	window.open('detail.php?kod='+id+'&print=1','detail_print','toolbar=no,status=no,scrollbars=yes,width='+x+',height='+y);
}

function list_print(query,x,y) { 
	window.open('index.php?'+query+'&print=1','list_print','toolbar=no,status=no,scrollbars=yes,width='+x+',height='+y);
}

function addurl()
{
	alert('pro přidání odkazu vyberte nejprve některou z kategorií')
}

function SetHomePage() {
	document.body.style.behavior='url(#default#homepage)';
	document.body.setHomePage('http://www.brnocity.cz');
}

function renderopt(a,ext) {
	document.write('<select '+ext+'>')
	for(var _p=0;_p< a.length;_p=_p+2) {
		document.write('<option value="'+a[_p]+'">'+a[_p+1]+'</option>')
	}
	document.write('</select>')
}

function setHeight() {
	if (getobj('left')!=null && getobj('middle')!=null) {
		if (getobj('left').offsetHeight==getobj('middle').offsetHeight) {
			clearTimeout(tm_height);
		}
		else {
			var ch = document.body.clientHeight-150
			var lh = getobj('left').offsetHeight
			var mh = getobj('middle').offsetHeight
			if ((ch>mh) && (ch>lh)) mh=ch
			if (mh>lh) lh=mh
			getobj('left').style.height=lh+'px'
			getobj('middle').style.height=lh+'px'
			tm_height=setTimeout("setHeight()",1500);
		}
	}
	
}

function setHeight2() {
	if (getobj('left')!=null && getobj('middle')!=null) {
			var ch = document.body.clientHeight-150
			var lh = getobj('left').offsetHeight
			var mh = getobj('middle').offsetHeight
			if ((ch>mh) && (ch>lh)) mh=ch
			if (mh>lh) lh=mh
			getobj('left').style.height=lh+'px'
			getobj('middle').style.height=lh+'px'
//		alert('left'+getobj('left').offsetHeight)
//		alert('middle'+getobj('middle').offsetHeight)
	//	getobj('left').style.height=lh+'px'
	//	getobj('middle').style.height=lh+'px'
	}	
}

function search_katalog() {
	getobj('vyhledavani').style.background='#B11000'
	getobj('vyhledavani_kontejner').innerHTML=getobj('vyhledavani_katalog').innerHTML
}

function search_bms() {
	getobj('vyhledavani').style.background='#8CB1FF'
	getobj('vyhledavani_kontejner').innerHTML=getobj('vyhledavani_bms').innerHTML
}

function search_internet() {
	getobj('vyhledavani').style.background='#8CB1FF'
	getobj('vyhledavani_kontejner').innerHTML=getobj('vyhledavani_internet').innerHTML
}

function pic_prev() {
	if (cislo>0) {
		cislo--;
		document.images['foto'].src=obrazky[cislo];
		getobj('imgcounter').innerHTML=(cislo+1)
		//document.galerie.next.disabled=false;
	}

	if (cislo<=0) {
		//document.galerie.prev.disabled=true;
	}
}
 
function pic_next() {
	if (cislo<imgmax-1) {
		cislo++;
		document.images['foto'].src=obrazky[cislo];
		getobj('imgcounter').innerHTML=(cislo+1)
		//document.galerie.prev.disabled=false;
	}

	if (cislo>=imgmax) {
		//document.galerie.next.disabled=true;
	}
}

function change_kat(k0,select) {
	document.location.href="katalog.php?action=browse&k0="+k0+"&k1="+select.value
}

function change_kat_bms(k0,select) {
	document.location.href="index.php?action=browse&k0="+k0+"&k1="+select.value
}

function autobazary_katalog(select) {
	if (select[select.selectedIndex].value!=0) {
//		alert(select[select.selectedIndex].value)
		window.open('http://www.auto.cz/main.php?site=katalog_automobilka&id_automobilky='+select[select.selectedIndex].value,'','');

	}
}

function autobazary_setmodel(select,id) {
var a = znacka[select[select.selectedIndex].value]
getobj('modelbox').innerHTML=autobazary_drawSelect(a,'model',id)
}

function autobazary_drawSelect(a,aname,id) {
	var out = "<select class=input style='width:160px' name="+aname+">\n"
	out += "<option value=0>nerozhoduje</option>\n";
	if (typeof(a)=='object')
		for (i=0; i<a.length; i=i+2) {
			if (id==a[i])
				out += "<option value="+a[i]+" selected>"+a[i+1]+"</option>\n";
			else
				out += "<option value="+a[i]+">"+a[i+1]+"</option>\n";
		}
	out += "</select>\n";
	return out
}

