function externalLinksAutocomplete() {  
  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";  
  }
  var f = document.getElementById('antispam');
  if (f != null) {
    f.setAttribute("autocomplete", "off");
  }  
}  
window.onload = externalLinksAutocomplete;

$(function() {
	$('.gallery_preview a').lightBox({
  	overlayBgColor: '#FFFFFF',
  	overlayOpacity: 0.6,
  	imageLoading: 'image/loading_image.gif',
  	imageBtnClose: 'image/close_image.gif',
  	imageBtnPrev: 'image/previous_image.gif',
  	imageBtnNext: 'image/next_image.gif',
  	containerResizeSpeed: 350,
  	txtImage: 'Obrázek',
  	txtOf: 'z'
   });
	$('.microsite_preview a').lightBox({
  	overlayBgColor: '#FFFFFF',
  	overlayOpacity: 0.6,
  	imageLoading: 'image/loading_image.gif',
  	imageBtnClose: 'image/close_image.gif',
  	imageBtnPrev: 'image/previous_image.gif',
  	imageBtnNext: 'image/next_image.gif',
  	containerResizeSpeed: 350,
  	txtImage: 'Obrázek',
  	txtOf: 'z'
   });
});

this.screenshotPreview = function(){	
	xOffset = 10;
	yOffset = 10;

	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='NĂˇhled' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

$(document).ready(function() {
	screenshotPreview();
  $('.menu h3').click(function(){
    $(this).parent('li').children('ul').slideToggle('slow');
  });
});

function add_text(target, text) {
  target.value = (target.value + text + " ");
  target.focus();
}

