var $j = jQuery.noConflict();
$j().ready(function() {

 $j(".top-poster01").hover(
   function () {
    $j(".arrow-down01").hide();
   },
   function () {
    $j(".arrow-down01").show();
   }
  );



var path = location.pathname.substring(1);
	if (path) $j('.mainmenu li a[href$="' + path + '"]').attr('class', 'current');

//hint02
if ( $j.browser.msie ) {
 $j(".hint02cont").hover(
   function () {
    $j(".hint02", this).show();
   },
   function () {
    $j(".hint02", this).delay(1500).hide();
   }
  );
 } else {

	$j('.hint02cont').each(function () {
		var distance = 10;
		var time = 250;
		var hideDelay = 100;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $j('.hinttrigger2', this);
		var info = $j('.hint02', this).css('opacity', 0);


		$j([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				return;
			} else {
				beingShown = true;

				info.css({
					bottom: 26,
					display: 'block'
				}).animate({
					bottom: '-=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		}).mouseout(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				info.animate({
					bottom: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});

			}, hideDelay);

			return false;
		});
	});
}
	
	
// tophint
if ( $j.browser.msie ) {
 $j(".hint01cont").hover(
   function () {
    $j(".hint01", this).show();
   },
   function () {
    $j(".hint01", this).delay(1500).hide();
   }
  );
 } else {
  var hhideDelayTimer = null;
  var hbeingShown = false;
  var hshown = false;
  var htrigger = $j(".hinttrigger");
  var hpopup = $j(".hint01");

  $j(htrigger, hpopup).mouseover(function () {
    if (hhideDelayTimer) clearTimeout(hhideDelayTimer);

    if (hbeingShown || hshown) {
   return;
    } else {
	$j('video').css({top: '-10000px', position: 'absolute'});
   hbeingShown = true;

   hpopup.css({
     top: 62,
     display: 'block'
   }).animate({
     top: '-=' + 20 + 'px',
     opacity: 1
   }, 250, 'swing', function() {
     hbeingShown = false;
     hshown = true;
   });
    }
  }).mouseout(function () {
    if (hhideDelayTimer) clearTimeout(hhideDelayTimer);

    hhideDelayTimer = setTimeout(function () {
   hhideDelayTimer = null;
   hpopup.animate({
     top: '+=' + 20 + 'px',
     opacity: 0
   }, 250, 'swing', function () {
     hshown = false;
     hpopup.css('display', 'none');
   });
    }, 500);
	$j('video').css({top: '0', position: 'relative'});
  });
  }
  
// mainmenu
$j(".mposition").each(function () {
	var mhideDelayTimer = null;
	var mbeingShown = false;
	var mshown = false;
	var mtrigger = $j("a", this);
	var mpopup = $j(".msubmenu", this);

	$j([mtrigger.get(0), mpopup.get(0)]).mouseover(function () {
	  $j(mtrigger).addClass("mhover");
	  if (mhideDelayTimer) clearTimeout(mhideDelayTimer);
	  if (mbeingShown || mshown) {
		return;
	  } else {
		mbeingShown = true;
		mpopup.css({display: 'block'}).animate({opacity: 0.8}, 250, 'swing', function() {
		  mbeingShown = false;
		  mshown = true;
		  $j('video').css({top: '-10000px', position: 'absolute'});
		});
	  }
	}).mouseout(function () {
	  $j('video').css({top: '0', position: 'relative'});
	  $j(mtrigger).removeClass('mhover');
	  if (mhideDelayTimer) clearTimeout(mhideDelayTimer);
	  
	  mhideDelayTimer = setTimeout(function () {
		mhideDelayTimer = null;
		mpopup.animate({opacity: 0}, 250, 'swing', function () {
		  mshown = false;
		  mpopup.css('display', 'none');
		});
	  }, 100);
	});
 });

 $j(".msubmenu table a").hover(
   function () {
    $j('video').css({top: '-10000px', position: 'absolute'});
   },
   function () {
    $j('video').css({top: '0', position: 'relative'});
   }
  );

  


$j("#menu_exit").click(function() {
	jQuery.get('/get/logout');
	setTimeout('window.location.reload()',2500);
});

// FancyBox
$j("#menu_login").fancybox({
	'titlePosition'	: 'inside',
	'transitionIn'	: 'none',
	'transitionOut'	: 'none',
	'onStart'		: function() {
	    $j('video').css({top: '-10000px', position: 'absolute'});
	},
	'onClosed'		: function() {
	    $j(".validatetips").hide();
		$j('video').css({top: '0', position: 'relative'});
	}
});
$j("#menu_register").fancybox({
	'titlePosition'	: 'inside',
	'transitionIn'	: 'none',
	'transitionOut'	: 'none',
	'onStart'		: function() {
	    $j('video').css({top: '-10000px', position: 'absolute'});
	},
	'onClosed'		: function() {
	    $j(".validatetips").hide();
		$j('video').css({top: '0', position: 'relative'});
	}
});

$j(".tofavs01").fancybox({
	'titlePosition'	: 'inside',
	'transitionIn'	: 'none',
	'transitionOut'	: 'none',
	'onStart'		: function() {
	    $j('video').css({top: '-10000px', position: 'absolute'});
	},
	'onClosed'		: function() {
		$j('video').css({top: '0', position: 'relative'});
	}
});




$j("#loginform").bind("submit", function() {
	$j.fancybox.showActivity();
	$j.post("/get/login", $j("#loginform").serialize(), function(data) {
		if (data == 200) {
			window.location.reload();
		} else {
			$j.fancybox.hideActivity();
			$j(".validatetips").text(data).show();
		}
	});
	return false;
});

$j(".feedback01").bind("submit", function() {
	$j.fancybox.showActivity();
	$j.post("/get/feedback", $j(".feedback01").serialize(), function(data) {
		if (data == 200) {
			$j(".feedback01").hide();
			$j.fancybox.hideActivity();
			$j(".feedback01-sent-msg").show();
		} else {
			$j.fancybox.hideActivity();
			$j(".vtfb").text(data).show();
		}
	});
	return false;
});

$j("#message01").maxlength({
	'feedback' : '.chars-left-count'
});

$j("#register").bind("submit", function() {
	$j.fancybox.showActivity();
	$j.post("/get/register", $j("#register").serialize(), function(data) {
		if (data == 200) {
			var mylocation;
			mylocation = window.location + "?registered";
			window.location = mylocation;
		} else {
			$j.fancybox.hideActivity();
			$j(".validatetips").text(data).show();
		}
	});
	return false;
});


$j("#loginform input").keypress(function(e) {
	if(e.which == 13) {
		$j("#gologin").focus().click();
	}
});

$j("#register input").keypress(function(e) {
	if(e.which == 13) {
		$j("#goregister").focus().click();
	}
});

$j(".bcancel").click($j.fancybox.close);
// /Fancybox


$j("#search").autocomplete("/get/suggest", { width: 220, selectFirst: false });
$j("#search").result(function(event, data, formatted) { document.search.submit(); });




	$j("#videoPlayer")
		.mouseenter( function () {
			$j("#pagelink").show();
			$j("#pagelink").css("display","block"); })
		.mouseleave( function () {
			$j("#pagelink").css("display","none"); }
	);
	$j("#pagelink")
		.mouseenter( function () {
			$j("#pagelink").css("display","block");
	});

	$j("#lightsOff").click(function () {
		
		$j("#videoplayer").css("z-index","11");
		$j("#ramka").css("z-index","11");
		
		$j("div#lb-bg:hidden:first").fadeIn("slow");
		$j("#lightsOff").fadeOut("slow");
		$j("#lightsOn:hidden").fadeIn("slow");
		return false;
		
	});
	
	$j("#lightsOn").click(function () {
		
		$j("#ramka").css("z-index","1");
		$j("#videoplayer").css("z-index","1");
		$j("div#lb-bg").fadeOut("slow");
		$j("#lightsOn").fadeOut("slow");
		$j("#lightsOff:hidden").fadeIn("slow");
		return false;
	});

	$j(".news-ticker-ctrls-next").click(function () {
		if ( $j(".news-ticker-newstxt li:visible").size() == 1 ) 
		{ 
			$j(".news-ticker-newstxt li").show();
		}
		else
		{
			$j(".news-ticker-newstxt li:visible:first").hide();
		}
	});
	$j(".news-ticker-ctrls-prev").click(function () {
		if ( $j(".news-ticker-newstxt li:hidden").size() == 0 ) 
		{ 
			$j(".news-ticker-newstxt li").hide();
			$j(".news-ticker-newstxt li:last").show();
		}
		else
		{
			$j(".news-ticker-newstxt li:hidden:last").show();
		}
	
	});
	
	$j(".tagssel").click(function () {
			$j(".tags-disp-sel a").removeClass("cursel");
			$j(".tagssel").addClass("cursel");
			$j("#tags").show();
			$j("#channels-studios").hide();
	});
	$j(".channelssel").click(function () {
			$j(".tags-disp-sel a").removeClass("cursel");
			$j(".channelssel").addClass("cursel");
			$j("#tags").hide();
			$j("#channels-studios").show();
	});

	$j(".wsublst01 a").click(function () {
		$j(this).parent("li").toggleClass("expanded");
		$j(this).next(".sublst01").slideToggle("fast");
	});

	$j(".sublst01 a").click(function () {
		$j(".musstylelist01 li").removeClass("current");
		$j(this).parent("li").addClass("current");
	});
	
	
});

 var curDim = 0; 
 function onDimLight() 
 { 
	
	if (curDim==0) 
	{   
		$j("#ramka").css("z-index","11");
		$j("#videoplayer").css("z-index","11");
		$j("div#lb-bg:hidden:first").fadeIn("slow"); 
		curDim = 1;  
		$j("#facebooklike").css("visibility","hidden");
	} 
	else 
	{ 
		$j("#ramka").css("z-index","1");
		$j("#videoplayer").css("z-index","1");
		$j("div#lb-bg").fadeOut("slow"); 
		$j("#facebooklike").css("visibility","visible");
		curDim = 0;  
	} 
}
 
 
var vidres = document.getElementById('videoPlayer');
var ramka = document.getElementById('ramka');
var pagelink = document.getElementById('pagelink');
var fb = document.getElementById('facebook_like');
