
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

// uprava nyroModal scriptu pri volani url obrazku pomoci queryStringu START // 

$(function() {
	$.fn.nyroModal.settings.processHandler = function(settings) {
		var from = settings.from;
		if (!settings.type && from && from.href) {
			/*alert(
				'type should be image: '+settings.type + '\n'
				+ "need to determine if image manually");*/
			var arr = from.href.split('?');
			//if carrying extra stuff
			if(arr.length>1){
				var newArr=arr[0].split('.');
				var newType=settings.type;
				//alert('extension is: ' + newArr[newArr.length-1]);
				switch(newArr[newArr.length-1].toUpperCase()){
					case 'IMG':
					case 'JPG':
					case 'JPEG':
					case 'PNG':
					case 'GIF':
					case 'ASPX':
						newType='image';
						break;
					default:
						newType=settings.type;
				}
				//alert("new type is " + newType);
				$.nyroModalSettings({
					type: newType
				});
			}
		}
	};
	
});

$(document).ready(function() {  
	
	$("#volbyBanner-env a.close").click(function(){
		
		$("#volbyBackground").hide();
		$("#volbyBanner-env").hide();
		
		//return close;
	});	
	
	$("#contact").click(function() {
		if( $(this).val() == ' ' ){
			$(this).val('');
		}
	});
	
  	// otevreni odkazu do noveho okna	
	$('a.nw').click( function() {
		$(this).attr("title","Odkaz se otevře do nového okna");
		window.open( $(this).attr('href') );
		return false;
	});	
			
	// inicializace nyromodalu
	$(".nyromodal").nyroModal({galleryCounts: false});		

	$("#videoList-env .vlTop").mousedown(function() {
		var topVal = parseInt($("#videoName").css("top"));
		if( topVal >= 10){ 
			topVal = 0; 
			$(this).css("visibility","hidden");			
		}
		else{
			$(this).css("visibility","visible");
			$("#videoList-env .vlBottom").css("visibility","visible");
		}
		$("#videoName").css("top", topVal + 10);
	});
	
	$("#videoList-env .vlBottom").mousedown(function() {
		var topVal = parseInt($("#videoName").css("top"));			
		// vyska rodice - vyska potomka + 20 padding
		var cssHeight = (-1) * (parseInt($("#videoName").css("height")) - parseInt($("#videoList").css("height")));

		if( topVal < cssHeight  ){ 
			topVal = cssHeight;
			$(this).css("visibility","hidden");			
		}
		else{
			$(this).css("visibility","visible");			
		}
		$("#videoList-env .vlTop").css("visibility","visible");
		$("#videoName").css("top", topVal - 10);					
	});
			
});

