if (!document.getElementById && document.all) document.getElementById = document.all;

function idStyle(idf) { 
    if (document.getElementById) {
      return document.getElementById(idf).style;
    } else if (document.all) {
      return document.all[idf].style;
    } else if (document.layers) {
      return document.layers[idf];
    } else { return null }
}

function newStyle(idEl,prop,value) {
     var object_style= idStyle(idEl);
	 if(object_style) 
        eval( 'object_style.' + prop + '="' + value+ '"' );
}

function vyjmoutZKosiku(val) {
	if (confirm("Skutečně toto zboží vyjmout z košíku?") != false) {
		eval("window.location.href='"+val+"'");
	  	document.returnValue = false;
	}
}

function preloadOnMouseOver() {
	MM_preloadImages(
	)
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//Otevira nove okno bez navigacnich prvku
function winOpen(url,w,h, winname,scroll) {
	if (scroll!='no')scroll='yes';
	window.open(url, winname, "toolbar=no,location=no,scrollbars="+scroll+",directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",left=10,top=10");
}

//Nastavuje velikost popUp okna podle načteného obrázku. Volá se v body popUp okna na událost onLoad.
//Obrázek podle kterého so okno nastavuje musí mít attribut id="MyImg"
function setWindowSize(){
	var ImgObj=document.getElementById('MyImg');
	var newWindowWidth = ImgObj.width;
	var newWindowHeight = ImgObj.height;
	window.resizeTo(newWindowWidth+40,newWindowHeight+120)
}

/*
Otevírání odkazů do nového okna bez použití atributu target (který nesežere norma 4.01 strict)
Stačí dát odkazů které se mají otevírat do nového okna atribut rel="external":
příklad: <a href="cosikdesi.html" rel="external">cosikdesi</a>
Funkci pak opět zavoláš v tagu BODY při události onLoad:

onLoad="externalLinks(); "
*/
function externalLinks() {
        if (!document.getElementsByTagName) return;
        var anchors = document.getElementsByTagName("a");
        for (var i=0; i<anchors.length; i++) {
                var anchor = anchors[i];
                if (anchor.getAttribute("href") &&
                anchor.getAttribute("rel") == "external")
                anchor.target = "_blank";
        }
}

//Mažeme příspěvek v diskuzi
function confirmDel(adr,strom){
	if (strom) {
		message = "Chcete příspěvek (včetně všech případných reakcí na něj) skutečně smazat?";
	}else{
		message = "Chcete příspěvek skutečně smazat?";
	}
	if(confirm(message)){
		self.location.href = adr
		//alert(adr)
	}
}

// admin - preruseni vlakna
function adminCutThread(url) {
	if (confirm("Skutečně chcete přerušit vlákno v tomto příspěvku?")) {
		self.location.href = url;
	}
}

// admin - prejmenovani vlakna
function adminRenameThread(url, oldname) {
	if (newname = prompt('Zadejte nový název vlákna:', oldname)) {
		if (newname != oldname) self.location.href = url + newname;
	}
}

// admin - presun vlakna
function adminMoveThread(url, oldid) {
	if (idf = prompt('Zadejte ID sekce DF (idforum), kam se má vlákno přesunout:', oldid)) {
		if (idf != oldid) self.location.href = url + idf;
	}
}

// admin - cenzura prispevku
function adminCensor(url) {
	if (confirm("Skutečně chcete tento příspěvek nahradit oznámením o nevhodném obsahu?")) {
		self.location.href = url;
	}
}

//Mažeme příspěvek v diskuzi
function confirmDelPosta(co){
	f = eval(document.forms.diskuze);
	if (co=="sel"){
		msg = "Chcete skutečně smazat vybrané příspěvky?";
	}else if (co=="all"){
		msg = "CHYSTÁTE SE NENÁVRATNĚ SMAZAT VEŠKEROU SVOJI POŠTU!\n\nSkutečně tak chcete učinit?";
	}else if (co=="new"){
		msg = "CHYSTÁTE SE NENÁVRATNĚ SMAZAT SVOJI STAROU POŠTU!\n\nSkutečně tak chcete učinit?";
	}else if (co=="set"){
		PostaCheckAll();
		return;
	}
	if(confirm(msg)){
		f.smazat.value = co;
		f.submit();
	}
}

//Ochrana proti robotům sbírajícím e-mailové adresy
function CreateLink(email){
		email = replace(email,'#','@')
		email = replace(email,',','.')
		document.write("<A HREF=\"ma"+"ilt"+"o:"+email+"\" class=\"zahlaviprispevek\">e"+"-m"+"ail</a>")
}

//Nahrazení znaků (kde, co, čím)
function replace(str, original, replacement) {
	var result;
	result = "";
	while(str.indexOf(original) != -1) {
		if (str.indexOf(original) > 0)
			result = result + str.substring(0, str.indexOf(original)) + replacement;
		else
			result = result + replacement;
			str = str.substring(str.indexOf(original) + original.length, str.length);
	}
	return result + str;
}

//Přesměruje na vybrané DF z comboboxu redirID
function autoredir(cesta){
	window.location.href=cesta+"?"+document.forms.search_form.redirID[document.forms.search_form.redirID.selectedIndex].value
}

function fixE(e) {
	if (!e) e = window.event;
	if (!e.which) e.which = e.keyCode;

	return e;
}

function clickKey(form,btn,e){
	e = fixE(e);
	button = eval ("document."+form+"."+btn);
	if ((e.ctrlKey && e.which == 10) || (e.ctrlKey && e.which == 13)|| (e.altKey && e.which == 83)) {
		//alert(e.ctrlKey + " = = " + e.which)
		button.click();
	}

}

function FileUploadCheck() {
	if (document.getElementById("foto1").value != "" || document.getElementById("foto2").value != "" || document.getElementById("foto3").value != "" ||
	document.getElementById("foto4").value != "" || document.getElementById("foto5").value != "" || document.getElementById("foto6").value != "")
		document.getElementById("sub_nahled").innerHTML = 'Funkce Náhled nyní není k dispozici.';
	else	document.getElementById("sub_nahled").innerHTML = '<input type="submit" name="nahled" class="button" value="Náhled">';
}
