var flashIt = true;

function navigateToURL( whichURL )
{
    window.location.href( whichURL );
}

function playVideo( whichVid )
{
    $( "html, body" ).animate( {scrollTop:0}, 1000 );
    $( '#VP10' )[0].playVideoFromJavaScript( whichVid );
}

function clean( user, domain, subject )
{
    var subjectLine = (subject != undefined) ? "?subject=" + subject : "";
    window.location = "mailto:" + user + "@" + domain + subjectLine;
}

function tweet()
{
    jQuery( function( $ )
    {
        $( ".tweet" ).tweet( {
            username: "spiritualution",
            join_text: "auto",
            avatar_size: 25,
            count: 10,
            auto_join_text_default: "@spiritualution:",
            auto_join_text_ed: "@spiritualution:",
            auto_join_text_ing: "@spiritualution:",
            auto_join_text_reply: "@spiritualution:",
            auto_join_text_url: "@spiritualution:",
            loading_text: "loading tweets..."

        } ).bind( "loaded", function() {$( this ).find( "a" ).attr( "target", "_blank" );} );
    } );
}

function loadPrettyPhotoGallery()
{
    $( document ).ready( function()
    {
        $( "a[rel^='prettyPhoto']" ).prettyPhoto( {overlay_gallery:true, theme:'dark_rounded'} );
    } );
}

function loadPrettyPhotoVideo()
{
    $( document ).ready( function()
    {
        $( "a[rel^='prettyPhoto']" ).prettyPhoto( { slideshow:false} );
    } );
}

function loadSocialShare()
{
    $(document).ready(function() {
    $('#social-share').dcSocialShare({
        location: 'bottom',
        align: 'left',
        offsetLocation: 30,
        offsetAlign: 30,
        width: 70,
        center: true,
        centerPx: 577,
        speedContent: 600,
        speedFloat: 1600,
        disableFloat: true,
        buttons: 'facebook,twitter,digg,stumbleupon,buzz'
    });
});
}

/*function validate( whichForm )
{
    if ( $( whichForm ).validationEngine( 'validate' ) )
    {
        $( whichForm ).submit();
    }
}*/

/*function loadValidators()
{
    $( document ).ready( function()
    {
        $( 'form' ).each( function()
        {
            $( this ).validationEngine( 'attach' );
        } );

    } );
}*/

function getLiveStreamStatus()
{
    $.ajax( {
        type: "POST",
        url: "/libs/php/get_ustream_status.php",
        success: statusReponse
    } );
}

function statusReponse( info )
{
    if (info == 'offline')
        return;

        $('#liveStreamImg').attr("src",'/view/images/graphics/occupy_congress_live.jpg');
        $('#liveStreamImg').css('margin-top','-115px');
        flashGraphic();
        if (flashIt)
            window.setInterval( flashGraphic, 20000 );

}

function flashGraphic()
{
    $('#liveStreamImg').css('margin-top','0px');
        var interval = window.setInterval( flashGraphicBack, 1000 );

        function flashGraphicBack()
        {
            $('#liveStreamImg').css('margin-top','-115px');
            clearInterval( interval );
        }
}

function dontFlash()
{
    flashIt = false;
}
