//as
jQuery(function(){
    /************************/
    /***********************/
    /*
     
     */
    if (jQuery.browser.version != '6.0') { // commented
/*        jQuery("#submenu a.sel").corner("7px");
        jQuery("#mainArea .steps div").corner("5px");
        jQuery(".infoBox").corner("10px");
        jQuery(".helpBox").corner("7px");
        jQuery(".errorBox").corner("10px");*/
    }
    
    jQuery.fn.disable = function(){
        jQuery(this).attr('disabled', 'disabled')
        jQuery(this).addClass('disabled');
        return this;
    }
    jQuery.fn.enable = function(){
        jQuery(this).attr('disabled', '');
        jQuery(this).removeClass('disabled');
        
        return this;
    }
    jQuery.fn.showhide = function(status){
        return (status) ? (jQuery(this).show()) : (jQuery(this).hide());
    }
    jQuery.fn.check = function(){
        return jQuery(this).attr('checked', 'checked');
    }
    jQuery.fn.uncheck = function(){
        return jQuery(this).attr('checked', '');
    }
    jQuery.fn.count = function(){
        return jQuery(this).length;
    }
    jQuery.fn.attrArray = function(field){
        temp = new Array;
        jQuery(this).each(function(){
            temp.push(jQuery(this).attr(field))
        })
        return temp;
    }
    
    jQuery.fn.doMyRows = function(){
        jQuery(this).hover(function(){
            jQuery(this).addClass("hightlight");
            
        }, function(){
            jQuery(this).removeClass("hightlight");
        });
        jQuery(this).filter(':even').addClass('odd')
        
    }
    jQuery.fn.serializeObject = function(){
        o = {};
        jQuery('input[@name], textarea[@name], select[@name]', this).each(function(){
            o[jQuery(this).attr('name')] = jQuery(this).val();
        })
        return o;
    }
    
    jQuery('.table_numrows').change(function(){
        this.form.submit();
    })
    
    jQuery(".std-table > tbody > tr").doMyRows()

    
    /************************/
    
    jQuery.ajaxSetup({
        cache: false
    });
    
    
    
    
})


function checkAll(o){
    temp = jQuery('input:eq(0)', jQuery('tr', jQuery(o).parents('table')))
    
    if (jQuery(o).attr('ch') == 'checked') {
        jQuery(temp).uncheck()
        jQuery(o).attr('ch', '')
    }
    else {
        jQuery(temp).check()
        jQuery(o).attr('ch', 'checked')
    }
    o.blur();
    return temp;
}

function backSubmit(obj){
    document.forms[0].elements['action'].value = 'back';
    obj.form.submit();
}

function goSubmit(obj){
    document.forms[0].elements['action'].value = 'continue';
    obj.form.submit();
}

function goToSubmit(obj, action){
    document.forms[0].elements['action'].value = action;
    obj.form.submit();
}

function go(url){
    document.location.href = $("base").attr('href') + url;
}

function submitMe(o){
    if (o.form) {
        o.form.submit()
    }
    else {
        jQuery(o).parents('form').filter('form').submit();
    }
}

function closeWindow(){
    window.close();
}

function setWindowSize(w, h){
    window.innerWidth = w;
    window.innerHeight = h;
    top.resizeTo(w, h);
}


/**
 * Opens window
 * @param {String} url
 * @param {Integer} width
 * @param {Integer} height
 * @param {Boolean} scrollVisible
 * @param {boolean} resizeble
 * @return {Object} window
 */
function openWindow(url, width, height, scrollVisible, resizeble){
    param = 'toolbar=no,scrollbars=' + ((scrollVisible) ? 'yes' : 'no') + ',directories=no,resizable=' + ((resizeble) ? 'yes' : 'no') + ',width=' + width + ',height=' + height;
    return window.open(jQuery('base:eq(0)').attr('href') + url, '', param);
}/**openWindow*/

function active_form(obj, arr){
    jQuery(arr).each(function(i){
        jQuery("[@name=" + this[0] + "]").remove();
        jQuery(obj).after('<input type="hidden" name="' + this[0] + '" value="' + this[1] + '" />')
    })
    submitMe(obj);
    // Clear
    jQuery(arr).each(function(i){
        jQuery("[@name=" + this[0] + "]").remove();
    })
    return false;
}

/**
 * Sumit form
 * @param {Object} obj Caller obj
 * @param {Array} arr Array of parameters to send
 */
function active_form(obj, arr){
    jQuery(arr).each(function(i){
        jQuery("[@name=" + this[0] + "]").remove();
        jQuery(obj).after('<input type="hidden" name="' + this[0] + '" value="' + this[1] + '" />')
    })
    submitMe(obj);
    // Clear
    jQuery(arr).each(function(i){
        jQuery("[@name=" + this[0] + "]").remove();
    })
    return false;
}

function submit_activ_form_page(obj, val){
    jQuery(obj).append('<input type="hidden" name="start" value="' + val + '" />');
    obj.submit();
    return false;
}

/***********************/
function set_my_page(n){
    jQuery('.steps .sel').removeClass('sel')
    jQuery('.textSteps .sel').removeClass('sel')
    jQuery('.steps>div:eq(' + n + ')').removeClass('sel').addClass('sel')
    jQuery('.textSteps>div:eq(' + n + ')').removeClass('sel').addClass('sel')
}



function stripLeadingZeroes(input){

    if (typeof(input) != 'undefined') {
        if ((input.length > 1) && (input.substr(0, 1) == "0")) 
            return input.substr(1);
        else 
            return input;
    }
}

