function open_close(img_id,div_id) {
    var img = document.getElementById(img_id); 
    var obj = document.getElementById(div_id);
    var st = img.src;
    
    if (st.match("down.jpg")) {
        img.src = st.replace("down.jpg","up.jpg");
    } else if (st.match("up.jpg")) {
        img.src = st.replace("up.jpg","down.jpg");
    }
    
    
    if (obj.style.display == 'none') {
        obj.style.display = 'block';
    } else {
        obj.style.display = 'none';
    }
}

function order_lister(order,cmd) {
    wLoader.show();
    var form = document.getElementById("lista_report_form");
    form.orderby.value      = order;
    form.actual_page.value  = 1;
    eval(cmd);
    //    xajax_lista_report(xajax.getFormValues('lista_report_form'));
}
function pager_lister(page,cmd) {
    wLoader.show();
    var form = document.getElementById("lista_report_form");
    form.actual_page.value      = page;
    eval(cmd);
    //    xajax_lista_report(xajax.getFormValues('lista_report_form'));
}
function onepage_count_lister(record,cmd) {
    wLoader.show();
    var form = document.getElementById("lista_report_form");
    form.actual_page.value      = 1;
    form.on_onepage_count.value = record;
    eval(cmd);
    //xajax_lista_report(xajax.getFormValues('lista_report_form'));
}
function reload_lister(sel_value,cmd) {
    wLoader.show();
    var form = document.getElementById("lista_report_form");
    form.actual_page.value  = 1;
    form.sel_value.value    = sel_value;
    eval(cmd);
    //    xajax_lista_report(xajax.getFormValues('lista_report_form'));
}
function search_lister(cmd) {
    wLoader.show();
    eval(cmd);
    //    xajax_lista_report(xajax.getFormValues('lista_report_form'));
}

/**
*  Letiltható az elem kijelölése
**/
function disableSelection(target){
    if (typeof target.onselectstart!="undefined") //IE route
    target.onselectstart=function(){return false}
    else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
    target.style.MozUserSelect="none"
    else //All other route (ie: Opera)
    target.onmousedown=function(){return false}
    target.style.cursor = "default"
}

//Sample usages
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"



function show_gallery() {
   document.getElementById('loading_index').style.display = "none";
   document.getElementById('gallery').style.display = "block";
   //fadeIn(document.getElementById('gallery'),100,2); 
   
}


function welcome() {
   
   setTimeout("fadeOut(document.getElementById('welcome_text'),5)",2000); 
   setTimeout("document.getElementById('welcome_text').style.display = 'none'",3000); 
   setTimeout("document.getElementById('welcome_imgs').style.display = 'block'",3000); 

   setTimeout("fadeIn(document.getElementById('welcome_1'),100,5)",3500); 
   setTimeout("document.getElementById('welcome_1').style.display = 'block'",3500); 

   setTimeout("fadeIn(document.getElementById('welcome_2'),100,5)",3500); 
   setTimeout("document.getElementById('welcome_2').style.display = 'block'",3500); 

   setTimeout("fadeIn(document.getElementById('welcome_3'),100,5)",3500); 
   setTimeout("document.getElementById('welcome_3').style.display = 'block'",3500); 

   setTimeout("fadeIn(document.getElementById('welcome_4'),100,5)",3500); 
   setTimeout("document.getElementById('welcome_4').style.display = 'block'",3500); 
}

function welcome_text() {
    document.getElementById('welcome_text').style.display = 'none';
}

function calendar_loader() {
    var div     = document.getElementById('calendar_main');
    var loader  = document.getElementById('calendar_loader');
    
    var height = div.offsetHeight;
    //alert(div.offsetHeight); 
    
    div.style.display = "none";
    loader.style.height = height + 'px';
    loader.style.display = "block";
    
}

    function maps_load() {
            if (GBrowserIsCompatible())
                {
                var bounds = new GLatLngBounds();
                var icon = new GIcon(G_DEFAULT_ICON); 
                icon.image = "frames/google_marker.png";
                icon.transparent = "frames/google_marker.png"; 
                
                function gmarker_object(infohtml,point,icon)
                    {
                    this.infohtml = infohtml ;
                    this.point = point ;
                    this.icon = icon ;
                    }
                var gmarkers = new Array() ;
                gmarkers[0] = new gmarker_object(
                    '',
                    new GLatLng(48.131268, 20.918484, true),
                    icon
                    ) ;

                var map = new GMap2(document.getElementById("map"));
                map.addControl(new GLargeMapControl());
                map.setCenter(gmarkers[0].point, 13);
                
                var opts = {maxWidth : 200};
                
                var marker1 = new GMarker(gmarkers[0].point,gmarkers[0].icon);
                //map.addOverlay(marker1);
                bounds.extend(marker1.getPoint()) ;
                }
    }            
    function maps_load2() {
            if (GBrowserIsCompatible())
                {
                var bounds = new GLatLngBounds();
                var icon = new GIcon(G_DEFAULT_ICON); 
                icon.image = "frames/google_marker.png";
                icon.transparent = "frames/google_marker.png"; 
                
                function gmarker_object(infohtml,point,icon)
                    {
                    this.infohtml = infohtml ;
                    this.point = point ;
                    this.icon = icon ;
                    }
                var gmarkers = new Array() ;
                gmarkers[0] = new gmarker_object(
                    '',
                    new GLatLng(48.131268, 20.918484, true),
                    icon
                    ) ;

                var map = new GMap2(document.getElementById("map"));
                map.addControl(new GLargeMapControl());
                map.setCenter(gmarkers[0].point, 10);
                
                var opts = {maxWidth : 200};
                
                var marker1 = new GMarker(gmarkers[0].point,gmarkers[0].icon);
                map.addOverlay(marker1);
                bounds.extend(marker1.getPoint()) ;
                }
    }    
/*    
    function gallery_upload(A_kekep,max,ac,gallery_id,topic_id,size,dir,orig,del) {
        for (i=1; i<=(max+1); i++) {
            //alert(i);
            xajax_imgs_upload(A_kekep,max,i,gallery_id,topic_id,size,dir,orig,del);
        }
        xajax_gallery_upload_complet(topic_id);
    }
*/    

function insertcode_msg(code,ta_id) {
    var textarea = document.getElementById(ta_id);
    szovegbe(code,textarea);
}

function refocus_msg(ta_id) {
    document.getElementById(ta_id).focus();
}

function instext_msg(obj, txt) {
    var otext   = obj.value; 
    var ss      = obj.selectionStart;
    obj.value = otext.substring(0,ss) + txt + otext.substring(ss,obj.value.length);
    obj.selectionStart = ss + txt.length;
    obj.selectionEnd = obj.selectionStart;
}

function szovegbe(text, textarea)
{
    // Attempt to create a text range (IE).
    if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
    {
        var caretPos = textarea.caretPos;

        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
        caretPos.select();
    }
    // Mozilla text range replace.
    else if (typeof(textarea.selectionStart) != "undefined")
    {
        var begin = textarea.value.substr(0, textarea.selectionStart);
        var end = textarea.value.substr(textarea.selectionEnd);
        var scrollPos = textarea.scrollTop;

        textarea.value = begin + text + end;

        if (textarea.setSelectionRange)
        {
            textarea.focus();
            textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
        }
        textarea.scrollTop = scrollPos;
    }
    // Just put it on the end.
    else
    {
        textarea.value += text;
        textarea.focus(textarea.value.length - 1);
    }
}
