function AddFavorite(linkObj,addUrl,addTitle)
{
	if (document.all && !window.opera) {
		window.external.AddFavorite(addUrl,addTitle);
		return false;
	} else if (window.opera && window.print) {
		linkObj.title = addTitle;
		return true;
	} else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) {
		if (window.confirm('Přidat oblíbenou stránku jako nový panel?')) {
			window.sidebar.addPanel(addTitle,addUrl,'');
			return false;
		}
	}
	window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
	return false;
}

$(document).ready(function() {
	var close = $('#writeus').append('<a href="#" class="close">zavřít</a>');

	$('#checkbox17').change(function() { $('.newsletterCheckbox').removeAttr('checked'); });

	$('.canBuy').click(function() { 
		var url = $(this).attr('href').replace(/eshop\/koupit\//, 'eshop/koupitAJAX/');
		var title = $(this).parent().parent().find('h3 a');
		if(title.html() == null) title = $(this).parent().parent().find('h2');
		$.ajax({
			type: "GET",
			url: url,
			data: '',
			success: function(data) {
				$('#cartContainer').html(data);
				if (jQuery.browser.msie) {
					if(parseInt(jQuery.browser.version) <= 6) alert('Zboží "' + title.html() + '" bylo vloženo do košíku.');
					else humanMsg.displayMsg('Zboží "' + title.html() + '" bylo vloženo do košíku.');
				} else {
					humanMsg.displayMsg('Zboží "' + title.html() + '" bylo vloženo do košíku.');
				}
			}
		});

		return false;
	});

	$('#catalog a.compare, a.compare-txt, #detail a.compare').click(function() { 
		var url = $(this).attr('href').replace(/eshop\/porovnavat\//, 'eshop/porovnavatAJAX/');
		var title = $(this).parent().parent().find('h3 a');
		if(title.html() == null) title = $(this).parent().parent().find('h2');
		$.ajax({
			type: "GET",
			url: url,
			data: '',
			success: function(data) {
				if (data.length > 0) {
					$('#compareContainer').html(data);
					if (jQuery.browser.msie) {
						if(parseInt(jQuery.browser.version) <= 6) alert('Zboží "' + title.html() + '" bylo zařazeno k porovnání.');
						else humanMsg.displayMsg('Zboží "' + title.html() + '" bylo zařazeno k porovnání.');
					} else {
						humanMsg.displayMsg('Zboží "' + title.html() + '" bylo zařazeno k porovnání.');
					}
				} else
					if (jQuery.browser.msie) {
						if(parseInt(jQuery.browser.version) <= 6) alert('Můžete porovnávat maximálně DVA produkty!');
						else humanMsg.displayMsg('Můžete porovnávat maximálně DVA produkty!');
					} else {
						humanMsg.displayMsg('Můžete porovnávat maximálně DVA produkty!');
					}
			}
		});

		return false;
	});
	
	if (location.hash == '#writeusanchor') {
		$('#writeus').css('display', 'block');
		$('html,body').animate( {scrollTop: $('#writeus').offset().top}, 500);
		
	}
	
	$('.sendform a').click(function() {
		$('#writeus').animate( {height: 'show', opacity: 'show'}, 500);
		var targetOffset = $('#writeus').offset().top;

	$('html,body').animate( {scrollTop: targetOffset}, 500);
		return false;
	}
			      );

	$('#writeus .close').click(function() {
		$('#writeus').animate( {height: 'hide', opacity: 'hide'}, 500);
		return false;
	}
				  );

	/* + NEWSLETTER*/
	var news_close = $('#newsletter_checkboxes').append('<a href="#" class="close"><span>zavřít</span></a>');

	$('#newsletter_checkboxes a.close').click(function() {
		$('#newsletter_checkboxes').hide(500);
		return false;
	}
						 );

	$('#newsletter_input').mouseover(function() {
		$('#newsletter_checkboxes').show(500);
	}
					);
	$('#newsletter_input').mousemove(function() {
		$('#newsletter_checkboxes').show(500);
	}
					);

	$('#newsletter_input').val('muj@email.cz');
	$('#newsletter_input').click(function() {
		if ($(this).val() == 'muj@email.cz') $(this).val('');
	}
				    );
	/* - NEWSLETTER*/

	/* + QUESTION */
	$('a.question').click(function() {
		$('#writeus').animate( {height: 'show', opacity: 'show'}, 500);
		var targetOffset = $('#writeus').offset().top;
		$('html,body').animate( {scrollTop: targetOffset}, 500);
		if ($(this).attr('rel')) $('#writeus textarea').val("Dobrý den,\npoptávam informace ohledně Vašeho produktu s označením \"" + $(this).attr('rel') + "\".");
		return false;
	}
			     );
	/* - QUESTION */

	/* + PRUVODCE AJAX*/
	$('.subcat li a.displayproducts').css('display', 'none');
	$('.subcat li.active a.displayproducts').css('display', 'block');
	//	$('.subcat li.active a.moreinfo').css('display', 'none');
	$('.subcat a.moreinfo, .subcat a.name').click(function() {
		var url = $(this).attr('href');
		var ajax_url = url.replace(/([^#]*)(#(.*))/, '$1');
		var li = $(this).parent();
		var ul = $(li).parent();
		var container = $(ul).parent();

		var targetOffset = $(ul).offset().top;
		$('html,body').animate( {scrollTop: targetOffset}, 500);

		$.ajax( {
			type: "POST",
			url: ajax_url + 'ajax/',
			data: "",
			success: function(msg) {
				$('.detail').css('display', 'none');
				$('.subcat li').attr('class', '');
				li.attr('class', 'active');

				$('.subcat li a.displayproducts').css('display', 'none');
				$('.subcat li a.moreinfo').css('display', 'block');

				var ars = $('.subcat li a');
				$(ars).css('font-weight', 'normal');
				$(ars).css('text-decoration', 'underline');
				$(ars).css('color', '#006666');

				var anchors = li.find('a');
				$(anchors.get(0)).css('font-weight', 'bold');
				$(anchors.get(0)).css('text-decoration', 'none');
				$(anchors.get(0)).css('color', '#000');
				$(li).find('.moreinfo').css('display', 'none');
				$(li).find('.displayproducts').css('display', 'block');

				$(container).find('.detail').css('display', 'block');
				$(container).find('.detail').css('background', 'transparent url(http://projekty.goodshape.cz/fispoclean.cz/web/images/ajax-loader.gif) 50% 50% no-repeat');
				$(container).find('.detail').css('height', '120px');

				$(container).find('.detail').html(msg);
				$(container).find('.detail').css('background', 'none');
				$(container).find('.detail').css('height', 'auto');
			}
		});
		$.ajax( {
			type: "POST",
			url: ajax_url + 'ajax-related/',
			data: "",
			success: function(msg) {
				$('#panel03').html('');
				$('#panel03').css('height', '193px');
				$('#panel03').append(msg);
			}
		});
		return false;
	});
	/* - PRUVODCE AJAX*/
});

window.onload = function() {
  document.onselectstart = function() {return false;} // ie
}

//Disable right click script
//It works for both firefox and internet explorer
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

