//
//title=main js;version=3.3.0.7;date=2009-09-16

function str_replace ( search, replace, subject ) {
    if(!(replace instanceof Array)){
        replace=new Array(replace);
        if(search instanceof Array){//If search    is an array and replace    is a string, then this replacement string is used for every value of search
            while(search.length>replace.length){
                replace[replace.length]=replace[0];
            }
        }
    }

    if(!(search instanceof Array))search=new Array(search);
    while(search.length>replace.length){//If replace    has fewer values than search , then an empty string is used for the rest of replacement values
        replace[replace.length]='';
    }

    if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
        for(k in subject){
            subject[k]=str_replace(search,replace,subject[k]);
        }
        return subject;
    }

    for(var k=0; k<search.length; k++){
        var i = subject.indexOf(search[k]);
        while(i>-1){
            subject = subject.replace(search[k], replace[k]);
            i = subject.indexOf(search[k],i);
        }
    }
    return subject;

}

function rawurlencode (str) {
    var hexStr = function (dec) {
        return '%' + dec.toString(16).toUpperCase();
    };

    var ret = '',
            unreserved = /[\w.~-]/; // A-Za-z0-9_.~-
    str = (str+'').toString();

    for (var i = 0, dl = str.length; i < dl; i++) {
        var ch = str.charAt(i);
        if (unreserved.test(ch)) {
            ret += ch;
        }
        else {
            var code = str.charCodeAt(i);
            // Reserved assumed to be in UTF-8, as in PHP
            if (code < 128) { // 1 byte
                ret += hexStr(code);
            }
            else if (code >= 128 && code < 2048) { // 2 bytes
                ret += hexStr((code >> 6) | 0xC0);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 2048 && code < 65536) { // 3 bytes
                ret += hexStr((code >> 12) | 0xE0);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 65536) { // 4 bytes
                ret += hexStr((code >> 18) | 0xF0);
                ret += hexStr(((code >> 12) & 0x3F) | 0x80);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
        }
    }
    return ret;
}

function rawurldecode (str) {
    var hash_map = {}, ret = str.toString(), unicodeStr='', hexEscStr='';

    var replacer = function (search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };

    // The hash_map is identical to the one in urlencode.
    hash_map["'"]   = '%27';
    hash_map['(']   = '%28';
    hash_map[')']   = '%29';
    hash_map['*']   = '%2A';
    hash_map['~']   = '%7E';
    hash_map['!']   = '%21';


    for (unicodeStr in hash_map) {
        hexEscStr = hash_map[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }

    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = ret.replace(/%([a-fA-F][0-9a-fA-F])/g, function (all, hex) {return String.fromCharCode('0x'+hex);}); // These Latin-B have the same values in Unicode, so we can convert them like this
    ret = decodeURIComponent(ret);

    return ret;
}

function get_html_translation_table (table, quote_style) {
    // http://kevin.vanzonneveld.net

    var entities = {}, hash_map = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};

    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';

    useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';

    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw new Error("Table: "+useTable+' not supported');
        // return false;
    }

    entities['38'] = '&amp;';
    if (useTable === 'HTML_ENTITIES') {
        entities['160'] = '&nbsp;';
        entities['161'] = '&iexcl;';
        entities['162'] = '&cent;';
        entities['163'] = '&pound;';
        entities['164'] = '&curren;';
        entities['165'] = '&yen;';
        entities['166'] = '&brvbar;';
        entities['167'] = '&sect;';
        entities['168'] = '&uml;';
        entities['169'] = '&copy;';
        entities['170'] = '&ordf;';
        entities['171'] = '&laquo;';
        entities['172'] = '&not;';
        entities['173'] = '&shy;';
        entities['174'] = '&reg;';
        entities['175'] = '&macr;';
        entities['176'] = '&deg;';
        entities['177'] = '&plusmn;';
        entities['178'] = '&sup2;';
        entities['179'] = '&sup3;';
        entities['180'] = '&acute;';
        entities['181'] = '&micro;';
        entities['182'] = '&para;';
        entities['183'] = '&middot;';
        entities['184'] = '&cedil;';
        entities['185'] = '&sup1;';
        entities['186'] = '&ordm;';
        entities['187'] = '&raquo;';
        entities['188'] = '&frac14;';
        entities['189'] = '&frac12;';
        entities['190'] = '&frac34;';
        entities['191'] = '&iquest;';
        entities['192'] = '&Agrave;';
        entities['193'] = '&Aacute;';
        entities['194'] = '&Acirc;';
        entities['195'] = '&Atilde;';
        entities['196'] = '&Auml;';
        entities['197'] = '&Aring;';
        entities['198'] = '&AElig;';
        entities['199'] = '&Ccedil;';
        entities['200'] = '&Egrave;';
        entities['201'] = '&Eacute;';
        entities['202'] = '&Ecirc;';
        entities['203'] = '&Euml;';
        entities['204'] = '&Igrave;';
        entities['205'] = '&Iacute;';
        entities['206'] = '&Icirc;';
        entities['207'] = '&Iuml;';
        entities['208'] = '&ETH;';
        entities['209'] = '&Ntilde;';
        entities['210'] = '&Ograve;';
        entities['211'] = '&Oacute;';
        entities['212'] = '&Ocirc;';
        entities['213'] = '&Otilde;';
        entities['214'] = '&Ouml;';
        entities['215'] = '&times;';
        entities['216'] = '&Oslash;';
        entities['217'] = '&Ugrave;';
        entities['218'] = '&Uacute;';
        entities['219'] = '&Ucirc;';
        entities['220'] = '&Uuml;';
        entities['221'] = '&Yacute;';
        entities['222'] = '&THORN;';
        entities['223'] = '&szlig;';
        entities['224'] = '&agrave;';
        entities['225'] = '&aacute;';
        entities['226'] = '&acirc;';
        entities['227'] = '&atilde;';
        entities['228'] = '&auml;';
        entities['229'] = '&aring;';
        entities['230'] = '&aelig;';
        entities['231'] = '&ccedil;';
        entities['232'] = '&egrave;';
        entities['233'] = '&eacute;';
        entities['234'] = '&ecirc;';
        entities['235'] = '&euml;';
        entities['236'] = '&igrave;';
        entities['237'] = '&iacute;';
        entities['238'] = '&icirc;';
        entities['239'] = '&iuml;';
        entities['240'] = '&eth;';
        entities['241'] = '&ntilde;';
        entities['242'] = '&ograve;';
        entities['243'] = '&oacute;';
        entities['244'] = '&ocirc;';
        entities['245'] = '&otilde;';
        entities['246'] = '&ouml;';
        entities['247'] = '&divide;';
        entities['248'] = '&oslash;';
        entities['249'] = '&ugrave;';
        entities['250'] = '&uacute;';
        entities['251'] = '&ucirc;';
        entities['252'] = '&uuml;';
        entities['253'] = '&yacute;';
        entities['254'] = '&thorn;';
        entities['255'] = '&yuml;';
    }

    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#39;';
    }
    entities['60'] = '&lt;';
    entities['62'] = '&gt;';


    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        hash_map[symbol] = entities[decimal];
    }

    return hash_map;
}

function htmlspecialchars (string, quote_style) {
    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();

    if (false === (hash_map = this.get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }

    hash_map["'"] = '&#039;';
    for (symbol in hash_map) {
        entity = hash_map[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }

    return tmp_str;
}

$(document).ready(function(){
    $("legend span.openhide").click(function(){
        $(this).parent().parent().find(".openhideblock").toggle('fast');
        $(this).find("strong").toggleClass("active");
    });

    $("#span_ee_link_clear").click(function(){
        $("#ee_link_current_link").removeAttr('value', '');
        $("#ee_link_current_title").fadeOut();
        $("#span_ee_link_clear").fadeOut();
        $("#ee_link_edit").fadeOut();
        $("#span_ee_link_lang_id").fadeIn();
        $("#span_ee_link_lang_id_arrow").fadeIn();
        $("#span_ee_link_type").fadeIn();

    });
	
    //SEO
    var seoarray = new Array();
    $("#seorefreshdiv #refresh").click(function(){
        seo_update_pb ("disabled");
        var module = $(this).attr("class");
        var page = $(this).attr("rel");
        $.ajaxSetup({
            url: '../ee_ajax.php',
            data: 'operation=seoprep&module=' + module + '&page=' + page + "&langid=" + gloaballangid,
            type: 'GET',
            dataType : 'xml',
            success: function(data){
                $(data).find('el').each(function(){
                    seoarray[$(this).find('key').text()] = new Array(
                        $(this).find('v1').text(),
                        $(this).find('v2').text(),
                        $(this).find('v3').text(),
                        $(this).find('v4').text(),
                        $(this).find('v5').text()
                        );
                });
            },
            cache: false
        });
   		
        $.ajax({
            complete: function(){
                seowork (seoarray);
            },
            error: function() {
                seo_update_pb ("");
            }
        });
        return false;
    });
	
    function seowork (seoarray)
    {
        var ee_seo_from_title = "";
        var ee_seo_from_text = "";
        var ee_seo_from_seourl = "";
        var ee_seo_from_imgalt = "";
        var seo_resault = new Array();
        if (seoarray["id"].length)
        {
            var ft = "";
            var ftt = "";
            var fs = "";
            var fi = "";
            for (var i=0; i<5; i++)
            {
                ft = "";
                ft = $("[name=" + seoarray["fromtitle"][i] + "]").val();
                if (ft != "on" && ft != "---") {
                    ee_seo_from_title += " " + ft;
                }
                //innovaedit patch
                ftt = "";
                ftt = $("iframe#idContentedit_"+seoarray["fromtext"][i]).contents().find("body").text();
                if (seoarray["fromtext"][i]) {
                    if(ftt && ftt != "---") {
                        ee_seo_from_text += " " + ftt;
                    }
                    else {
                        ftt = $("[name=" + seoarray["fromtext"][i] + "]").val();
                        if (ftt != "on" && ftt != "---") {
                            ee_seo_from_text += " " + ftt;
                        }
                    }
                }
                fs = "";
                fs = $("[name=" + seoarray["fromseourl"][i] + "]").val();
                if (fs != "on" && fs != "---") {
                    ee_seo_from_seourl += " " + fs;
                }
                fi = "";
                fi = $("[name=" + seoarray["fromimgalt"][i] + "]").val();
                if (fi != "on" && fi != "---") {
                    ee_seo_from_imgalt += " " + fi;
                }
            }
	         
            var module = $("#seorefreshdiv #refresh").attr("class");
            var page = $("#seorefreshdiv #refresh").attr("rel");
			
            $.ajaxSetup({
                url: '../ee_ajax.php',
                data: 'operation=seowork&module=' + module + '&page=' + page + '&langid=' + gloaballangid + '&fti=' + ee_seo_from_title + '&fte=' + ee_seo_from_text + '&fsu=' + ee_seo_from_seourl + '&fia=' + ee_seo_from_imgalt,
                type: "POST",
                dataType : 'xml',
                success: function(msg){
		 			
                    $(msg).find('el').each(function(){
                        seo_resault[$(this).find('key').text()] = $(this).find('val').text();
                    });
                },
                cache: false
            });
	        
            $.ajax({
                complete: function(){
                    update_seo (seoarray, seo_resault);
                },
                error: function() {
                    //    				alert();
                    seo_update_pb ("");
                }
            });
        }
        else
        {
            seo_update_pb ("");
        }
    }
	
    function update_seo (seoarray, seo_resault)
    {
        var ch = $("#refreshallcheckbox").attr("checked");
		
        if (ch || $("[name="+seoarray["meta"][0]+"]").val() == "") {
            $("[name="+seoarray["meta"][0]+"]").val(seo_resault["meta_description"]);
        }
		
        if (ch || $("[name="+seoarray["title"][0]+"]").val() == "") {
            $("[name="+seoarray["title"][0]+"]").val(seo_resault["meta_title"]);
        }
		
        if (ch || $("[name="+seoarray["title"][0]+"]").val() == "") {
            $("[name="+seoarray["tags"][0]+"]").val(seo_resault["meta_tags"]);
        }
		
        if (ch || $("[name="+seoarray["imgalt"][0]+"]").val() == "") {
            $("[name="+seoarray["imgalt"][0]+"]").val(seo_resault["file_alt"]);
        }
		
        if (ch || $("[name="+seoarray["seourl"][0]+"]").val() == "") {
            $("[name="+seoarray["seourl"][0]+"]").val(seo_resault["seo_url"]);
        }

        seo_update_pb ("");
    //		alert("Complete!");
    }
	
    function seo_update_pb (dis)
    {
        $("#eeseotable input").attr("disabled", dis);
        $("#eeseotable textarea").attr("disabled", dis);
    }
	
    $("#loglist strong").css("cursor", "pointer");
    $("#loglist strong").css("border-bottom", "1px dashed gray");
    $("#loglist strong").css("padding-bottom", "1px");
    $("#loglist strong").click(function(){
        var cid = $(this).attr("class");
        $("#loglist div#"+cid).toggle("fast");
    });
	
    //multichecbox
    $("div.category").click(function(){
        var id = $(this).attr("id");
        $(this).find("span").toggleClass("active");
        $("div#it" + id).toggle("show");
    });
	
    $("div.categoryitems label input").click(function(){
        ee_multicheckbox_count ($(this).parent().parent().attr("id"));
        $(this).parent().toggleClass("thischeckboxisselected");
    });
	
    $("div.multicheckboxblocktable label input").click(function(){
        $(this).parent().toggleClass("thischeckboxisselected");
    });
	
    $("div.multicheckboxblock label input").click(function(){
        $(this).parent().toggleClass("thischeckboxisselected");
    });
	
    $("div.categoryitems").each(function(){
        ee_multicheckbox_count ($(this).attr("id"));
    });
	
    function ee_multicheckbox_count (id)
    {
        var count = $("div#" + id + " label input:checked").length;
        if(count > 0){
            $("strong." + id).text(" [" + count + "]");
        }
        else {
            $("strong." + id).text("");
        }
    }

    //inlinks
    //обнуляємо попередні вибірки. якщо поміняли мову
    $('#ee_link_lang_id').change(function(){
        $('#ee_link_type').val('');
        if ($('#ee_link_object').length) $('#ee_link_object').attr('disabled', 'disabled');
    });
    //посилаємо запит на вивід інлінків
    $('#ee_link_type').change(function(){
        //alert($('#ee_link_lang_id').val());
        if ($('#ee_link_object').length) $('#ee_link_object').attr('disabled', 'disabled');
        $('#span_ee_link_object').fadeOut();

        var eelinktype = $(this).val();
        var eelinklangid = $('#ee_link_lang_id').val();
        var ee_link_object_content = '';
        $('#span_ee_link_progress').css('background-image', 'url(../ee_images/ee_status_bar.gif)');
        $.ajax({
            url: '../ee_ajax.php',
            data: 'operation=geteelinks&eelinktype=' + eelinktype + '&eelinklangid=' + eelinklangid,
            type: 'GET',
            dataType : 'xml',
            success: function(data, textStatus){
                //                alert(textStatus);
                $(data).find('e').each(function(){
                    var s = $(this).find('s').text();
                    var i = $(this).find('i').text();
                    var t = $(this).find('t').text();
                    ee_link_object_content += '<option value="'+i+'" class="'+s+'">'+t+'</option>';
                });
            },
            cache: false,
            complete: function(){
                $('#span_ee_link_object').each(function(){
                    $(this).empty();
                    $(this).append('<select id="ee_link_object" name="ee_link_object">' + ee_link_object_content + '</select>');
                    $(this).fadeIn();
                    $('#span_ee_link_progress').css('background-image', 'none');
                });
                if ($('#ee_link_object').length)
                {
                    $('#ee_link_object').attr('disabled', '');
                    //якщо змінився інлінк
                    $('#ee_link_object').change(function(){
                        var eelinkid = $(this).val();
                        $('#ee_link_current_link').attr('value', eelinkid);
                        eelinkfullpath (eelinkid);
                    });
                }
            }          
        });

    });

    function eelinkfullpath (id)
    {
        var res = 'none';
        $.ajax({
            url: '../ee_ajax.php',
            data: 'operation=eelinkfullpath&id=' + id,
            type: 'GET',
            dataType : 'xml',
            success: function(data){
                $(data).find('e').each(function(){
                    res = $(this).find('t').text();
                });
            },
            complete: function(){
                $('#ee_link_current_title').html(res);
                $('#ee_link_current_title').css('display', 'block');
                $('#ee_link_edit').css('display', 'inline');
                $('#span_ee_link_lang_id').fadeOut();
                $('#span_ee_link_lang_id_arrow').fadeOut();
                $('#span_ee_link_type').fadeOut();
                $('#span_ee_link_progress').fadeOut();
                $('#span_ee_link_object').fadeOut();
                $('#span_ee_link_clear').show();

            },
            cache: false
        });
    }
    
    $('#ee_link_edit').click(function(){
        $('#span_ee_link_lang_id').fadeIn();
        $('#span_ee_link_lang_id_arrow').fadeIn();
        $('#span_ee_link_type').fadeIn();
        $('#span_ee_link_progress').fadeIn();
        $('#span_ee_link_object').fadeIn();
    });

    //внутрішні посилання
    $('#darrbuttoneelinks').click(function(){
        var eelinktype = $('#ee_links_type').val();
        var eelinklangid = $('#ee_link_lang_id').val();
        var ee_link_object_content = '';
        $.ajax({
            url: './ee_ajax.php',
            data: 'operation=geteelinks&eelinktype=' + eelinktype + '&eelinklangid=' + eelinklangid,
            type: 'GET',
            dataType : 'xml',
            success: function(data, textStatus){
                $(data).find('e').each(function(){
                    var s = $(this).find('s').text();
                    var i = $(this).find('i').text();
                    var t = $(this).find('t').text();
                    if (i > 0)
                    {
                        //                        var t2 = str_replace('\\\'', '&#039;', t);
                        var t2 = htmlspecialchars(t,'ENT_QUOTES');
                        //                        t = str_replace('"', '&quot;', t);
                        ee_link_object_content += '<li onclick="doInsert(\'inlink:'+i+':inlink\',\''+t2+'\')" class="eelink">'+t+'</li>';
                    }
                });
            },
            cache: false,
            complete: function(){
                $('#linkslist').each(function(){
                    $(this).empty();
                    $(this).append('<ol>' + ee_link_object_content + '</ol>');
                });
            }
        });
    });

    //новий список і взаємодія в ньому
    if ($('.ll_table').length){
        //зебра
        $('.ll_table tbody tr.ll01:even').addClass('zebra_odd');
        $('.ll_table tbody tr.ll02:even').addClass('zebra_odd');

        //підсвітка рядку таблиці
        $('.ll_table tbody tr.ll01').live('mouseover', function(){
            $(this).addClass('zebra_over');
            $(this).next().addClass('zebra_over');
        });
        $('.ll_table tbody tr.ll01').live('mouseout', function(){
            $(this).removeClass('zebra_over');
            $(this).next().removeClass('zebra_over');
        });
        $('.ll_table tbody tr.ll02').live('mouseover', function(){
            $(this).addClass('zebra_over');
            $(this).prev().addClass('zebra_over');
        });
        $('.ll_table tbody tr.ll02').live('mouseout', function(){
            $(this).removeClass('zebra_over');
            $(this).prev().removeClass('zebra_over');
        });

        //підтвердження операцій
        $('.ll_operations a[class!="edit"]').live('click', function(){
            return confirm($(this).attr('title'));
        });

        //операції над статусами (показувати, публікувати, гаряча)
        $('.ll_status span').css('cursor', 'pointer');
        $('.ll_status span').live('click', function(){
            var ll_id = $(this).parent().parent().find('.cur_id').html();
            var ll_table = $('input#table').val();
            var ll_class = $(this).attr('class');
            var curr_span = $(this);
            //початкове значення поля :)
            var status_type = ll_class.substring(0,1);
            var t = ll_class.substring(1,2);
            $.ajax({
                url: '../ee_ajax.php',
                data: 'operation=statuschange&id=' + ll_id + '&table=' + ll_table + '&class=' + ll_class,
                type: 'GET',
                dataType : 'xml',
                success: function(data){
                    $(data).find('e').each(function(){
                        t = $(this).find('t').text();
                    });
                },
                cache: false,
                complete: function(){
                    $(curr_span).attr('class', status_type+t);
                }
            });
        });

        //кількіст відібраних чекбоксів
        $('.check input').live('click', function(){
            $('.totalcheckboxes').text($('.check input:checked').length);
        });
    }
});
function ocmenu(item, tid, t1, t2) {
    var id = document.getElementById(item);
    var textid = document.getElementById(tid);
    if (t1 == null)
    {
        t1 = "+";
    }
    if (t2 == null)
    {
        t2 = "-";
    }
    if (id.style.display == "block")
    {
        id.style.display = "none";
        textid.innerText = t1;
    }
    else
    {
        id.style.display = "block";
        textid.innerText = t2;
    }
}

function selectall(formname)
{
    var num = document.forms[formname].length;
    if (document.forms[formname].elements["selectallch"].checked)
    {
        document.forms[formname].elements["selectallch"].checked = false;
    }
    else
    {
        document.forms[formname].elements["selectallch"].checked = true;
    }
    for ( var i=0; i<num; i++)
    {
        if (document.forms[formname].elements[i].type == "checkbox")
        {
            if (document.forms[formname].elements[i].checked)
            {
                document.forms[formname].elements[i].checked = false;
            }
            else
            {
                document.forms[formname].elements[i].checked = true;
            }
        }
    }
}

function count_process(elt, operation)
{
    var count = document.getElementById(elt);
    var valuethis = count.value;
    if ( valuethis == "NaN")
    {
        valuethis = 1;
    }
    else
    {
        if (operation == "+")
        {
            valuethis++;
        }
        else
        {
            if (operation == "-")
            {
                valuethis--;
            }
        }
        if (valuethis < 0)
        {
            valuethis = 0;
        }
    }
    if ( valuethis == "NaN")
    {
        valuethis = 1;
    }
    count.value = valuethis;
}

function eelogexpand(item, tid, t1, t2) {
    var id = document.getElementById(item);
    var textid = document.getElementById(tid);
    if (t1 == null)
    {
        t1 = "+";
    }
    if (t2 == null)
    {
        t2 = "—";
    }
    if (id.style.height != "auto")
    {
        id.style.height = "auto";
        textid.innerText = t2;
    }
    else
    {
        id.style.height = "30px";
        textid.innerText = t1;
    }
    return false;
}

function getPosit(elem) {
    var pos = {
        x : elem.offsetLeft,
        y : elem.offsetTop
    };
    if (elem.offsetParent) {
        var tmp = getPosit(elem.offsetParent);
        pos.x += tmp.x;
        pos.y += tmp.y;
    } 
    return pos;
}

function zoomover(id)
{
    var a = document.getElementById(id);
    if (a.hasChildNodes)
    {
        var i = a.childNodes.length;
        for (ii=0; ii<i; ii++)
        {
            if (a.childNodes[ii].tagName == 'IMG')
            {
                if (a.childNodes[ii].offsetParent)
                {
                    var left = getPosit(a.childNodes[ii]);
                }
            }
            if (a.childNodes[ii].tagName == 'SPAN')
            {
                a.childNodes[ii].style.display = "inline";
                a.childNodes[ii].style.left = left.x + "px";
                a.childNodes[ii].style.top = left.y + "px";
            //				alert (a.childNodes[ii].offsetLeft);
            }
        }
    }
}

function zoomout(id)
{
    var a = document.getElementById(id);
    if (a.hasChildNodes)
    {
        var i = a.childNodes.length;
        for (ii=0; ii<i; ii++)
        {
            if (a.childNodes[ii].tagName == 'SPAN')
            {
                a.childNodes[ii].style.display = "none";
            }
        }
    }
}

function updown (id, operation)
{
    var num2 = document.getElementById(id);
    var num = parseInt(num2.value);
    if (isNaN(num))
    {
        num = 0;
    }
    if (operation == 'up')
    {
        num++;
    }
    else if (operation == 'down')
    {
        num--;
    }
	
    num2.value = num;
}

/* eEgnith multilang library */
function ml(formid, name)
{
    for (var i=1; i<=5; i++)
    {
		
        var temp = name+'0'+i;
        var tempflag = 'flag'+name+'0'+i;
		
        var fid = document.getElementById(temp);
        var fidflag = document.getElementById(tempflag);
        if (fid != null)
        {
            if (temp == formid)
            {
                fid.style.display = 'block';
                fidflag.style.backgroundColor = '#ececec';
                fidflag.style.paddingTop = '2';
                fidflag.style.paddingBottom = '6';
                fidflag.style.marginTop = '0';
            }
            else
            {
                fid.style.display = 'none';
                fidflag.style.backgroundColor = 'white';
                fidflag.style.paddingTop = '2';
                fidflag.style.paddingBottom = '2';
                fidflag.style.marginTop = '4';
            }
        }
    }
	
}

var cache = new Array();
var flags = new Array();
var gloaballangid = "01";

function mlall(id)
{
    gloaballangid = id;
    var len = cache.length;
    var thisid = '';
	
    for (var i=1; i<=5; i++)
    {
        var temp = '0'+i;
        var fidflag = document.getElementById(flags[i]);
        if (fidflag)
        {
            if (temp == id)
            {
                fidflag.style.backgroundColor = '#eff5e5';
                fidflag.style.paddingTop = '2';
                fidflag.style.paddingBottom = '10';
                fidflag.style.marginTop = '0';
                if (fidflag.hasChildNodes())
                {
                    fidflag.childNodes(0).style.opacity = "0";
                    fidflag.childNodes(0).style.filter = "alpha(opacity=99)";
                }
            }
            else
            {
                fidflag.style.backgroundColor = 'white';
                fidflag.style.paddingTop = '2';
                fidflag.style.paddingBottom = '2';
                fidflag.style.marginTop = '8';
                if (fidflag.hasChildNodes())
                {
                    fidflag.childNodes(0).style.opacity = "0.5";
                    fidflag.childNodes(0).style.filter = "alpha(opacity=50)";
                }
            }
        }
    }
	
    for (i = 1; i <= len; i++)
    {
        if (cache[i])
        {
            thisid = cache[i].substring(3,5);
            var fid = document.getElementById(cache[i]);
            if (thisid == id)
            {
				
                fid.style.display = 'block';
            }
            else
            {
                fid.style.display = 'none';
            }
        }
    }
}

function ee_js_replace_value (from, to)
{
    var fromvalue = document.getElementById(from);
    var tovalue = document.getElementById(to);
    tovalue.value = fromvalue.value;
}

function ee_js_set_display (id, display)
{
    var el = document.getElementById(id);
    el.style.display = display;
}

function oc(item)
{
    var id = document.getElementById(item);
    if (id.style.display == "block")
    {
        id.style.display = "none";
    }
    else
    {
        id.style.display = "block";
    }
}