$(document).ready(function(){
		
	corners();
	forms();
	pgPlayers();
	
	if($("#page.print").length > 0) {
		window.print();
	}
	
	$(".bigPic span").append('<span class="top">&nbsp;</span><span class="bot">&nbsp;</span>');
	//$("#sbLang, #sbLang a").click(function(){ alert('Jazykové mutace prozatím nejsou k dispozici\nAlternative language versions are not available yet'); return false; });
	$(".vidListItem").hover(function(){
		$(this).addClass("emph");
	}, function(){
		$(this).removeClass("emph");
	});
	$(".vidListItem").click(function(){
		location.href = $(this).find("a").attr("href");
	});
});


this.corners = function() {
	
	ratio = "10px";

	$(".rounded").corner();
	$(".roundedTop").corner("tl tr " + ratio);
	$(".roundedTopLeft").corner("tl" + ratio);
	$(".roundedTopRight").corner("tr" + ratio);
	$(".roundedBot").corner("bl br" + ratio);
	$(".roundedBotLeft").corner("bl" + ratio);
	$(".roundedBotRight").corner("br" + ratio);
	
	$("#sbLang").corner("bl " + ratio + " cc:#171717").corner("br " + ratio + " cc:#141414").corner("tl " + ratio + " cc:#161616").corner("tr " + ratio + " cc:#101010");
	$("#sbBrowse").corner("tl tr " + ratio + " cc:#161616").corner("bl " + ratio + " cc:#1A1A1A").corner("br " + ratio + " cc:#2A2A2A");
	$("#sbVideos").corner("tr " + ratio + " cc:#2A2A2A").corner("tl " + ratio + " cc:#181818").corner("bl " + ratio + " cc:#171717").corner("br " + ratio + " cc:#292929");
	$("#sbSearch").corner("tr " + ratio + " cc:#292929").corner("tl " + ratio + " cc:#171717").corner("bl " + ratio + " cc:#0E0E0E").corner("br " + ratio + " cc:#242424");
	
}

this.forms = function() {

	$(".nums .fCheckArrayItem").each(function(){
		n = $(this).find("input").val();
		$(this).children().click(function(){return false;}).addClass("invisible");
		$(this).append('<a class="num" id="nm' + n + '" href="javascript:void(0);" title="' + n + '">&nbsp;</a>');
	});
	
	$(".nums .num").click(function() {
		
		if($(this).siblings("input").attr("checked") == "") {
			$(this).siblings("input").attr("checked", "checked");
			$(this).addClass("emph");
		} else {
			$(this).siblings("input").attr("checked", "");
			$(this).removeClass("emph");
		}
		
	});
	
	$("#Ff_txtLastName").focus(function(){
		if($(this).val() == $(this).attr("title")) {
			$(this).val("");
		}
	});
	
	$("#Ff_txtLastName").blur(function(){
		if($(this).val() == "") {
			$(this).val($(this).attr("title"));
		}
	});
	
	// search
	$("#frmSearch .fakeFieldHolder, #frmVideos .fakeFieldHolder").each(function(){
		
		var label = "";
		opts = new Array();
		$(this).find("option").each(function(){
			if($(this).attr("value") != "") {
				opts[opts.length] = '<li><a href="' + $(this).attr("value") + '" title="' + $(this).text() + '">' + $(this).text() + '</a></li>';
			} else {
				label = $(this).text();
			}
		});
		
		if(opts.length) {
		
			items = 5;
			blck = new Array();
			blck[0] = "";
			for(i = 0; i < opts.length; i++) {
				idx = (i < ((blck.length - 1) * items) + items) ? blck.length - 1 : blck.length;
				blck[idx] = (blck[idx] ? blck[idx] : "") + opts[i];
			}
			
			fsel = "";
			for(i = 0; i < blck.length; i++) {
				fsel += '<ul>' + blck[i] + '</ul>';
			}
			
			sectors = blck.length;
			
		} else {
			
			fsel = '<p>No items available</p>';
			sectors = 1; 
		}
		
		$(this).append('<div class="fakeField"><div class="fakeLink"><span>' + label + '</span></div><div class="fakeSelect clear">' + fsel + '</div></div>');
		
		$(this).find(".fakeField").each(function(){
			this.sectors = sectors;
			
			$(this).children(".fakeSelect").hide().removeClass("hidden");
			
			$(this).hover(function(){
				/* $(this).animate({width: "" + (this.sectors * 140) + "px"}, 0, false, function(){
					$(this).find(".fakeSelect").slideDown("fast");
				});  */
				$(this).width(this.sectors * 140 + "px").show();
				$(this).find(".fakeSelect").show();
			}, function(){
				$(this).find(".fakeSelect").hide();
				$(this).width("140px");
			});
		});
		
	});
	
}

this.pgPlayers = function() {
	
	$("#tbPlayers tbody tr").click(function(){
		location.href = $(this).find("a").attr("href");
	});
	
}
