/*!

(c) Xenario GmbH - All rights reserved.

Common javascript for design enhancements.

@author Jean-François Müller (mueller at xenario dot de)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/* making links unfocused after click */
$('a').live('click',
    function()
    {
        this.blur();
    }
    );


// If a captcha is found, make it regenerateable
$(function(){
    $(".refreshIBCaptcha").each(function(){
        var attributeID   = this.id.replace(/refreshIBCaptcha/, "");
        var regenerateIRL = $("#IBCaptchaRefreshUrl"+attributeID).val();
        $(this).click(function() {
            $( '#IBCaptcha' + attributeID ).attr( 'src', false );
            $( '#IBCaptcha' + attributeID ).attr( 'src', regenerateIRL + '/' + Math.round((Math.random()*(9999999-99999))+99999));
            return false; // prevent page reload
        } );

        $(this).click();
    });
});

/* initiates the popdiv */
var MoreInformationPopup = null;
$(function(){

    $("#moreinformation-pop").click(function(){

        if(MoreInformationPopup){
            MoreInformationPopup.show();
            return false;
        }

        MoreInformationPopup = new PopDiv("more-information-popdiv");
        $.ajax({
            url: $(this).attr("href"),
            async: true,
            contentType: "html",
            success: function(data){
                MoreInformationPopup.setContent($(data).find(".col1").removeAttr("col1"));
                MoreInformationPopup.setWidth(630);
                MoreInformationPopup.setHeight(500);
                MoreInformationPopup.show();
            }
        });

        return false; // disabling the link
    });
});

var ImprintPopup = null;
$(function(){

    $("#imprint-pop").click(function(){

        if(ImprintPopup){
            ImprintPopup.show();
            return false;
        }

        ImprintPopup = new PopDiv("imprint-popdiv");
        $.ajax({
            url: $(this).attr("href"),
            async: true,
            contentType: "html",
            success: function(data){
                ImprintPopup.setContent($(data).find(".col1").removeAttr("col1"));
                ImprintPopup.setWidth(630);
                ImprintPopup.setHeight(500);
                ImprintPopup.show();
            }
        });

        return false; // disabling the link
    });
});

/*
	Simple Focus Handler's
	@params: target - InputField, initialValue
 */
function handleInputFocus( target, initialValue )
{
    if ( target.value == initialValue )
    {
        target.value = '';
    }
}

function handleInputBlur( target, initialValue )
{
    if ( target.value == '' )
    {
        target.value = initialValue;
    }
}

jQuery(function(){
    if(jQuery.isFunction(jQuery.fn.minigallery)){
        jQuery("body").minigallery({
            // callback processor which adapts the src attribute accordingly for the full preview image
            srcProcessor: function(src){
                return src.replace(new RegExp("thumb\."), ".");
            },
            // optional
            hideAnimation: {
                opacity: "hide"
            },
            // optional
            showAnimation: {
                opacity: "show"
            }
        });
    }
});

/*  auskommentiert weil flash-ladezeit zu lang um auf ready zu warten
    lable nicht als suche absenden

$(function(){
	$("#officesearch .zip").labelin();
    $("#personsearch .person").labelin();
});

*/

