/// ----------------------------------------------------------------------------
/// --- All elements copyright (c) 2002 - 2008 by
/// --- SFW - Stefan Falz Webconsulting
/// --- http://www.asp-solutions.de/
/// --- 
/// --- Unauthorized use is strongly prohibited
/// ----------------------------------------------------------------------------
/// --- Frontend JavaScript functions
/// ---
/// --- Created on: 24.04.2007 von SFW (SF)
/// ----------------------------------------------------------------------------
/// --- Last changed on  : 17.06.2007
/// --- Last changed from: SF
/// --- Reason           : Inserted several functions
/// ---                    - changeColor
/// ---                    - highlightItem
/// ---                    - gotoPage
/// ---                    - changeVideo
/// ---
/// --- Last changed on  : 20.11.2007
/// --- Last changed from: SF
/// --- Reason           : Inserted several functions
/// ---                    - activateFlash
/// ---                    - activateMedia
/// ---
/// --- Last changed on  : 15.02.2008
/// --- Last changed from: SF
/// --- Reason           : Changed code
/// ----------------------------------------------------------------------------

var currentArticle = 0;

/// <summary>
/// Changes color of preview images
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	17.06.2007	Created
/// </history>
function changeColorFrontend( control, newColor )
    {
    for( i = 0; i < control.childNodes.length; i++ )
        {
        try
            {
            if( control.childNodes[ i ].id.indexOf( "PreviewImageMarker" ) >= 0 )
                {
                if( control.childNodes[ i ].className != "PreviewImageMarkerActive" )
                    {
                    control.childNodes[ i ].style.backgroundColor = newColor;
                    }
                break;
                }
            }
        catch( ex )
            {
            a=0;
            }
        }
    }

/// <summary>
/// Sets article details data
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	28.02.2007	Created
/// </history>
function setArticleData( articleId )
    {
    }

/// <summary>
/// Highlights active item
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	17.06.2007	Created
/// </history>
function highlightItem( articleId )
    {
    // reset previous highlighted items
    var controls = document.getElementsByTagName( "div" );

    for( i = 0; i < controls.length; i++ )
        {
        if( controls[ i ] )
            {
            if( controls[ i ].id.indexOf( "PreviewImageMarker" ) >= 0 )
                {
                controls[ i ].className = "PreviewImageMarker"
                }
            }
        }

    // highlight current item
    if( document.getElementById( "PreviewImageMarker|" + articleId ) )
        {
        document.getElementById( "PreviewImageMarker|" + articleId ).className = "PreviewImageMarkerActive";
        }
    }

/// <summary>
/// Changes current location
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	17.06.2007	Created
/// </history>
function gotoPage( Url )
    {
    self.location.href = Url;
    }

/// <summary>
/// Switch player control to fullscreen mode
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	17.06.2007	Created
/// </history>
function switchToFullscreen()
    {
    if( document.getElementById( "Player" ).playState == "3" )
        {
        alert( "Die Anwendung wechselt nun in den Vollbildmodus. Drücken Sie \"ESC\", um zur normalen Anzeige zurückzuwechseln.\n\nThe video now switches to fullscreen mode. With \"ESC\" you can return to the default view." );
        document.getElementById( "Player" ).fullScreen = true;
        }
    }

/// <summary>
/// Starts playback of a specific video
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	17.06.2007	Created
/// </history>
function playVideo( videoId )
    {
    var videoUrl;
    
    switch( videoId )
        {
        case 1: videoUrl = ""; break;
        case 2: videoUrl = ""; break;
        case 3: videoUrl = ""; break;
        case 4: videoUrl = ""; break;
        case 5: videoUrl = ""; break;
        }
        
    document.getElementById( "Player" ).controls.stop();
    document.getElementById( "Player" ).url = videoUrl;
    document.getElementById( "Player" ).controls.play();
    }

/// <summary>
/// Inserts and activates flash content
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	20.11.2007	Created
/// </history>
function activateFlash( Movie, BgColor, Id, Class )
    {
    if (AC_FL_RunContent == 0)
        {
        alert("Diese Seite erfordert die Datei \"AC_RunActiveContent.js\".");
        }
    else
        {
        AC_FL_RunContent(
	        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
	        'width', '100%',
	        'height', '100%',
	        'src', Movie,
	        'quality', 'high',
	        'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
	        'align', 'middle',
	        'play', 'true',
	        'loop', 'true',
	        'scale', 'exactfit',
	        'wmode', 'opaque',
	        'devicefont', 'false',
	        'bgcolor', BgColor,
	        'id', Id,
	        'class', Class,
	        'name', 'Layout',
	        'menu', 'true',
	        'allowFullScreen', 'false',
	        'allowScriptAccess','sameDomain',
	        'movie', Movie,
	        'salign', '' ); //end AC code
        }
    }

/// <summary>
/// Inserts and activates windows media content
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	20.11.2007	Created
/// </history>
function activateMedia( PlayerId, Movie, AutoStart, FullScreen, ShowControls, StretchToFit, ShowTracker, ShowDisplay, ShowGotoBar, ShowAudioControls, ShowPositionControls, ShowStatusBar, TransparentAtStart, AnimationAtStart, AllowChangeDisplaySize, EnableContextMenu )
    {
    var ContainerContent  = "<object id='" + PlayerId + "' width='100%' height='100%' classid='CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6' data='" + Movie + "' type='application/x-oleobject'>";
        ContainerContent += "<param name='AutoStart'              value='" + AutoStart + "' />";
        ContainerContent += "<param name='FullScreen'             value='" + FullScreen + "' />";
        ContainerContent += "<param name='FileName'               value='" + Movie + "' />";
        ContainerContent += "<param name='URL'                    value='" + Movie + "' />";
        ContainerContent += "<param name='ShowControls'           value='" + ShowControls + "' />";
        ContainerContent += "<param name='StretchToFit'           value='" + StretchToFit + "' />";
        ContainerContent += "<param name='ShowTracker'            value='" + ShowTracker + "' />";
        ContainerContent += "<param name='ShowDisplay'            value='" + ShowDisplay + "' />";
        ContainerContent += "<param name='ShowGotoBar'            value='" + ShowGotoBar + "' />";
        ContainerContent += "<param name='ShowAudioControls'      value='" + ShowAudioControls + "' />";
        ContainerContent += "<param name='ShowPositionControls'   value='" + ShowPositionControls + "' />";
        ContainerContent += "<param name='ShowStatusBar'          value='" + ShowStatusBar + "' />";
        ContainerContent += "<param name='TransparentAtStart'     value='" + TransparentAtStart + "' />";
        ContainerContent += "<param name='AnimationAtStart'       value='" + AnimationAtStart + "' />";
        ContainerContent += "<param name='AllowChangeDisplaySize' value='" + AllowChangeDisplaySize + "' />";
        ContainerContent += "<param name='EnableContextMenu'      value='" + EnableContextMenu + "' />";
        ContainerContent += "</object>";

        document.getElementById( 'Video' ).innerHTML = ContainerContent;
    }

/// <summary>
/// Logs the current request
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	15.02.2008	Created
/// </history>
function sendState( ArticleId )
{
var randomId = Math.random();
    document.getElementById( 'StatusImage' ).src = "/Handler/State.ashx?ArticleId=" + ArticleId + "&Random=" + randomId;
}

/// <summary>
/// initiates quick search
/// </summary>
/// <remarks></remarks>
/// <history>
/// 	[Stefan Falz]	28.05.2010	Created
/// </history>
function search( searchControl )
{
    this.location.href = "/Search.aspx?SearchTerm=" + document.getElementById( searchControl ).value;
    return false;
}

$(document).ready(function() {
    $('img.Thumbnail').click(function() {

    var BigImageUrl = new String();
        BigImageUrl = this.getAttribute('longdesc');

        if( BigImageUrl == null || BigImageUrl == "" )
        {
            BigImageUrl = this.getAttribute('src');
            BigImageUrl = BigImageUrl.replace( "\.jpg", "-gross.jpg" );
        }

        return hs.expand(this,
                {
                    src: BigImageUrl,
                    outlineType: 'rounded-white',
                    fadeInOut: false
                });
    });
});


