var URL = 'http://www.alsan.cz';

function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}


// preloader obrazku menu
if (document.images) {
	/*
	var preImages = new Array();
	preImages['novinky'] = new Image(); preImages['novinky'].src = "images/menu-novinky.gif";
	preImages['novinky2'] = new Image(); preImages['novinky2'].src = "images/menu-novinky-on.gif";
	
	preImages['galerie'] = new Image(); preImages['galerie'].src = "images/menu-galerie.gif";
	preImages['galerie2'] = new Image(); preImages['galerie2'].src = "images/menu-galerie-on.gif";
	*/
}

// jQuery
$(document).ready(function() {
	
	// menu
	$('#menu div, #menu li').mouseenter(function(){
		$(this).css({'background': '#FFF7D9'});
		var podmenu = $(this).find('ul:first');
		if(!podmenu.hasClass('podpod')) { podmenu.css({'left': $(this).position().left + 'px', 'top': $(this).position().top + $(this).height() + 'px'}); }
		//else { podmenu.css({'left': $(this).position().left + $(this).width() + 'px', 'top': $(this).position().top + 'px'}); }
		else { podmenu.css({'margin-left': '10px', 'margin-top': '-3px'}); }
		if($.browser.msie) podmenu.show(); else podmenu.fadeTo(200, 1);
		$(this).mouseleave(function() {
			podmenu.hide();
			$(this).css({'background': ''});
		});
	});
	//$('.mmain').mouseleave(function(){$('.mul').hide();});
	
	// odkaz na cizi web
	$("a[target=_blank]")
		.after('<img class="blank_img" align="absmiddle" style="padding: 0px 0px 3px 1px;" src="' + URL + '/images/new_window.png" border="0" alt="" title="Otevře stránku v novém okně">');
	$('.blank_img').css({'opacity': '0.3'});
	
	// piseme jenom cisla
	$('input[rel=seo_url]').keyup(function(event) {
		//event.target.value = event.target.value.replace(/[^a-zA-Z0-9-_]/g, "");
		event.target.value = event.target.value.replace(/[^a-z0-9-_]/g, "");
	});
	
	// login tlacitko, pripise text prihlasuji apod..
	$('#submit_login[rel=1]').click(function(event) {
		$(this).after('<i class="info"> probíhá přihlašování..</i>');
		$(this).removeAttr('rel');
		//$(this).after('<img align="absmiddle" src="images/loading.gif" border="0" alt="">');
	});
	
	
	$('.fade0').fadeTo(0, 0);
	
		
	// AlertClose FCE
	$('.AlertMessage').click(function() {
		$(this).fadeOut(250, function() {
			$(this).remove();
		});
	});
	$('.AlertMessage').oneTime(1000, "hide", function() {
		//$(this).animate({'backgroundColor': '#F5F5F5', 'borderColor': '#EEEEEE'}, 1000);
		$(this).animate({'backgroundColor': '#F5F5F5', 'borderTopColor': '#EEEEEE', 'borderRightColor': '#EEEEEE', 'borderLeftColor': '#EEEEEE', 'borderBottomColor': '#EEEEEE'}, 2000);
	});
	
	
	// reference
	$('.reference_div img').mouseover(function() {
		$(this).parent().parent('.reference_div').css('border', '1px solid #FFA351').css('background', '#FFCEA3');
		$(this).mouseout(function() {
			$(this).parent().parent('.reference_div').css('border', '1px solid #ADD7FF').css('background', '#D0E7FF');
		});
	});
	$('.more').css({'opacity': '0.8'});
	$('.ref_popis').each(function() {
		if($(this).find('.text div:first').height() > $(this).find('.text').height()) {
			$(this).find('.prechod').show();
			$(this).find('.more').show();
		}
	});
	$('.more').toggle(function(e) {
		e.preventDefault();
		$(this).parent().find('.text').animate({'height': $(this).parent().find('.text div').height() + 'px'});
		$(this).parent().find('.prechod').fadeOut("fast", 0.0);
		$(this).find('a').html('&laquo; skrýt');
	}, function() {
		$(this).parent().find('.text').animate({'height': '70px'});
		$(this).parent().find('.prechod').fadeIn("fast", 0.0);
		$(this).find('a').html('celý text &raquo;');
	});
	
});
