$(document).ready(function()	{

	/*
		Search autocomplete
	*/
	$("#searchbox").autocomplete(whisper, {
		minChars: 1,
		max: 5,
		autoFill: true,
		mustMatch: false,
		matchContains: false
	});

	/*
		Galleria
	*/

	/*
		Embed fix
	*/
	$('<param name="wmode" value="opaque"></param>').insertBefore('embed');
	$('embed').attr('wmode','opaque');

	/*
		Collapse newsbox
	*/
	$('#newsbox-less').hide();
	$('#newsbox-more').click(function()	{
		$('#newsbox-more').hide();
		$('#videobox').slideUp();
		$('#videolist').slideUp();
		$('#newsbox').animate({ height: 645 }, "slow", function(){
			$('#newsbox-less').show();
		});
	});
	$('#newsbox-less').click(function()	{
		$('#newsbox-less').hide();
		$('#videobox').slideDown();
		$('#videolist').slideDown();
		$('#newsbox').animate({ height: 192 }, "slow", function(){
			$('#newsbox-more').show();
		});
	});

	/*
		Main menu
	*/

	$('#topmenu a img').mouseover(function(){
		if ($(this).attr('class') != "imgactive")	{
			$(this).attr({ src: "/templates/images/menu-"+$(this).attr('alt')+"_on.png" });
		}
	});
	$('#topmenu a img').mouseout(function(){
		if ($(this).attr('class') != "imgactive")	{
			$(this).attr({ src: "/templates/images/menu-"+$(this).attr('alt')+".png" });
		}
	});

	$('#topmenu input[type="image"]').mouseover(function(){
		$(this).attr({ src: "/templates/images/button-submit_on.png" });
	});
	$('#topmenu input[type="image"]').mouseout(function(){
		$(this).attr({ src: "/templates/images/button-submit.png" });
	});

	$('img.vidleft ').click(function(){
		vidpage_up = vidpage - 1;	/* countdown pages */
		if (vidpage_up >= 0)	{	/* until $page_up is bigger or equal to 0 */
			$('#vidpage_'+vidpage).slideUp();	/* hide active page */
			$('#vidpage_'+vidpage_up).slideDown();	/* show previous page */
			vidpage = vidpage - 1;	/* decrase $page */
			vidpage_temp = vidpage - 1;
			ball = vidpage_up+1;
			$('#vidball_'+ball).attr({ src: "/templates/images/ico-dot0.png" });
			$('#vidball_'+vidpage_up).attr({ src: "/templates/images/ico-dot1.png" });
		}
	});
	$('img.vidright').click(function(){
		vidpage_down = vidpage + 1;
		if (vidpage_down <= vidpages)	{
			$('#vidpage_'+vidpage).slideUp();
			$('#vidpage_'+vidpage_down).slideDown();
			vidpage = vidpage + 1;
			vidpage_temp = vidpage + 1;
			ball = vidpage_down-1;
			$('#vidball_'+ball).attr({ src: "/templates/images/ico-dot0.png" });
			$('#vidball_'+vidpage_down).attr({ src: "/templates/images/ico-dot1.png" });
		}
	});
	$('img.vidright').mouseover(function(){
		$(this).attr({ src: "/templates/images/ico-vidarrowrighta.png" });
	});
	$('img.vidright').mouseout(function(){
		$(this).attr({ src: "/templates/images/ico-vidarrowright.png" });
	});
	$('img.vidleft').mouseover(function(){
		$(this).attr({ src: "/templates/images/ico-vidarrowlefta.png" });
	});
	$('img.vidleft').mouseout(function(){
		$(this).attr({ src: "/templates/images/ico-vidarrowleft.png" });
	});

	/*
		Akce
	*/
	$('img.playfile').mouseover(function(){
		$(this).attr({ src: "/templates/images/akce-play_on.jpg" });
	});
	$('img.playfile').mouseout(function(){
		$(this).attr({ src: "/templates/images/akce-play.jpg" });
	});
	$('img.getfile').mouseover(function(){
		$(this).attr({ src: "/templates/images/akce-get_on.jpg" });
	});
	$('img.getfile').mouseout(function(){
		$(this).attr({ src: "/templates/images/akce-get.jpg" });
	});
	$('img.buydiscount_fulltrack').mouseover(function(){
		$(this).attr({ src: "/templates/images/akce-buy-on.jpg" });
	});
	$('img.buydiscount_fulltrack').mouseout(function(){
		$(this).attr({ src: "/templates/images/akce-buy.jpg" });
	});
	$('img.buydiscount_real').mouseover(function(){
		$(this).attr({ src: "/templates/images/akce-buy-on.jpg" });
	});
	$('img.buydiscount_real').mouseout(function(){
		$(this).attr({ src: "/templates/images/akce-buy.jpg" });
	});

	/*
		Login help
	*/
	$('input#username').mouseover(function(){
		$('div#usernamehelp').show();
	});
	$('input#username').mouseout(function(){
		$('div#usernamehelp').hide();
	});
	$('input#password').mouseover(function(){
		$('div#passwordhelp').show();
	});
	$('input#password').mouseout(function(){
		$('div#passwordhelp').hide();
	});
	
	/**
	 * ATS box
	 * 
	 */
   
   	$('a.buy-real-discount').click(function(){
		track = $(this).attr('name');		
		$('#box-ats').show();
		$('#box-ats .box-content').load('/scripts/ats.php?a=ring-discount&t='+track);
	});
	
	$('a.buy-fulltrack-discount').click(function(){
		track = $(this).attr('name');		
		$('#box-ats').show();
		$('#box-ats .box-content').load('/scripts/ats.php?a=track-discount&t='+track);
	});
  
  	$('#box-ats a.continue').click(function(){
		$('#box-ats').hide();
	});      	

	/**
	 * ColorBox
	 */
	$.fn.colorbox.settings.bgOpacity = "0.9";
	$("a[rel^='newsgallery']").colorbox({transition:"fade"});
	$("a[rel^='intgallery']").colorbox({transition:"fade"});

	var maxh = 640;
	var clanekh = $("#clanek").height();
	var obsahh = $("#obsah").height();
	var mezerah = maxh - clanekh - obsahh - 60;
	if (mezerah > 0) {
		$("#mezera").height(mezerah);
	}
/*
	$("#open_reg_form").click(function(){
		window.open("http://www.musicreg.net/checkform?force_form=1&form_id=6651", "_blank", "width=680,height=800");
	});
*/
//*
	$("#open_reg_form").click(function(){
		$("#ecrmform").show();
		$("#ecrmframe").attr({ src:"http://www.musicreg.net/checkform?force_form=1&form_id=6651"});
	});

	$("#ecrmform input[name='close']").click(function(){
		$("#ecrmform").hide();
	});

	$("#ecrmframe").load(function(){
		$("#ecrmframe").contents().find("body").attr({ color: "#FFFFFF" });
	});
//*/

});

