
var config = {
    vars: {
        blankCharHtml: '&nbsp;'
    },
    
    gallery: {
        scrollOffset: 109,
        scrollDuration: 700,
        imagesPerPage: 3
    },
    
    menu: {
        color: '#ffba00'
    }
};



$(document).ready(function(){

    gp.swf.replaceSwf();
    menu.domIsReady();
    colorForm.domIsReady();
    gallery.domIsReady();
    project.domIsReady();
    $('#staff').bind('click', function(){
        $(document).scrollTo({
            top: '0',
            left: '970px'
        }, 500);
    });
    
    $('.checkSearchWrapper').bind('click', function(){
        $('#tx_iportfolio_pi1_searchTagUnselectAll').attr('checked', '');
        $('#tx_iportfolio_pi1_searchTagSelectAll').attr('checked', '');
    });
    
    //searchtag functions
    $('#tx_iportfolio_pi1_searchTagSelectAll').bind('click', function(){
        if (!$(this).attr('checked')) 
            return false;
        $('input', $('#searchTagForm .checkSearchWrapper')).each(function(i, j){
            $(j).attr('checked', 'checked');
        });
        $('#tx_iportfolio_pi1_searchTagUnselectAll').attr('checked', '');
    });
    
    $('#tx_iportfolio_pi1_searchTagUnselectAll').bind('click', function(){
        if (!$(this).attr('checked')) 
            return false;
        $('input', $('#searchTagForm .checkSearchWrapper')).each(function(i, j){
            $(j).attr('checked', '');
        });
        $('#tx_iportfolio_pi1_searchTagSelectAll').attr('checked', '');
    });
    
    
    
    if ($('.customerMenu').is('ul')) {
        $('li ul', $('.customerMenu')).css('display', 'none');
        $('li.selected ul', $('.customerMenu')).css('display', 'block');
        $('li a', $('.customerMenu')).toggle(function(){
            if ($('ul', $(this).parent()).is('ul')) {
                if ($(this).parent().hasClass('selected')) {
                    $(this).parent().removeClass('selected');
                    $(this).parent().addClass('firstSelected');
                    $('ul', $(this).parent()).slideUp();
                }
                else {
                    $('ul', $(this).parent()).slideDown();
                    $(this).parent().addClass('selected');
                }
            }
            else {
                location.href = $(this).attr('href');
            }
        }, function(){
            if ($('ul', $(this).parent()).is('ul')) {
                if ($(this).parent().hasClass('firstSelected')) {
                    $('ul', $(this).parent()).slideDown();
                    $(this).parent().addClass('selected');
                }
                else {
                    $('ul', $(this).parent()).slideUp();
                    $(this).parent().removeClass('selected');
                }
            }
            else {
                location.href = $(this).attr('href');
            }
        });
    }
    
    //openRemoteDataViaAjax('/fileadmin/user_upload/remoteData/test/test.html',563,318);

});


function openRemoteDataViaAjax(url, width, height){

    if ($.browser.msie && $.browser.version < 7) {
		var winTitle = 'MediaRef' + Math.floor(Math.random()*11);
    	window.open(url,winTitle,'width='+width+',height='+height+',toolbar=no, location=no,status=yes,menubar=no,scrollbars=no,resizable=yes');
    }
    else {
        var data = gp.ajax.ajaxRequest(url, '', false, 'GET');
        var top = Math.round(($(window).height() - height) / 2);
        top = $(document).scrollTop() + 50;
        var left = Math.round(($(window).width() - width) / 2);
        $.blockUI({
            message: data,
            css: {
                width: width + 'px',
                height: height + 'px',
                position: 'absolute',
                top: top + 'px',
                left: left + 'px'
            },
            centerX: false,
            centerY: false
        });
        $('.blockOverlay').attr('title', 'Click per chiudere').click($.unblockUI);
        $('.blockOverlay').css({
            cursor: 'default'
        });
        $('.blockMsg').css({
            cursor: 'default'
        });
    }
    
    
}



