var isLayout = 0;
var bannerId = 921059;

function uw_showVideo(num)
{
  document.getElementById('sg_big'+bannerId+'_'+num).style.display = 'block';
  document.getElementById('sg_big'+bannerId+'_'+num).style.visibility = 'visible';
}

jQuery(function($) {

	var timerID = new Array (0,0,0);
	var cur = 0;
	var hltn = 0;

	show_m2 = function (m2, x) {
		var offset = $(x).offset();
		$("#"+m2).css({
			top: (offset.top + 14) + 'px',
			left: offset.left + 'px',
			display: "block"
		});
	}

	hide_m2 = function (m2) {
		$("#"+m2).css("display", "none");
	}

	$('#topmenu ul li a[id^="m1"]').each(function(i){
		$("#"+this.id.replace(/1/i, "2")).each(function(i){
			$(this).hover(
				function() {
					$("#"+this.id.replace(/2/i, "1")).addClass("a");
					clearTimeout(timerID[cur]);
				},
				function() {
					if (!hltn)
					{
						$("#"+this.id.replace(/2/i, "1")).removeClass("a");
					}
					hide_m2(this.id);
				}
			);
		});

		$(this).hover(
			function() {
				hltn = $(this).attr("class") == "a" ? 1:0;
				show_m2 (this.id.replace(/1/i, "2"), this);
				if (timerID[i])
				{
					clearTimeout(timerID[i]);
				}
			},
			function() {
				cur = i;
				timerID[i] = setTimeout('hide_m2("'+this.id.replace(/1/i, "2")+'")', 20);
			}
		);
	});
})

function showAddBox() {
	clearTimeout(boxTimer[1]);
	var self = jQuery('#add-item');
	var pos = self.offset();
	var k = self.parent().hasClass('act') ? 10 : 2; 
	jQuery('#add-box').css({left:pos.left+self.width()+2, top:pos.top+k}).show();
}

function showFilter() {
	clearTimeout(boxTimer[2]);
	var self = jQuery('#mailFilter');
	var pos = self.offset();
	jQuery('#mailFilter-box').css({left:pos.left+self.width()+2, top:pos.top+2}).show();
}

function show_mailsCheckersControl() {
	clearTimeout(boxTimer[3]);
	var self = jQuery('#mailsCheckersControl');
	var pos = self.offset();
	jQuery('#mailsCheckersControl-box').css({left:pos.left+self.width()+2, top:pos.top+2}).show();
}

var boxTimer = Array(); // Для того, что бы не перекрывались менюхи
function _hideAddBox() { jQuery('#add-box').hide(); }
function hideAddBox() { boxTimer[1] = setTimeout('_hideAddBox()', 100); }

function _hideFilter() { jQuery('#mailFilter-box').hide(); }
function hideFilter() { boxTimer[2] = setTimeout('_hideFilter()', 100); }

function _hide_mailsCheckersControl() { jQuery('#mailsCheckersControl-box').hide(); }
function hide_mailsCheckersControl() { boxTimer[3] = setTimeout('_hide_mailsCheckersControl()', 100); }




jQuery(document).ready(function() {

	// init user menu
	jQuery('#add-item').mouseover(showAddBox).mouseout(hideAddBox);
	jQuery('#add-box').mouseover(showAddBox).mouseout(hideAddBox);
	
	// init filters in mail
	jQuery('#mailFilter').mouseover(showFilter).mouseout(hideFilter);
	jQuery('#mailFilter-box').mouseover(showFilter).mouseout(hideFilter);
	
	//mailsCheckersControl
	jQuery('#mailsCheckersControl').mouseover(show_mailsCheckersControl).mouseout(hide_mailsCheckersControl);
	jQuery('#mailsCheckersControl-box').mouseover(show_mailsCheckersControl).mouseout(hide_mailsCheckersControl);
});

function showWaiting(elem, is_center) {
	var is_center = is_center||false;
	var tmp = jQuery('#footer').prev();//elem.prev();//jQuery('#btop').prev();//$('body a:first');//
	if(tmp.is('.waiting')) {
		tmp.remove();
	} else {
		tmp = jQuery(elem).offset();
		jQuery('#footer').before( '<img class="waiting" src="/img/nphoto/waiting.gif" style="'+
								'left:'+(tmp.left+jQuery(elem).innerWidth()/2-10)+'px;'+
								'top:'+((is_center?jQuery(elem).innerHeight()/2-10:0)+tmp.top)+'px;" />');
	}
}

function hideWaiting(elem) {
	var tmp = jQuery('#footer').prev();//elem.prev();//
	if(tmp.is('.waiting')) {
		tmp.remove();
	}
}

(function (jQuery) {
	jQuery.loadWait = function(options) {
		return jQuery.loadWait.init(null, options);
	}
	
	jQuery.fn.loadWait = function(options) {
		return jQuery.loadWait.init(this, options);
	}
	
	jQuery.loadWait.defaults = {
		onDone: null,
		onError: null,
		url: '',
		params: {},
		elem: null,
		rotate: true,
		full: false,
		rotateCenter: false,
		type : 'POST'
	}
	
	jQuery.loadWait.init = function(elem, options) {
		var opts = null;
		elem = elem || null;
		opts = jQuery.extend({}, jQuery.loadWait.defaults, options);
		if(cur_url != null) opts.params.cur_url = cur_url;
		
		if(!opts.url) return;
		
		if(opts.rotate) showWaiting(opts.elem, opts.rotateCenter);
		jQuery.ajax({
			url: (opts.full?'http://'+cur_host:'')+opts.url,
			type: opts.type,
			data: opts.params,
			dataType: 'json',
			success: function(data) {
				if(opts.rotate) hideWaiting(opts.elem);
				if(data.status == 'ok'){
					if(opts.onDone != undefined) opts.onDone.apply(this, [data] );
				} else {
					if(opts.onError != undefined && opts.onError != null) opts.onError.apply(this, [data] );
						else if(data.html) $.fn.colorbox({ html : data.html });
				}
			},
			timeout: function(data) {
				if(opts.rotate) hideWaiting(opts.elem);
				if(opts.onError != undefined && opts.onError != null) opts.onError.apply(this, [data] );
			},
			error: function(data) {
				if(opts.rotate) hideWaiting(opts.elem);

				if(opts.onError != undefined && opts.onError != null) opts.onError.apply(this, [data] );
					else if(data.html) $.fn.colorbox({ html : data.html });
			}
		});
		
		return this;
	}
	
})(jQuery);

/* блок всплывающих подсказок */
var align = 0;
function hideTips (event)
{
	jQuery("div.popup").css({top: 0, left: 0, display:"none" });
	jQuery("div.popup p").html();
}
function showTips(event) {
	var tiptext = jQuery(event.target).attr("tiptext");
	if ( tiptext && tiptext.length > 1)
	{
		var popup = jQuery("div.popup");
		var tPosX;
		jQuery("div.popup p").html(tiptext);
		popup.css({ display:"block" });
		if (align) { tPosX = event.pageX - 5 - popup.width(); } else { tPosX = event.pageX - 5; }
		var tPosY = event.pageY + 10;
		popup.css({top: tPosY, left: tPosX});
	}
};

function tipsInit() {
	jQuery(".tips").mouseover(showTips);
	jQuery(".tips").mouseout(hideTips);
}


// функция для рассчета вертикального смещения
function getyScroll() {
    yScroll = 0;
    if (window.innerHeight && window.scrollMaxY) {
        yScroll = window.innerHeight + window.scrollMaxY;
        var deff = document.documentElement;
        var hff = deff && deff.clientHeight ||
            document.body.clientHeight ||
            window.innerHeight || self.innerHeight;
        yScroll -= (window.innerHeight - hff);
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        yScroll = document.body.scrollHeight;
    } else {
        yScroll = document.body.offsetHeight;
    }
    return yScroll;
}

// функция для получения координат элемента element
function getElemCoord(element)
{
	var left = element.offsetLeft;
	var top = element.offsetTop;
	for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
	{
		left += parent.offsetLeft;
		top += parent.offsetTop;
	}
	return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

// функция для показа всплывающих окон
function showPWin(x, url) {
	jQuery("#hidden-url").val(url);
	jQuery("#over-box").css({display : "block"});
	jQuery("#over").height(jQuery("body").height());
	jQuery("#over-mes").css({margin : (getElemCoord(x).top-(jQuery("#over-mes").height()/2))+"px auto auto auto"});
	jQuery("#snd-name").focus();
    jQuery("#over").css({display : "block"});
}

// функция для скрытия всплывающих окон
function hidePWin() {
    jQuery("#over-box").css({display : "none"});
    jQuery("#over").css({display : "none"});
}




var req_countryCity = false;

function setOptions(select, arr)
{
	select.length = 0;
	for (var i in arr) {
		select.options[select.length] = new Option(arr[i], i, false, false);
	}
	select.selectedIndex = 0;
	select.disabled = false;
	return;
}

function doLoad_city(form, nm)
{
	if (!req_countryCity)
		req_countryCity = new Subsys_JsHttpRequest_Js();
	form.elements[nm+"_city"].disabled = true;
	var country = form.elements[nm+"_country"].options[form.elements[nm+"_country"].selectedIndex].value;
	if (country) {
		req_countryCity.onreadystatechange = function() {
			if ( req_countryCity.readyState == 4 && req_countryCity.responseJS && req_countryCity.responseJS.citys)
			{
				eval("cc = {"+req_countryCity.responseJS.citys+"};");
				setOptions(form.elements[nm+"_city"], cc);
			}
		}
		req_countryCity.caching = false;
		req_countryCity.open('GET', '/gen/reg_city.php', true);
		req_countryCity.send({ c: country });
	} else {
		setOptions(form.elements[nm+"person_city"], []);
	}
}

function confirmPost(confirmMsg, act, data, formName)
{ 
   var is_confirmed = confirm(confirmMsg);
  
   if (is_confirmed){
	   post(act, data, formName);
	   return true;
   } else {
	   return false;
   }
}

function post(act, data, formName){


	if (formName != null){
		formObj = eval ('document.' + formName);
		if(!formObj)
		{
			formObj = eval(formName);
		}
	} else {
		formObj = document.forms[0];
	}

	formObj.elements["act"].value = act;

	if (data != null){
		formObj.elements["somedata"].value = data;
	}
	formObj.submit();
}


      function sendMessage() {
	  	if (jQuery('#hidden-url').val())
		{
			site_url = jQuery('#hidden-url').val(); 	
		}
		else
		{
			site_url = document.location.href; 	
		}
		var message = jQuery('#snd-text').val();
		var r_name = jQuery('#snd-name').val();
		var r_email = jQuery('#snd-email').val();
	  
		var req = new JsHttpRequest();
		req.onreadystatechange = function() {
			if (req.readyState == 4)
			{
//				jQuery('#snd-name').css({ background: "#FFFFFF" });
//				jQuery('#snd-email').css({ background: "#FFFFFF" });
				if (req.responseJS.errors.length != 0)
				{
					for (var i = 0; i < req.responseJS.errors.length; i++ )
					{
						alert("Ошибка заполнения полей !");
//						jQuery('#'+req.responseJS.errors[i]).css( { background: "#FFFFEE" } );
					}
				}
				else
				{
					hidePWin();
				}
			}
		}
		req.open(null, '/inc/_common/send_to_friend.php', true);
		req.send( { message: message, r_name: r_name, r_email:r_email, site_url: site_url} );
	  }

function applyPosition() {
	if(jQuery('#p_a > div').length == 0) return;
	jQuery('#p_a').css({
		top : (jQuery(window).scrollTop() + screen.availHeight/2 - 250)+'px',
		left : (jQuery('body').width()/2 - 125)+'px'
	});
}
function closeRichMedia() {
	jQuery('#p_a').remove();
}
function onFinishedPlaying() {
	jQuery('#p_a').remove();
}
function onFinishedPlayingCross() {
	jQuery('#p_a').remove();
}

jQuery(window).resize(function() {
	applyPosition();
}).scroll(function() {
	applyPosition();
});	


var tooltipCache = Array();
var showenElement = null;
var isOver = 0;
var curElement = null;
var curElementTag = null;
var aTime = Array();
var aTimeOut = Array();
var iItemOut = '';

function hideBox() {
	jQuery('#popup').hide();
}

function hidePopup() {
 	if(!isOver) {
	 	iItemOut = window.clearInterval(iItemOut);
 		hideBox();
	}
}

function showBox(content, element) {
	
	showenElement = element;
	
	jQuery('#popup .ccontent').html(content);
	
	var pos = element.offset();
	
	var h = element.height();
	
	jQuery('#popup').show().css({
		left: pos.left,
		top: pos.top+(h>50&&!element.is('.tip-bottom')?parseInt(h/2):h),
		position: 'absolute'
	});
}

function showPopup() {
	
	aTime[curElementTag] = window.clearInterval(aTime[curElementTag]);
	
	if(showenElement == curElement && jQuery('#popup').is(':visible')) return;

	hideBox();
	
	if(tooltipCache[curElementTag] != undefined) {
		if(tooltipCache[curElementTag] != -1)
			showBox(tooltipCache[curElementTag], curElement);
	} else {
		jQuery.loadWait({
			elem: curElement,
			rotate: false,
			url: '/ajaxnew/tooltip/',
			type: 'GET',
			params: {type: curElementTag},
			onDone : function(data) {
				if(data.status == 'ok' && data.content.length > 0 && data.attr == curElementTag) {
					showBox(data.content, curElement);
					tooltipCache[data.attr] = data.content;
				}
			},
			onError : function(data) {
				tooltipCache[data.attr] = -1;
			}
			
		});
	}
}

function getFlashMovieObject(movieName) {
	if (window.document[movieName]) return window.document[movieName];
	if (navigator.appName.indexOf("Microsoft Internet")==-1)if (document.embeds && document.embeds[movieName])return document.embeds[movieName];
		else return document.getElementById(movieName);
}

function parseAudioId(str) {
	var res = {
		id : parseInt(str),
		width : 195
	};
	if(str.indexOf('-') >= 0) {
		var tmp = str.split('-');
		res.id = parseInt(tmp[0]);
		res.width = parseInt(tmp[1]);
	}
	return res;
}

var topdjMiniPlayerSwf = "/swf/topdj-player/player.swf", topdjMiniPlayerClass = '', topdjMiniPlayerHTML = '';

function placePlayer(pid, name) {
	jQuery('#ac'+pid.id).removeClass('a-play').addClass('a-pause');
	if(jQuery('#ac'+pid.id).hasClass('self')) {
		jQuery('#ac'+pid.id).parent().hide();
	}
	swfobject.embedSWF(topdjMiniPlayerSwf, 'audio'+pid.id, pid.width, "13", "8.0.0", false, {
		prw:name,
		prwid:pid.id,
		session_id:sesid,
		cur_host: cur_host,
		p_width: pid.width
	}, { allowScriptAccess: 'always', wmode: 'transparent' }, { styleclass : topdjMiniPlayerClass });
}

function loadPreview(pid, name) {
	stopPreview(pid);
	if(name != undefined && name != '') {
		placePlayer(pid, name);
	} else {
		jQuery.loadWait({
			elem: '#ac'+pid.id,
			url: '/ajax/?action=audio&aid='+pid.id,
			type: 'GET',
			onDone: function(data) {
				if(data.status == 'ok') {
					placePlayer(pid, data.name);
				}
			}
		});
	}
}

function stopPreview(pid) {

	var player = null;
	
	$('a.audio-listen').each(function(n) {
		var self = $(this);
		var aid = parseAudioId(self.attr('rel'));

		if(aid.id != pid.id) {
			$('#ac'+aid.id).removeClass('a-pause').addClass('a-play');
			$('#ac'+aid.id).parent().show();
			player = getFlashMovieObject("audio"+aid.id);
			if(typeof player == "function") {
				//player.SetVariable("new_status", "pause");
				$('#audio'+aid.id).replaceWith('<div id="audio'+aid.id+'"></div>');
			}
		}
	});
	
	$('object.topdj-audio-player').each(function(n) {
		var self = $(this);
		
		if(self.attr('rel'))
		{
			var aid = parseInt(self.attr('rel'));
		} else
		{
			var aid = self.attr('id').split('-');
			aid = aid[aid.length-1];
		}
		
		if(aid != pid.id) {
			player = getFlashMovieObject("topdj-audio-player-"+aid);
			if(typeof player == "function") {
				player.SetVariable("action", 0);
			}
		}
	});
	
	if(topdjMiniPlayerHTML != '' && topdjMiniPlayerClass != '')
	{
		$('object.'+topdjMiniPlayerClass).each(function(n) {
			var self = $(this);
			var aid = parseInt(self.attr('id').replace('audio', ''));
			
			if(aid != pid.id)
			{
				self.replaceWith(topdjMiniPlayerHTML.replace(/%ID%/gi, aid));
				
				initAudioPreview($('#ac'+aid).parent());
			}
			
		});
	}
}

function initPause(id) {
	stopPreview({id:id});
}

function initTooltips(context) {
	if(isLayout == 0)
	{
		var context = context || null;
		jQuery('a[topdj], div[topdj]', context).mouseover(function(){
			curElement = jQuery(this);
			curElementTag = curElement.attr('topdj');
			aTime[curElementTag] = window.setInterval('showPopup()', 150);
			iItemOut = window.clearInterval(iItemOut);
		}).mouseout(function(){
			curElement = jQuery(this);
			curElementTag = curElement.attr('topdj');
			aTime[curElementTag] = window.clearInterval(aTime[curElementTag]);
			iItemOut = window.setInterval('hidePopup()', 300);
		});
	}
}

function initAudioPreview(context) {
	var context = context || null;
	jQuery('a.audio-listen', context).click(function(e) {
		e.preventDefault();
		var self = jQuery(this);
		var aid = parseAudioId(self.attr('rel'));
		if(jQuery('#ac'+aid.id).hasClass('pause')) {
			stopPreview(0);
		} else {
			if(aid.id > 0) { 
				var atr = jQuery('#a'+aid.id).val();
				loadPreview(aid, atr);
			}
		}
	});	
}

/* Load ajax top mp3 box */
function loadTopMp3(elem, type, period) {
	var self = jQuery(elem);
	
	jQuery.loadWait({
		elem: elem,
		url: '/ajax/?action=audio-top&type='+type+'&period='+period,
		type: 'GET',
		onDone: function(data) {
			if(data.status == 'ok') {
				self.parent().parent().replaceWith(data.content);
	
				// initialising tooltips for a[topdj]
				initTooltips(jQuery('#top-'.type));
			
				// initialising audio previews
				initAudioPreview(jQuery('#top-'.type));	
			}
		}
	});
}

// star rating
function starRatingClick(self) {	
	
	var self = $(self);
	var item = self.parent().parent().attr('rel').split('-');
	var rate = self.attr('rel');
	if(item[1] > 0 && item[0] != '' && rate > 0) {
		$.loadWait({
			elem: self,
			url: '/ajaxnew/rate/',
			params: {type: item[0], id: item[1], rate: rate},
			onDone: function(data) {
				var eul = self.parent().parent();
				$('li.current-rating', eul).css({width: parseInt(data.rating*16)+'px'});
				if(eul.next().hasClass('rate'))
				{
					eul.next().html(data.rating_text);
				}
			}
		});
	}
	
	return false;
}

function userFixBoxes()
{
	jQuery('.page-profile .column-right .column div.box').removeClass('first');
	jQuery('.page-profile .column-right .column div.box:first').addClass('first');
	
	jQuery('.page-profile #profile .main div.box').removeClass('first');
	jQuery('.page-profile #profile .main div.box:first').addClass('first');
	
	jQuery('.page-profile #profile .right div.box').removeClass('first');
	jQuery('.page-profile #profile .right div.box:first').addClass('first');
	
}


$(document).ready(function() {
	
	if(jQuery('#popup')) {
		jQuery('#popup').mouseover(function(){
			isOver = 1;
		}).mouseout(function(){
			isOver = 0;
		});
	}
	
	// initialising tooltips for a[topdj]
	initTooltips();

	// initialising audio previews
	initAudioPreview();	

	applyPosition();
	
	$().bind('cbox_complete', function(){
		$('#cboxLoadedContent a.topdj-help').cluetip({splitTitle: '|', showTitle: false, dropShadowSteps: 3, width: 240, cluezIndex: 9990}); 
	});
	
	$('a.sms-activate').colorbox({href: '/lib/sms/confirmNumber/'});
	
	$('a.colorbox').colorbox();
	$('a.ajaxbox').click(function(e){
		e.preventDefault();
		var self = $(this);
		if(self.attr('ajax') != undefined)
		{
			var url = $(this).attr('ajax');
			var width = parseInt($(this).attr('ajaxwidth')) || false;
			var height = parseInt($(this).attr('ajaxheight')) || false;
			
			$.fn.colorbox({
				href: url + (url.indexOf('?')>0 ? '&' : '?' ) + 'cur_url=' + cur_url,
				width: width,
				height: height,
				innerWidth: false, 
				classAdd: self.attr('ajaxclass')
			});
		} else
			$(this).colorbox({width: false, innerWidth: false, classAdd: self.attr('ajaxclass')});
	});
	$('a.cboxSlideshow').colorbox({ slideshow:true, width: false, innerWidth: false });
	
	// init help tips
	if(jQuery('.topdj-help').cluetip) {
		jQuery('.topdj-help').cluetip({splitTitle: '|', showTitle: false, dropShadowSteps: 3, width: 240});
		jQuery('.topdj-help-double').cluetip({splitTitle: '|', showTitle: false, dropShadowSteps: 3, width: 480});
	}

	$('.collapse-head a').click(function(e) {
		e.preventDefault();
		var self = $(this);
		if(self.next().hasClass('opened')) {
			self.next().removeClass('opened');
			self.parent().next().hide();
		} else {
			$('.collapse-text').hide();
			$('.collapse-head i').removeClass('opened');
			self.next().addClass('opened');
			self.parent().next().show();
		}
	});
	
	// login|email swap login
	$('.box-auth .u-login a').click(function(e) {
		e.preventDefault();
		$('.box-auth .u-login').hide();
		$('.box-auth .u-email').show();
	});
	$('.box-auth .u-email a').click(function(e) {
		e.preventDefault();
		$('.box-auth .u-email').hide();
		$('.box-auth .u-login').show();
	});
	
	userFixBoxes();
	
});

// track action
function gat(url, is_show) {
	if(url == '') return;
	
	var is_show = is_show == undefined ? true : false;
	
	// if it's element show tracking - then adding source
	if(is_show == true && cur_path != '') {
		url += (url.indexOf('?') == -1? '?' : '&') + 'source=' + cur_path;
	}

	// tracking
	_gaq.push(['t2._trackPageview', url]);
}

// tracking multiple actions at once
function gats(url, ids) {
	if(!ids) return;
	
	for(var i=0; i<ids.length; i++) {
		url += '/'+ids[i];
	}
	gat(url+'/');
}


function submitForm(elem, form_id, url_submit, box_width)
{
	var box_width = box_width || false;

	// submitting form
	$.loadWait({
		elem: $(elem),
		url: url_submit,
		params: $('#'+form_id).serializeArray(),
		onDone: function(data) {
			$.fn.colorbox({ html : data.html });
		},
		onError: function(data) {
			if(!data.html && data.status) {
				if(!data.message) data.message = "Произошла ошибка при отправке формы, попробуйте ещё раз."; 
				alert(data.message);
			} else {
				$.fn.colorbox({ html : data.html, width: box_width });
			}
		}
	});
	
}

var bannersList = ['adriver_back', 'adriver_very_top', 'adriver_left', 'adriver_top', 'adriver_bottom'];

function refreshBanners()
{
	for(i in bannersList)
	{
		if($('#'+bannersList[i]).length > 0)
		{
			$('#'+bannersList[i]).html('');
		}
	}
}

function shareUrl(elem, w, h, t)
{
	var st = t == undefined ? 0 : t;
	
	window.open($(elem).attr('href')+(st ? encodeURIComponent(document.title.toString()) : ''), 'share_url', 'width='+w+',height='+h).focus();

	return false;
}


function i_like_it_do(el, id, object_type)
{
    $.loadWait({
        elem: $(el),
        url:'/ajaxnew/i-like-it/i-like-it', 
        params: {object_type: object_type, object_id: id, value:$('#i_like_it').attr('ref')}, 
        onDone : function(data) {
            $('#i_like_it_cnt').html(data.i_like_it_cnt_text);
            $('#i_like_it_title').show();
            
            $('#i_like_it').attr('ref', $('#i_like_it').attr('ref') == 0 ? 1 : 0);
            
            if ($('#i_like_it').attr('ref') == 0)
            {
                $('#i_like_it').addClass('ilike');
            }else{
                $('#i_like_it').removeClass('ilike');
            }   
            
            if(data.i_like_it_cnt == 0){
                $('#i_like_it_title').hide();
                $('#user_also_like_block').html('').hide();
            } else
            {
                $('#user_also_like_block').html(data.html);
                
            	initTooltips('#user_also_like_block');
            }
            
        }
    });                 
    
    return false;
}

function i_like_it_show(el, id, object_type, always)
{
	if($('#user_also_like_block').is(':visible') && !always)
	{
		$('#user_also_like_block').hide();
	} else
	{
		if($('#user_also_like_block').html() == '' || always)
		{
		    $.loadWait({
		        elem: $(el),
		        url:'/ajaxnew/i-like-it/i-like-it-show', 
		        params: {object_type: object_type, object_id: id},
		        onDone: function(data)
		        {
		        	$('#user_also_like_block').html(data.html);
		        	initTooltips('#user_also_like_block');
		        	if(!always)
		        	{
		        		$('#user_also_like_block').show();
		        	}
		        }
		    });
		} else
		{
			$('#user_also_like_block').show();
		}
		
	}
	return false;
}