var view = {
    view_phone: function(ev) {
        ev.preventDefault();
        var _this = this;
        $(this).text('Getting Phone # . . .')
            .unbind('click', view.view_phone);
        site.style_buttons(this);
        var id = $('#id').val();

        function finish(val) {
            $(_this).removeClass('btn')
                .removeClass('orange').text('Phone: ' + val);
        }

        function error() {
            $(_this).text('Error Getting Phone, Click to Try Again')
                .click(view.view_phone);
            site.style_buttons(_this);
        }

        $.ajax({
            type: 'POST',
            url: '/index.php/profile/get_phone/' + id,
            success: finish,
            error: error,
            dataType: 'json'});
    },

    view_calendar: function(ev) {
        $('#calendar_display').animate({opacity: 'show'});
        //ie6 hacks XXX put this in js that can be included in the relevant pages and only call it for ie6
        $('legend>span,#footer').css('position', 'relative')
        $('legend>span,#footer').css('position', 'absolute')
    },

    init: function() {
        $('#view_phone').click(view.view_phone);
        $('#calendar_display.public').hide();
        $('#view_calendar').click(view.view_calendar);
    }
}
$(document).ready(view.init);

$(document).ready(function(){
	$('#btnEmailProfile').colorbox(
	{
		width:"363px",
		inline:true,
		href:"#EmailProfileDIV",
		onComplete:function(){ $('#EmailProfileDIV').css('visibility', 'visible'); },
		onClosed:function(){ $('#EmailProfileDIV').css('visibility', 'hidden'); }
	});
	$('#UpgradeToPro').colorbox(
	{
		width:"363px",
		inline:true,
		href:"#UpgradeDIV",
		onComplete:function(){ $('#UpgradeDIV').css('visibility', 'visible'); },
		onClosed:function(){ $('#UpgradeDIV').css('visibility', 'hidden'); }
	});
	$('#EmailProfileDIV, #UpgradeDIV').css('visibility', 'hidden');
});

function goUrl(obj)
{
	window.location = $(obj).prev().val();
}
function ForwardProfileToEmail(id)
{
	var oVars = {'email' : $('#tbForwardEmail').val()};
	$.post('/index.php/profile/forward/' + id, oVars);
	$.fn.colorbox.close();
}
function AddToFavorites(id, bLoggedIn)
{
	if(!bLoggedIn)
	{
		alert('Your not logged in. Employers, Pilots and Flight Attendants can mark a profile as their favorite so they can easily find that person again.');	
	}
	else
	{		
		$.post('/index.php/profile/favorite/' + id, {});
		$('#btnAddFavorite img').attr('src', '/Library/Images/icon_favorite.png'); 
	}
}

