﻿	//General JavaScript & Ajax file [jQuery compatible]
	//Copyright Eurograf.pl 2010 - All rights reserved

	//Setup some variables
   	var opened_comment_id = '';
	var opened_comment_form_id = '';
	var opened_post_id = '';
	var post_display_effect = 'fast';

	//Helpers Functions
	function random_string()
	{
		var list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		var string = '';
		for (i = 0; i < 40; i++)
		string += list.charAt(Math.floor(Math.random()*list.length));
		return string;
	}

	function rand_value()
	{
		var rand_value = Math.round(Math.random() * 10000000000000000);
		return rand_value;
	}

	function count_array(array)
	{
		var count = 0;
		for(key in array){count++;}
		return count;
	}

	function remove_characters(string)
	{
		var search_array = new Array('<', '>', '~', '`', '!', '?', '/', '\\', '\'', '"', '@', '#', '€', '$', '%', '^', '&', '*', '(', ')', '=', '+', '-', '[', ']', '{', '}', ':', ';', '|', ',', '.', ' ', 'ą', 'ę', 'ż', 'ź', 'ć', 'ń', 'ó', 'ł', 'ś', 'Ą', 'Ę', 'Ż', 'Ź', 'Ć', 'Ń', 'Ó', 'Ł', 'Ś', '¶', '±', 'Ľ', 'ˇ', '¬', '¦');
		var replace_array = new Array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '_', '', '', '', '', '_', '_', '', '', '', '', '', '', '', '', '', '_', 'a', 'e', 'z', 'z', 'c', 'n', 'o', 'l', 's', 'A', 'E', 'Z', 'Z', 'C', 'N', 'O', 'L', 'S', 's', 'a', 'z', 'Z', 'A', 'S');
		var search = [].concat(search_array);
		var replace = [].concat(replace_array)
		var i = (string = [].concat(string)).length;
		while(j = 0, i--)
		{
			while(string[i] = string[i].split(search[j]).join(replace[j] || ""), ++j in search);
		}
		return string;
	}

	//Main functions
	var userAgent = navigator.userAgent.toLowerCase();
	var client = {
		isOpera: userAgent.indexOf('opera') > -1,
		isFirefox: userAgent.indexOf('firefox') > -1,
		isChrome: userAgent.indexOf('chrome') > -1,
		isIE: userAgent.indexOf('msie') > -1,
		isSafari: /webkit|khtml/.test(userAgent)
	};

	function onLoadInit()
	{
		imagesPreloader();
		timer();
	}

	function imagesPreloader()
	{
		if (document.images) {
			var imagesEmots = '/application/images/emots/, icon_biggrin.gif, icon_confused.gif, icon_cool.gif, icon_eek.gif, icon_evil.gif, icon_lol.gif, icon_mad.gif, icon_mrgreen.gif, icon_neutral.gif, icon_razz.gif, icon_redface.gif, icon_rolleyes.gif, icon_sad.gif, icon_smile.gif, icon_twisted.gif, icon_wink.gif';
			var imagesSite = '/application/images/layout/, loading.gif, loading2.gif, loading_small.gif, loader_big.gif';
			var imagesEmotsArray = new Array();
			var imagesEmotsObject = new Array();
			var imagesSiteArray = new Array();
			var imagesSiteObject = new Array();
			imagesEmotsArray = imagesEmots.split(", ");
			imagesSiteArray = imagesSite.split(", ");
			var imagesEmotsCount = count_array(imagesEmotsArray);
			var imagesSiteCount = count_array(imagesSiteArray);
			for(var i = 1; i < (imagesEmotsCount); i++) {
				if(imagesEmotsArray[i] != undefined) {
					imagesEmotsObject[i] = new Image();
					imagesEmotsObject[i].src = imagesEmotsArray[0] + imagesEmotsArray[i];
				}
			}
			for(var i = 1; i < (imagesSiteCount); i++) {
				if(imagesSiteArray[i] != undefined) {
					imagesSiteObject[i] = new Image();
					imagesSiteObject[i].src = imagesSiteArray[0] + imagesSiteArray[i];
				}
			}
		}
	}

	function displayImage(url, width, height)
	{
		var newWindow = window.open(url, rand_value(), 'width=' + width + ', height='+ height + ', resizable=no, scrollbars=no, menubar=no, status=no, toolbar=no');
		newWindow.focus();
	}

	function displayWindow(url, width, height)
	{
		var newWindow = window.open(url, rand_value(), 'width=' + width + ', height=' + height + ', resizable=no, scrollbars=yes, menubar=no, status=no, toolbar=no');
		newWindow.focus();
	}

	function displayPopup(url)
	{
		var newWindow = window.open(url, rand_value(), 'width=1, height=1, resizable=no, scrollbars=yes, menubar=no, status=no, toolbar=no');
		newWindow.focus();
	}

	function windowResize(width, height)
	{
		window.resizeTo(width + 30, height + 60 - ((navigator.appName == 'Netscape')? 10 : 0));
		self.focus();
	}

	function comments_display(comment_id, order_marker)
	{
		if ((opened_comment_id != '') && (opened_comment_id == comment_id))
		{
			$('#comment_for_id_' + opened_comment_id).hide(post_display_effect);
			$('#comment_for_id_' + opened_comment_id).empty();
			opened_comment_id = '';
		}
		else if ((opened_comment_id != '') && (opened_comment_id != comment_id))
		{
			$('#comment_for_id_' + opened_comment_id).hide(post_display_effect);
			$('#comment_for_id_' + opened_comment_id).empty();
			comments_get(comment_id, order_marker);
			$('#comment_for_id_' + comment_id).show(post_display_effect);
			opened_comment_id = comment_id;
		}
		else
		{
			comments_get(comment_id, order_marker);
			$('#comment_for_id_' + comment_id).show(post_display_effect);
			opened_comment_id = comment_id;
		}
	}

	function comments_parse(xml)
	{
		var output_tags = '';
		var comments = xml.getElementsByTagName("comment_item");
		for(i = 0; i < comments.length; ++i)
		{
			output_tags += '<div class="comment_content"> <b class="comment_who">Napisany przez: ' + comments[i].getElementsByTagName("author")[0].childNodes[0].nodeValue + ' | Dodano: ' + comments[i].getElementsByTagName("add_time")[0].childNodes[0].nodeValue + '</b>';
			output_tags += '<div class="comment_tresc">' + comments_insert_emoticons(comments[i].getElementsByTagName("comment")[0].childNodes[0].nodeValue.replace(/\n/g, "<br>")) + '</div></div>';
			output_tags += '<div style=\"height: 1px; padding: 5px 0px 5px 0px; float:none; margin-bottom:10px; \"></div>';
		}
		return output_tags;
	}

	function comments_get(id, order_marker)
	{
		$.ajax({
			url: '/ajax/comments/index/' + id + '/' + order_marker,
			type: 'GET',
			cache: false,
			dataType: 'xml',
			beforeSend: function(){$('#comment_for_id_' + id).html('<div align="center">Ładowanie komentarzy<br>Proszę czekać...<br><img border="0" src="/application/images/layout/loading2.gif" width="160" height="5"></div>');},
			error: function(){$('#comment_for_id_' + id).html('<div align="center">Brak połączenia z serwerem.</div>');},
			success: function(xml){$('#comment_for_id_' + id).html(comments_parse(xml)); comments_anchor_jump(id);}
		});
	}

	function comments_anchor_jump(anchor_id)
	{
		//window.location.hash = 'post_jump_' + anchor_id;
		return false;
	}

	function comments_insert_emoticons(string)
	{
		var text_emoticons = new Array(":D",":d",":?","8)",":shock:",":evil:",":lol:",":x",":mrgreen:",":|",":P",":p",":oops:",":roll:",":(",":)",":twisted:",":wink:");
		var img_emoticons = new Array("icon_biggrin.gif","icon_biggrin.gif","icon_confused.gif","icon_cool.gif","icon_eek.gif","icon_evil.gif","icon_lol.gif","icon_mad.gif","icon_mrgreen.gif","icon_neutral.gif","icon_razz.gif","icon_razz.gif","icon_redface.gif","icon_rolleyes.gif","icon_sad.gif","icon_smile.gif","icon_twisted.gif","icon_wink.gif");
		var new_img_emoticons = new Array(img_emoticons.length);
		var preload_img_emoticons = new Array(img_emoticons.length);
		for(a = 0; a < img_emoticons.length; a++)	
		{
			preload_img_emoticons[a] = new Image();
			preload_img_emoticons[a].src = '/application/images/emots/' + img_emoticons[a];
			new_img_emoticons[a] = '<img border="0" src="/application/images/emots/' + img_emoticons[a] + '" width="19" height="19" align="absmiddle">';
		}
		var search = [].concat(text_emoticons);
		var replace = [].concat(new_img_emoticons)
		var i = (string = [].concat(string)).length;
		while(j = 0, i--)
		{
			while(string[i] = string[i].split(search[j]).join(replace[j] || ""), ++j in search);
		}
		return string;
	}

	function comment_add(comment_form_id, comment_form_order)
	{
		if ((opened_comment_form_id != '') && (opened_comment_form_id == comment_form_id))
		{
			$('#comment_form_id_' + opened_comment_form_id).hide(post_display_effect);
			$('#comment_form_id_' + opened_comment_form_id).empty();
			opened_comment_form_id = '';
		}
		else if ((opened_comment_form_id != '') && (opened_comment_form_id != comment_form_id))
		{
			$('#comment_form_id_' + opened_comment_form_id).hide(post_display_effect);
			$('#comment_form_id_' + opened_comment_form_id).empty();
			comment_insert_form(comment_form_id, comment_form_order);
			$('#comment_form_id_' + comment_form_id).show(post_display_effect);
			opened_comment_form_id = comment_form_id;
		}
		else
		{
			comment_insert_form(comment_form_id, comment_form_order);
			$('#comment_form_id_' + comment_form_id).show(post_display_effect);
			opened_comment_form_id = comment_form_id;
		}
	}

	function comment_insert_form(comment_form_id, comment_form_order)
	{
		var output_form = '';
		output_form += '<form id="send_form_ajax" name="send_comment" action="/ajax/add_comment/index" method="post">\n';
		output_form += '<input type="hidden" name="code_value">\n';
		output_form += '<input type="hidden" name="item_id\" value="' + comment_form_id + '">\n';
		output_form += '<input type="hidden" name="item_order\" value="' + comment_form_order + '">\n';
		output_form += '<div class="emots">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_biggrin.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':)\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_confused.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':?\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_cool.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\'8)\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_eek.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':shock:\');" style="cursor: pointer">\n';
		output_form += '<br>\n';
		output_form += '<img border="0" src="/application/images/emots/icon_evil.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':evil:\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_lol.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':lol:\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_mad.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':x\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_mrgreen.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':mrgreen:\');" style="cursor: pointer">\n';
		output_form += '<br>\n';
		output_form += '<img border="0" src="/application/images/emots/icon_neutral.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':|\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_razz.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':P\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_redface.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':oops:\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_rolleyes.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':roll:\');" style="cursor: pointer">\n';
		output_form += '<br>\n';
		output_form += '<img border="0" src="/application/images/emots/icon_sad.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':(\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_smile.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':)\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_twisted.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':twisted:\');" style="cursor: pointer">\n';
		output_form += '<img border="0" src="/application/images/emots/icon_wink.gif" width="19" height="19" onclick="javascript:comment_form_emoticon(\':wink:\');" style="cursor: pointer">\n';
		output_form += '</div>\n';
		output_form += '<div class="text_comments">\n';
		output_form += '<b>Nick:</b><br /><input class="form_comments" type="text" name="author" value="" maxlength="32"><br />\n';
		output_form += '<b>Treść komentarza:</b><br /><textarea class="form_comments_text" name="comment" wrap="virtual"></textarea><br />';
		output_form += '</div>';
		output_form += '<table class="comments_code">';
		output_form += '<tr>';
		output_form += '<td><b>Przepisz kod: </b></td>';
		output_form += '<td><div id="code_image" style="width:69px; height:17px;"></div></td>';
		output_form += '<td>\n';
		output_form += '<input class="form_code_text" type="text" name="code" maxlength="6"></td>';
		output_form += '<td><input class="submit" style="cursor: pointer;" type="button" name="submit" value="Wyślij" onclick="comment_form_send();"></td>';
		output_form += '</tr>\n';
		output_form += '</table>\n';
		output_form += '<div id="comment_info" class="txt_alert" style="clear: both; text-align: center; padding-top: 10px"></div>\n';
		output_form += '</form>\n';
		output_form += '<div class="line" />\n';
		$('#comment_form_id_' + comment_form_id).html(output_form);
		setTimeout("comment_form_code_reload();", 200);
	}

	function comment_form_response(responseXML)
	{
		var comment_attributes = responseXML.getElementsByTagName("comment")[0];
		var item_id = comment_attributes.getAttribute("item_id");
		var item_order = comment_attributes.getAttribute("item_order");
		var errors = comment_attributes.getAttribute("errors");
		if(errors == 1)
		{
			var errors_string = responseXML.getElementsByTagName("error")[0].childNodes[0].nodeValue.replace(/@/g, "<br />");
			$('#comment_info').html('<span class="red">' + errors_string + '</span>');
			comment_form_code_reload();
		}
		else
		{
			$('#comment_info').empty();
			$('#comment_form_id_' + item_id).empty();
			opened_comment_form_id = '';
			var item_counter = parseInt($('#comment_counter_id_' + item_id).text()) + 1;
			$('#comment_link_id_' + item_id).html('<a href="javascript:;" onclick="javascript:comments_display(' + item_id + ', \'' + item_order + '\')\"">Komentarze (<span id="comment_counter_id_' + item_id + '">' + item_counter + '</span>)</a>');
			opened_comment_id = '';
			comments_display(item_id, item_order);
		}
	}

	function comment_form_code_reload()
	{
		var randon_code_value = random_string();
		$('#send_form_ajax input[name="code_value"]').val(randon_code_value);
		$('#send_form_ajax input[name="code"]').empty();
		$('#code_image').css('background', 'url(/ajax/image_code/index/' + randon_code_value + ')');
	}

	function comment_form_send()
	{		
		$.ajax({
			url: '/ajax/add_comment/index/',
			type: 'POST',
			dataType: 'xml',
			data: $('#send_form_ajax').serialize(),
			beforeSend: function(){$('#comment_info').html('<div align="center">Proszę czekać...<br><img border="0" src="/application/images/layout/loading2.gif" width="160" height="5"></div>');},
			error: function(){$('#comment_info').html('<div align="center">Brak połączenia z serwerem.</div>');},
			success: function(xml){comment_form_response(xml);}
		});
	}

	function comment_form_emoticon(text)
	{
		var txtarea = document.send_comment.comment;
		text = ' ' + text + ' ';
		if (txtarea.createTextRange && txtarea.caretPos)
		{
			var caretPos = txtarea.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
			txtarea.focus();
		}
		else
		{
			txtarea.value  += text;
			txtarea.focus();
		}
	}

	function post_display(post_id)
	{
		if ((opened_post_id != '') && (opened_post_id == post_id))
		{
			$('#post_id_' + opened_post_id).hide(post_display_effect);
			$('#post_display_label_' + opened_post_id).html('Czytaj całość');
			opened_post_id = '';
		}
		else if ((opened_post_id != '') && (opened_post_id != post_id))
		{
			$('#post_id_' + opened_post_id).hide(post_display_effect);
			$('#post_display_label_' + opened_post_id).html('Czytaj całość');
			$('#post_id_' + post_id).show(post_display_effect);
			$('#post_display_label_' + post_id).html('Ukryj treść');
			post_anchor_jump(post_id);
			opened_post_id = post_id;
		}
		else
		{
			$('#post_id_' + post_id).show(post_display_effect);
			$('#post_display_label_' + post_id).html('Ukryj treść');
			post_anchor_jump(post_id);
			opened_post_id = post_id;
		}
	}

	function post_anchor_jump(anchor_id)
	{
		window.location.hash = 'post_jump_' + anchor_id;
	}

	function timer()
	{
		if($('#date') != null)
		{
			var date = new Date();
			var minutes = (date.getMinutes() < 10)? '0' + date.getMinutes() : date.getMinutes();
			var secounds = (date.getSeconds() < 10)? '0' + date.getSeconds() : date.getSeconds();
			$('#date').html('dziś jest: '+ date.getDate() + '.' + (date.getMonth() + 1) + '.' + date.getFullYear() + ', godz. ' + date.getHours() + ':' + minutes + ':' + secounds);
			setTimeout('timer()', 1000);
		}
	}

	function subscribe_form_response(status)
	{
		var subscribe_status_array = new Array();
		subscribe_status_array[0] = 'Adres dodany do bazy - dziękujemy!';
		subscribe_status_array[1] = 'Niepoprawny adres e-mail!';
		subscribe_status_array[2] = 'Adres email już istnieje w bazie!';
		subscribe_status_array[100] = 'Błąd zapisu adresu do bazy prosimy spróbować ponownie!';
		$('#note').html((subscribe_status_array[status] != undefined)? subscribe_status_array[status] : subscribe_status_array[100]);
	}

	function subscribe_form_send()
	{
		$.ajax({
			url: '/ajax/subscribe/index/',
			type: 'POST',
			dataType: 'html',
			data: $('#email_form').serialize(),
			error: function(){$('#note').html('Brak połączenia z serwerem.');},
			success: function(response){subscribe_form_response(response);}
		});
	}

	function subscribe_form_swap_message(action)
	{
		if(action == 'hide')
		{
			$("#email").val(($("#email").val() == labels['type_email'])? '' : $("#email").val());
		}
		else if(action == 'check')
		{
			$("#email").val(($("#email").val() != '')? $("#email").val() : labels['type_email']);
		}
	}

	function search_form_swap_message(action)
	{
		if(action == 'hide')
		{
			$("#search_string").val(($("#search_string").val() == labels['type_search'])? '' : $("#search_string").val());
		}
		else if(action == 'check')
		{
			$("#search_string").val(($("#search_string").val() != '')? $("#search_string").val() : labels['type_search']);
		}
	}

	function switchHomeMovie(id, movieUrl)
	{
		$(id).html((!iskValidUrl(movieUrl))? insetVimeoMovie(movieUrl) : insetMovie(movieUrl));
	}

	function insetVimeoMovie(movieId)
	{
		var movieObj = '';
		//movieObj += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="350" width="600">';
		//movieObj += '<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=' + movieId + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1">';
		//movieObj += '<param name="menu" value="false">';
		//movieObj += '<param name="quality" value="best">';
		//movieObj += '<param name="wmode" value="transparent">';
		//movieObj += '<param name="allowfullscreen" value="true">';
		//movieObj += '<param name="allowscriptaccess" value="always">';
		//movieObj += '<embed src="http://vimeo.com/moogaloop.swf?clip_id=' + movieId + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" quality="best" menu="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" allowfullscreen="true" allowscriptaccess="always" height="350" width="600">';
		//movieObj += '</object>';
		movieObj += '<iframe src="http://player.vimeo.com/video/' + movieId + '" width="600" height="350" frameborder="0"></iframe>';
		return movieObj;
	}

	function insetMovie(movieUrl)
	{
		var movieObj = '';
		movieObj += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" height="350" width="600">';
		movieObj += '<param name="movie" value="' + movieUrl + '">';
		movieObj += '<param name="menu" value="false">';
		movieObj += '<param name="quality" value="best">';
		movieObj += '<param name="wmode" value="transparent">';
		movieObj += '<param name="allowfullscreen" value="true">';
		movieObj += '<param name="allowscriptaccess" value="always">';
		movieObj += '<embed src="' + movieUrl + '" quality="best" menu="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" allowfullscreen="true" allowscriptaccess="always" height="350" width="600">';
		movieObj += '</object>';
		return movieObj;
	}

	function iskValidUrl(url)
	{
		var RegexUrl = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
		return RegexUrl.test(url);
	}

	function submitMotyForm() {
		var errorFlag = false;
		if($('#man_of_the_year #candidate').val().length < 3) {
			$('#man_of_the_year #candidate').addClass('error');
			$('#man_of_the_year #candidate').next().text('Prosimy podać Imię i Nazwisko kandydata');
			errorFlag = true;
		} else {
			$('#man_of_the_year #candidate').removeClass('error');
			$('#man_of_the_year #candidate').next().empty();
		}
		if($('#man_of_the_year #justification').val().length < 3) {
			$('#man_of_the_year #justification').addClass('error');
			$('#man_of_the_year #justification').next().text('Prosimy o uzasadnienie kandydatury');
			errorFlag = true;
		} else {
			$('#man_of_the_year #justification').removeClass('error');
			$('#man_of_the_year #justification').next().empty();
		}
		if(!errorFlag) {
			$('#man_of_the_year').submit();
		}
	}
	
	$(document).ready(function(){
		
		//FB slide
		$('.facebook').hover(function(){
			$(this).stop(true, false).animate({left:'0'},'medium');
		},function(){
			$(this).stop(true, false).animate({left:'-225'},'medium');
		},500);
		//zyczenia slide
		$('.zyczenia').hover(function(){
			$(this).stop(true, false).animate({right:'0'},'medium');
		},function(){
			$(this).stop(true, false).animate({right:'-600'},'medium');
		},500);
	
		//Media tabs
		$(".media #tabs li a").click(function(){
			$(".media #tabs li a").removeClass("active-tab");
			$(this).addClass("active-tab");
			var element_index = $(".media #tabs a").index(this);
			$(".media .media_mini_border div.media_mini:visible").hide();
			$(".media .media_mini_border div.media_mini").eq(element_index).show();
			return false;
		});

	});
	
