/**
 * Shaken & Stirred - modal.js
 *
 * Core javascript library
 *
 * @author Daniel Mullin daniel@nuguru.com
 * @author Brent McDowell brent@nuguru.com
 * @version 0.1
 * @todo ???
 */

$().ready(function()
{
	shakenAndStirred ()
});

/**
 * shakenandstirred - shaken-and-stirred.js - userLogout()
 * 
 * Logout.
 *
 * @author Brent McDowell brent@nuguru.com
 * @author Daniel Mullin daniel@nuguru.com
 * @version	1.0
 * @todo 	UAT
 * 
 * @param void
 * 
 * @return void
 */
function userLogout()
{
	if($.ajax({type: "GET", url: 'http://' + document.location.hostname + '/api/users/logout', async: false}).responseText == 'true')
	{
		window.location = 'http://' + document.location.hostname;
	}
	else
	{
		alert('Sorry! An error occurred, please try again!');
	}
}

function loginJoinModal() 
{
	
    // join modal
    $('.nav-join').click(function(e){  
    	
    	e.preventDefault();
    	
        $('#modal-join').jqm({modal : true, overlay: 90}).jqmShow();
        return false;
    }); 
    
    // login modal
    $('#nav-login').click(function(){                           
        $('#modal-login').jqm({modal : true, overlay: 90}).jqmShow();
            return false;
    }); 

}

function logoutModal() 
{
	
    $('#nav-logout').click(function(){                           
        userLogout();
        return false;
    });
    // edit modal
    $('#edit').click(function(){                           
        $('#modal-edit').jqm({modal : true, overlay: 90}).jqmShow();
        return false;
    }); 
}

function ageVarification() 
{
	// age verification
    $('#modal-age-verification').jqm({modal : true, overlay: 90}).jqmShow(); 
}

function shakenAndStirred () 
{
	
    $("body").css('backgroundImage', 'url(' + BODY_BACKGROUND_IMAGE + ')').css('background-repeat', 'no-repeat').css('background-position', 'center 42px');
	
    $('.modal-close').click(function() {
        $(this).parent().jqmHide();
    });
    
}
