$(document).ready(function() {
    $(this).run();
});

jQuery.fn.run = function() {

    var context = this;
    
    $.ifixpng('/images/blank.gif');
    $('*', context).ifixpng();
    
    $('input[type=text], input[type=password], input[type=file]', context).addClass('text');
    $('input[type=button], input[type=submit], input[type=reset]', context).addClass('button');
    
    $('.focus-blur', context).each(function() {
        var val = $(this).val();
        $(this).bind('focus', function() {
            if ($(this).val() == val) {
                $(this).val('');
            }
        });
        $(this).bind('blur', function() {
            if ($(this).val() == '') {
                $(this).val(val);
            }
        });
    });
    
    $('.form-submit', context).click(function() {
        $(this).parents('form').submit();
        return false;
    });
    
    $('a[href$=.jpg],a[href$=.png],a[href$=.gif],a[href$=.JPG],a[href$=.PNG],a[href$=.GIF]', context).each(function() {
        $(this).fancybox({'titlePosition':'inside','overlayShow':true,'centerOnScroll':true});
    });
    
    $('table.tech', context).attr('border', '0');
    $('table.tech > tbody > tr:even', context).addClass('even');
    $('table.tech > tbody > tr:odd', context).addClass('odd');
    
    $('.good .thumb a', context).unbind('click');
    
    $('.good .thumb a', context).click(function() {
        $(this).addClass('active').siblings().removeClass('active');
        $('.good .small a').eq($(this).index()).addClass('active').siblings().removeClass('active');
        return false;
    });
    
    $('.ajax form', context).submit(function() {
        $.fancybox.showActivity();
        $ajax = $(this).parents('.ajax');
        $form = $(this);
        $form.ajaxSubmit({
            'data': {
                'isNaked':1,
                'REQUESTED_FROM':window.location.pathname
            },
            'complete':function(data) {
                $temp = $("<div></div>").html("<div class='ajax'>" + data.responseText + "</div>");
                $temp.run();
                $ajax.replaceWith($('.ajax', $temp));
                $.fancybox.hideActivity();
            }
        });
        return false;
    });
    
    return this;

};

