var bubble =
{
	bubbleObj: null,
	ref: null,
	productId: null,
	storeId: null,
	identifier: null,
	inCloset: 0,
	loading: '<div align="center"><img src="/images/loading.gif" width="32" height="32" alt="[Cargando...]" title="Cargando..." /><br />Cargando...</div>',
	bubbleCache: new Array(),
	doc: new Array(),
	
	init: function (ref, storeId, productId, inCloset)
	{
		this.docInfo();
		this.element = getObj('dashboard');
		this.element.style.height = $(document).height() + 'px';
		this.show("fast");
		this.inCloset = inCloset ? inCloset : 0;
		
		this.bubbleObj = getObj('bubble');
		this.bubbleContent = getObj('bubbleContent');
		this.storeId = storeId;
		this.productId = productId;
		this.identifier = 'prod-' + storeId + '-' + productId;
		this.element = this.bubbleObj;
		this.ref = ref;
        
        document.location = document.location.href.replace(/#.+$/i, '') + '#t' + storeId + '-p' + productId;
		this.setBubble();
	},
	
	docInfo: function ()
	{
		this.doc['width'] = $(document).width();
		this.doc['height'] = $(document).height();
	},
	
	setBubble: function ()
	{
		var refOffset = $(this.ref).offset();
		
		this.element.style.left = (refOffset.left + ($(this.ref).width() / 4)) + 'px';
		this.element.style.top = refOffset.top - 20 + 'px';
		this.show();
		
		if (!this.bubbleCache[this.identifier])
		{
			$(this.element).animate(
			{
				left: (this.doc['width'] / 2) - 268 + 'px',
				top: $(document).scrollTop() + 10 + 'px',
				opacity: 1,
				width: '536px',
				height: '84px'
			}, 250
			);
		}
		else
		{
			$(this.element).animate(
            { 
				left: (this.doc['width'] / 2) - 268 + 'px',
				top: $(document).scrollTop() + 10 + 'px',
				opacity: 1,
				width: '536px'
			}, 250
			);
		}
		
		//this.bubbleObj.style.left = x + 'px';
		
		this.requestInfo();
	},
	
	requestInfo: function ()
	{
		if (!this.bubbleCache[this.identifier])
		{
			this.bubbleContent.innerHTML = this.loading;
			
			var date = new Date();
			var xh = new XHConn();
			xh.connect('/top_trends/informacionProducto/' + this.storeId + '/' + this.productId + '/' +this.inCloset, 'GET', 'd=' + date.getTime(), this.getInfo);
			xh = null;
		}
		else
			this.setInfo();
	},
	
	getInfo: function (ajax)
	{
		if (ajax.responseText.indexOf('success::') >= 0)
		{
			var bTmp = ajax.responseText.split('::');
            bubble.bubbleCache[bubble.identifier] = bTmp[1];
            bubble.productImage = bTmp[2];
			bubble.setInfo();
		}
		else
		{
			bubble.error();
		}
	},
	
	setInfo: function ()
	{
		this.bubbleContent.innerHTML = this.bubbleCache[this.identifier];
        
        // Configuracion para el AddToAny
        var storeName = $('#bubbleContent a.storelink:first').html();
        var section = $('div.mainContent:first h1.title:first a:first').html();
        
        /* var a2a_config = a2a_config || {}; */
        a2a_config.linkname = storeName + ' - ' + section + ' - Trend*e Shopping Guide';
        a2a_config.linkurl = location.href;
        a2a.init();
        
        /*if (location.href.indexOf('mas_o_menos') == -1)
            a2a_config.linkurl = location.href;
        else
            a2a_config.linkurl = location.href.replace('mas_o_menos', 'tiendas');*/
        
        $(this.element).animate(
		{ 
            height: 261 + $('#bubbleContent div.bubbleImg').children('img:first').attr('height') + 'px'
		}, 250
		);
        
        if (this.bubbleCache[this.identifier].indexOf('productImage') != -1)
        {
            var img = new Image();
            $(img).load(function(){
                $(this).hide();
                $(bubble.element).animate({
                    height: 293 + $(this).attr('height') + 'px'
                }, 150);
                $('#productImage').replaceWith($(this));
                $(this).fadeIn('slow');
                
                var rImg = '<img src="' + $(this).attr('src') + '" width="' + $(this).attr('width') + '" height="' + $(this).attr('height') + '" />';
                bubble.bubbleCache[bubble.identifier] = bubble.bubbleCache[bubble.identifier].replace('<img src="/images/loading.gif" width="32" height="32" alt="[Cargando...]" title="Cargando..." id="productImage" />', rImg);
            }).attr('src', this.productImage);
        }
        
        //if (document.documentElement.scrollTop > 0)
        //    $.scrollTo(0, 500);
	},
	
	addCloset: function ()
	{
		var xh = new XHConn();
		xh.connect('/closet/agregar/' + this.productId + '/' + this.storeId + '/', 'GET', '', this.getInfo);
		xh = null;
	},
	
	error: function ()
	{
		if (getObj('bubble_error'))
		{
			var e = getObj('bubble_error');
			e.parentNode.removeChild(e);
		}
		
		var error = document.createElement('p');
		error.id = 'bubble_error';
		error.appendChild(document.createTextNode('Error al tratar de extraer la informaci�n.'))
		
		this.bubbleContent.appendChild(error);
	},
	
	close: function ()
	{
		var refOffset = $(this.ref).offset();
		
		$(this.element).animate(
		{ 
			left: (refOffset.left + ($(this.ref).width() / 4)) + 'px',
			top: refOffset.top - 20 + 'px',
			opacity: 0,
			width: 0,
			height: 0
		}, 500
		);
		
		this.element = getObj('dashboard');
		loginAlert('close');
		this.hide('slow');
	},
	
    // deprecated
	loginAlert: function (action)
	{
		loginAlert(action);
	}
};

function loginAlert(action, text, obj)
{
    if (action == 'open')
    {
        bubble.docInfo();
        var doc = bubble.doc;
        var warn = getObj('generalalert');
        var o = $(obj).offset();
        
        warn.style.left = (o['left'] - (($('#generalalert').outerWidth() - $(obj).width()) / 2)) + 'px';
        warn.style.top = (o['top'] - (($('#generalalert').outerHeight() - $(obj).height()) / 2)) + 'px';
        
        $('#generalalert span:first').html(text);
        $('#dashboard').css('height', document.documentElement.scrollHeight + 'px').fadeIn();
        $('#generalalert').fadeIn('normal', function(){$(this).removeClass('hide')});
    }
    else if (action == 'close')
    {
        $('#generalalert').fadeOut('fast', function(){$(this).addClass('hide')});
        if (text === true)
            $('#dashboard').fadeOut('fast');
    }
}

function checkIOForm()
{
    if ($('input[name="ionombre"]').val() == '')
    {
        formAlert('input[name="ionombre"]', 'No debe dejar el campo de nombre vac�o.');
        return false;
    }
    
    if ($('input[name="ioemail"]').val() == '')
    {
        formAlert('input[name="ioemail"]', 'No debe dejar el campo de email vac�o.');
        return false;
    }
    
    var email = /^[a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i;
    if (!email.test($('input[name="ioemail"]').val()))
    {
        formAlert('input[name="ioemail"]', 'Debe introducir un email valido.');
        return false;
    }
    
    if (!$('input[name="acepto"]:checked').val())
    {
        formAlert('input[name="acepto"]', 'Debes de aceptar los Términos y Condiciones para enviar imagen.', 5000);
        return false;
    }
    
    if ($('input[name="images"]').val() == '')
    {
        formAlert('input[name="images"]', 'Tienes que especificar una imagen.');
        return false;
    }
    
    var ext = /\.(jpg|jpeg|gif|png|bmp)$/i;
    if (!ext.test($('input[name="images"]').val()))
    {
        formAlert('input[name="images"]', 'Solo se permite enviar im�genes.');
        return false;
    }
    
    return true;
}

function formAlert(ref, text, time)
{
    var o = $(ref).offset();
    if (!time)
        time = 2500;
    
    $('#formalert').html(text).css({'left': o['left'] + 'px', 'top': o['top'] + $(ref).outerHeight() + 5 + 'px'}).fadeIn('fast');
    $(ref).focus();
    
    setTimeout("$('#formalert').fadeOut('fast');", time);
}

var display =
{
	element: null,
	
	show: function (speed)
	{
		//this.element.className = this.element.className.replace('hide', 'show');
		$(this.element).fadeIn(speed);
		$(this.element).toggleClass('hide');
	},
	
	hide: function (speed)
	{
		//this.element.className = this.element.className.replace('show', 'hide');
		$(this.element).fadeOut(speed);
		$(this.element).toggleClass('hide');
	}
}

function login()
{
	if ($("#login").hasClass("hide"))
	{
		if (jQuery.browser.msie)
			$("#login").css('margin-left', $('div.container').offset().left + 550 + 'px')
		$('#dashboard').css('height', document.documentElement.scrollHeight + 'px').fadeIn('fast');
		$('#dashboard').fadeIn("fast", function(){
            $("#login").fadeIn(function(){$('#nickname').focus();}).removeClass("hide");
        });
	}
	else
	{
		$("#login").fadeOut("fast", function(){$('#dashboard').fadeOut();}).addClass("hide");
	}
}

function initPP(carousel)
{
	var imgs = $('#trendecarousel li img');
	
	for (var i = 0; i < imgs.length; i++)
		imgs[i].onclick = switchPPImage;
	
	if (document.location.hash)
	{
		var s = document.location.hash.replace('#', '');
		switchPPImage($('#cin_' + s + ' img:first'));
	}
    else
        switchPPImage($('#cin_1 img:first'));
}

function initMM(carousel)
{
	var imgs = $('#mmcarousel li img');
	
	for (var i = 0; i < imgs.length; i++)
		imgs[i].onclick = switchMM;
}

function initWall(carousel)
{
    var imgs = $('#wallcarousel li img');
    
	for (var i = 0; i < imgs.length; i++)
		imgs[i].onclick = switchWall;
}

function npImage(dir)
{
	var current = parseInt($('#id_current').html());
    var total = parseInt($('#totalimages').attr('value'));
    
    if (dir == 'prev' && current > 1)
	{
		switchPPImage($('#cin_' + (current - 1) + ' img:first'));
	}
    else if (dir == 'prev' && current == 1)
    {
        switchPPImage($('#cin_' + total + ' img:first'));
    }
	else if (dir == 'next' && current < total)
	{
		switchPPImage($('#cin_' + (current + 1) + ' img:first'));
	}
	else if (dir == 'next' && current == total)
	{
		switchPPImage($('#cin_1 img:first'));
	}
    
	return;
}

function switchPPImage(ppObj)
{
	//var s = this.src.replace(/_s\.(jpg|gif|jpeg|png)$/i, '_th.$1');
	if (!$(ppObj).attr('src'))
		ppObj = this;
	
	var s = $(ppObj).attr('src').replace('th_', '');
	
	if (s != $('#id_image img:first').attr('src'))
	{
		var t = $(ppObj).attr('title');
		$('#id_loader').removeClass('hide');
		$('#id_image img:first').fadeOut();
		
		var img = new Image();
		$(img).load(function ()
		{
			$(this).css('display', 'none');
			$('#id_image img:first').replaceWith($(this));
			$('#id_loader').addClass('hide');
			$('#id_people').html(t);
			$(this).css('margin-left', ((600 - $(this).attr('width')) / 2) + 'px');
			$(this).css('margin-top', ((500 - $(this).attr('height')) / 2) + 'px');
			$(this).fadeIn();
		}).attr('src', s);
		
        $('#id_current').html($(ppObj).parent().attr('id').replace('cin_', ''));
		$('#sendpic').html($('#id_current').html());
	}
}

function switchMM()
{
    var id_mm = $(this).parent().attr('id').replace('mmin_', '');
    $('#mm_loader').fadeIn('fast');
    
    jQuery.get('/mas_o_menos/compare/' + id_mm, '', function(data, status){
        if (status == 'success' && data != 'error')
        {
            $('#mm_body').html(data);
            $('#mmdisplay a').tooltip({delay: 0, track: true, showURL: false, extraClass: 'escTooltip'});
        }
        
        $('#mm_loader').fadeOut('fast');
    }, 'html');
}

function switchWall()
{
	var wallObj = this;
	
	var s = $(wallObj).attr('src').replace('th_', '');
	//var s = $(wallObj).attr('src');
	
	if (s != $('#wall_body img:first').attr('src'))
	{
		$('#wall_loader').css('height', $('#wall_body img:first').attr('height'));
        var t = $(wallObj).attr('title');
		$('#wall_loader').removeClass('hide');
		$('#wall_body img:first').fadeOut();
		$('#wall_details div:not(.hide)').fadeOut('normal', function(){$(this).addClass('hide')});
        
		var img = new Image();
		img.onload = function ()
		{
			$(this).css('display', 'none');
            $(this).attr('height', (624/img.width)*img.height);
            $(this).attr('width', 624);
            $('#wall_body').animate({height: img.height});
			$('#wall_body img:first').replaceWith($(this));
			$('#wall_loader').addClass('hide');
			$(this).fadeIn('normal', function(){
                $('#' + $(wallObj).parent().attr('id').replace('wli_', 'wd_')).fadeIn('normal', function(){$(this).removeClass('hide')});
            });
            
		};
        img.src = s;
	}
}

function setSexo(s, d)
{
	getObj('chk_' + d).className = 'chk';
	getObj('sexo_' + d).checked = '';
	
	getObj('chk_' + s).className = 'chk sel';
	getObj('sexo_' + s).checked = 'checked';
}

function setCheck(w)
{
	if (getObj('int_' + w).checked)
	{
		getObj('chk_' + w).className = 'chk';
		getObj('int_' + w).checked = '';
	}
	else
	{
		getObj('chk_' + w).className = 'chk sel';
		getObj('int_' + w).checked = 'checked';
	}
}

function sendPicture()
{
	$('#sendwarn').fadeOut('fast');
	if ($('#sendform').hasClass('hide'))
	{
		$('#sendpic').html($('#id_current').html());
		$('#dashboard').css('height', document.documentElement.scrollHeight + 'px').fadeIn('fast');
		$('#sendform').fadeIn().removeClass('hide');
	}
	else
	{
		$('#dashboard').fadeOut('fast');
		$('#sendform').fadeOut('fast').addClass('hide');
	}
}

function checkSendForm(fObj)
{
	var email = /^[a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i;
	
	if (fObj['nombre'].value == '')
		$('#sendwarn').html('Debes especificar tu nombre para enviar la imagen.').fadeIn();
	else if (fObj['email'].value == '')
		$('#sendwarn').html('Debes especificar el email del destinatario.').fadeIn();
	else if (!email.test(fObj['email'].value))
		$('#sendwarn').html('El email es incorrecto. Favor de revisar.').fadeIn();
	else
	{
		var t = $('#id_info h2:first').html();
		var e = fObj['email'].value;
		var n = fObj['nombre'].value;
		var i = $('#sendpic').html();
		var u = document.location;
		
		var ajax = new XHConn();
		ajax.connect('/picture_perfect/enviar_amigo/', 'POST', '?evento=' + t + '&email=' + e + '&name=' + n + '&url=' + u + '&image=' + i, function(ajax)
        {
            var msg = ajax.responseText.split('::');
            $('#sendmessage').removeClass('sending success error');
            
            if (msg[0] == 'success')
            {
                $('#sendmessage').addClass('success');
                $('#dashboard').fadeOut();
            }
            else if (msg[0] == 'error')
                $('#sendmessage').addClass('error');
            
            $('#sendmessage').html(msg[1]);
            setTimeout("$('#sendmessage').fadeOut('fast');", 3000);
        });
		ajax = null;
        
        $('#sendform').fadeOut('fast').addClass('hide');
        $('#sendmessage').removeClass('success error').addClass('sending');
        $('#sendmessage').html('Enviando <img src="/images/loading_bar.gif" width="128" height="15" alt="..." />').fadeIn();
	}
}

function checkClosetSendForm(fObj)
{
	var email = /^[a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i;
	
	if (fObj['email'].value == '')
		$('#sendwarn').html('Debes especificar el email del destinatario.').fadeIn();
	else if (!email.test(fObj['email'].value))
		$('#sendwarn').html('El email es incorrecto. Favor de revisar.').fadeIn();
	else
	{
		var e = fObj['email'].value;
        
        var ajax = new XHConn();
		ajax.connect('/closet/enviar_amigo/', 'POST', '?email=' + e, function(ajax)
        {
            var msg = ajax.responseText.split('::');
            $('#sendmessage').removeClass('sending success error');
            
            if (msg[0] == 'success')
            {
                $('#sendmessage').addClass('success');
                $('#dashboard').fadeOut();
            }
            else if (msg[0] == 'error')
                $('#sendmessage').addClass('error');
            
            $('#sendmessage').html(msg[1]);
            setTimeout("$('#sendmessage').fadeOut('fast');", 3000);
        });
		ajax = null;
        
        $('#sendform').fadeOut('fast').addClass('hide');
        $('#sendmessage').removeClass('success error').addClass('sending');
        $('#sendmessage').html('Enviando <img src="/images/loading_bar.gif" width="128" height="15" alt="..." />').fadeIn();
	}
}

function initTooltip()
{
	$('#other_events > div').mouseover(function()
	{
		if (jQuery.browser.msie)
		{
			$(this).children('div:first').removeClass('hide');
		}
		else
			$(this).children('div:first').css('margin-left', -($(this).children('div:first').outerWidth()/2) + 38.5 + 'px').removeClass('hide');
	});
	
	$('#other_events > div').mouseout(function(){ $(this).children('div:first').addClass('hide'); });
}

function initPerfilToolTip()
{
    $('#lapiz').mouseover(function(){$('div.editperfil:first').removeClass('hide');});
	$('#lapiz').mouseout(function(){$('div.editperfil:first').addClass('hide'); });
    
    $('#dev').mouseover(function(){$(this).children('div:first').removeClass('hide')});
    $('#dev').mouseout(function(){$(this).children('div:first').addClass('hide')});
}

function selectIO(io)
{
    if (io)
        $('#inout').val(io);
    
    if ($('#inout').val() == 'IN')
    {
        $('#ini').attr('src', '/images/in_button_sx.gif');
        $('#outi').attr('src', '/images/out_button_s.gif');
    }
    else if ($('#inout').val() == 'OUT')
    {
        $('#ini').attr('src', '/images/in_button_s.gif');
        $('#outi').attr('src', '/images/out_button_sx.gif');
    }
}

function getEventInfo(obj)
{
    var url = obj.href;
    $('div#calbox div.mainbg').html('<img src="/images/loading.gif" width="32" height="32" alt="[Loading...]" />');
    $('div#cal-body a.sel').removeClass('sel');
    $(obj).addClass('sel');
    
    var xy = $(obj).offset();
    $('div#calbox').css({'left': xy.left + 55 + 'px', 'top': xy.top + 30 + 'px'});
    $('div#calbox').fadeIn();
    
    jQuery.get(url, '', function(data, status){
        if (status == 'success' && data != 'error')
        {
            $('div#calbox div.mainbg').html(data);
        }
        
        return false;
    }, 'html');
    
    return false;
}

function closeEventInfo()
{
    $('#calbox').fadeOut('normal', function(){$('div#cal-body a.sel').removeClass('sel')});
}

function showDirInfo(dirId)
{
    var d = $('#tienda_' + dirId);
    
    if (d.hasClass('hide'))
        d.slideDown().removeClass('hide');
    else
        d.slideUp('fast').addClass('hide');
    
    return false;
}

//=====================================================================================

function nextGrid()
{
    var current = $('#currentGrid').html() * 1;
    var next = current + 1;
    var total = $('#currentGrid').attr('totalGrids') * 1;
    
    if (next > total)
        next = 1;
    
    $('div.gridPage:first img.next:first').unbind('click', nextGrid);
    $('#ts_tg_' + next).css({'marginLeft': '267px'}).addClass('show');
    $('#ts_tg_' + current).animate({
        'marginLeft': '-257px'
    },
    500,
    function() {
        $(this).removeClass('show');
        $('div.gridPage:first img.next:first').bind('click', nextGrid);
    });
    
    $('#ts_tg_' + next).animate({
        'marginLeft': '0'
    }, 500);
    
    $('#currentGrid').html(next);
}

function prevGrid()
{
    var current = $('#currentGrid').html() * 1;
    var prev = current - 1;
    var total = $('#currentGrid').attr('totalGrids') * 1;
    
    if (prev < 1)
        prev = total;
    
    $('div.gridPage:first img.prev:first').unbind('click', prevGrid);
    $('#ts_tg_' + prev).css({'marginLeft': '-257px'}).addClass('show');
    $('#ts_tg_' + current).animate({
        'marginLeft': '267px'
    },
    500,
    function() {
        $(this).removeClass('show');
        $('div.gridPage:first img.prev:first').bind('click', prevGrid);
    });
    
    $('#ts_tg_' + prev).animate({
        'marginLeft': '0'
    }, 500);
    
    $('#currentGrid').html(prev);
}

function initShoots()
{
    // Cambiado por el jQuery Fancybox
    /*$('div.thumbGrid img').click(function() {
        var url = this.src.match(/(.+\/)th_(.+)/);
        url = url[1] + url[2];
        var width = $('div.shootContent:eq(0)').width();
        var height = $('div.shootContent:eq(0)').height();
        
        $('div.thumbLoader:eq(0)').css({'width': width + 'px', 'height': height + 'px'}).fadeIn();
        
        var shoot = null;
        shoot = new Image();
        $(shoot).load(function(){
            $(this).hide();
            $(this).attr('id', 'shoot');
            
            var w = ($(this).attr('width') * 1) > 360 ? 360 : ($(this).attr('width') * 1);
            var h = $(this).attr('height') * 1;
            
            $('div.thumbLoader:eq(0)').fadeOut('fast');
            $('div.shootContent:eq(0)').animate({
                'width': w + 'px',
                'height': h + 'px'
            });
            $('#shoot').replaceWith($(this));
            $(this).fadeIn();
        });
        $(shoot).attr('src', url);
    }); */
    
    $('div.gridPage:first img.next:first').bind('click', nextGrid);
    $('div.gridPage:first img.prev:first').bind('click', prevGrid);
}

function shootVideo(vtitle, vsrc, vid, vw, vh)
{
    var dw = $(window).width();
    var dh = $(window).height();
    
    $('#videolayer').css({
        'width': vw + 'px',
        'height': vh + 'px',
        'left': ((dw - vw) / 2) + 'px',
        'top': ((dh - vh - 48) / 2) + 'px'
    });
    
    a2a_config.linkname = $('#id_info h2:first').html() + ' - Editorial - Video - Trend*e Shopping Guide';
    a2a_config.linkurl = 'http://' + location.host + location.pathname + '#video';
    a2a.init();
    
    $('#videolayer div.videoTitle:first').html(vtitle);
    $('#videolayer iframe:first').attr('src', '/shootvideo.html?vsrc=' + vsrc + '&vid=' + vid);
    
    $('#dashboard').css('height', $(document).height() + 'px').fadeIn(200, function(){
        $('#videolayer').fadeIn();
    });
}

function closeShootVideo()
{
    $('#videolayer').fadeOut(200, function(){
        $('#videolayer div.videoTitle:first').html('');
        $('#videolayer iframe:first').attr('src', '');
    });
    $('#dashboard').fadeOut();
}

//=====================================================================================

function showMap(storeId)
{
    var dw = $(window).width();
    var dh = $(window).height();
    
    $('#maplayer').css({
        'left': ((dw - 900) / 2) + 'px',
        'top': ((dh - 540) / 2) + 'px'
    });
    $('#maplayer iframe:first').attr('src', '/escaparate/tienda_mapa/' + storeId);
    
    $('#dashboard').css('height', $(document).height() + 'px').fadeIn(200, function(){
        $('#maplayer').fadeIn();
    });
}

function closeMap()
{
    $('#maplayer').fadeOut(200, function(){
        $('#maplayer iframe:first').attr('src', '');
    });
    $('#dashboard').fadeOut();
}

//=====================================================================================

function getObj(element)
{
	if (typeof element == 'string')
		element = document.getElementById(element);
	
	return element;
}

Object.extend = function(destination, source)
{
  for (var property in source)
    destination[property] = source[property];
  return destination;
};

function closetHelp()
{
	if ($('#queescloset').hasClass('hide'))
		$('#queescloset').fadeIn().removeClass('hide');
	else
		$('#queescloset').fadeOut('fast').addClass('hide');
}

function checkEnteraste(s)
{
    if (s.value == -1)
        $(s).after('<br /><input type="text" name="enteraste_otro" size="30" class="ins required" />').next().next().focus();
    else
        $(s).next().remove();
}

Object.extend(bubble, display);

jQuery(document).ready(function() {
    var userOSAgent = navigator.userAgent.toLowerCase();
    if (/mac/.test(userOSAgent))
        $('head:first').append('<link rel="stylesheet" href="/css_engine/custom_styles/mac.css" type="text/css" />');
});