$(document).ready(function(){
    
    //upload
    $("span.removeFile").live('click', function(){
        $(this).parent("div").remove();
    });
    
    $("input.multiUpload").livequery('change', function(){
        var max_files = $("input[name='max_num_files']").val();
        
        if($("input.multiUpload").length > max_files){
            $(this).parent('div').clone(true).insertAfter($(this).parent('div'));
            $(this).remove();
            $(this).parent('div').append("<span>"+ $(this).val() +"</span><span class='removeFile'></span>")
            alert("You have reached the limit.");
        }else{
            $(this).parent('div').clone(true).insertAfter($(this).parent('div'));
            $(this).hide();
            $(this).parent('div').append("<span>"+ $(this).val() +"</span><span class='removeFile'></span>")
        }
    });
    
    $("input[type='text'], input[type='password']").addClass('text');
    $("select").addClass('select');
    
    $("div.captcha a").click(function() {
        $(this).blur();
    });
    $("* a").click(function() {
        $(this).blur();
    });
    
    $('li').livequery(function(){ 
        $(this) 
            .hover(function() { 
                $(this).addClass('hover'); 
            }, function() { 
                $(this).removeClass('hover'); 
            }); 
    }, function() {
        $(this) 
            .unbind('mouseover') 
            .unbind('mouseout'); 
    });
    
    //gallery
    $().piroBox({
        my_speed: 300, //animation speed
        bg_alpha: 0.5, //background opacity
        radius: 4, //caption rounded corner
        scrollImage : true, // true == image follows the page _|_ false == image remains in the same open position
        // in some cases of very large images or long description could be useful.
        slideShow : 'true', // true == slideshow on, false == slideshow off
        slideSpeed : 3, //slideshow 
        pirobox_next : 'piro_next', // Nav buttons -> piro_next == inside piroBox , piro_next_out == outside piroBox
        pirobox_prev : 'piro_prev', // Nav buttons -> piro_prev == inside piroBox , piro_prev_out == outside piroBox
        close_all : '.piro_close' // add class .piro_overlay(with comma)if you want overlay click close piroBox
    });
    
});