/*
 * Campaign-specific stuff can be included here
 *
 */



// To allow cross-frame or cross-browser scripting 
//document.domain = 'movember.dm';

var fancyboxSettings = {
    autoDimensions: false,
    padding: 20,
    width: 610
};


// Setup the search box background to disappear when focussed or containing a search term...
$(function(){
    $( '#hd_search-input' ).focus( function() { $( this ).addClass( 'focus' ) } );
    $( '#hd_search-input' ).blur( function() {
        var value = $( this ).val();
        //alert( 'value is:' + value + '::' );
        if( value == '' )
            $( this ).removeClass( 'focus' );
    });

    if($('.other-email-client').length > 0) {
        $('.other-email-client').each(function(){
            $(this).click(function() {
                if ( $(this).hasClass( 'spread-word' ) ) {
                    $('#emailDonate').show();
                    fancyboxSettings.height = 380;
                    $('#emailDonate').fancybox(fancyboxSettings).trigger('click');
                }
                else if ( $(this).hasClass( 'spread-gala' ) ) {
                    $('#emailSpreadGala').show();
                    fancyboxSettings.height = 380;
                    $('#emailSpreadGala').fancybox(fancyboxSettings).trigger('click');
                }
            });
        });
    }

    $('a.future').removeAttr('href');
	$('a.stepDisabled').removeAttr('href');
});



 
if (typeof Samurai == 'undefined') Samurai = {};

$.extend(Samurai, {

    /** 
     * Load samurai text via ajax 
     *
     * Place holder can be a type of jquery dom element or an element id
     *  
     * @param string/int id
     * @param DOMid placeholder The element you want to update
     * @param function callback Anonymous function that will be evaluated on response from the server. The response is passed as a param to the anonymous function also.
     */
    loadText: function (id, placeholder, callback) {
        var targetElm = null;
        
        if ( typeof placeholder == 'object' )
            targetElm = placeholder
        else if ( typeof placeholder == 'string' )
            targetElm = $('#'+placeholder);
        else
            return false;
        
        $.getJSON( baseUrl + 'campaign/samurai/load-text/id/' + id,
            function(jsonObj){
                if( jsonObj )
                {
                    targetElm.html(jsonObj.text);

                    if ( typeof SamuraiCms != 'undefined' )
                    {
                        $( ".sm-js-cmsitem_editable" ).samurize();
                    }
                    
                    // callback evaluated if available, jsonObj passed as param
                    if ( typeof callback == 'function' )
                    {
                        eval( callback( jsonObj ) );
                    }
                }
            }
        );
    }
});



function stepsCleanUp()
{
    if ($('a.future').length == 0)
    {
		$('.steps a').removeAttr('href');
        $('.steps a').addClass('stepDisabled');
    }
	else
		$('a.future').removeAttr('href');
}

/**
 * Redirect the user to the required News items
 */
function goNewsItem(id, target)
{
    if( target )
        window.open( baseUrl+'news/view/id/'+id );
    else
        window.location = baseUrl + 'news/view/id/'+id;
}

