$(document).ready(function(){
						   
	
	var landContent = $("#land").html(); //alert(landContent.length)	
	
	if(landContent.length > 1) {
	
		$("#pageContiner").css("margin-top", "116px");
		
		setTimeout(function(){
				$("#land").fadeIn("slow");
			}, 600);
		
	}

});

function checkMail(mail){
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(mail)){
		return false;
	}else{
		return true;
	}	
}

$(document).ready(function(){
	$('#getNews').submit(function() {	
 	var mail = $(this).find('input[type="text"]').val();
	if(checkMail(mail)){
		$.post("_ajax/newsletter-sub.php", $(this).serializeArray(), function(html){
					$('#getNews').find('i').html(html)
		});
	}else{
		$(this).find('i').html('<span style="color:red;">Nesprávný formát adresy</span>');
	}
	return false;
	});
});



// fce pro ovladani kalendare ------------------------ */
	
	function changeCal(data){

			// ajaxLoader('!!!komponenty/ajax-side-calendar.php','calendar','".$prev."')
			var elemHeight = $("#calendar").height();
			if(elemHeight<'50'){elemHeight = '120'}
			$("#calendar").html('<div class="preloader" style=" width:100%; height:'+elemHeight+'px;"></div>');
			
		  $(".itemN, .itemY").animate({ 
			//height: "100%",
			opacity: 0.5
		  }, 200 );
		  
			$.post("!!!komponenty/ajax-side-calendar.php", { data: data},
		  
		  	function(html){

			 setTimeout(function(){
				$("#calendar").html(html);
			}, 300);
			  
			
		  });
	}

	


/*** DSIABLED CTRL+ ***/
function disableCtrlModifer(evt)
{
	
	var disabled = {a:0, c:0, x:0, v:0};
	var ctrlMod = (window.event)? window.event.ctrlKey : evt.ctrlKey;
	var key = (window.event)? window.event.keyCode : evt.which;
	key = String.fromCharCode(key).toLowerCase();
	return (ctrlMod && (key in disabled))? false : true;
}



$(document).ready(function(){
	
//	var data = $("div#centerContainer .obsahStrany").html();
//	$("div#printHolder").html(data);
//	
//	
//	$("div#pageContiner").css("margin-top","0px");
//	$("body").css("background-color","#fff");
//	$(".imgRam").hide();
//	$("div.artticleSettings").hide();
//	$("div.rate").hide();
//	$("div#popupWindow").hide();
//	$("div#diskuseHolder").hide();
//	$("div#leftContainer").hide();
//	$("div#topContainer").hide();
//	$("div#centerContainer").hide();
//	$("div#rightContainer").hide();
//	$("div#bottomContainer").hide();
//	$("div#land").hide();
//	$("div#sky").hide();
//	//$("div").hide();
//	$("div#printHolder").show();


$(".a_help").easyTooltip({
		tooltipId: "easyTooltip",
		useElement: "tipContent"	
	});

});


$(document).ready(function(){
  
	$(".playButt").animate({ 
	opacity: 0.4
	}, 200 );


	$(".playButt").hover(
	function () {
	$(this).animate({ 
	opacity: 0.8
	}, 200 );
	  }, 
	  function () {
	$(this).animate({ 
	opacity: 0.4
	}, 200 );
	  }
	);

});



$(document).ready(function(){	
	
    $('textarea.changeSize').each(function () {
    	
          var elemName = $(this).attr("name");
		  var elemHeight = $(this).height();
		  $(this).after("<div class=\"textRight\"><a onclick=\"changeAreaH('less',"+elemHeight+",'"+elemName+"')\"><img title=\"Zmensit\" alt=\"Zmensit\" src=\"../layout/_icons/decrease.gif\"></a> <a onclick=\"changeAreaH('more',"+elemHeight+",'"+elemName+"')\"><img title=\"Zvetsit\" alt=\"Zvetsit\" src=\"../layout/_icons/increase.gif\"></a></div>");
        });

});

$(document).ready(function(){
						   
	$('textarea.autoresize').autoResize({
		// On resize:
		onResize : function() {
			$(this).css({opacity:0.8});
		},
		// After resize:
		animateCallback : function() {
			$(this).css({opacity:1});
		},
		// Quite slow animation:
		animateDuration : 300,
		// More extra space:
		extraSpace : 30
	});
});	

function changeAreaH(action,pixels,elem){
		
		var actH = $("#"+elem).height();	
		var elem = $("#"+elem);

		if(action == 'more'){
			
			var newH = actH + pixels;
		}else{
			if(actH >= (2*pixels)){
				var newH = actH - pixels;
			}else{
				alert('Textové pole již nelze změnšit!')	
			}			
		}
		
		$(elem).animate( { height:newH+"px"}, 600 )

}



$(document).ready(function(){
						   
	$("input, select").focus(function () {
			 $(this).css('border-color','#cc0000');
		});
		$("input, select").blur(function () {
			 $(this).css('border-color','#999999');
		});
});


function tipContent(content) { //v9.0
		
		$("#tipContent").css("border-color:", "#cc0000;");
		$("#tipContent").html('<div class="inner">'+content+'</div>');
		
	
	}

	$(document).ready(function() {
	
//	  $('.list_item:odd').addClass('listOdd');
//	  $('.list_item:even').addClass('listEven');
//	  $('.list_item:first').addClass('listFirst');
	  
	  $('table.tbl tr:first td').addClass('first');
	  $('table.tbl tr:first th').addClass('first');
	  
	  $('table#mainInfo tr:odd').addClass('odd');
	  $('table#mainInfo tr:even').addClass('even');

	  $('table#promo_tbl tr:odd').addClass('odd');
	  $('table#promo_tbl tr:even').addClass('even');
	  

	  $('#videoGalery tr:last td').css("border-bottom", "none");
	   $('#videoGalery td.trojka').css("border-right", "none");
	   
	   $('table.tbl .tblLogo:first').css("background-color", "white");
	  
	
	});

	$(document).ready(function(){
	
		$("a#changeLogo").click(function () {
			//$("#seeLogo").toggle();
			$("#logo").toggle();
		});		

	});



	$(document).ready(function(){
	
		$("a.newComment").click(function () {
		
			$("#addCommentForm").fadeIn("fast", fadeOut_timeout('.no_diskuse', 800, "slow"))
			//fadeIn_timeout("#addCommentForm", 600, "slow") //$("#addCommentForm").fadeIn('fast');
		 		  
		});


		$(".seeCoomentsForm").click(function () {
		
			$("#addCommentForm").fadeIn("fast", fadeOut_timeout('.no_diskuse', 1000, "slow"))
			//fadeIn_timeout("#addCommentForm", 600, "slow") //$("#addCommentForm").fadeIn('fast');
		 		  
		});
		$(".no_diskuse").click(function () {
		
			$("#addCommentForm").fadeIn("fast", fadeOut_timeout('.no_diskuse', 800, "slow"))
			//$(".no_diskuse").fadeOut("fast")
			//$("#addCommentForm").fadeIn('fast');
		 		  
		});

	});


	function addFieldVal(elem, value) { //v9.0
	
		$("#" + elem).attr("value" , value)
	
	}

	function disableField(elem) { //v9.0
	
		$("#" + elem).attr("readonly" , "readonly")
	
	}



	// inicializace konkrétního data v malem kalendári
	function calTip(elem,text){
		
		$(document).ready(function(){
		$("#" + elem).easyTooltip({
				tooltipId: "easyTooltip2",
				content: text
			});
		});		
	}
	
	
/*function callCalendar(){
	$(document).ready(function(){
		$(".calendarField").datepicker($.datepicker.regional['cs']);
	});
}
callCalendar()*/


$(document).ready(function(){
    // OVLADANI ZMENY CSS HALVNIHO MENU ------------------------------- */
	$("#mainMenu .item").hover(
      function () {
        $(this).addClass("active");
      }, 
      function () {
        $(this).removeClass("active");
      }
    );
});

//$(document).ready(function(){
//	// ovladani rerroru a reportu ------------------------------- */
//	// cele to je rizene funkcemi callback [js/_callback_functions.js] */
//	$(".report").fadeIn(1000, callback_pulsate_hide(".report, .error", 2, 300));
//		
//});

//$(document).ready(function(){	
//		
//	$(".helpMe").easyTooltip({
//		tooltipId: "easyTooltip2",
//		}
//	);
//});

$(document).ready(function(){
	/* nastaveni zmeny pozadi v tabulce hodnoceni v detailu derku*/
	$("#rating tr:odd").css("background-color", "#fff8e8");

	
});

$(document).ready(function(){	
	$(".send").click(function () {
		$("#odeslat").slideToggle("slow")
		}
	);
	 
});

$(document).ready(function(){	
	$("#add_1").click(function () {
		$("#givePersonList").toggle("fast")
		}
	);
	 
});


$(document).ready(function(){	
	
	$(".seeCooments").click(function () {
      $("#commentForm").animate({ 
        height: "100%",
        opacity: 1.0
      }, 2200 );

   });
	
});

$(document).ready(function(){    
	/* ovladani rerroru a reportu */
		$(".error, .report").click(function () {
		  $(this).fadeOut("slow");
		});
	/* ovladani rerroru a reportu */
	
	
});


$(document).ready(function(){    
	
	/* ovladani filtrace */
	$(".filtrOvladac").click(
      function () {
        $(".editResults").slideToggle("slow");
		
				
		var img = $("#filtrSipka").attr("src");
		if(img == '../layout/_arrows/red-up.gif'){
			var img = $("#filtrSipka").attr("src", "../layout/_arrows/red-down.gif");
			}else{
		
			var img = $("#filtrSipka").attr("src", "../layout/_arrows/red-up.gif");
		}


      });

	/* ovladani rerroru a reportu */
		
});


function getDimensions(elem){
	
	var w = $("#"+elem).width();
	var h = $("#"+elem).height();
	alert(w+'px X '+h+'px');
	//$("#target"+elem).width(w / 2);
	//$("#target"+elem).height(h / 2);
}

// fce pro overovani checkboxu a radiobuttonu ------------------------ */
	function isChecked(select_item, idParam, typ, group, valToChange){
		//alert('jirka');
		
		/* zjistim soucasnou hodnotu skryteho pole */
		var elemValue = $('#pole_'+ select_item +'_'+ idParam).attr('checked');
		
		/* zjistim zda se jedna o RADIO nebo SELECT */
		if(typ == 'radio'){
			$('.' + group).css("background-image","url(layout/r_unchecked.png)");
		};

		$.ajax({
		  url: '_ajax/update_filter_checkbox.php',
		  cache: false,
		  data: 'select=select_'+ select_item +'&idParam='+ idParam +'&typ='+ typ +'',

		  success: function(html){

			var img = html;
			var value = valToChange;
			
			/* zmena obrazku */
			$('#'+ select_item +'_'+ idParam).css("background-image","url(layout/"+img+".png)");
			
				/* zmena hodnoty skryteho pole */
				if(elemValue == false){
					$('#pole_'+ select_item +'_'+ idParam).attr('checked', true);
				}else{
					$('#pole_'+ select_item +'_'+ idParam).attr('checked', false);
				}

			/* zmena zobrazene hodnoty [tyka se pole select] */
			if(value != ''){
				$('#'+ select_item +'_selected_value').text(''+value+'');
			}
			
		  }
		});

	
	}
	
// vypocet stredu
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}


//centering div
function centerDiv(elem){
	
	var scrollDim = getScrollXY();
	var widthPlus =scrollDim[0];
	var heightPlus =scrollDim[1];
	//alert (scrollDim);	
	
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(elem).height();
	var popupWidth = $(elem).width();
	

	//centering
	$(elem).css({
		"position": "absolute",
		"top": (windowHeight/2-popupHeight/2) + heightPlus,
		"left": (windowWidth/2-popupWidth/2) + widthPlus
	});
	//only need force for IE6
	//$("#backgroundPopup").css({
		//"height": windowHeight
	//});
	
}


// fce pro overovani poli ve formularich ------------------------ */
	function ajaxCheckUnique(sendData, field, cond, form){
		
		var ret;
		$('#'+ field).removeClass('cancel');
		$('#'+ field).removeClass('ok');
		//$('#'+ field).removeClass('ok');
		
		//var formElem = '#'+form+' .formError';
		var formElem = '#fromErrorDiv';
		
		$.post("_forms/_check-form-field.php", { data: sendData, cond: cond , field: field },
		  
		  function(html){
			  
			var data  = html.split("@");
			
			if(data[0] == 'cancel'){

				$('#'+ field).addClass(data[0]);

				$(formElem).append(data[1], fadeOut_timeoutError(formElem, 1000, "slow"))
				centerDiv(formElem);
				fadeInFast(formElem);

			}else{
				$('#'+ field).addClass(data[0]);
			}
			
		  });
	}

	
  $(document).ready(function(){
  $('.obsahStrany a').filter(function() {
    return this.hostname && this.hostname !== location.hostname;
  }).after(' <img src="layout/_icons/external-link.gif" alt="external link">');
  
 });

	
// fce pro vkladani do oblibenych ------------------------ */
//	function addFavorite(idArticle, action){
//			
//			$.post("_ajax/favorities.php", { data: idArticle, action: action},
//		  
//		  	function(html){
//
//			  $("#favCount").html(html, callback_pulsate('#favCount', 1, 200));
//			
//		  });
//	}

	
	




	function addContentData(elem, callingFile, id){

			$.post(callingFile, {id:id},
		  
		  	function(html){

			  $("#"+elem).html(html);
			
		  });
	}

	function addContent(elem, callingFile){

			$.post(callingFile, {},
		  
		  	function(html){

			  $("#"+elem).html(html);
			
		  });
	}

	function addMap(elem, callingFile, param){
		alert(param)

			$.post(callingFile, {unique_id: param},
		  
		  	function(html){

			  $("#"+elem).html(html);
			
		  });
	}
	
	function updateSelect(elem, callingFile, compareValue){

			var id = getSelected(compareValue)
			$.post(callingFile, {id: id},
		  
		  	function(html){

			  $("#"+elem).html(html);
			
		  });
	}	
	
	function scrollToElem(elem){
	
		var destination = $(elem).offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 700)
	}

	function scrollToTop(){
	
		var destination = $("body").offset().top;
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 700)
	}
	
	function playVideo(media, elem, media_id, divHeight){
			
			// vyscrolluju okno do topu
			$(scrollToElem("#nadpisek_1"), 700, function() {
			var elemHeight = $("#"+elem).height();
			if(elemHeight==0){
				
				$("#"+elem).animate( { height:divHeight+"px"}, 800)
			}
			});
			
			if(media == 'video'){var action = 'getVideo';}
			if(media == 'photo'){var action = 'getPhoto';}
			$.post('_ajax/_play-video.php', {action:action, media_id: media_id},
		  
		  	function(html){
			
			setTimeout(function(){
				$("#"+elem).html(html);
				$("#videoInfoData").fadeIn(1200);
				$("#videoBottomInfo").fadeIn(1200);
			}, 850);

			
		  });
			
	}
	
	function LoadVideoInfo(elem, video_id){

			var elemHeight = $("#"+elem).height();
			$.post('_ajax/_play-video.php', {action:'getInfo', video_id: video_id},
		  
		  	function(html){

			  $("#"+elem).html(html, 100);
			
		  });
	}	



	function hidePlayer(elem){

		var elemHeight = $("#"+elem).height();
		if(elemHeight!=0){
			
			$("#"+elem).fadeOut(400);
				setTimeout(function(){
				$("#"+elem).html('');
				}, 600);
			$("#"+elem).animate( { height:0}, 1500)
		}
		
	}
	
	
	
	function getSelected(elem) /* tato fce zjisti value vzbraneho pole v selectu*/
		{
			
			var selObj = document.getElementById(elem);
			var selIndex = selObj.selectedIndex;
			var val = selObj.options[selIndex].value;
			alert(val)
			return val;
		}
		
	function showHide(elem, elem2){
				
				var aaa = $('#' + elem).attr('checked');
				//alert(aaa)
	
				if(aaa == true){
					
					$("#" + elem2).slideDown("slow");
				}else{
					$('#' + elem2 +' .podCheck').attr('checked', false);
					$("#" + elem2).slideUp("slow");
				}
			
			}
		


	function getUrlVars(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		 
		for(var i = 0; i < hashes.length; i++)
		
		{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
		}
		
		return vars;
	}

	var urlVars = getUrlVars()
/*	var aa = locationHref.split('#');
	alert(aa[0] +'\n'+ aa[1]);
	alert(urlVars['scroll']);*/
	
//	$(document).ready(function(){
//		// vyscrolluju okno do topu
//		var destination = $("#"+urlVars['scroll']).offset().top;
//			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 700)
//	});


	function unique(arrayName)
	{
		var newArray=new Array();
		label:for(var i=0; i<arrayName.length;i++ )
		{  
			for(var j=0; j<newArray.length;j++ )
			{
				if(newArray[j]==arrayName[i]) 
					continue label;
			}
			newArray[newArray.length] = arrayName[i];
		}
		return newArray;
	}