if(typeof window.addEventListener != 'undefined') {
	window.addEventListener('load', addAnchors, false);
	window.addEventListener('load', attachFormHandlers, false);
}
else if(typeof document.addEventListener != 'undefined') {
	document.addEventListener('load', addAnchors, false);
	document.addEventListener('load', attachFormHandlers, false);
}
else if(typeof window.attachEvent != 'undefined') {
	window.attachEvent('onload', attachFormHandlers);
	window.attachEvent('onload', addAnchors);
}
else {
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			attachFormHandlers; addAnchors;
		}
	}
	else
	{
		window.onload = attachFormHandlers; addAnchors;
	}
}

// Kalkulacka
function attachFormHandlers() {
	if (document.getElementById) {
		var myForm = document.getElementById('calc');
		if (!myForm) return;
		for (var a=0; a<myForm.length; a++) {
            myForm[a].onchange = function(){
                return checkChanges(this.form);
			}
		}
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


// Nahrada display a undisplay z odstraneneho user.js 
function showMall()
{
	$('#areaallshops').show();	
}
function hideMall()
{
	$('#areaallshops').hide();	
}

// Drive lastOrderedVisited.js

$(function() {
	$('.img-posl-prohl').tooltip({
		delay: 0,
		showURL: false,
		track: true,
		opacity: 1, 
		fade: 550,
		bodyHandler: function() {
			return $("<img/>").attr("src", this.src.replace("small", "big"));
			//return $("<img/>").attr("src", this.src.replace("small", "big")).attr("style", "max-width: 400px; max-height:400px");
			//return $("<img/>").attr("src", this.src.replace("small", "big")).attr("width", 500).attr("height",500);
			//return $("<img/>").attr("src", this.src);
		}
	});
});



// OTEVIRANI YOUTUBE EMBEDU V THICKBOXU
function videoLinks(){
$('a.video-button').click(function(){
	ukazVideo(this.href, this.name);
	return false;
	});
}
addLoadEvent(videoLinks);

function ukazVideo(link, nazevVidea){

	if(link.substring(23,24)=="v"){
		link = link.substring(25,36);
		}
	else{
		link = link.substring(31,42);
		}
	
	tb_show(nazevVidea,"/img/dum.png");
	$('<div id="vid_wrap" width="480" height="390"></div>').appendTo($('div#TB_window'));
	$('<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/v/'+link+'&autoplay=1" frameborder="0" allowfullscreen></iframe>').appendTo($("div#vid_wrap"));
}
