/**
 * p24Win javascript file
 *
 * @since 26.12.2010
 * 
 *
 *
 */
jQuery(document).ready(function($) {

    /**
     * Footer scroller (sponsors)
     *
     * @since 26.12.2010
     * 
     *
     *
     */
    if ( parseInt( $( '#p24WinContent' ).css( 'width' ) ) > 850 )
    {
        $("#p24WinFooterSponsorsHelper").amazon_scroller({
            scroller_title_show: 'disable',
            scroller_time_interval: '10000',
            scroller_window_padding: '0',
            scroller_border_size: '0',
            scroller_border_color: '#000',
            scroller_images_width: '148',
            scroller_images_height: '43',
            scroller_title_size: '11',
            scroller_title_color: '#ccc',
            scroller_show_count: '4',
            directory: 'images'
        });
    }
    else 
    {
        $("#p24WinFooterSponsorsHelper").amazon_scroller({
            scroller_title_show: 'disable',
            scroller_time_interval: '10000',
            scroller_window_padding: '0',
            scroller_border_size: '0',
            scroller_border_color: '#000',
            scroller_images_width: '148',
            scroller_images_height: '43',
            scroller_title_size: '11',
            scroller_title_color: '#ccc',
            scroller_show_count: '3',
            directory: 'images'
        }); 
    }
    
    /**
     * color selector
     *
     * @since 28.12.2010
     *
     *
     *
     */

    try {
    	background = jQuery( '#p24WinSelectionElementLink1' ).css( 'background-image' );
    	jQuery( '#p24WinSelectionElementLink1' ).css( 'background-image', background.replace(  '.jpg' , '_selected.jpg' ) );
    } catch(e) {
    	
    }
	    
    $("li.p24WinSelectionElement a").mouseover( function() {
        selectedValue = 'p24WinSelectionElementLink' + $( this ).parent().parent().next().val();
        
        if ( selectedValue != this.id )
        {
            background = $( this ).css( 'background-image' );
            $( this ).css( 'background-image', background.replace( '.jpg', '_selected.jpg' ) );
        }
    });

    $("li.p24WinSelectionElement a").mouseout( function() {
        selectedValue = 'p24WinSelectionElementLink' + $( this ).parent().parent().next().val();

        if ( selectedValue != this.id )
        {
            background = $( this ).css( 'background-image' );
            $( this ).css( 'background-image', background.replace( '_selected.jpg', '.jpg' ) );
        }
    });

    /**
     * Coreg
     *
     *
     */
    try {
        if ( $( '#fld_COREG_QUESTION' ) )
        {
            layerHeight = $( '#fld_COREG_QUESTION' ).height();
            $( '#btn_BTN_SUBMIT2' ).css( 'margin-top', layerHeight + 20 );
            $( '#fld_COREG_QUESTION' ).css( 'top', '307px' );
            $( '#fld_COREG_QUESTION' ).css( 'left', '-320px' );
            $( '#fld_COREG_QUESTION' ).css( 'display', 'block' );
        }
    } catch (e) {

    }
    
    /**
     * CoReg
     * 
     *
     *
     */
    $( '.p24win_coreg_box_element_terms_link' ).click( function() {
        objText = $( this ).parent().next();
        $( objText ).css( 'display', 'block' );
    });
    
    $( '.p24win_coreg_box_element_terms_textclose' ).click( function() {
        $( this ).parent().parent().css( 'display', 'none' );
    });
});

/**
 * color selection onclick handler
 *
 * @since 02.01.2011
 *
 * 
 * 
 */
var colorSelect = function( el, elementId, selectionValue )
{
    jQuery( '#' + elementId ).val( selectionValue );

    if ( el.id != 'p24WinSelectionElementLink1' )
    {
        background = jQuery( '#p24WinSelectionElementLink1' ).css( 'background-image' );
        jQuery( '#p24WinSelectionElementLink1' ).css( 'background-image', background.replace( '_selected.jpg', '.jpg' ) );
    }

    if ( el.id != 'p24WinSelectionElementLink2' )
    {
        background = jQuery( '#p24WinSelectionElementLink2' ).css( 'background-image' );
        jQuery( '#p24WinSelectionElementLink2' ).css( 'background-image', background.replace( '_selected.jpg', '.jpg' ) );
    }

    if ( el.id != 'p24WinSelectionElementLink3' )
    {
        background = jQuery( '#p24WinSelectionElementLink3' ).css( 'background-image' );
        jQuery( '#p24WinSelectionElementLink3' ).css( 'background-image', background.replace( '_selected.jpg', '.jpg' ) );
    }
}

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