function make_gallery_slide(current){
    if (window.addEvent){
        window.addEvent('domready', function(){
            if(!$('bilzlente2')) return false;
            YAHOO.namespace("cms");
            YAHOO.cms.scroll = new Fx.Scroll('bilzlente2', {
                wait: false,
                duration: 500,
                offset: {'x': -0, 'y':-14 },
                transition: Fx.Transitions.Quad.easeInOut
            });
            var frames = $$('#bilzlente3 .absm');
            var pos=0
            if(current){
                YAHOO.cms.scroll.toElement(current);
            }else{
                YAHOO.cms.scroll.toElement(frames[0].id);
            }
            $$('.prev_arrow')[0].addEvent('click', function(event) {
                event = new Event(event).stop();
                if (pos==0) {pos=frames.length-1}else{
                    pos-=3
                    if (pos<0) pos=0
                }
                YAHOO.cms.scroll.toElement(frames[pos].id);
            });
            $$('.next_arrow')[0].addEvent('click', function(event) {
                event = new Event(event).stop();
                if (pos==frames.length-1){ pos=0}else{
                    pos+=3
                    if (pos>=frames.length) pos=frames.length-1
                }
                YAHOO.cms.scroll.toElement(frames[pos].id);
            });  
        })
    }
}
function change_large_picture(picture_id,parent_id){
    var requestHandler={
        success: function(r){
            $$(".absa").each(function(element,i){
                if(element.id==("list_thumb_picture_"+r.argument.picture_id)){
                    element.className="absa aktivs"
                }else{
                    element.className="absa"
                }
            })
            $('single_image_container').innerHTML=(r.responseText);
        },
        failure:function(r){},
        argument:{picture_id:picture_id}
    };
    this.req=YAHOO.util.Connect.asyncRequest('POST', "/picture/single_image", requestHandler,"id="+picture_id+"&parent_id="+parent_id+"&container=single_image_container");
}
function toggle_images(object,images){
    for(var i=0;i<images.length;i++){
        if(object.src.match(images[i])) break;
    }
    last=i;
    if(i==images.length-1) i=-1
    object.src=object.src.replace(images[last],images[i+1]);
}
function change_schools(id){
    select=elementById('object[team][school_id]')
    if (!select) return
    current_name="area_"+id;
    current_element=select.options[select.selectedIndex]
    if(current_element.className!="area_"+id && current_element.className!="area_"){
        select.selectedIndex=0;
    }
    for(var i=1;i<select.length;i++){
        if(select.options[i].className==current_name || select.options[i].className=="area_"){
            select.options[i].style.display="block";
            select.options[i].disabled=false
        }else{
            select.options[i].style.display="none";
            select.options[i].disabled=true
        }
    }
    return false;
}

function toggle_team_school(value){
    main_select=elementById('object[team][school_id]')
    if(value){
        main_select.selectedIndex=0
        main_select.disabled=true;
        disp="block"
    }else{
        main_select.disabled=false;
        disp="none";
    }
    for(var i=0;i<6;i++){
        elementById('div_object[competitor]['+i+'][school_id]').style.display=disp;
    }
    return false
}
function change_team_area(area_id,current){
    if(area_id==0){
        window.location="../team/view"
    }else{
        if(current!=area_id) window.location="../team/view?area_id="+area_id
    }
}
function change_result_area(area_id,current){
    if(area_id==0){
        window.location="../result/view"
    }else{
        if(current!=area_id) window.location="../result/view?area_id="+area_id
    }
}
function elementById(id){
    if (document.getElementById)
        return (document.getElementById(id));
    if (document.all)
        return document.all[id];
    if (document.layers)
        return document.layers[id];
    return false;
}
