
function checkExternalLinks() {
	if(!document.getElementsByTagName) return;
	var content = document.getElementById('content');
	var anchors = content.getElementsByTagName('a');
	var lang = (location.pathname.indexOf("/en/")<0 && location.pathname.indexOf("/ru/")<0)?"cs":"en";
	var newWindowText = new Array();
	var externalLinkText = new Array();
	newWindowText["cs"]="Odkaz bude otevřen v novém okně";
	newWindowText["en"]="Open in new window";
	externalLinkText["cs"]="Odkaz vede na jiný web";
	externalLinkText["en"]="External link";
	
	for(var i=0; i < anchors.length; i++) {
	  if(anchors[i].href) {
	  	var curHost = anchors[i].href.split('/');
	  	var isNotPredi = (location.host.indexOf("distribuce") < 0);

	  	if (location.host != curHost[2] && anchors[i].href.substring(0,4) == 'http') {
	    anchors[i].target = '_blank';
	    //alert(anchors[i].getElementsByTagName('IMG').src);
	    var anchorImg = anchors[i].getElementsByTagName('IMG');
	  	if (anchorImg.length == 0) {
	    	if (anchors[i].className != "overviewListItem")
	    		anchors[i].className = (anchors[i].className != '') ? anchors[i].className + ' external' : 'external';
	    		anchors[i].title = (anchors[i].title != '') ? anchors[i].title + ' - ' + externalLinkText[lang] : externalLinkText[lang];
	  	}
	    if (anchors[i].title.indexOf("odkaz bude") < 0)
	    	anchors[i].title = (anchors[i].title != '') ? anchors[i].title + ' - ' + newWindowText[lang] : newWindowText[lang];
	  	} else {
	  		if (anchors[i].target == '_blank') {
	  			if (anchors[i].title.indexOf("odkaz bude") < 0)
	  				anchors[i].title = (anchors[i].title != '') ? anchors[i].title + ' - ' + newWindowText[lang] : newWindowText[lang];

	  		}
	  	}
	  }
	}
}

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false);
   return true;
 } else if (obj.attachEvent){
   var r = obj.attachEvent("on"+evType, fn);
   return r;
 } else {
   return false;
 }
}
addEvent(window,"load",checkExternalLinks);

function hideDiscont() {
	$(".discontBox").hide('slow');
}
$(document).ready(function() {
	
	if (window.location.pathname == '/' /* && ! $.cookie('homediscount') */) {
	    $(".discontBox").show('slow');
	    $(".discontBox .discClose").click = hideDiscont;
	    /*if (window.location.pathname == '/') {
	        $.cookie('homediscount', true);
	    }*/
	}

});

