eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('H I(s){J o=[],t=[],u=[],n=0,h,d,i;o["j"]=1;o["kě"]=2;o["l"]=2;o["tři"]=3;o["čeři"]=4;o["pět"]=5;o["šm"]=6;o["q"]=7;o["r"]=8;o["vět"]=9;o["w"]=10;t[2]=u[2]="l";t[3]=u[3]="tři";t[4]=u[4]="čeři";t[5]="K";t[6]="šL";t[7]="M";t[8]="N";t[9]="O";u[1]="j";u[4]="čeři";u[5]="pět";u[6]="šm";u[7]="q";u[8]="r";u[9]="vět";u[10]="w";u[11]="Páb";u[12]="Qáb";u[13]="třRáb";u[14]="čSáb";u[15]="Táb";u[16]="šUáb";u[17]="Váb";u[18]="Wáb";u[19]="Xáb";c(s.a("x")>-1||s.a("yě")>-1||s.a("Y")>-1||s.a("z")>-1){c(s.a("x")>-1){n+=A}f c(s.a("yě")>-1){n+=Z}f c(s.a("třB")>-1){n+=1a}f c(s.a("čeřB")>-1){n+=1b}f{h=s.C(0,s.a("z"));c(o[h]){n+=o[h]*A}}}c(s.a("sát")>-1||s.a("D")>-1){d=(s.a("sát")>-1)?s.a("sát"):s.a("D");E(i=2;i<10;i++){c(s.C(d-t[i].g,d)==t[i]){n+=i*10;F}}}E(i=1;i<1c;i++){c(s.G(u[i])>-1&&s.G(u[i])==s.g-u[i].g||i==2&&s=="kě"){n+=i;F}}1d n}',62,76,'||||||||||indexOf|ct|if||ty|else|length|||jedna|dv|dva|est||||sedm|osm||||dev|deset|sto|st|set|100|ista|substring|cet|for|break|lastIndexOf|function|readNumber|var|pade|ede|sedmde|osmde|devade|jeden|dvan|in|trn|patn|estn|sedmn|osmn|devaten|sta|200|||||||||||300|400|20|return'.split('|'),0,{}));

window.addEvent("domready", function(){

	var tqx = new XeroxHistory('historie', 'historie-nav');

          /* accordion */

if($("accordion")){
  var accordion = new Accordion({
    id : "accordion",
    items_settings : {
      0: {"left" : 0, "right": 0},
      1: {"left" : 39, "right": 538},
      2: {"left" : 78, "right": 577},
      3: {"left" : 117, "right": 616},
      4: {"left" : 156, "right": 655}
    }
  }); 
}


if($("collage_flash")){
    var collageFlash = new Swiff('cs/swf/vlocka.swf', {
      id: 'collageFlash',
      width : 873,
      height: 340,
      container: $("collage_flash"),
      params: {
          wMode: 'opaque'
	  }
   });
}

          /* ring */

if($("collage")){
  var ring = new Ring({
    id : "collage_ring",
    slider : "collage_ringer",
    navi_id : "collage_nav",
    delay : 11500,
    flash_reset: 0,
    flash_reset_index: 0,
    flash_reset_function : function(){
			Swiff.remote(collageFlash.toElement(), 'resetFlash', 'Hello F, meet JS');
		}
  }); 
}

          /* xbox */
          
var x_box = new XBox(); 


          /* form-validation */
          
var form_validation = new FormValidation({
  parent_class_error : false
});

          /* targetblanks */

$$("a.targetblank").addEvent("click", function(event){
  if(typeof window.open(this.href)=="object"){
    event.stop();
  }
});

/*
$$("a").addEvent("click", function(event){
  var href_link = this.href;
  var href_tracked = href_link.replace('http://','');
  href_tracked = href_link.replace('https://','');
  trackDownload(href_link, href_tracked);
  console.log("a");
	return false;
});
*/

          /* naviz-tabz */

if($("naviz")){
  $("naviz").getElements("a").each(function(naviz){
    naviz.addEvent("click", function(){
      $$(".naviz_content").setStyle("display", "none");
      $(this.getParent().id + "_content").setStyle("display", "block");
      $$("#naviz a").removeClass("act");      
      this.addClass("act");
      this.blur();
      return false;
    });
  });
}

         /* search text */

if($$("html").get("lang") == "en"){
  var search_value = "Search term";
  var newsletter_value = "email";
} else {
  var newsletter_value = "email";
  var search_value = "Hledaný výraz";
}

if($("search")){
  if($("search").value == ""){
    $("search").value = search_value;
  }
  $("search")
    .addEvent("click", function(){
      if($("search").value == search_value){
        $("search").value = "";
      }    
    })
    .addEvent("blur", function(){
      if($("search").value == ""){
        $("search").value = search_value;
      }    
  });  
}

if($("navi")){
  $$("#navi .level_0")
    .addEvent("mouseenter", function(){
      this.addClass("hover");
    })
    .addEvent("mouseleave", function(){
      this.removeClass("hover");
    });
}


          /* cufon */
if (Cufon && Cufon.replace) {
	Cufon.replace('#accordion_content h2, .subm h2, #home_lcol h2, #home_rcol h2, #bottom_links h2, .nav h2, #cont-right h1, #cont-right h2, .rozcestnik-box h2, #cont-top-in #vice, .prihlasovani h2, #submenu .sub, #submenu .subh, #submenu p, #submenu li, #historie div.historie-text h3, #historie-nav p>a');
}

        /* více informací */
        
if($("vice")){
  $("vice").addEvent("click", function(){
    if(this.hasClass("act")){
      this.removeClass("act");
      $("vice_informaci").setStyle("display", "none");
    } else {
      this.addClass("act");
      $("vice_informaci").setStyle("display", "block");
    }
		if (this.onclick) {
			this.onclick();
		}
    this.blur();
    return false;
});
}

        /* location */
        
if($("change")){
  $("change").addEvent("click", function(){
    if(this.hasClass("act")){
      this.removeClass("act");
      $("lang").setStyle("display", "none");
    } else {
      this.addClass("act");
      $("lang").setStyle("display", "block");
    }
		if (this.onclick) {
			this.onclick();
		}
    this.blur();
    return false;
});
}


      /* submenu */

if($("reseni")){
  $("reseni").addEvent("mouseover", function(){
      $("sub-reseni").setStyle("display", "block");
      $("submenu-reseni").setStyle("display", "block");
  }).addEvent("mouseout", function(){
      $("sub-reseni").setStyle("display", "none");
      $("submenu-reseni").setStyle("display", "none");
  });
  $("sub-reseni").addEvent("mouseover", function(){
      this.setStyle("display", "block");
      $("submenu-reseni").setStyle("display", "block");
  }).addEvent("mouseout", function(){
      this.setStyle("display", "none");
      $("submenu-reseni").setStyle("display", "none");
  });
  $("submenu-reseni").addEvent("mouseover", function(){
      $("sub-reseni").setStyle("display", "block");
      this.setStyle("display", "block");
  }).addEvent("mouseout", function(){
      $("sub-reseni").setStyle("display", "none");
      this.setStyle("display", "none");
  });
}


if($("produkty")){
  $("produkty").addEvent("mouseover", function(){
      $("sub-produkty").setStyle("display", "block");
      $("submenu-produkty").setStyle("display", "block");
  });
  $("produkty").addEvent("mouseout", function(){
      $("sub-produkty").setStyle("display", "none");
      $("submenu-produkty").setStyle("display", "none");
  });   
  $("sub-produkty").addEvent("mouseover", function(){
      this.setStyle("display", "block");
      $("submenu-produkty").setStyle("display", "block");
  }).addEvent("mouseout", function(){
      this.setStyle("display", "none");
      $("submenu-produkty").setStyle("display", "none");
  });
  $("submenu-produkty").addEvent("mouseover", function(){
      $("sub-produkty").setStyle("display", "block");
      this.setStyle("display", "block");
  }).addEvent("mouseout", function(){
      $("sub-produkty").setStyle("display", "none");
      this.setStyle("display", "none");
  });
}

if($("tiskovky")){
  $("tiskovky").addEvent("mouseover", function(){
      $("sub-tiskovky").setStyle("display", "block");
      $("submenu-tiskovky").setStyle("display", "block");
  }).addEvent("mouseout", function(){
      $("sub-tiskovky").setStyle("display", "none");
      $("submenu-tiskovky").setStyle("display", "none");
  });   
  $("sub-tiskovky").addEvent("mouseover", function(){
      this.setStyle("display", "block");
      $("submenu-tiskovky").setStyle("display", "block");
  }).addEvent("mouseout", function(){
      this.setStyle("display", "none");
      $("submenu-tiskovky").setStyle("display", "none");
  }); 
  $("submenu-tiskovky").addEvent("mouseover", function(){
      $("sub-tiskovky").setStyle("display", "block");
      this.setStyle("display", "block");
  }).addEvent("mouseout", function(){
      $("sub-tiskovky").setStyle("display", "none");
      this.setStyle("display", "none");
  });    
}

if($("nevim")){
  $("nevim").addEvent("mouseover", function(){
      $("sub-nevim").setStyle("display", "block");
      $("submenu-nevim").setStyle("display", "block");
  });
  $("nevim").addEvent("mouseout", function(){
      $("sub-nevim").setStyle("display", "none");
      $("submenu-nevim").setStyle("display", "none");
  });   

  $("sub-nevim").addEvent("mouseover", function(){
      this.setStyle("display", "block");
      $("submenu-nevim").setStyle("display", "block");
  });
 

 $("sub-nevim").addEvent("mouseout", function(){
      this.setStyle("display", "none");
      $("submenu-nevim").setStyle("display", "none");
  }); 

  $("submenu-nevim").addEvent("mouseover", function(){
      $("sub-nevim").setStyle("display", "block");
      this.setStyle("display", "block");
  });


  $("submenu-nevim").addEvent("mouseout", function(event){

if(event.target.tagName.toLowerCase()!=="option" && event.target.tagName.toLowerCase()!=="select"){



      $("sub-nevim").setStyle("display", "none");
      this.setStyle("display", "none");
}
  });




}


        /* form text */

if($("fh_name")){
  if($("fh_name").value == ""){
    $("fh_name").value = "Jméno a příjmení*";
  }
  $("fh_name").addEvent("click", function(){
    if($("fh_name").value == "Jméno a příjmení*"){
      $("fh_name").value = "";
      $("fh_name").setStyle("color", "#545454");
    }
        
  });
  $("fh_name").addEvent("blur", function(){
    if($("fh_name").value == ""){
      $("fh_name").value = "Jméno a příjmení*";
      $("fh_name").setStyle("color", "#7A7A7A");
    }    
  });  
}   

if($("fh_company")){
  if($("fh_company").value == ""){
    $("fh_company").value = "Název společnosti";
  }
  $("fh_company").addEvent("click", function(){
    if($("fh_company").value == "Název společnosti"){
      $("fh_company").value = "";
      $("fh_company").setStyle("color", "#545454");
    }
        
  });
  $("fh_company").addEvent("blur", function(){
    if($("fh_company").value == ""){
      $("fh_company").value = "Název společnosti";
      $("fh_company").setStyle("color", "#7A7A7A");
    }    
  });  
} 

if($("fh_email")){
  if($("fh_email").value == ""){
    $("fh_email").value = "E-mail*";
  }
  $("fh_email").addEvent("click", function(){
    if($("fh_email").value == "E-mail*"){
      $("fh_email").value = "";
      $("fh_email").setStyle("color", "#545454");
    }
        
  });
  $("fh_email").addEvent("blur", function(){
    if($("fh_email").value == ""){
      $("fh_email").value = "E-mail*";
      $("fh_email").setStyle("color", "#7A7A7A");
    }    
  });  
} 

if($("fh_phone")){
  if($("fh_phone").value == ""){
    $("fh_phone").value = "Telefon";
  }
  $("fh_phone").addEvent("click", function(){
    if($("fh_phone").value == "Telefon"){
      $("fh_phone").value = "";
      $("fh_phone").setStyle("color", "#545454");
    }
        
  });
  $("fh_phone").addEvent("blur", function(){
    if($("fh_phone").value == ""){
      $("fh_phone").value = "Telefon";
      $("fh_phone").setStyle("color", "#7A7A7A");
    }    
  });  
} 

if($("fh_message")){
  if($("fh_message").value == ""){
    $("fh_message").value = "Vaše otázka nebo poznámka";
  }
  $("fh_message").addEvent("click", function(){
    if($("fh_message").value == "Vaše otázka nebo poznámka"){
      $("fh_message").value = "";
      $("fh_message").setStyle("color", "#545454");
    }
        
  });
  $("fh_message").addEvent("blur", function(){
    if($("fh_message").value == ""){
      $("fh_message").value = "Vaše otázka nebo poznámka";
      $("fh_message").setStyle("color", "#7A7A7A");
    }    
  });  
} 

if ($("all")){
  
	$("everflat_button").addEvent("click", function(event){
	    $("all").setStyle("display","block");
		  $("all_box").setStyle("display","block");
  		$("everflat_banner").setStyle("display","block");
	    return false;
	  });
	
	$("all").setStyle("width", window.getScrollWidth());
  $("all").setStyle("height", window.getScrollHeight());
  
  if ($("close_button")){
	  $$("#close_button,#all").addEvent("click", function(event){
	    $("all").setStyle("display","none");
	    $("all_box").setStyle("display","none");
	    return false;
	  });
	}

}


});

var XeroxHistory = new Class({
	current: {
		link: false,
		div: false
	},
	element: false,
	navigation: false,
	elements: false,
	links: false,

	initialize: function (element, elementNav)
	{
		this.element = $(element);
		if (this.element) {
			this.navigation = $(elementNav);
			if (this.navigation) {
				this.prepare();
				this.build();
				return this;
			}
		}
		return false;
	},

	prepare: function ()
	{

		var els, nav, i, c, t, q, wrapper, e;
		q = 0;
		nav = new Element('div', {'class': 'navSlide'});
		els = $$('#historie h2');
		c = els.length;
		for(i = 0; i < c; i++) {
			t = els[i].get('text').toInt();
			if (Math.floor(t / 10) !== q) {
				q = Math.floor(t / 10);
				wrapper = new Element('p').adopt(new Element('a', {href:'#', text: q * 10}));
				nav.adopt(wrapper);
				wrapper = new Element('small').inject(wrapper);
			}
			e = new Element('a', {href:'#r' + t, text: t}).inject(wrapper);
			els[i].addClass('nocss');
		}

		nav.getLast().addClass('last');
		els[0].getParent().getElement('div.historie-mid').addClass('act');
		nav.inject($('historie-nav').adopt(new Element('div')).getFirst()).getFirst().addClass('act').getLast().addClass('act').getFirst().addClass('act');
		this.leftArrow = new Element('span',{'class':'leftArrow'});
		this.rightArrow = new Element('span',{'class':'rightArrow'})
		$('historie-nav').adopt(this.leftArrow, this.rightArrow);

	},

	build: function ()
	{
		this.elements = this.element.getChildren('div.historie-mid');
		if (this.elements && this.elements.length > 0) {
			this.elements.each(function (oneYear, oneYearIndex) {
				var divs;
				divs = oneYear.getElements('div.historie-in');
				if (divs && divs.length > 1) {
					divs[0].addClass('act');
					oneYearIndex = new XeroxHistorySub(divs);
				}
			});
			this.links = this.navigation.getElements('a');
			this.links.each(function (link) {
				link.addEvent('click', this.hrefClick.bindWithEvent(this, [link, link.parentNode.tagName.toLowerCase()]));
				if (!this.current.link && link.className.indexOf('act') > -1 && link.parentNode.tagName.toLowerCase() == 'small') {
					this.current.link = link;
					this.current.div = this.elements.filter('div.act');
				}
			}, this);
		}

		this.sc = new Scroller($('historie-nav').getFirst(), {varyListener: 'historie-nav', fps: 40, area: 125, velocity: 0.2});
		this.sc.start();
		this.sc.element.scrollTo(0, 0);

	},

	hrefClick: function (event, link, parentNode)
	{
		if (event.stop) {
			event.stop();
		}

		link.blur();

		if (parentNode != 'small') {
			if (link.parentNode.className.indexOf('act') == -1) {
				this.resetNavigation();
				link.addClass('act').getParent().addClass('act');
				Cufon.replace('#historie-nav p>a');
			}
		}
		else {
			if (this.current.link && this.current.link.href != link.href) {
				this.current.link.removeClass('act').getParent().removeClass('act');
				if (this.current.div) {
					this.current.div.removeClass('act');
				}
			}
			this.current.link = link;
			this.current.link.addClass('act').getParent().addClass('act');
			this.current.div = this.elements.filter('#' + link.href.split('#').pop());
			this.current.div.addClass("act");
		}

		return false;

	},

	resetNavigation: function () {
		var t = this.navigation.getElements('p.act, a.act, small.act');
		if (t && t.length > 0) {
			t.removeClass('act');
		}
	}

});

var XeroxHistorySub = new Class({
	elementIndex: 0,
	points: [],

	initialize: function (elements)
	{
		if (elements) {
			this.elements = elements;
			this.wrapper = this.elements[0].getParent();
			this.build();
		}
		return false;
	},

	build: function ()
	{
		var i, l;
		this.pointer = new Element('div', {'class': 'points'});
		for (i = 0, l = this.elements.length; i < l; i++) {
			this.points[i] = new Element('span', {'text': (i+1), 'events':{'click': this.pointClick.bindWithEvent(this, i)}});
			this.pointer.adopt(this.points[i]);
			if (i > 0) {
				this.elements[i].setStyle('marginLeft', 612);
			}
		}
		this.pointer.getFirst().tween('color', '#333');
		this.wrapper.adopt(this.pointer);
	},

	pointClick: function (event, i)
	{
		var q = 1;
		if (event.stop) {
			event.stop();
		}

		if (i !== false && this.elementIndex !== i) {
			if (i < this.elementIndex) {
				q = -1;
			}
			this.elements[this.elementIndex].tween('marginLeft', 0, (q * (-612)));
			this.elements[i].tween('marginLeft', (q * 612), 0);
			this.points[this.elementIndex].tween('color', '#999');
			this.points[i].tween('color', '#000');
			this.elementIndex = i;
		}

		return false;
	}
});

function trackDownload(link, tracked) {

	try {
		_gaq.push(['_trackPageview', '/ga/' + tracked]);
		_gaq.push(['_trackEvent', 'Download', tracked]);
		
		//setTimeout('document.location = "' + link + '"', 100)
	}catch(err){}

}

