
//zobrazeni obrazku v novem okne
var newWindow = null
function makeNewWindow(name,width,height) {
  var rozmery = null
  
  rozmery = "HEIGHT=" + height + ",WIDTH=" + width
  newWindow = window.open("","",rozmery)
  if (newWindow != null) {
    
    var newContent = "<HTML><HEAD><TITLE>Veselyklaun.cz - kliknutim na obrazek okno zavrete</TITLE></HEAD>"
    newContent += "<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 BGCOLOR='#C0C0CC'>"
    newContent += "<IMG SRC=" + name + " BORDER=0 ALIGN='CENTER' TITLE='Kliknutim na obrazek okno zavrete' VSPACE=0 onclick='self.close()'>"
       
    
    newContent += "</BODY></HTML>"
    newWindow.document.write(newContent)
    newWindow.document.close()
  }
}

 
//schova element podle id a zapise hodnotu do cookie    
function schovatCook(i,name){
  if (i.style.display=='none'){
    i.style.display='';
    nastavCookie(name);
  }
  else {
    i.style.display='none'
    nastavCookie(name);
  }
}

//pro inicializaci, precte cookie a nastavi podle ni styl
function schovat(i,name){
  var hodnota = readCookie(name);
  if (hodnota =='on') { 
    document.getElementById(name).style.display = "none";
  }
}

//cteni cookie
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
//nastavi cookie podle hodnoty, kdyz on -> smaze ji, jinak nastavi expires date na 2010 ==> predelat!
function nastavCookie(name){
  //nacteni
  var hodnota = readCookie(name);
  if (hodnota=='on') {
    document.cookie = name+'=mazu to tu; expires=Fri, 27 Jul 2010 02:47:11 UTC';

  } else {
    var vyprs=new Date(); 
    vyprs.setDate(vyprs.getDate() - 365); 
    document.cookie = name+'=on; expires=Fri, 27 Jul 2010 02:47:11 UTC';
  }
} 

//vymaze hodnotu elementu (napr. onfocus="clearInput('mujinput','text');")
function clearInput(id, value) {
  if (document.getElementById(id).value == value) {
    document.getElementById(id).value = "";
  }
}

//nastavi hodnotu elementu (napr. onblur="fillInput('mujinput','text');")
function fillInput(id, value) {
  if (document.getElementById(id).value == "") {
    document.getElementById(id).value = value;
  }
}


//nastavi hodnotu elementu na check nebo uncheck (napr. onblur="fillInput('mujinput','text');")
function checkUncheck(id) {
  if (document.getElementById(id).checked == false) {
    document.getElementById(id).checked = true;
  } else {
    document.getElementById(id).checked = false;
  }
}

function zobraz(name){
  if (document.getElementById(name).style.display=='none'){
    document.getElementById(name).style.display = "";
  }
  else {
    document.getElementById(name).style.display = "none";
  }
}

// schovavani elementu a zobrazeni pri přesunuti na odkazovaný element (url../#element), viditelny bez javascriptu
function show_hide(el) {
	var url = '/_images/';
	//var url = '/home/veselyklaun/_images/';
	elem = document.getElementById(el);
	li   = document.getElementById('li_'+el);
	pic  = document.getElementById('img_'+el);
	o_open=document.getElementById('openMenu');
	var open = o_open.value;

    if (/(^| )closed( |$)/.test(elem.className)) {
        elem.className = elem.className.replace(/(^| )closed( |$)/, '$2');
        li.className = 'li_open';        
        pic.src = url+'li_open.gif';
        o_open.value = el;
        if (open!=0) {
			document.getElementById(open).className += ' closed';
			document.getElementById('li_'+open).className = 'li_closed';
			document.getElementById('img_'+open).src = url+'li_closed.gif';
        }	               
    } else {
        elem.className += ' closed';
        li.className = 'li_closed'; 
        pic.src = url+'li_closed.gif'
        o_open.value = 0;
    }
    return true;
}

function getCenaSDph(x) {	 
	var z = x.replace(',','.');
	var y = Math.round(z*10 * 1.19)/10;
	document.getElementById('cenaDPH').value = y;
}
function getCenaBezDph(x) {
	var z = x.replace(',','.');
	var y = Math.round(z*10 / 1.19)/10;
	document.getElementById('cena').value = y;
}

function resortClasses( sPart ) {
    $('#'+sPart + ' tr')
        .removeClass('odd')
        .removeClass('even');

    $.each( $('#'+sPart + ' tr'), function(i,n) {
        if ( i % 2 ) {
            $(this).addClass('odd');
        } else {
            $(this).addClass('even');
        }
    });
}


function AddFavorite(linkObj,addUrl,addTitle) { 
  if (document.all && !window.opera) 
  { 
    window.external.AddFavorite(addUrl,addTitle); 
    return false; 
  } 
  else if (window.opera && window.print) 
  { 
    linkObj.title = addTitle; 
    return true; 
  } 
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) 
  { 
    if (window.confirm('Přidat oblíbenou stránku jako nový panel?')) 
    { 
      window.sidebar.addPanel(addTitle,addUrl,''); 
      return false; 
    } 
  } 
  window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.'); 
  return false; 
} 


// JavaScript Document
/*
// ///////////////////////////
// isdefined v1.0
// 
// Check if a javascript variable has been defined.
// 
// Author : Jehiah Czebotar
// Website: http://www.jehiah.com
// Usage  : alert(isdefined('myvar'));
// ///////////////////////////
*/
function isdefined(variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}



