function update_autopost_status(){
    window.location = '/user/settings';
}


function show_league_member_div(){
    document.getElementById('league_member_div').style.display = '';
}

function popUp(id){
    if(document.getElementById(id).style.display == 'none'){
        if( id== 'city_list'){
            jQuery('#city_list').show("blind");
            jQuery("#city_list").css("border-bottom", "2px solid #67BF2A");
        }
        else{
            document.getElementById(id).style.display = '';
            //jQuery('#'+id).show("bounce");
        }
        
        if( id == 'city_list'){
            //document.getElementById("tab1").setAttribute("class", "tab_active");
        }
        if( id == 'leaguesPopUpId'){
            document.getElementById("tab3").setAttribute("class", "round-tab tab_active");
        }
        if(id == 'loginPopUpId'){
            document.getElementById('registrationPopUpId').style.display = 'none';
            document.getElementById('tab2').setAttribute("class", "");
            document.getElementById('tab3').setAttribute("class", "tab_active");
        }else if (id == 'registrationPopUpId'){
            document.getElementById('loginPopUpId').style.display = 'none';
            document.getElementById('tab3').setAttribute("class", "");
            document.getElementById('tab2').setAttribute("class", "tab_active");
        }
    }else{
        
        if( id == 'city_list'){
            //document.getElementById("tab1").setAttribute("class", "");
            jQuery('#city_list').hide("blind");
            jQuery("#city_list").css("border-bottom", "2px solid #5AB033");
        }else{
            document.getElementById(id).style.display = 'none';
        }
        if(id == 'loginPopUpId'){
            document.getElementById('tab3').setAttribute("class", "");
            //document.getElementById('tab2').setAttribute("class", "tab_active");
        }else if (id == 'registrationPopUpId'){
            document.getElementById('tab2').setAttribute("class", "");
            //document.getElementById('tab3').setAttribute("class", "tab_active");
        }
        if( id == 'leaguesPopUpId'){
            document.getElementById("tab3").setAttribute("class", "round-tab");
        }
    }
}

function bodyDropDown(id){
    if(document.getElementById(id).style.display == 'none'){
        document.getElementById(id).style.display = '';
    }else{
        document.getElementById(id).style.display = 'none';
    }
}

function openAllSports(id,imgId){
    if(document.getElementById(id).style.display == 'none'){
        document.getElementById(id).style.display = '';
        document.getElementById(id).style.display = '';
        document.getElementById(imgId).src='/images/up_arrow.gif';
    }else{
        document.getElementById(id).style.display = 'none';
        document.getElementById(imgId).src='/images/down_arrow.gif';
    }
}

function eFocus(field, obj){
    if (field.value == obj){
        field.value ='';
    }
}

function eBlur(field, obj){
    if (field.value == ''){
        field.value = obj;
    }
}

function show_registration(){
    popUp('registrationPopUpId');
}

function changeAll(field,parentId){
    for (i = 0; i < field.length; i++){
        if(field[i].checked == false){
            document.getElementById(parentId).checked=false;
            return true;
        }else{
            document.getElementById(parentId).checked=true;
        }
    }
    return true;
}
function checkUncheck(field,parentId){
    if(document.getElementById(parentId).checked==true){
        checkAll(field);
    }else{
        uncheckAll(field);
    }
    Custom.clear();
}
function checkAll(field){
    for (i = 0; i < field.length; i++){
        field[i].checked = true ;
    }
}
function uncheckAll(field){
    for (i = 0; i < field.length; i++){
        field[i].checked = false ;
    }
}
function changeCheckBox(id){
    if(document.getElementById(id).checked){
        document.getElementById(id).checked = false;
    }else{
        document.getElementById(id).checked = true;
    }
}

function highlightTab(league_id, showTab1, replace_class){
    $('league_details').innerHTML=" ";
    $(showTab1).className = replace_class;
    $('searchLoader').hide();
    if (showTab1=='schedules_rules'){
        $('searchLoader').show();
        if ($('standings')){$('standings').className = 'bigButton'};
        if ($('new_rosters')){$('new_rosters').className = 'bigButton'};
        $('message_box').className = 'bigButton';
        $('league_details').style.display = '';
        $('message_box_details').style.display = 'none';
        new Ajax.Request('/league/schedules_rules/'+league_id, {
            method:'get',
            asynchronous:true,
            evalScripts:true
        });
    }
    else if(showTab1=='standings'){
        $('searchLoader').show();
        if ($('schedules_rules')){$('schedules_rules').className = 'bigButton'};
        if ($('new_rosters')){$('new_rosters').className = 'bigButton'};
        $('message_box').className = 'bigButton';
        $('league_details').style.display = '';
        $('message_box_details').style.display = 'none';
        new Ajax.Request('/league/standings/'+league_id, {
            method:'get',
            asynchronous:true,
            evalScripts:true
        });
    }
    else if(showTab1=='new_rosters'){
        $('searchLoader').show();
        if ($('schedules_rules')){$('schedules_rules').className = 'bigButton'};
        if ($('standings')){$('standings').className = 'bigButton'};
        $('message_box').className = 'bigButton';
        $('league_details').style.display = '';
        $('message_box_details').style.display = 'none';
        new Ajax.Request('/league/new_rosters/'+league_id, {
            method:'get',
            asynchronous:true,
            evalScripts:true
        });
    }
    else if(showTab1=='message_box'){
        if ($('standings')){$('standings').className = 'bigButton'};
        if ($('new_rosters')){$('new_rosters').className = 'bigButton'};
        if ($('schedules_rules')){$('schedules_rules').className = 'bigButton'};
        $('message_box_details').style.display = '';
        $('league_details').style.display = 'none';
    }
}

function registerNow(){
    document.getElementById('registrationPopUpId').style.display = '';
}

function display_form(id,val) {
  pars = "id=" + id + "&val=" + val + "&sid=" + jQuery('#league_signup_option_id').val();
  new Ajax.Request('/league/display_form',
  { method:'get',
    asynchronous:true,
    evalScripts:true,
    parameters:pars});
}
