/* USER DEFINED */
var mbindex = 0;
var mzHandle = false;       


/* Functions */

window.addEvent('domready', function(){
  
    if($('hledaniSelecty')) {
      try{
       search.init();
      } catch(e) {}
       
    }
});

window.addEvent('domready', function(){
    var ttips = new Tips($$('.tooltip'), { 
      className: 'TTbox'
    });
});


window.addEvent('domready', function(){
  if($$('a#galLeft')!='' && $$('a#galRight')!= '') {
    try{
      scrl = new Fx.Scroll('galInner');
      $('galLeft').addEvent('mouseover', function(){ moveStart(-119, $('galInner'));    });
      $('galLeft').addEvent('mouseout', function(){ moveEnd();    });
      $('galRight').addEvent('mouseover', function(){ moveStart(119, $('galInner'));   });
      $('galRight').addEvent('mouseout', function(){ moveEnd();    });
    } catch(e) {}
  }
});



window.addEvent('load', function(){   
  if($$('img.zooming')!= []) {
    try{
      if(Browser.Engine.trident == true && Browser.Engine.version <= 4) {
        
      } else {
        var listmenu = new mooZoomMenu({ zoomlevel: 1.5, imgClass: "zooming", effectDuration: 200, IEofset : -2, FFofsetX : 1 });
      }
      
    } catch(e) {}
  }
});

window.addEvent('load', function(){   
  if($$('img.zoomi120ng')!= []) {
    try{
      var listmenu2 = new mooZoomMenu({ zoomlevel: 1.2, imgClass: "zoomi120ng", effectDuration: 200, IEofset : -2 });
    } catch(e) {}
  }
});


window.addEvent('domready', function(){
  try{
    upLVL();
  } catch(e) {}
});


window.addEvent('domready', function(){
  try{
    upLVLrem();
  } catch(e) {}
});

window.addEvent('domready', function() {
	$(document.body).addEvent('contextmenu',function(e) {
    showProducts(e.page);
		e.stop();
	});
});


window.addEvent('load', function(){
    try{
      if(Browser.Engine.trident == true && Browser.Engine.version <= 4) {
      
      } else {
        remakeSRC = $$('span.icqbox img');
        $each(remakeSRC, function(obj) {
          obj.src = 'http://status.icq.com/online.gif?icq=313077894&img=5';
        });
      }
    } catch(e) {}
});

window.addEvent('load', function(){
    try{
      if(Browser.Engine.trident == true && Browser.Engine.version <= 4) {
      
      } else {
        remakeSRC = $$('span.skypebox img');
        $each(remakeSRC, function(obj) {
          obj.src = 'http://mystatus.skype.com/smallicon/kyos9942229942';
        });
      }
    } catch(e) {}
});


var showProducts = function(cords) {

  if($('prodMenu')) {
    $('prodMenuInner').setStyles({
            'left': cords.x ,
            'top': cords.y 
          });
    $('prodMenu').setStyles({
            'width': $(document).getScrollSize().x ,
            'height': $(document).getScrollSize().y ,
            'display' : 'block'  
      });
  
  
  } else {
    var over = new Element('div', {
          id : 'prodMenu',
          styles : {
            'position': 'absolute',
            'left':0,
            'top':0,
            'z-index' : 5000,
            'width': $(document).getScrollSize().x ,
            'height': $(document).getScrollSize().y ,
            'display' : 'block',
            'background' : 'url(/graphics/blank.gif) repeat'
          }
    }); 
    
    over.addEvent('click', function() {
         $('prodMenu').setStyle('display', 'none');
    });
    
    var inner = new Element('div', {
              id : 'prodMenuInner',
              styles : {
                'position': 'absolute',
                'left':cords.x ,
                'top':cords.y ,
                'width': 'auto',
                'height': 'auto',
                'display' : 'block'          
              }
    });
    
    var linky = new Array();
    linky.extend(['Svatební oznámení|http://www.kyoprint.cz/svatebni-oznameni/']);
    linky.extend(['Novoročenky|http://novorocenky.kyoprint.cz/']);
    linky.extend(['Narození dítěte|http://www.kyoprint.cz/narozeni-ditete/']);
    linky.extend(['Promoční oznámení|http://promocni-oznameni.kyoprint.cz/']);
    linky.extend(['Úmrtní oznámení|http://www.kyoprint.cz/umrtni-oznameni/']);
    linky.extend(['Razítka|http://razitka.kyoprint.cz/']);
    linky.extend(['Vizitky|http://vizitky.kyoprint.cz/']);
    linky.extend(['Kalendáře|http://kalendare.kyoprint.cz/']);
    linky.extend(['Diáře|http://diare.kyoprint.cz/|last']);
    
    linky.each( function(val) {
      var pomar = val.split('|');
    
      var inlink = new Element('a', {
                'href' : pomar[1],
                'html' : pomar[0],
                styles : {
                  'display' : 'block'          
                }
      });
      if(pomar[2]) {
        inlink.addClass(pomar[2]);
      }
      inner.adopt(inlink);
    });
    
    over.adopt(inner);
    $(document.body).adopt(over);
  
  }  
    
    
    
    
}


function mzload() {
  if(Browser.Engine.trident == true && Browser.Engine.version <= 4) {
      
  } else {
    mzHandle = new mooZoom({image:this});
  }	
}

var upLVL = function() {
  
  var upLVLs = $$('.upLVL');
  
  if(upLVLs != '' && upLVLs != []) {
  
    var upLVLlayer = new Element('div', {
          id : 'upLVLlayer',
          styles : {
            'position': 'absolute',
            'left':0,
            'top':0,
            'z-index' : 50
          }
    
    });
    
    $each(upLVLs , function(el) {
      var clone = el.clone();
      clone.setStyles({
          'display':'block',
          'position': 'absolute',
          'top': el.getPosition().y ,
          'left': el.getPosition().x ,
          'z-index' : 100
        });
      upLVLlayer.adopt(clone);
      el.setStyle('visibility','hidden');
    });
    $(document.body).adopt(upLVLlayer);
  }
}

var upLVLrem = function() {
  
  var upLVLs = $$('.upLVLrem');
  
  if(upLVLs != '' && upLVLs != []) {
  
    var upLVLlayer2 = new Element('div', {
          id : 'upLVLlayer2',
          styles : {
            'position': 'absolute',
            'left':0,
            'top':0
          }
    
    });
    
    
    
    $each(upLVLs , function(el) {
      var clone = el.clone();
      var zindx = 100;
      if(el.hasClass('101')) { var zindx = 101; }
      
      clone.setStyles({
          'position': 'absolute',
          'top': el.getPosition().y ,
          'left': el.getPosition().x ,
          'z-index' : zindx
        });
      clone.set('id', el.get('id'))
      $(document.body).adopt(clone);
      el.dispose();
        
      
    });
    
    // $(document.body).adopt(upLVLlayer);
  
  }  
}


var showSleva = function(idcko, el) {
   // if($type($('upLVLlayer2')) != false ) {
      var korekce = 5;
      if($type(Browser.Engine.trident) != false) { korekce = 20; }
      var pos = $(el).getPosition();
      var dim = $(el).getSize();
      $(idcko).setStyle('display' , 'block');
      dim2 = $(idcko).getSize();
      $(idcko).setStyles({
           'top' : pos.y  - dim2.y,
           'left' : pos.x + dim.x - korekce 
        });
   // }
    
  
}

var hideSleva = function(idcko) {
   $(idcko).setStyles({
       'display' : 'none'
    });    
}

var showTable = function(idcko, el) {
   if($type($('upLVLlayer2')) != false && $type($(idcko)) != false) {
      if($(idcko).getStyle('display') == 'none') {
        var korekcex = 0;
        var korekcey = 0;
        if($type(Browser.Engine.trident) != false && Browser.Engine.version == 5)  { korekcey = 3; korekcex = 2;  }
        if($type(Browser.Engine.gecko) != false) { korekcex = -1; }
        var pos = $(el).getPosition();
        var dim = $(el).getSize();
        $(idcko).setStyles({
             'top' : pos.y  + dim.y - korekcey,
             'left' : pos.x  - korekcex 
          });
        $(idcko).setStyle('display' , 'block');
        
        
      
      } else {
        $(idcko).setStyle('display' , 'none');
      }
      
      
   }
    
  
}



var MVmove = false;
var MVmoveObj = false;
var MVmoveTime = 0;

function moveStart(smer, obj) {
  $clear(MVmove);
  MVmoveObj = obj;
  (function(){ move(smer) }).delay(MVmoveTime);
}

function move(smer) {
  scrl.start(MVmoveObj.getScrollLeft()+smer , 0);
  MVmoveTime = 100;
  MVmove = (function(){ move(smer) }).delay(MVmoveTime);
}

function moveEnd() {
  $clear(MVmove);
  MVmoveTime = 0;
}


function upravURL() {
  window.location.hash = 'scrl'+ getScroll().y;
  return true;
}




function active(idcko) {
  document.getElementById(idcko).className="active";
}

function notactive(idcko) {
  document.getElementById(idcko).className="normal";
}



function mbcall() {
  milkbox.showGallery({ gallery:'galerie', index:mbindex });
  return false;
}


function lbCall(kde) {
  
  
  kde.click(); 
  
  try {
    
    
  } catch(e) { try {kde.onclick(); } catch(ee){} }
  return false;
}
function blind() {}


/* OLD SCRIPT */

function showEL(idcko,neco) {
  $(idcko).setStyle('display', 'block');
}

function hideEL(idcko,neco) {
  $(idcko).setStyle('display', 'none');
}


function pocetstranekJS(redirURL) {
  document.location = redirURL + '/nastranku/' + document.getElementById('nastranku').value + '/';
  
}

function vymenobrazek(kde, zaco, w, h, index) {

  mbindex = index;
  
  document.getElementById(kde).src=zaco; 
 
  if (w > h) { 
    document.getElementById(kde).style.width= 450; 
    document.getElementById(kde).style.height= Math.ceil((450/w)*h);
  }
  else { 
    document.getElementById(kde).style.height= 450; 
    document.getElementById(kde).style.width= Math.ceil((450/h)*w);
  } 
  
}

function vymenobrazekNew(kde, zaco, w, h, index) {

  if(mzHandle) {
    mzHandle.destroy();
  }
  

  mbindex = index;
  
  document.getElementById(kde).src=zaco;
  try {
    document.getElementById(kde).parentNode.href=zaco;
  } catch(e) {}
  
  if (w/500 > h/375) { 
    document.getElementById(kde).style.width= 500; 
    document.getElementById(kde).style.height= Math.ceil((500/w)*h);
  }
  else { 
    document.getElementById(kde).style.height= 375; 
    document.getElementById(kde).style.width= Math.ceil((375/h)*w);
  } 
  
  if(mzHandle) {
    mzHandle.initialize({image:document.getElement('img.moozoom')});
  }
  
}

function formular_logo(odkud, kam) {
  var pokusna = document.getElementById(odkud).value;
  document.getElementById(kam).value= pokusna; 
}

function zmenaction(kde,naco) {
  document.getElementById(kde).action= naco;
}

function OtevriOkno(adresa,sirka,vyska) {
    var param = 'toolbar=0,location=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=1,target=_blank, modal=1, top=40, left=40, status=0, width=' + sirka + ', height=' + vyska;
    window.open(adresa, '', param);
}

function OtevriOknoBezScroll(adresa,sirka,vyska) {
    var param = 'toolbar=0,location=0,directories=0,menubar=0,status=0,resizable=1,scrollbars=0,target=_blank, modal=1, top=40, left=40, status=0, width=' + sirka + ', height=' + vyska;
    window.open(adresa, '', param);
}


function prenesz5barvu(kam,co) {
    opener.document.getElementById(kam).style.background = co; 
}


function prenesz5(kam,co) {
    var text=document.getElementById(co).innerHTML;
    opener.document.getElementById(kam).value= text; 
    window.close();
}

function prenesz5text(kam,co) {
    var is_ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);
    var text=document.getElementById(co).innerHTML;
    if (is_ie) {
      text = str_replace("&lt;br>","\r",text);
      text = str_replace("<br>","\r",text);
      text = str_replace("<BR>","\r",text);
      text = str_replace("&lt;BR>","\r",text);
    }
    else {
      text = str_replace("&lt;br>","",text);
      text = str_replace("<br>","",text);
      text = str_replace("<BR>","",text);
      text = str_replace("&lt;BR>","",text); 
    }
    opener.document.getElementById(kam).value= text; 
    window.close();
}

function maxWH(obj, sirka, vyska) {
  obj.onload = function() {
    var w = this.width;
    var h = this.height;
    var pomerW = w/sirka;
    var pomerH = h/vyska;
    if((pomerW >= pomerH) && (w > sirka)) {
      this.style.width = sirka + 'px';
      this.style.height = 'auto';
    } else if((pomerW < pomerH) && (h > vyska)) {
      this.style.height = vyska + 'px';
      this.style.width = 'auto';
    }
  }
}



function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}

//////////////////////////////////////
//////////////////////////////////////






function prenesz5barvaRGB(kam,co) {
    opener.document.getElementById(kam).value= co; 
}


function prenesz5barvatext(kam,co) {
    opener.document.getElementById(kam).value= co; 
    window.close();
} 

function ZiskejFormat(adresa,idfrm,format)
     {
        opener.document.vyberformatu.src = adresa;
        opener.document.form.elements["id_format"].value = idfrm;
        
          if(opener.document.all) {
            opener.document.all.format.innerText = format;
          } else {
            opener.document.getElementById('format').innerHTML = format;
          }

        
        close();
     }
