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';
}

$(document).ready(function(){

	$('a.sms-activate').colorbox({href: '/lib/sms/confirmNumber/'});

	$('a.ajaxbox').click(function(e){
		e.preventDefault();
		if($(this).attr('ajax') != undefined)
		{
			var url = $(this).attr('ajax');
			$.fn.colorbox({href: url+(url.indexOf('?')>0?'&':'?')+'cur_url='+cur_url, width: false, innerWidth: false});
		} else
			$(this).colorbox({width: false, innerWidth: false});
	});

	$('#auth-registration').attr('href', url_urbanwave+'/register/');
	
	$('#auth-forget-password').colorbox({href: url_urbanwave+'/ajax-local/forget-password/', width: false, innerWidth: false});
	$('#auth-login').colorbox({href: url_uwn+'/ajax-login/?cur_url='+cur_url, width: false, innerWidth: false});
	
	// Fixing height of main content part
	
	if($('#content .box').length == 1 && $('#content .box').innerHeight() < $('#sidebar').innerHeight())
	{
		$('#content .box').css({height: parseInt($('#sidebar').innerHeight())-17-10});
	}
	
	$('#send-code').click(function(e){
		e.preventDefault();
		$.fn.colorbox({href: '/ajax-local/send-code/?number='+$('#mnumber').val(), width: false, innerWidth: false});
	});
	
	/*
	if($('#ps-head').length == 1) {
		swfobject.embedSWF(src_uw+'/swf/pirate_head_urban_wave2.swf', 'ps-head', 278, 234, "8.0.0", false, false, {allowScriptAccess: 'always', wmode: 'transparent'});
	}
	
	if($('#ps-cherep').length == 1) {
		swfobject.embedSWF(src_uw+'/swf/pirate_head_urban_wave_large.swf', 'ps-cherep', 574, 586, "8.0.0", false, false, {allowScriptAccess: 'always', wmode: 'transparent'});
	}
	*/
	
});


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);
            }
            
        }
    });                 
    
    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);
		        	if(!always)
		        	{
		        		$('#user_also_like_block').show();
		        	}
		        }
		    });
		} else
		{
			$('#user_also_like_block').show();
		}
		
	}
	return false;
}


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;
}

