jQuery(document).ready(function($)
{
	// HIDE - DLL
	$(".urlDLL").click(function() {
		var rel = $(this).attr("rel");
		if($(".hideDLL."+rel).is(":visible")) {
			$(this).css("color", "#000000");
			return true;
		} else {
			$(".hideDLL").slideUp("slow");
			$(".hideDLL."+rel).slideDown("slow");
			$(".urlDLL").css("color", "#004899");
			$(this).css("color", "#000000");
			return true;
		}
	});

	// AutoHIDE
	$('.hideURL').click(function() {
		var URL = $(this).parent().parent();
		if($(URL).find(".hideSHOW").is(":visible")) {
			$(URL).find(".hideSHOW").not(":hidden").hide("slow");
			return true;
		} else {
			$(".hide").not(this).each(function(i) {
				$(this).find(".hideSHOW").hide("slow");
			});
			$(URL).find(".hideSHOW").show("slow");
			return false;
		}
	});

	// Text select
	$('.select').click(function() {
		$(this).focus();
		$(this).select();
	});
	
	// Scroll to...
	var scroll_time = 800;
	$('#func_start').click(function() {$.scrollTo('body', scroll_time);});
	$('#func_text').click(function() {$.scrollTo('#content', scroll_time);});
	$('#func_end').click(function() {$.scrollTo('#footer', scroll_time);});
	$('#func_back').click(function() {window.history.back(1);});

	// ColorBox
	$("div.preview a").each(function () {
		var rel = /box\[([\w_-]*?)\]/.exec(this.rel);
		if (rel && rel.lenght)
			rel = rel[1];
		else {
			var header = $(this).parents("div.post").find(".header h1");
			rel = (header && header[0].innerHTML) || "nofollow";
		}
		$(this).colorbox({
			maxWidth:'90%',
			maxHeight:'80%',
			opacity:'0.75',
			preloading:'true',
			current:'Bild {current} aus {total}',
			previous:'vorheriges',
			next:'n&#228;chstes',
			close:'schlie&#223;e',
			fixed:'true',
			rel:rel
		});
	});
	$("a[rel^='box']").each(function () {
		var rel = /box\[([\w_-]*?)\]/.exec(this.rel);
		rel = (rel && rel.lenght) ? rel[1] : "nofollow";
		$(this).colorbox({
			maxWidth:'90%',
			maxHeight:'80%',
			opacity:'0.75',
			preloading:'true',
			current:'Bild {current} aus {total}',
			previous:'vorheriges',
			next:'n&#228;chstes',
			close:'schlie&#223;e',
			fixed:'true',
			rel:rel
		});
	});
	/*
	$("a[rel='box']").colorbox({
		maxWidth:'90%',
		maxHeight:'80%',
		opacity:'0.75',
		preloading:'true',
		current:'Bild {current} aus {total}',
		previous:'vorheriges',
		next:'n&#228;chstes',
		close:'schlie&#223;e',
		fixed:'true'
	});
	$("div.preview a").colorbox({
		maxWidth:'90%',
		maxHeight:'80%',
		opacity:'0.75',
		preloading:'true',
		current:'Bild {current} aus {total}',
		previous:'vorheriges',
		next:'n&#228;chstes',
		close:'schlie&#223;e',
		fixed:'true'
	});
	*/
	$(".boxvideo").click(function() {
		var details = $(this).attr('name').split("|");
		var titel = $(this).attr('title') || $(this).parent().parent().children('td:first').html() || '';
		var width = details[1] || 704;
		var height = details[2] || 470;
		var id = details[0];
		if($(this).hasClass('ru')) {
			$.colorbox({
				title:titel,
				fixed:'true',
				html:'<object width="'+width+'" height="'+height+'"><param name="movie" value="http://video.rutube.ru/'+id+'"></param><param name="wmode" value="window"></param><param name="allowFullScreen" value="true"></param><embed src="http://video.rutube.ru/'+id+'" type="application/x-shockwave-flash" wmode="window" width="'+width+'" height="'+height+'" allowFullScreen="true" ></embed></object>'
			});
		} else {
			$.colorbox({
				title:titel,
				fixed:'true',
				html:'<object width="'+width+'" height="'+height+'"><param name="movie" value="http://www.megavideo.com/v/'+id+'"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.megavideo.com/v/'+id+'" type="application/x-shockwave-flash" allowfullscreen="true" width="'+width+'" height="'+height+'"></embed></object>'
			});
		}
	});
	$(".boxiframe").colorbox({width:"85%",height:"85%",fixed:'true',iframe:'true'});
	$("a.sd").colorbox({width:"860",height:"730",iframe:'true'});
	$("a.hd").colorbox({width:"860",height:"730",iframe:'true'});
	$("a.fhd").colorbox({width:"860",height:"730",iframe:'true'});
});


