// JavaScript Document
// Shadowbox
Shadowbox.loadSkin('classic', '/_fc_/js/sb/skin');
Shadowbox.loadLanguage('cs', '/_fc_/js/sb/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], '/_fc_/js/sb/player');
 
// Shadowbox options	
var options = {
	animate:     false,
	animateFade: false,
	continuous: true,
	counterType: 'skip',
	flvPlayer:     "/_fc_/js/sb/mediaplayer/player.swf"
};

window.addEvent('domready', function(){

	// Tips
	var myTips = new Tips($$('.tips'));
	// Shadowbox	
	Shadowbox.init(options);	



});

// prepocet mj na ks
function mj2ks(o,p) {
	var mj = parseFloat(o.value.replace(",", '.'));
	var p = parseFloat(p);
	if (mj > 0) {
		document.getElementById('mj2ks').innerHTML = ((Math.ceil(mj/p)*p)+'').replace(".", ',');
	}
}

function podzimni_slevy(url) {
    Shadowbox.open({
        content:    url,
        player:     "iframe",
	    width:      600,
        height:     400
    });
}

function fce_cislo(object,cislo) {
	n = cislo
	for(var i = 0; i < cislo.indexOf(","); i ++) {
		tecka = cislo.indexOf(",")
		len = cislo.length;
		cislo = cislo.substring(0, tecka)+"."+cislo.substring(tecka+1, len);
	}
	for(var i = 0; i < cislo.indexOf(" "); i ++) {
		tecka = cislo.indexOf(" ")
		len = cislo.length;
		cislo = cislo.substring(0, tecka)+cislo.substring(tecka+1, len);
	}
	if ((object != 0) && (n != cislo)) {
		object.value = cislo
	} else {
		return cislo;
	}
}


function enable(o) {
if (o) {
 o.disabled = false; 
 }
} // o.className = "fieldEnabled";


function disable (o) {
	if (o) {
	o.disabled = true; 
	}
} // o.className = "fieldDisabled"; 

function datePicker(id) { //v1.1
	var date = window.showModalDialog("include/datepicker.php","datum","edge:raised; status:0; dialogWidth:180px; dialogHeight:175px; center:yes; help:no; scroll:no");
	if (date) document.getElementById(id).value = date
}

function dateYearPicker(idA,idB) { //v1.0
	var date = window.showModalDialog("include/yearDatePicker.php","datum","edge:raised; status:0; dialogWidth:540px; dialogHeight:490px; center:yes; help:no; scroll:no");
	if (date) { 
		document.getElementById(idA).value = date[0]
		if ((date[1]) && (idB)) {
			document.getElementById(idB).value = date[1]
		}
	}
}

function df(o) {

	var d = o.value
	if ((d.indexOf(".")==0) && (d.length==1)) { d = '01.' }
	
	o.value = d

}

function expl(item,delimiter) {

  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);

  while (tempString.indexOf(delimiter)>0) {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
    Count=Count+1
  }

  tempArray[Count]=tempString;
  return tempArray;

}

function fce_explode(item,delimiter) {

  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);

  while (tempString.indexOf(delimiter)>0) {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
    Count=Count+1
  }

  tempArray[Count]=tempString;
  return tempArray;

}

function confirm_window(text,odkaz){
	if (confirm(text))
		location.href=odkaz;
	return " ";
}

function fce_round(cislo) {
	cislo = Math.round(cislo * 100);
	cislo = cislo / 100;

	return cislo;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	new_window =  window.open(theURL,winName,features);
	new_window.focus()
	return new_window
}

var exit = false

function listLink(id,odkaz){
	if (id != 0) { 
		if (odkaz) { fce_goto(odkaz) }
		exit = true; return 
	}
	if (exit == false){ fce_goto(odkaz) }
	exit = false
}

function fce_goto(odkaz) {
	location.href=odkaz;
}

function printLink(id,odkaz){
	if (id != 0) { 
		if (odkaz) { printWindow(odkaz) }
		exit = true; return 
	}
	if (exit == false){ printWindow(odkaz) }
	exit = false
}

function printWindow(odkaz){
	MM_openBrWindow(odkaz,'print','menubar=yes,scrollbars=yes,width=800,height=600')	
}

function fce_lst_wind(id,odkaz,features){
	if (id != 0) { exit = true; return }
	if (exit == false){ MM_openBrWindow(odkaz,"nevim",features) }
	exit = false
}

// *** VALIDATE FORM DATA
// *** verze 1.0
// *** copyright cetis s.r.o.
function validateForm(validate,c) {
	var alertText = '';
	for (i=0; i<(validate.length); i++) {
		if (validate[i].indexOf("=")>0) {
			tempArray = fce_explode(validate[i],"=");
			element1 = document.getElementById(tempArray[0]);
			element2 = document.getElementById(tempArray[1]);
			if (element1.value != element2.value) {
				alertText += "- " + element1.title + " a " + element1.title + " nesouhlasí\n";
			}
		} else if (validate[i].indexOf("|")>0) {
			tempArray = fce_explode(validate[i],"|");
			element1 = document.getElementById(tempArray[0]);
			element2 = document.getElementById(tempArray[1]);
			if (element1.type == "radio") { 
				value1 = element1.status;
			} else {
				value1 = element1.value;
			}
			if (element2.type == "radio") { 
				value2 = element2.status;
			} else {
				value2 = element2.value;
			}
			if ((!value1) && (!value2)) {
				alertText += "- " + element1.title + " nebo " + element2.title + "\n";
			}	
		
		} else {
			element = document.getElementById(validate[i]);
			if (!element.value) {
				alertText += "- " + element.title + "\n";
			}
		}
	}
	if (alertText) {
		alert("Zadejte prosím správne tyto údaje:\n" + alertText)
	} else if (c) {
		if (!confirm(c)) {
			alertText = '-';
		}
	} 
	document.returnValue = (alertText == '');
}

// *** ENABLE / DISABLE FORM ELEMENTS
// *** verze 1.0
// *** copyright cetis s.r.o.
function enableDisable(enable,disable) {
	for (i=0; i<(enable.length); i++) {
		temp = document.getElementById(enable[i]);
		temp.disabled = false;
		temp.style.backgroundColor = '';
	}
	for (i=0; i<(disable.length); i++) {
		temp = document.getElementById(disable[i]);
		temp.disabled = true;
		temp.style.backgroundColor = '#EBEBEB';
	}
}

function getLS(o,t) {
	if (t == '<') {
		o.style.color = 'FFFFFF';
		o.style.backgroundColor = '413B5D';
	} else {
		o.style.color = '';
		o.style.backgroundColor = '';
	}

}

function obrWin(file,sirka,vyska,nazev) {
  okno=window.open("/obrWin.php?file="+file+"&nazev="+nazev,"_blank","width="+sirka+",height="+vyska+",scrollbars=0,status=0,menubar=0,resizable=0,location=0,toolbar=0");
}
function parWin(id) {
  window.open('/parametr.php?id='+id,'parametr'+id,'width=500,height=350').focus();
}
function newWin(file,name,w,h) {
  window.open('/'+file,name,'width='+w+',height='+h+',status=0,menubar=0,resizable=0,location=0,toolbar=0').focus();
}
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_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_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];}
}
function toggleDisplay(o) {
	if (document.layers) {
		current = (document.layers[o].display == 'none') ? 'block' : 'none';
		document.layers[o].display = current;
	} else if (document.all) {
		current = (document.all[o].style.display == 'none') ? 'block' : 'none';
		document.all[o].style.display = current;
	} else if (document.getElementById) {
		vista = (document.getElementById(o).style.display == 'none') ? 'block' : 'none';
		document.getElementById(o).style.display = vista;
	}
}