$( document ).ready( function() {
        if ( $( "#image li img" ).size() )
        {
                $( "#image li img" ).bind( "click", function( e ) {
                    $( '#bigpic' ).attr( 'src', $( this ).attr( 'src' ).replace( /-tiny/, '-medium' ) );
                    var s = $( '#bigpic' ).attr( 'src' ).match( /([^\/]+)-medium(\.\w{3})$/i );
                    if ( $( "#enlarge" ) )
                    {
                        $( "#enlarge" ).attr( 'href', $( "#enlarge" ).attr( 'href' ).replace(/(&show=).*?$/, "$1" + s[1] + s[2] ) );
                    }
                    e.preventDefault();
                    return false;
                } );
        }
    if ( $( "#modeltabs" ) )
    { // main tabbed
        $( "#modeltabs li" ).bind( "click", function( k, v ) {
                $( this ).bind( 'click', function( e ) {
                        $( "#modeltabs li" ).removeClass( "active" );
                        $( "[id^=group]" ).removeClass( "current" );
                        $( this ).addClass( "active" );
                        $( '#group' + $( this ).attr( "group" ) ).addClass( "current" );
                    e.preventDefault();
                    return false;
                } );
        } );
    }
    var m;
    if ( m = document.location.toString().match( /#(.*)$/ ) ) {

        $( '#' + m[1] ).parent().parent().addClass( "highlight" );
    }
    if ( $( '#review' ) )
    {
        $( '#review' ).bind( "submit", function( e ) {
            if ( !$( "#clientphone" ).val().length && !$( "#clientmail" ).val().length )
            {
                $( "#misswhat" ).html( "контактный телефон» или «электронный адрес" );
                $( "#error1" ).show();
                $( "#error2" ).hide();
                if ( $( "#error3" ) )
                        $( "#error3" ).hide();
            }
            else if ( !$( "#clientreview" ).val().length )
            {
                $( "#misswhat" ).html( "отзыв" );
                $( "#error1" ).show();
                $( "#error2" ).hide();
                if ( $( "#error3" ) )
                        $( "#error3" ).hide();
            }
            else if ( !$( "#captcha" ).val().length )
            {
                $( "#error1" ).hide();
                $( "#error2" ).show();
                if ( $( "#error3" ) )
                        $( "#error3" ).hide();
            }
            else
            {
                return true;
            }
            return false;
        } );
    }
} );

function showPicWin(sHref, iW, iH)
{
    popupWin = window.open(sHref, 'Image', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+(iW+47)+',height='+(iH+70)+',screenX=150,screenY=150,top=150,left=150');
    popupWin.focus();
}
