var error = {    server : 'Sorry, cannot contact the server. Please, try again',    user_added : 'Your account was successfully created. Now you may proceed with your order.',    first_task_register : 'Your task added successfully',    thanks_message : '<h1>We have received your inquiry. Please wait until our expert evaluates. The AssignmentExpert.com will contact you ASAP</h1>',    upload_denied : 'You have unuploaded files that you selected.\n Please, press "Start upload" button.'}var control_vars = {    username_lenth : 2,    host : '/assignments/',    host_satelit : 'http://64.120.250.181/',    url_satelite : 'index.php?',    url : 'http://www.assignmentexpert.com',    root_url: ''}var forced_to_sortnum = ['Inquiry/Visits', 'Payed/Inquiry', 'Payed/Visits','#', 'Price', 'Refund', 'Orders', 'Payed','Inquiry', 'Visits', 'Estimated traffic', 'W ID','Registration date', 'Last activity', 'GMT', 'Date','Ord ID', 'TIP', 'Google pos', 'Google estim','Yahoo pos', 'Bing pos', 'Yahoo,Bing estim', 'Prev pos1', 'Prev pos2', 'Prev pos3'];var forced_to_sortstring = ['Domain', 'Login', 'Username', 'User','Email', 'Order title', 'Operator','Writer', 'Status', 'Keyword','Refferer', 'Page visit', 'CC', 'State'];/*------------------------------------------------*/var tmr;var tmr_count = 0;var upload_active = false;function timer(){    $.ajax({        url : control_vars.host + 'index.php/requests/update_activity',        success : function (html){            if (html != 'false'){                tmr_count = 0;                var r = eval(html);                var c_r = r.length;                for (var i = 0; i < c_r; i++) {                    if (r[i].num > 0){                        $(r[i].id).html('&nbsp;('+r[i].num+')');                    } else {                        $(r[i].id).empty();                    }                }            }        }    });    tmr = setTimeout('timer()', 1000*60);}/*--------------------------------------------------*/function SetCookie(name, value, expires, path, domain, secure){    document.cookie = name + "=" + escape(value) +    ((expires) ? "; expires=" + expires.toGMTString() : "") +    ((path) ? "; path=" + path : "") +    ((domain) ? "; domain=" + domain : "") +    ((secure) ? "; secure" : "");}function DeleteCookie(name, path, domain){    if(GetCookieValueByName(name))        document.cookie = name + "=" +        ((path) ? "; path=" + path : "") +        ((domain) ? "; domain=" + domain : "") +        "; expires=Thu, 01-Jan-70 00:00:01 GMT";}function GetCookieValueByName(name){    var beg = document.cookie.indexOf(name+"=");    if(beg==-1)        return false;    var end = document.cookie.indexOf(";", beg + name.length);    if(end==-1)        end = document.cookie.length;    return unescape(document.cookie.substring(beg + name.length + 1, end));}function update_perpage(name, value){    var old_val = GetCookieValueByName(name);    var new_val = value;    if (old_val != new_val){        DeleteCookie(name);        SetCookie(name, value, new Date(2099, 7, 8, 2, 13, 45), '/');    }}//---------------------------------------------------------//function ajaxChain(handler){    if (ajax_processing){        showError('Please, be patient. Server is already processing your request.');        return false;    } else {        //in ajaxChain for compability with html events quotes were replaced with :^        handler = handler.replace(/\:\^/gi, '\'');        eval(handler);    }}/*-------------------------------------------*/var glob;var toasas;var ajax_processing = false;$(document).ready(    function(){        timer();        $("#loading").bind("ajaxSend", function(){            ajax_processing = true;            $("#loading").fadeIn('fast');            if (document.getElementById('items_per_page')){                document.getElementById('items_per_page').disabled = true;            }        }).bind("ajaxError", function(){            ajax_processing = false;            if (document.getElementById('items_per_page')){                document.getElementById('items_per_page').disabled = false;            }        }).bind("ajaxSuccess", function(){            ajax_processing = false;            if (document.getElementById('items_per_page')){                document.getElementById('items_per_page').disabled = false;            }            $("#loading").fadeOut('fast');            //for admin to change foot position            if (document.getElementById('huhuiii')){                $('.admin_titul_admin').attr('style', 'height:auto');                pos_foot_div_admin();            }            $('.tool_div').tooltip({                track: true,                delay: 0,                fade: 100,                bodyHandler: function() {                    var m = this.children;                    for (i=0; i<m.length; i++) {                        if (m.item(i).className == 'tooltip_tag')                            var aaa =  m.item(i).innerHTML;                    }                    return aaa;                },                showURL: false            });        });        //4 dropdowns        $(document).bind('click', function(e) {            var $clicked = $(e.target);            if (! $clicked.parents().hasClass("dropdown"))                $(".dropdown dd ul").slideUp('fast');        });        //for footer to be in right place        if (document.getElementById('huhuiii')){            $('.admin_titul_admin').attr('style', 'height:auto');            pos_foot_div_admin();        }        //        if(document.getElementById('login')){            document.getElementById('login').onclick = function(){                flogin();                return false;            };        }        //load resistration form if needed        if (location.hash == '#register_page'){            $('#tab3').click();        }        //if access level == user        $.ajax({            url : control_vars.host + 'index.php/requests/get_user_role',            type : 'post',            success : function (html) {                var tmpp = parseInt(html);                if (tmpp == 1) {//if user logged in - load his history                    $('#error').bind("ajaxError", function(){                        showError(error.server);                    });                    getHistory();                    showTheLastTask();                    var er = GetCookieValueByName('error_first');                    if(er != ''){                        MoveUp();                        showError15(er);                        update_perpage('error_first', '');                    }                					$(".table_body").bind("click",function(){                						$.clear(toasas);                						toasas = $.timeout(function() {                							$('#ordHist').click();                						}, 600000);                					});                }                if (tmpp == 2){ // if oper logged in                    $('#error').bind("ajaxError", function(){                        showError(error.server);                    });                    setTimeout("O_loadOrders()", 500);                //					$(".table_body").bind("click",function(){                //						$.clear(toasas);                //						toasas = $.timeout(function() {                //							reload();                //						}, 300000);                //					});                }                if (tmpp == 3 || tmpp == 4){ // if admin logged in                    $('#error').bind("ajaxError", function(){                        showError(error.server);                    });                    A_viewStatistics();                    showOrderStatistics('online');                }                if (tmpp == 7){ // if SEO logged in                    $('#error').bind("ajaxError", function(){                        showError(error.server);                    });                    A_viewStatistics();                }            },            error: function(){                showError(error.server);            }        });    });//---------------------------------------------------------//function showTheLastTask(){    $.ajax({        url : control_vars.host + 'index.php/requests/get_the_last_task',        type : 'post',        success : function (html) {            var tmpp = parseInt(html);            if (tmpp > 0) {                setTimeout(function(){                    $('#task_div_' + tmpp).click();                }, 500);            }        },        error: function(){            showError(error.server);        }    });}//---------------------------------------------------------//function updatePage(transport){    var o = document.createElement('DIV');    o.innerHTML = transport;    var cc = o.childNodes;    for (var i = 0; i < cc.length; i++)        try {            if (typeof cc[i]['id'] == "string")                if (document.getElementById(cc[i]['id'])) {                    if (typeof cc[i]['className'] == "string")                        if (cc[i]['className'])                            document.getElementById(cc[i]['id']).className = cc[i]['className'];                        else                            document.getElementById(cc[i]['id']).innerHTML = cc[i]['innerHTML'];                }        } catch (exception) {}}//---------------------------------------------------------//function flogin() {    if (checkLoginSubmitData())     //IE fix to login button, that can't be disabled    {        $.ajax({            url : control_vars.host + 'index.php/requests/login',            type : 'post',            data : {                name : $('#name').val(),                pass : $('#pass').val(),                js : true            },            success : function(html){                if (html == 'false'){                    showError('Please enter your login/password');                } else {                    $('#error').remove();                    location = control_vars.host + 'index.php/requests/login';                }            },            error : function(){                $('#error').empty();            }        });    }    return false;}//---------------------------------------------------------//function auto_login(name, pass) {    $.ajax({        url : control_vars.host + 'index.php/requests/login',        type : 'post',        data : {            name : name,            pass : pass        },        success : function() {            var err = 'We have received your inquiry. Please wait until our expert evaluates. <br>The AssignmentExpert.com will contact you ASAP.';            update_perpage('error_first', err);            setTimeout(function(){                location = '/assignments/index.php/requests/login'            }, 30);        }    });}//---------------------------------------------------------////function to fix the undisabling login button in IEfunction checkLoginSubmitData() {    var nameResult, passResult = false;    if (($('#name').val().length >= control_vars.username_lenth) && ($('#name').val() != 'Please, enter your login...')) {        nameResult = true;        $('#err_name').empty().css('visibility', 'hidden');    } else {        nameResult = false;        $('#err_name').html('<span class="denied">Name length must be at least ' + control_vars.username_lenth + ' symbols</span>').css('visibility', 'visible');    }    if ($('#pass').val().length > 5) {        passResult = true;        $('#err_pass').html('').css('visibility', 'hidden');    } else {        passResult = false;        $('#err_pass').html('<span class="denied">Pass length must be at least 6 symbols</span>').css('visibility', 'visible');    }    if (nameResult && passResult)	{        return true;    } else {        return false;    }}//---------------------------------------------------------//function registers(id){    var f = $('#authForm');    var param = f.serialize();    var url = control_vars.host + "index.php/requests/add_user";    if (id == 'task_submit') { // second button        if ($('.MultiFile-remove').size() > 0 || upload_active) {            alert(error.upload_denied);            return;        }        url = control_vars.host + "index.php/requests/add_register_first_task";        //param = 'login=' + $('#login_add').val();        param = 'login=' + $('#email').val() + '&order_title=' + encodeURIComponent($('#ot').val());        param += '&';        //task categoty        param +='cat_id=' + encodeURIComponent($('#task_category').val());        param += '&';        //level id        param +='level_id=' + encodeURIComponent($('#task_level').val());        param += '&';        //deadline        param +='deadline=' + encodeURIComponent($('#dl').val());        param += '&';        //task        param +='task_info=' + encodeURIComponent($('#task').val());        param += '&';        //checbox        param +='chb_detailed=';        $('#chb').attr('checked') ? param +='yes' : param +='no';        param += '&';        //spec info        if ($('#sr').val().length > 2) {            param +='spec_info=' + encodeURIComponent($('#sr').val());            param += '&';        }        //files        var files = getUploadedFiles();        if (files > 0)        {            var resultf = '';            var fileNum = $('#fileUpload2 .inp_file_filename').size();            if ( fileNum > 0 ) {                for (var i = 0; i < fileNum; i++) {                    if ($('#fileUpload2 .inp_file_filename')[i].innerHTML.length > 0){                        var ttmp = 'uploaded_files/' + $('#fileUpload2').multiUpload_upl.dir + '/' + $('#fileUpload2 .inp_file_filename')[i].innerHTML;                        resultf += ttmp + ',';                    }                }            } else {                resultf = '';            }            param +='attached_files=' + encodeURIComponent(resultf) + '&';        }        $('.MultiFile-list').empty()        //        param += '&captcha_text=' + $('#confirm_captcha').val();        $.ajax({            url: url,            type: 'post',            data: param,            success: function (html)            {                if (html == error.first_task_register)                {                    var pass = $('#pass_add').val();                    var name = $('#email').val();                    auto_login(name, pass);                    //empty fields and errors                    $('#div.err').empty();                    togglePass('fake_pass_add','pass_add');                    togglePass('fake_pass_add_ch','pass_add_ch');                    $('div.left, div.right, #task_submit').fadeOut('slow');                    $('div#register_div').empty();                } else {                    showError(html);                    $('#captcha').empty().load('index.php/requests/captchaImg');                    $('#confirm_captcha').attr('value', '').select();                }            }        });    } else if (id == 'register_submit'){        f = $('#authForm');        param = f.serialize();        url = control_vars.host + "index.php/requests/add_user";        $.ajax({            url: url,            type: 'post',            data: param + '&captcha_text=' + $('#confirm_captcha').val(),            success: function (html) {                if (html == error.user_added) {                    //showError(html);                    $('#reg_spacer').html(html).fadeIn('slow', function(){                        setTimeout(function(){                            $('#reg_spacer').empty()                        }, 10000)                    })                    $.ajax({                        url: control_vars.host + "index.php/requests/get_dir",                        type: 'post',                        data : {                            'login':$('#email').val()                        },                        success: function (html) {                            //empty fields and errors                            $('#first_name, #last_name, #email, #login_add, #pass_add, #pass_add_ch, #terms').attr('disabled', true);                            $('#err_em span, #err_login_add span, div.err').empty().css('visibility', 'hidden');                            $('#captcha, #register_submit').css('display', 'none').each(                                function() {                                    $(this).parents('tr').css('display', 'none')                                }                                );                            $('div.right, div#add_text_register').slideDown(1500);                            $('#task_submit').css('display', 'inline');                            initColumnTooltip('#question, #question2');                            initCalendar('dl', '');                            //load uploadify button                            $("#fileUpload2").multiUpload({                                uploader : control_vars.host + 'index.php/requests/process_upload',                                dir : html                            });                        }                    });                } else {                    $('#confirm_captcha').attr('value', '').select();                    showError(html);                }            }        });    }    checkForm();}//---------------------------------------------------------//function precheckEmail(value){    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;    if (!filter.test(value)) {        if (document.getElementById('register_submit')) {            $('#register_submit').attr('disabled', true).removeClass('active_big').addClass('inactive_big');        }        return false;    } else {        if (document.getElementById('register_submit')) {        }        return true;    }}//--------------------------------------------------------//function precheckIdentificator(value){    var filter = /^[a-zA-Z0-9_\.\-]/;    if (!filter.test(value)) {        if (document.getElementById('register_submit')) {            $('#register_submit').attr('disabled', true).removeClass('active_big').addClass('inactive_big');        }        return false;    } else {        if (document.getElementById('register_submit')) {        }        return true;    }}//---------------------------------------------------------//function checkLogin(){    if (($('#name').val().length >= control_vars.username_lenth) && ($('#name').val() != 'Please, enter your login...') && ($('#pass').val() != 'Please, enter your pass...') && ($('#pass').val().length > 4))    {        $('#login').attr('disabled', false).attr('class', 'active_big');        return true;    } else {        $('#login').attr('disabled', true).attr('class', 'inactive_big');        return false;    }}//---------------------------------------------------------//function checkFormAdmin() {    var flag = true;    if (($('#first_name').val().length < 3) && ($('#first_name').val() != 'Your first name...')) {        flag = false;    }    if (!precheckEmail($('#email').val())) {        if (($('#email').attr('class') != 'approved') || ($('#email').attr('className') != 'approved')) {            flag = false;        }    }    if (($('#login_add').attr('class') != 'approved') || ($('#login_add').attr('className') != 'approved')) {        flag = false;    }    if (($('#login_add').val().length < control_vars.username_lenth) && ($('#login_add').val() != 'Your login...')) {        flag = false;    }    if (($('#pass_add').val().length < 6) && ($('#pass_add').val() != 'Your pass...')) {        flag = false;    }    if ($('#pass_add').val() != $('#pass_add_ch').val()) {        flag = false;    }    //return flag;    if (flag) {        $('#register, #register_submit').attr('disabled', false).attr('class', 'active_big');    } else {        $('#register, #register_submit').attr('disabled', true).attr('class', 'inactive_big');    }    return flag;}//------------------------------------------------------------//function checkForm() {    var flag = true;    if (($('#first_name').val().length < 3) && ($('#first_name').val() != 'Your name...')) {        flag = false;    }    if (!precheckEmail($('#email').val())) {        if (($('#email').attr('class') != 'approved') || ($('#email').attr('className') != 'approved')) {            flag = false;        }    }    if (($('#pass_add').val().length < 6) && ($('#pass_add').val() != 'Your pass...')) {        flag = false;    }    if ($('#pass_add').val() != $('#pass_add_ch').val()) {        flag = false;    }    if ($('#confirm_captcha').val().length < 4) {        flag = false;    }    if (!$('#terms').attr('checked')) {        flag = false;    }    if (flag) {        $('#register, #register_submit').attr('disabled', false).attr('class', 'active_big');    } else {        $('#register, #register_submit').attr('disabled', true).attr('class', 'inactive_big');    }    return flag;}//---------------------------------------------------------//function checkDiscuss(){    var flag = true;    var filter = /^[\d]{4}\-[\d]{2}\-[\d]{2} [\d]{2}(:[\d]{2})+$/;    //check deadline field    if (!filter.test($('#cngDl').val())) {        flag = false;    }    //comment field    if ($('#cngComment').val().length < 3) {        $('#err_comm').html('<span class="denied">Comment must be longer</span>').css('visibility', 'visible');        flag = false;    } else {        $('#err_comm').empty().css('visibility', 'hidden');    }    if (flag){        $('#cngSend').attr('disabled', false).attr('class', 'active');    } else {        $('#cngSend').attr('disabled', true).attr('class', 'inactive');    }    return flag;}//---------------------------------------------------------//function checkTask(id) {    var flag = true;    var filter = /^[\d]{4}\-[\d]{2}\-[\d]{2} [\d]{2}\:[\d]{2}$/;    //if id passed - we must check only 1 field value    if (typeof(id)=='string') {        //check order title field        if (id == 'ot') {            if ($('#ot').val().length < 3) {                $('#err_ot').html('<span class="denied">Field "Order title" must have more than 3 symbols</span>').css('visibility', 'visible');            } else {                $('#err_ot').html('').css('visibility', 'hidden');            }        }        //check deadline field        if (id == 'dl') {            if (!filter.test($('#dl').val())) {                $('#err_dl').html('<span class="denied">You must place your deadline</span>').css('visibility', 'visible');            } else {                $('#err_dl').html('').css('visibility', 'hidden');            }        }        //check task field        if (id == 'task') {            if ($('#task').val().length < 3) {                $('#err_task').html('<span class="denied">Field "Task" must have more than 3 symbols</span>').css('visibility', 'visible');            } else {                $('#err_task').html('').css('visibility', 'hidden');            }        }        return false;    } else  //if no id was passed - fullcheck the form and disable button if needed{        //check order title field        if ($('#ot').val().length < 3)        {            flag = false;            $('#err_ot').html('<span class="denied">Field "Order title" must have more than 3 symbols</span>').css('visibility', 'visible');        } else {            $('#err_ot').html('').css('visibility', 'hidden');        }        //check deadline field        if (!filter.test($('#dl').val()))        {            flag = false;            $('#err_dl').html('<span class="denied">You must place your deadline</span>').css('visibility', 'visible');        } else {            $('#err_dl').html('').css('visibility', 'hidden');        }        //task field        if ($('#task').val().length < 3)        {            flag = false;            $('#err_task').html('<span class="denied">Field "Task" must have more than 3 symbols</span>').css('visibility', 'visible');        } else {            $('#err_task').html('').css('visibility', 'hidden');        }        //check subject        if ( $('#task_subject option:selected').text().length < 2)        {            $('#err_subject').html('<span class="denied">Select the subject</span>').css('visibility', 'visible');            flag = false;        } else {            $('#err_subject').html('').css('visibility', 'hidden');        }        //check category        if ( $('#task_category option:selected').text().length < 2)        {            $('#err_category').html('<span class="denied">Select the category</span>').css('visibility', 'visible');            flag = false;        } else {            $('#err_category').html('').css('visibility', 'hidden');        }        //check level        if ( $('#task_level option:selected').text().length < 2)        {            $('#err_level').html('<span class="denied">Select the level</span>').css('visibility', 'visible');            flag = false;        } else {            $('#err_level').html('').css('visibility', 'hidden');        }        if (flag){            $('#order').attr('disabled', false).attr('class', 'active_big');        } else {            $('#order').attr('disabled', true).attr('class', 'inactive_big');        }        return flag;    }}//---------------------------------------------------------//function checkFirstTask(id){    //first check the task fields    var flag = checkTask(id);    if (flag){        $('#task_submit').attr('disabled', false).attr('class', 'active_big');    } else {        $('#task_submit').attr('disabled', true).attr('class', 'inactive_big');    }}//---------------------------------------------------------///* * function checks p#f1_uploaded_files element if it has child divs * this divs id is our required filenames divided by comas * @return string with filenames divided by comas */function getUploadedFiles() {    return $('.inp_file_filename').size();}//---------------------------------------------------------//function restPass(){    $('#restore_pass').slideToggle();}//---------------------------------------------------------//function checkRestore(){    if ($('#rest_em').val() == 'Please enter your e-mail...') {        $('#rest_em').attr('value', '')    }    if(precheckEmail($('#rest_em').val())){        $('#rp').attr('disabled', false).attr('class', 'active_big')    } else {        $('#rp').attr('disabled', true).attr('class', 'inactive_big')    }}//---------------------------------------------------------//function restore(){    var url = control_vars.host + "index.php/requests/ResetPassword";    $.ajax({        url : url,        type : 'post',        data : {            email : $('#rest_em').val()        },        success : function(html) {            showError(html);            $('#rp').attr('disabled', true).attr('class', 'inactive');            $('#rest_em').val('');            if ($('#restore_pass').css('display') == 'block') {                $('#restore_pass').slideToggle();            }        }    });}//---------------------------------------------------------//function logout(e){    var url = control_vars.host + "index.php/requests/logout";    $.ajax({        url : url,        success : function(){            window.location = "http://" + location.host;        }    });}//---------------------------------------------------------//function placeOrder(e){    if ($('.MultiFile-remove').size() > 0 || upload_active) {        alert(error.upload_denied);        return;    }    function gatherTask() {        var result ='order_title=' + encodeURIComponent($('#ot').val())        + '&cat_id=' + encodeURIComponent($('#task_category option:selected').val())        + '&level_id=' + encodeURIComponent($('#task_level option:selected').val())        + '&deadline=' + encodeURIComponent($('#dl').val())        + '&task_info=' + encodeURIComponent($('#task').val())        + '&chb_detailed=' + ($('#chb').attr('checked')?'yes':'no')        + '&' + (($('#sr').val().length > 2) ? 'spec_info=' + encodeURIComponent($('#sr').val()) + '&' : '');//        $('#dl, #task, #sr, #ot').val('');//        document.getElementById('task_subject').selectedIndex = 0;//        while (document.getElementById('task_category').firstChild) {//            document.getElementById('task_category').removeChild(document.getElementById('task_category').firstChild);//        }//        document.getElementById('task_level').selectedIndex = 0;//        $('#task_subject, #task_level, #task_category').change();//        $('#chb').attr('checked', false);        //files        var resultf = '';        var fileNum = $('#fileUpload2 .inp_file_filename').size();        if ( fileNum > 0 ) {            for (var i = 0; i < fileNum; i++) {                if ($('#fileUpload2 .inp_file_filename')[i].innerHTML.length > 0){                    var ttmp = 'uploaded_files/' + $('#fileUpload2').multiUpload_upl.dir + '/' + $('#fileUpload2 .inp_file_filename')[i].innerHTML;                    resultf += ttmp + ',';                }            }        } else {            resultf = '';        }        result +='attached_files=' + encodeURIComponent(resultf) + '&';        $('.MultiFile-list').empty()        return result;    }    var param = gatherTask();    MoveUp();    var url = control_vars.host + "index.php/requests/add_task";    $.ajax({        url : url,        type : 'post',        data : param,        success : function(){            showError15('We have received your inquiry. Please wait until our expert evaluates. The AssignmentExpert.com will contact you ASAP.');            $('#ordHist').click();            setTimeout('showTheLastTask()', 1000);        }    });}//---------------------------------------------------------//function checkFilter(){    var ids = arguments;    var ids_num = ids.length;    var elem;    for (var i = 0; i < ids_num; i++ ){        if (typeof(ids[i]) == 'string') {            if (document.getElementById(ids[i])) {                elem = document.getElementById(ids[i]);                switch (elem.tagName) {                    case 'INPUT':                        if(elem.id == 'since') {}//there goes check for date                        if(elem.id == 'until') {}//there goes check for date                        if(elem.value.length > 0){                            $('#applyFilter, #removeFilter').attr('disabled', false).attr('class', 'active');                        }else{                            $('#applyFilter, #removeFilter').attr('disabled', true).attr('class', 'inactive');                        }                        break;                    case 'SELECT':                        if(parseInt(elem.value) > -1){                            $('#applyFilter, #removeFilter').attr('disabled', false).attr('class', 'active');                        }else{                            $('#applyFilter, #removeFilter').attr('disabled', true).attr('class', 'inactive');                        }                        break;                    default:                        break;                }            }        }    }}//---------------------------------------------------------//function getHistory(){    changeTabAdm('ordHist');    var page = 0;    var per_page = $('#items_per_page option:selected').val();    if (arguments.length > 0) {        page = arguments[0];    }    //filter fieldsets    var newHtml = '<table class="t" cellpadding="0" cellspacing="0">\n\		<tr><td style="text-align:left; vertical-align:top">\n\			<table class="t2" style="border:1px;" cellpadding="0" cellspacing="0">\n\				<tr><td><div id="orders"></div></td>\n\				</tr>\n\			</table></td></tr>\n\		<tr class="taskInfo"><td colspan="6" align="center"></td></tr>\n\		</table>';    $('#ok').html(newHtml);    var param = {        page : page,        per_page : per_page    };    var url = control_vars.host + "index.php/requests/get_history";    $.ajax({        url: url,        type: 'post',        data: param,        success: function (html)        {            $('#orders').html(html);            sortables_init();            init_highlight_not_seen();            highlight_statuses('table.admin_table_grey', 'div.admin_table_margin_min');            $('div#orders table#unique_id tr td:nth-child(1)').css('text-align', 'center').css('width', '20px');            $('div#orders table#unique_id tr td:nth-child(2)').css('text-align', 'center').css('width', '30px');            $('div#orders table#unique_id tr td:nth-child(6)').css('text-align', 'center');        }    });}//---------------------------------------------------------//function searchTask(){    //$('#error').empty();    if ($('div#noData')[0]) $('div#noData').remove();    if ($('div#pages')[0]) $('div#pages').remove();    if ($('tr.taskInfo td[colspan=6]')) $('tr.taskInfo td[colspan=6]').empty();    if ($('#task_item')[0]) $('#task_item').empty();    var filter = /^[\d]{4}\-[\d]{2}\-[\d]{2}$/;    var name = '';    var since = '';    var until = '';    var status = '';    var type = '';    if ($('#nameSearch').val()) {        name = $('#nameSearch').val();    }    if ($('#since').val() && $('#since').val().search(filter) != -1) {        since = $('#since').val();    }    if ($('#until').val() && $('#until').val().search(filter) != -1) {        until = $('#until').val();    }    if ($('select#byTask option:selected').val()) {        status = $('select#byTask option:selected').val();    }    if (typeof ($("input[name='type']:checked").val()) != 'undefined') {        type = $("input[name='type']:checked").val();    }    var param = {        'name' : name,        'until' : until,        'since' : since,        'status' : status,        'type' : type    };    var url = control_vars.host + 'index.php/requests/search_task';    $.ajax({        url: url,        type: 'post',        data: param,        success: function (html) {            $('table#unique_id').remove();            $('#orders').prepend(html);            sortables_init();            init_highlight_not_seen();        }    });}//---------------------------------------------------------//function viewOrders(s){    $('#orders').html(s + '<p><input type="button" disabled value="Info" id="btnInfo" onclick="getTaskInfo()" class="disabled"></p>');    sortables_init();}//---------------------------------------------------------//function viewUserProfile(){    changeTabAdm('myProf');    $('#changeProfile').unbind('click');    $('div#filter').empty();    $('#ok').load(control_vars.host + "index.php/requests/get_user_profile", '', '');}//---------------------------------------------------------//function orderConstructor(){    changeTabAdm('newOrd');    $.ajax({        data : '',        type : 'get',        url : control_vars.host + "index.php/requests/set_task",        success : function(html){            $('#ok').attr('innerHTML', html);            initCalendar('dl', '');            $.ajax({                url : control_vars.host + 'index.php/requests/get_logged_dir',                success : function (html) {                    $("#fileUpload2").multiUpload({                        uploader : control_vars.host + 'index.php/requests/process_upload',                        dir : html                    });                    //jQuery(".input_select").select_skin();                    createDropDown(document.getElementById('ts_cont1'));                    createDropDown(document.getElementById('tc_cont1'));                    createDropDown(document.getElementById('tl_cont1'));                    $('#question').tooltip({                        track: true,                        delay: 0,                        fade: 100,                        bodyHandler: function() {                            var ids = $(this).attr('id');                            return $('#span_'+ids).html();                        },                        showURL: false                    });                    $('#question2').tooltip({                        track: true,                        delay: 0,                        fade: 100,                        bodyHandler: function() {                            var ids = $(this).attr('id');                            return $('#span_'+ids).html();                        },                        showURL: false                    });                }            });        }    });}//---------------------------------------------------------//var SORT_COLUMN_INDEX;function sortables_init(){    // Find all tables with class sortable and make them sortable    if (!document.getElementsByTagName("table"))        return;    var tbls = document.getElementsByTagName("table");    for (var ti = 0; ti < tbls.length; ti++) {        var thisTbl = tbls[ti];        if (((' ' + thisTbl.className + ' ').indexOf("sortable") != -1) && (thisTbl.id)) {            ts_makeSortable(thisTbl);            makeStripe(thisTbl);        }    }}//---------------------------------------------------------//function makeStripe(thisTbl){    //make thead always at the top of ok div    $('.scroll_table table.sortable').each(function(){        if ($(this).find('thead tr').size() < 2){            var new_t = $(this).find('thead tr:first-child').html();            $(this).find('thead').append('<tr style="visibility:hidden">' + new_t + '</tr>');            $(this).find('thead > tr:first-child')            .css({                'position':'absolute',                'top':'-1px',                'border-top':'solid 1px #CCC',                'margin':'0',                'padding':'0',                'width':'100%',                'background':'#FFF',                'z-index':'1'            });            var thead_rows = $(this).find('thead > tr:first-child > td');            var thead_rows2 = $(this).find('thead > tr:last-child > td');            var t_rows = $(this).find('tbody > tr:first-child > td');            var k = 0;            t_rows.each(function(){                thead_rows.eq(k).css({                    'width':(this.offsetWidth) + 'px',                    'height':'10px !important',                    'padding':0,                    'border':'none'                });                thead_rows2.eq(k).css({                    'width':(this.offsetWidth) + 'px',                    'height':'10px !important',                    'padding':0,                    'border':'none'                });                k++;            })            var tr_w = 0;            $(this).find('tbody>tr:first-child').each(function(){                if (tr_w == 0){                    tr_w = this.offsetWidth;                }            })            $(this).find('thead > tr:first-child').css('width', tr_w + 'px');            //make thead always at the top of ok div            if (!thisTbl.getElementsByTagName)                return;            var rows = $(this).find('tbody > tr');            var i = 0;            rows.each(function(){                if ($(this).attr('class') == '' || this.className == 'odd' || this.className == 'even') {                    $(this).css('background-color', ((i % 2) == 0 ? "#FFF" : "#EEE"))                    .attr('class', ((i % 2) == 0 ? "odd" : "even"));                }                i++;            });        }        $('table.sortable tr.even').unbind('mouseover').bind('mouseover', function() {            this.style.backgroundColor = '#ddd';        }).unbind('mouseout').bind('mouseout', function() {            this.style.backgroundColor = '#eee';        }).unbind('click').bind('click', function() {            this.style.backgroundColor = '#ddd';        });        $('table.sortable tr.odd').bind('mouseover', function() {            this.style.backgroundColor = '#ddd';        }).bind('mouseout', function() {            this.style.backgroundColor = '#fff';        });        $("#tableTaskHead").unbind('mouseover').unbind('mouseout');    })}//---------------------------------------------------------//function ts_makeSortable(table){    if (table.rows && table.rows.length > 0)        var firstRow = table.rows[0];    if (!firstRow) {        return;    }    // We have a first row: assume it's the header, and make its contents clickable links    for (var i = 0; i < firstRow.cells.length; i++) {        var cell = firstRow.cells[i];        if (cell.className.indexOf("unsort") == -1) {            var txt = ts_getInnerText(cell);            cell.innerHTML = '<a href="#" class="sortheader" id="table_a_header_'+i+'" onclick="ts_resortTable(this);return false;">' + txt + '<span class="sortarrow"></span></a>';        }    }}//---------------------------------------------------------//function ts_getInnerText(el){    if (typeof el == "string"){        return el;    }    if (typeof el == "undefined"){        return el;    }    if (el.innerText){        return el.innerText; //Not needed but it is faster    }    var str = "";    var cs = el.childNodes;    var l = cs.length;    for (var i = 0; i < l; i++){        switch (cs[i].nodeType){            case 1: //ELEMENT_NODE                str += ts_getInnerText(cs[i]);                break;            case 3: //TEXT_NODE                str += cs[i].nodeValue;                break;        }    }    return str;}//---------------------------------------------------------//function ts_resortTable(lnk){    var span;    for (var ci = 0; ci < lnk.childNodes.length; ci++)        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span')            span = lnk.childNodes[ci];    var td = lnk.parentNode;    var column = td.cellIndex;    var table = getParent(td, 'TABLE');    // Work out a type for the column    if (table.rows.length <= 1)        return;    var itm = ts_getInnerText(table.rows[1].cells[column]);    var sortfn = ts_sort_caseinsensitive;    if (itm.match(/^[\d\.-]+$/))        sortfn = ts_sort_numeric;    //check title of the column to force sort function to the type needed    if( lnk.text in oc(forced_to_sortnum) ) {        sortfn = ts_sort_numeric;    } else if( lnk.text in oc(forced_to_sortstring) ) {        sortfn = ts_sort_caseinsensitive;    }    SORT_COLUMN_INDEX = column;    var firstRow = new Array();    var newRows = new Array();    for (var i = 0; i < table.rows[0].length; i++)        firstRow[i] = table.rows[0][i];    for (var j = 0; j < table.tBodies[0].rows.length; j++) {        newRows.push(table.tBodies[0].rows[j]);    }    newRows.sort(sortfn);    if (span.getAttribute("sortdir") == 'down') {        newRows.reverse();        span.setAttribute('sortdir', 'up');    } else        span.setAttribute('sortdir', 'down');    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones    // don't do sortbottom rows    for (i = 0; i < newRows.length; i++){        if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))){            table.tBodies[0].appendChild(newRows[i]);        }    }    // do sortbottom rows only    for (i = 0; i < newRows.length; i++){        if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)){            table.tBodies[0].appendChild(newRows[i]);        }    }    makeStripe(table);}//---------------------------------------------------------//function getParent(el, pTagName){    if (el == null)        return null;    else    if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) // Gecko bug, supposed to be uppercase        return el;    else        return getParent(el.parentNode, pTagName);}//---------------------------------------------------------//function ts_sort_numeric(a, b){    var aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));    if (isNaN(aa))        aa = 0;    var bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));    if (isNaN(bb))        bb = 0;    return aa - bb;}//---------------------------------------------------------//function ts_sort_caseinsensitive(a, b){    var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();    var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();    if (aa == bb)        return 0;    if (aa < bb)        return -1;    return 1;}//---------------------------------------------------------//function ts_sort_default(a, b){    var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);    var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);    if (aa == bb)        return 0;    if (aa < bb)        return -1;    return 1;}/******************************************END SORT ******************************************///---------------------------------------------------------///** function highlights table rows with received status* @param table [object] table to highlight* @param value [string] rows with this keyword will be highlighted*/function highlight_by_status(table, value){    var firstRow = table.rows[0];    var status_row = 0;    var re = "/" + value + "/i";    re = eval(re); //change it to an object    for (var ci = 0; ci < firstRow.cells.length; ci++){        if (firstRow.cells[ci].getElementsByTagName('a')[0].innerHTML.toLowerCase().match(/status.*/i) != null){            status_row = ci;        }    }    for (var i = 1; i < table.rows.length; i++){        if (table.rows[i].cells[status_row].innerHTML.toLowerCase().match(re) != null){            $(table.rows[i]).attr('class', 'highlight');        }    }    $('table.sortable tr.highlight').unbind('mouseover').bind('mouseover', function() {        setClass(this, 'highlight-over');    }).unbind('mouseout').bind('mouseout', function() {        setClass(this, 'highlight');    }).unbind('click');}//---------------------------------------------------------//function init_highlight_not_seen(){    $('table.sortable tr.not_seen').unbind('mouseover').bind('mouseover', function() {        setClass(this, 'not_seen-over');    }).unbind('mouseout').bind('mouseout', function() {        setClass(this, 'not_seen');    }).unbind('click');}//--------------------------------------------------------------//function highlight_statuses(title_row_class, div_with_order_table_class){    //number of td elements    var row_size = $(title_row_class + ':first td').size();    var order_tables = $(div_with_order_table_class + ' table');    var tables_size = $(order_tables).size();    var status_row = 0;    var re_statuses = [];    var statuses = ['new', 'checking', 'discussion', 'waiting for payment', 'solving', 'done'];    var colors = ['red', 'orange', 'blue', 'green_blink', 'yellow', 'gray'];    for( var re_i = 0; re_i < statuses.length; re_i++){        re_statuses[re_i] = eval('/' + statuses[re_i] + '/i');    }    for (var ci = 1; ci <= row_size; ci++){        //find the number of status row        if ($(title_row_class + ':first td:nth-child(' + ci + ')').html().toLowerCase().match(/status.*/i) != null){            status_row = ci;        }    }    //highlight statuses of each table    for (var i = 0; i < tables_size; i++){        for(var ii = 0; ii < statuses.length; ii++){            if ($(div_with_order_table_class + ':nth(' + i + ') table tbody tr td:nth(' + (status_row - 1) + ')').html().toLowerCase().match(re_statuses[ii]) != null){                $(div_with_order_table_class + ':nth(' + i + ') table tbody tr td:nth(' + (status_row - 1) + ')').html('<span class="' + colors[ii] + '">' + $(div_with_order_table_class + ':nth(' + i + ') table tbody tr td:nth(' + (status_row - 1) + ')').html() + '</span>');            }        }    }    $('table.sortable tr.highlight').unbind('mouseover').bind('mouseover', function() {        setClass(this, 'highlight-over');    }).unbind('mouseout').bind('mouseout', function() {        setClass(this, 'highlight');    }).unbind('click');}//---------------------------------------------------------///** function highlights table rows with received status* @param table [object] table to highlight* @param row_title [string] rows with this title will be searched to contain value* @param value [string] rows with this keyword will be highlighted*/function highlight_by_field_param(table, row_title, value){    var firstRow = table.rows[0];    var searched_row = 0;    var reVal = "/" + value + "/i";    reVal = eval(reVal); //change it to an object    var reTitle = "/" + row_title + "/i";    reTitle = eval(reTitle); //change it to an object    for (var ci = 0; ci < firstRow.cells.length; ci++){        if (firstRow.cells[ci].getElementsByTagName('a')[0].innerHTML.toLowerCase().match(reTitle) != null){            searched_row = ci;        }    }    for (var i = 1; i < table.rows.length; i++){        if (table.rows[i].cells[searched_row].innerHTML.toLowerCase().match(reVal) != null){            setClass(table.rows[i].cells[searched_row], 'highlight_content');        }    }}//----------------------------------------------------------//function highlight_by_field_approved(table, row_title, value){    var firstRow = table.rows[0];    var searched_row = 0;    var reVal = "/" + value + "/i";    reVal = eval(reVal); //change it to an object    var reTitle = "/" + row_title + "/i";    reTitle = eval(reTitle); //change it to an object    for (var ci = 0; ci < firstRow.cells.length; ci++){        if (firstRow.cells[ci].getElementsByTagName('a')[0].innerHTML.toLowerCase().match(reTitle) != null){            searched_row = ci;        }    }    for (var i = 1; i < table.rows.length; i++){        if (table.rows[i].cells[searched_row].innerHTML.toLowerCase().match(reVal) != null){            setClass(table.rows[i].cells[searched_row], 'highlight_approved');        }    }}//---------------------------------------------------------//function highlight_price_if_received(table, highlighted_row_title, status_row_title){    var firstRow = table.rows[0];    var searched_row_1 = 0, final_row = 0;    var reVal = "/" + highlighted_row_title + "/i";    reVal = eval(reVal); //change it to an object    var reTitle1 = "/" + status_row_title + "/i";    reTitle1 = eval(reTitle1); //change it to an object    var appVal = ['solving', 'solution sended', 'done'];    for (var ci = 0; ci < firstRow.cells.length; ci++) {        //search first approved row        if (firstRow.cells[ci].getElementsByTagName('a')[0].innerHTML.toLowerCase().match(reTitle1) != null) {            searched_row_1 = ci;        }        //highlighted row number        if (firstRow.cells[ci].getElementsByTagName('a')[0].innerHTML.toLowerCase().match(reVal) != null) {            final_row = ci;        }    }    var summ = 0;    for (var i = 1; i < table.rows.length; i++) {        for (var j = 0; j < appVal.length; j++) {            if (table.rows[i].cells[searched_row_1].innerHTML.toLowerCase().match(appVal[j])) {                setClass(table.rows[i].cells[final_row], 'highlight_content');                summ += parseFloat(table.rows[i].cells[final_row].innerHTML);            }        }    }    $('#price_shet').prepend('<div class="float_left">' + summ + '$</div>');}//---------------------------------------------------------//function loadTask(id){    var url = control_vars.host + "index.php/requests/load_task/";    $.ajax({        url : url,        type : 'post',        data : 'id=' + id,        success : function(html) {            $('#task_item').html(html);        }    });    if (parseInt($('#spanId').attr('name'), 10) > 0) {        $("table.t tr.taskInfo td").slideUp(500, function () {            $("tr.taskInfo td table.task_info").remove();        });    }}//---------------------------------------------------------//function changeProfile(e){    $('#last_name, #first_name, #email, #login_add').attr('disabled', false);    userProfile = new Array($('#first_name').val(),$('#email').val());    $('#pass_tr1, #pass_tr2, #pass_tr3, #pass_tr1_err, #pass_tr2_err, #pass_tr3_err, #cancelProfile').css('display', '');    $('#changeProfile').css('display', 'none');}//---------------------------------------------------------//function processLoginInput(field){    //for name field    if (field.id == 'name' && field.value == 'Please, enter your login...'){        field.value = '';        return false;    }    if (field.id == 'name' && field.value == ''){        field.value = 'Please, enter your login...';        return false;    }}//---------------------------------------------------------///*** function сhecks the inputed value on registration page*/function processAuthInput(field){    //for first_name field    if (field.id == 'first_name' && field.value == ''){        field.value = 'Your name...';        return;    }    if (field.id == 'first_name' && field.value == 'Your name...'){        field.value = '';        return;    }    //for last_name field    if (field.id == 'last_name' && field.value == 'Your last name...'){        field.value = '';        return;    }    if (field.id == 'last_name' && field.value == '')	{        field.value = 'Your last name...';        return;    }    //for email field    if (field.id == 'email' && field.value == 'Your e-mail...'){        field.value = '';        return;    }    if (field.id == 'email' && field.value == ''){        field.value = 'Your e-mail...';        return;    }    //for login_add field    if (field.id == 'login_add' && field.value == 'Your login...'){        field.value = '';        return;    }    if (field.id == 'login_add' && field.value == ''){        field.value = 'Your login...';        return;    }}//---------------------------------------------------------///*** function сhecks the inputed value on registration page*/function processUserProfileInput(field){    function checkSaveButton(){        if (            (($('#first_name').val().length > 3) && ($('#first_name').val() != userProfile[0])) ||            ((precheckEmail($('#email').val())) && ($('#email').val() != userProfile[1]) && ($('#email').attr('className') != 'denied')) ||            (($('#pass_new').val() == $('#pass_new_cf').val()) && ($('#pass_new').val().length > 5))            ){            enableInputs('saveProfile');        }	else {            disableInputs('saveProfile');        }    }    if (typeof (field) != 'undefined'){        if (field.id == 'first_name'){            if (field.value == ''){                $('#first_name').attr('value', userProfile[0]);                $('#err_fn').html('').css('visibility', 'hidden');                checkSaveButton();                return;            }	else if (field.value.length < 3){                $('#err_fn').html('<span class="denied">This name is too short</span>').css('visibility', 'visible');                checkSaveButton();                return;            }	else if (field.value.length > 3) {                $('#err_fn').html('').css('visibility', 'hidden');                checkSaveButton();                return;            }        }        //email check        if (field.id == 'email'){            if (field.value == ''){                field.value = userProfile[2];                $('#err_em').html('').css('visibility', 'hidden');                checkSaveButton();                return;            }	else if (precheckEmail(field.value)) {                checkSaveButton();                $('#err_em').html('').css('visibility', 'hidden');                return;            } else if (!precheckEmail(field.value)) {                checkSaveButton();                $('#err_em').html('<span class="denied">E-mail adress is wrong</span>').css('visibility', 'visible');                return;            }        }        //new passwords        if (field.id == 'pass_new' || field.id == 'pass_new_cf') {            if ($('#pass_new').val().lenght < 6 || $('#pass_new_cf').val().lenght < 6) {                $('#err_pass_new').html('<span class="denied">Password length must be more than 6 symbols</span>').css('visibility', 'visible')            }            checkSaveButton();            return;        } else {            checkSaveButton();            return;        }    } else {        checkSaveButton();    }}//---------------------------------------------------------///** function submits new values of user profile to server* after successfull updating - returns status message into #error*/function updateUserProfile(){    var url = control_vars.host + 'index.php/requests/update_profile';    $.ajax({        url: url,        type: 'post',        data: 'first_name='+ $('#first_name').val() + '&'        + 'email='+ $('#email').val() + '&'        + 'pass_old='+ $('#pass_old').val() + '&'        + 'pass_new='+ $('#pass_new').val() + '&'        + 'pass_new_cf='+ $('#pass_new_cf').val(),        success: function(html){            //MAKE NULL USERPROFILE ARRAY            userProfile = null;            showError(html);            viewUserProfile();        },        error: function(){            showError(error.server);        }    });}//---------------------------------------------------------///** function do AJAX check of inputted login on the registration page*/function checkUsername(field){    if ((field.value != 'Your login...') && (field.value.length >= control_vars.username_lenth)) {        $('#' + field.id).removeClass().addClass('thinking');        $('#err_' + field.id).html('<span style="color:black;">Processing...</span>').css('visibility', 'visible');        var usernameField = field;        var url= control_vars.host + "index.php/requests/check_login/"        $.ajax({            url: url,            type: 'post',            data:'login='+ $("#login_add").val(),            success: function(html){                if (html == "okay")	{                    $('#' + field.id).removeClass().addClass('approved');                    $('#err_' + usernameField.id).html('<span class="success">You may use this login</span>').css('visibility', 'visible');                    usernameValid = true;                } else if (html == "denied") {                    $('#' + field.id).removeClass().addClass('denied');                    $('#err_' + usernameField.id).html('<span class="denied">Sorry, but this login is already registered</span>').css('visibility', 'visible');                    usernameField.focus();                    usernameField.select();                    usernameValid = false;                } else if (html == "this is you")	{                    $('#' + field.id).removeClass().addClass('approved');                    $('#err_' + usernameField.id).html('<span class="current">This is your current username</span>').css('visibility', 'visible');                    usernameValid = true;                }            }        });    }}//---------------------------------------------------------///** function does AJAX check of inputted login on the registration page*/function confirmPass(field){    if (field.value.length > 5) {        $('#' + field.id).removeClass().addClass('thinking');        $('#err_' + field.id).html('<span style="color:black;">Processing...</span>').css('visibility', 'visible');        passField = field;        var url= control_vars.host + "index.php/requests/confirm_pass/";        $.ajax({            url: url,            type: 'post',            data:'password='+ field.value,            success: function(html) {                if (html == "okay") {                    $('#' + field.id).removeClass().addClass('approved');                    $('#err_' + passField.id).html('<span class="success">Password accepted</span>').css('visibility', 'visible');                    $('#' + field.id).attr('disabled', true);                    $('#fake_pass_new, #fake_pass_new_cf').attr('disabled', false);                    passValid = true;                } else if (html == "denied") {                    $('#' + field.id).removeClass().addClass('denied');                    $('#err_' + passField.id).html('<span class="denied">Sorry, but your password is not correct</span>').css('visibility', 'visible');                    passField.focus();                    passField.select();                    $('#fake_pass_new, #fake_pass_new_cf').attr('disabled', true);                    $('#' + field.id).attr('disabled', false);                    passValid = false;                }            }        });    }}//---------------------------------------------------------///** function do AJAX check of inputted email adress on the registration page*/function checkEmail(handler) {    emailValid = false;    $('#email').removeClass().addClass('thinking');    $('#err_em').html('<span style="color:black;">Processing...</span>').css('visibility', 'visible');    var url= control_vars.host + "index.php/requests/check_email";    var theMail = $("#email").val();    $.ajax({        url: url,        type: 'post',        data:'email='+ theMail,        success: function(html) {            if (html == "okay") {                $('#email').removeClass().addClass('approved');                $('#err_em').html('<span class="success">E-mail is valid</span>').css('visibility', 'visible');                emailValid = true;            } else if (html == "denied") {                $('#email').removeClass().addClass('denied');                $('#err_em').html('<span class="denied">Sorry, but this e-mail is already registered or doesn\'t exist</span>').css('visibility', 'visible');                $("#email").focus().select();                emailValid = false;            } else if (html == "this is you") {                $('#email').removeClass().addClass('approved');                $('#err_em').html('<span class="current">This is your current e-mail</span>').css('visibility', 'visible');                emailValid = true;            }            if (handler) {                if (typeof handler == 'function') {                    if (emailValid)                        handler();                }            }        }    });}function checkEmail_domain(handler) {    $('#email').removeClass().addClass('thinking');    $('#err_em').html('<span style="color:black;">Processing...</span>').css('visibility', 'visible');    var url= control_vars.host + "index.php/requests/check_email_domain";    var theMail = $("#email").val();    $.ajax({        url: url,        type: 'post',        data:'email='+ theMail,        success: function(html) {            if (html == "okay") {                $('#email').removeClass().addClass('approved');                $('#err_em').html('<span class="success">E-mail is valid</span>').css('visibility', 'visible');                emailValid = true;            } else if (html == "denied") {                $('#email').removeClass().addClass('denied');                $('#err_em').html('<span class="denied">Sorry, but this e-mail doesn\'t exist</span>').css('visibility', 'visible');                $("#email").focus().select();                emailValid = false;            } else if (html == "this is you") {                $('#email').removeClass().addClass('approved');                $('#err_em').html('<span class="current">This is your current e-mail</span>').css('visibility', 'visible');                emailValid = true;            }            if (handler) {                if (typeof handler == 'function') {                    if (emailValid)                        handler();                }            }        }    });}function check_identificator(handler) {    $('#identificator').removeClass().addClass('thinking');    $('#err_iden').html('<span style="color:black;">Processing...</span>').css('visibility', 'visible');    var url= control_vars.host + "index.php/requests/check_identificator";    var theIden = $("#identificator").val();    var theIdSat = $("input[name='satelit']:checked").val();    $.ajax({        url: url,        type: 'post',        data: 'ident='+ theIden+'&id='+theIdSat,        success: function(html) {            if (html == "okay") {                $('#identificator').removeClass().addClass('approved');                $('#err_iden').html('<span class="success">Identificator is valid</span>').css('visibility', 'visible');                emailValid = true;            } else if (html == "denied") {                $('#identificator').removeClass().addClass('denied');                $('#err_iden').html('<span class="denied">Sorry, but this Identificator doesn\'t exist</span>').css('visibility', 'visible');                $("#identificator").focus().select();                emailValid = false;            }            if (handler) {                if (typeof handler == 'function') {                    if (emailValid)                        handler();                }            }        }    });}function check_new_identificator(obj) {    $('#identificator').removeClass().addClass('thinking');    $('#err_iden').html('<span style="color:black;">Processing...</span>').css('visibility', 'visible');    var url= control_vars.host + "index.php/requests/check_new_identificator";    var theIden = obj.value;    $.ajax({        url: url,        type: 'post',        data: 'ident='+ theIden,        success: function(html) {            if (html == "okay") {                $('#identificator').removeClass().addClass('approved');                $('#err_iden').html('<span class="success">Identificator is valid</span>').css('visibility', 'visible');                emailValid = true;            } else if (html == "denied") {                $('#identificator').removeClass().addClass('denied');                $('#err_iden').html('<span class="denied">Sorry, but this Identificator doesn\'t exist</span>').css('visibility', 'visible');                $("#identificator").focus().select();                emailValid = false;            }        }    });}function checkEmail_domain_type(us, id) {    if (parseInt(id) > 0 ){        id = id;    } else {        id = 0;    }    $('#email').removeClass().addClass('thinking');    $('#err_em').html('<span style="color:black;">Processing...</span>').css('visibility', 'visible');    var url= control_vars.host + "index.php/requests/check_email_domain_type";    var theMail = $("#email").val();    var param = {        'email': theMail,        'type_user':us,        'id':id    };    $.ajax({        url: url,        type: 'post',        data: param,        success: function(html) {            if (html == "okay") {                $('#email').removeClass().addClass('approved');                $('#err_em').html('<span class="success">E-mail is valid</span>').css('visibility', 'visible');                emailValid = true;            } else if (html == "denied") {                $('#email').removeClass().addClass('denied');                $('#err_em').html('<span class="denied">Sorry, but this e-mail is already used or doesn\'t exist</span>').css('visibility', 'visible');                $("#email").focus().select();                emailValid = false;            } else if (html == "this is you") {                $('#email').removeClass().addClass('approved');                $('#err_em').html('<span class="current">This is your current e-mail</span>').css('visibility', 'visible');                emailValid = true;            }        }    });}//---------------------------------------------------------///** function loads values to select 'categories' according to value of select 'subjects'*/function loadTaskCats(id_parent_select, id_child_select){    var theId = $('#'+id_parent_select).val();    if ((theId != -1) && (theId != 0)) {        var url= control_vars.host + "index.php/requests/load_task_cats/";        $.ajax({            url: url,            type: 'post',            dataType: 'json',            data: {                'id':theId            },            success: function(html) {                var ret = '';                if (!html.error){                    for(var i = 0; i < html.length; i++){                        ret += '<option value="' + html[i].cat_id + '">' + html[i].title + '</option>';                    }                    $('#' + id_child_select + '_fdd').remove()                    $('#' + id_child_select).html(ret).change();                    if (document.getElementById('tc_cont1')) createDropDown(document.getElementById('tc_cont1'));                } else {                    showError(html.error);                }            }        });    }}//---------------------------------------------------------///** FUNCTION load task information intothe bottom of the page*/function getTaskInfo(selected){    selected = parseInt(selected);    if ($('div#order_info').size() == 0 || selected != $('#spanId').attr('name'))    {        var url = control_vars.host + "index.php/requests/load_task_info";        $.ajax({            url: url,            type: 'post',            data:'id='+ selected,            success: function(html) {                $('div#order_info').remove();                $("div#task_div_" + selected).after(html);                $('div.admin_table_margin_min table').attr('class', 'admin_table_order');                $('div#task_div_' + selected + ' table').attr('class', 'admin_table_green');                $("div#order_info").slideDown('fast');                $('.admin_table_margin_min .td6 a').html('View');                $('#a' + selected).html('Hide');            }        });    } else {        $('div#order_info').remove();        $('div#task_div_' + selected + ' table').attr('class', 'admin_table_order');        $('#a' + selected).html('View');    }}//---------------------------------------------------------///** function gets task_process_statuses table and appends select in fieldset#byTask*/function printProcessStatuses(id){    $.ajax({        dataType:'json',        url : control_vars.host + 'index.php/requests/get_process_statuses',        success : function (data){            var newHtml = '<option value="-1" selected></option>';            var i = data.length - 1;            while(i > 0){                newHtml += '<option value="' + data[i].pid + '" name="searchStatus">' + data[i].title + '</option>';                i--;            }            $('#' + id).html(newHtml);        }    });}//---------------------------------------------------------//function viewTaskHistory(){    var id = $('#spanId').attr('name');    if ($('#fullhistorycontent').size() <= 0) {        var param = {            id : id        };        var url = control_vars.host + 'index.php/requests/view_task_history';        $.ajax({            url : url,            type : 'post',            data : param,            success : function(html) {                $('div.scroll:first').html('<div id="fullhistorycontent">' + html + '</div>');                if (document.getElementById('fullHistory')) {                    $('#fullHistory').attr('value', 'Hide History');                }            }        });    } else {        //emulate taskInfo button click        var selected = $("#spanId").attr('name');        url = control_vars.host + "index.php/requests/load_task_info";        $.ajax({            url: url,            type: 'post',            data:'id='+ selected,            success: function(html) {                $('div#order_info').remove();                $("div#task_div_" + selected).after(html);                $('div.admin_table_margin_min table').attr('class', 'admin_table_order');                $('div#task_div_' + selected + ' table').attr('class', 'admin_table_green');                $("div#order_info").slideDown('fast');            }        });    }}//---------------------------------------------------------//function acceptTask(){    var selected = $("span#spanId").attr('name');    if (confirm('Do you really want to accept order #' + selected + '?')) {        var url = control_vars.host + 'index.php/requests/accept_task';        var param = {            id : selected        };        $.ajax({            url : url,            type : 'post',            data : param,            success : function(html) {                getHistory();                showError(html);            }        });    }}//---------------------------------------------------------//function declineTask(){    var selected = $("span#spanId").attr('name');    var url = control_vars.host + 'index.php/requests/decline_task';    if (confirm('Do you really want to decline task #' + selected + '?')) {        var param = {            id : selected        };        $.ajax({            url : url,            type : 'post',            data : param,            success : function(html){                getHistory();                showError(html);            }        });    }}//---------------------------------------------------------//function replyTask(){    if ($('#repl').size() <= 0){        var url = control_vars.host + 'index.php/requests/load_view_change_task';        var selected = $("span#spanId").attr('name');        var param = {            id : selected        };        $.ajax({            url : url,            type : 'post',            data : param,            success : function(html){                $('div.scroll:first').append(html);                initCalendar('cngDl', 'td_dl');                $('#disabled_button').val('display', '');                $('#enabled_button').val('display', 'none;');                document.getElementById('cngSpanId').scrollIntoView();            }        });    }}function unfreezeTask(){    if ($('#repl').size() <= 0){        //var url = control_vars.host + 'index.php/requests/load_view_change_task';        var url = control_vars.host + 'index.php/requests/load_view_unfreeze_task';        var selected = $("span#spanId").attr('name');        var param = {            id : selected        };        $.ajax({            url : url,            type : 'post',            data : param,            success : function(html){                $('div#order_info .admin_border_name div#scroll').slideUp(function(){                    $(this).html(html).slideDown();                });            }        });    }}//---------------------------------------------------------//function sendTask(){    var param = {        order_id : $('#cngSpanId').attr('name'),        cat_id : $('#category_val').attr('name'),        level_id : $('#level_val').attr('name'),        deadline : $('#cngDl').val(),        bid_placed : $('#cngBp').val(),        commentary : $('#cngComment').val()    };    var url = control_vars.host + 'index.php/requests/add_discussion';    $.ajax({        url : url,        data : param,        type : 'post',        success : function(html) {            getHistory();            MoveUp();            showError(html);        }    });}//---------------------------------------------------------//function cancTask(){    $('#repl').remove();    $('#disabled_button').css('display', 'none');    $('#enabled_button').css('display', '');    $('#btnInfo').attr('value', 'Info');}//---------------------------------------------------------//function createLayer(){    if (!document.getElementById('flooder')) {        $('body').append('<div id="flooder">&nbsp;</div>');    }    resizeLayer();}//----------------------------------------------------//function resizeLayer() {    if (document.getElementById('flooder')) {        $('#flooder').css({            'top':'0',            'left':'0',            'height':document.documentElement.clientHeight + 'px',            'width':document.documentElement.clientWidth + 'px'        });    }    if (document.getElementById('pay_options')) {        positionPayment()    }    if (document.getElementById('writers_list')) {        positionPayment()    }}//----------------------------------------------------//function createPayment(){    if (!document.getElementById('pay_options')) {        $('body').append('<div id="pay_options"><b class="r5"/><b class="r3"/><b class="r2"/><b class="r1"/><b class="r1"/><div class="inner-box"><table width="100%"><tr><td class="name_chat">Payment options</td><td align="right"><img alt="Cancel" onclick="cancel_payTask()" src="' + control_vars.host + 'images/cancel.png">&nbsp;</td></tr><tr><td  colspan="2"><hr></td></tr><tr><td  colspan="2"><div id="pay_options_center"></div></td></tr></table></div><b class="r1"/><b class="r1"/><b class="r2"/><b class="r3"/><b class="r5"/></div>');    }}//----------------------------------------------------//function positionPayment() {    if (document.getElementById('pay_options_center')) {        var cWidth = Math.round(document.documentElement.clientWidth / 2) - 200;        if (cWidth < 0) cWidth = 0;        var cHeight = Math.round(document.documentElement.clientHeight / 2) - 150;        if (cHeight < 0) cHeight = 0;        $('#pay_options_center').css('top', cHeight + 'px').css('left', cWidth + 'px');    }    //for operator    if (document.getElementById('writers_list')) {        cWidth = Math.round(document.documentElement.clientWidth / 2) - 400;        if (cWidth < 0) cWidth = 0;        cHeight = Math.round(document.documentElement.clientHeight / 2) - 150;        if (cHeight < 0) cHeight = 0;        $('#writers_list').css('top', cHeight + 'px').css('left', cWidth + 'px');    }}//----------------------------------------------------//function payTask(){    createLayer();    createPayment();    $.get(control_vars.host + "index.php/tools/paypal", function(data){        document.getElementById('pay_options_center').innerHTML += '<div class="paybutton">' + data + '</div>';    });}//----------------------------------------------------//function cancel_payTask(){    $('#pay_options, #flooder, #writers_list').remove();}//----------------------------------------------------//function check_paypal() {    var param = {        'id' : $('span#spanId').attr('name')    };    var url = control_vars.host + 'index.php/requests/check_task_parameters';    $.ajax({        url : url,        type : 'post',        data : param,        success : function(html){            if (parseFloat(html) >= 0) {                document.getElementsByName('amount')[0].value = html;                document.getElementsByName('item_number')[0].value = param.id;                $('form#paypal').submit();            } else {                showError(html);                MoveUp();            }        }    });}//--------------------------------------------------------//function deleteTask(){    var selected = $("span#spanId").attr('name');    if (confirm('Do you really wand to delete task #'+selected+'?')) {        var url = control_vars.host + 'index.php/requests/delete_task';        var param = {            id : selected        };        $.ajax({            url : url,            type : 'post',            data : param,            success : function(data){                //if access level == user                $.ajax({                    url : control_vars.host + 'index.php/requests/get_user_role',                    type : 'post',                    success : function (html) {                        var tmpp = parseInt(html);                        if (tmpp == 1) {//if user logged in - load his history                            getHistory();                            showTheLastTask();                            showError(data);                        }                        if (tmpp == 2){ // if oper logged in                            setTimeout("$('#loadMO').click()", 500);                        }                    },                    error: function(){                        showError(error.server);                    }                });            }        });    }}//-----------------------------------------------------//function changeTab(ths){    $('#tabs li').attr('className', 'tab-inactive').attr('class', 'tab-inactive');    $('#' + ths).attr('className', 'tab-active').attr('class', 'tab-active');    if (ths == 'tab1') {//========================================================if LOGIN was selected        $(".top_menu ul li").attr('class', '');        $(".top_menu ul li a[href='javascript:void(0)']").parent('li').attr('class', 'act');        $('#captcha').empty();        $('#register, #register_submit, #task_submit, #register_div').css('display', 'none');        $('#login, #login_div').css('display', 'inline');        $('#login').attr('disabled', true).attr('class', 'inactive_big');        $('#add_text_register').css('display', 'none');        $('#captcha, #register_submit').css('display', '').each(            function() {                $(this).parents('tr').css('display', '')            }            );    } else if (ths == 'tab3') {//=================================================if REGISTER was selected        $(".top_menu ul li").attr('class', '');        $(".top_menu ul li a[href='http://www.assignmentexpert.com/assignments/index.php#register_page']").parent('li').attr('class', 'act');        if ($('#restore_pass').css('display') == 'block') {            $('#restore_pass').slideToggle();        }        if ($('#register_div').html() != error.thanks_message) {            //reser the values and states of fields            $('#first_name').val('Your name...').attr('disabled', false);            $('#last_name').val('Your last name...').attr('disabled', false);            $('#email').val('Your e-mail...').attr('disabled', false);            $('#login_add').val('Your login...').attr('disabled', false);            $('#pass_add, #pass_add_ch').val('').attr('disabled', false);            $('#fake_pass_add').val('Your pass...').attr('disabled', false);            $('#fake_pass_add_ch').val('Retype your pass...').attr('disabled', false);            $('#confirm_captcha').val('').attr('disabled', false);            togglePass('fake_pass_add','pass_add');            togglePass('fake_pass_add_ch','pass_add_ch');            $('#captcha').empty().load(control_vars.host + 'index.php/requests/captchaImg').css('display', 'block');            $('#register_submit').css('display', 'block').attr('disabled', true).attr('class', 'inactive_big');            $('#register').attr('disabled', true).attr('class', 'inactive');            initCalendar('dl', 'td_dl');        }        $('#login, #login_div, div.right, div.right_button, #register, #task_submit').css('display', 'none');        $('#register_div').css('display', 'block');        $('div.left').css('display', '');    }}//-------------------------------------------------//function sanitatePhoneNumber(field){    field.value = field.value.replace(/[a-zA-Z\<\>\%\&\,\/\\\.\@\;\|\[\]\=\`\"\']+/g, '');}//--------------------------------------------------//function sanitateName(field){    field.value = field.value.replace(/[\<\>\%\&\,\/\\\.\@\;\|\[\]\=\`\"\']+/g, '');}//----------------------------------------------------//function changeTabAdm(id){    $('.tab_holder .tab-active, tr.tab_holder div.tab-active').attr('class', 'tab-inactive');    $('#' + id).attr('class', 'tab-active');}//---------------------------------------------------//function changeSubTabAdm(id){    $('tr#panel td.tab-active-sub').attr('class','tab-inactive-sub');    document.getElementById(id).className = 'tab-active-sub';}//----------------------------------------------------//function changeSubSubTabAdm(id){    $('tr#pane2 td.tab-active-sub-sub').attr('class','tab-inactive-sub-sub');    document.getElementById(id).className = 'tab-active-sub-sub';}//---------------------------------------------------//function pos_foot_div(){    var yAvail = getClientHeight();    var hfoot = $('.foot').height();    $('.admin_titul_operator').attr('style', 'height:'+(yAvail-hfoot+5)+'px');}//----------------------------------------------------//function getClientHeight() {    return document.documentElement.clientHeight;}//----------------------------------------------------//function getBodyScrollTop(){    return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);}//----------------------------------------------------//function pos_foot_div_admin(){    $('#content').css('height','auto');    $('.admin_titul_admin').attr('style', 'height:auto;');    $('.admin_titul_admin').attr('style', 'height:'+(document.getElementById('content').offsetHeight + 110)+'px');}//---------------------------------------------------//function showError(html){    MoveUp();    $('#error').html(html).fadeIn('slow');    setTimeout("$('#error').fadeOut('slow');", 5500);}//---------------------------------------------------//function showError15(html){    MoveUp();    $('#error').html(html).fadeIn('slow');    setTimeout("$('#error').fadeOut('slow');", 15000);}//----------------------------------------------------//function grant_discount(user_id){    $.ajax({        url : control_vars.host + 'index.php/requests/grant_discount',        type : 'post',        data : {            user : user_id        },        success : function (html) {            if (html == 'okay'){                $('#loadMO').click();            }        },        error: function(){            showError(error.server);        }    })}//----------------------------------------------------//