/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
// alert(window.website_url);

$(".use-submission-credits").live('click',function(){
    $("#submission-credits-content").slideToggle(1000,function(){
       
        });
});

function filter_submit_sites(group_id){
    var current_td;
    var counter=0;
    var current_class;
    var current_id;
    var found=false;
    //$("#submit_sites").empty().html('<img src="../images/loading.gif" />');
    /*$("#result_area").hide();
    $("#error_area").hide();
    $('#selectall').attr('checked', false);
    clear_searchmatching();
    if(all_submitted_sites!=""){
        $("#main-submit-sites").html("");
        all_submitted_sites.appendTo("#main-submit-sites");
    }
    $.ajax({
        type: "get",
        url: "../ajax/ajax.php",
        data: "action=submit_site&group_id="+group_id+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#submit_sites").html(resp);
        }
    });*/
    /*$(".submit_sites").hide();
    $("#submit_sites_table td.site-"+profile_id).show();*/
    // checked_sites=get_all_checked_sites();
    if(all_submitted_sites==""){
        all_submitted_sites=$("#main-submit-sites").clone();
    }
    
    if(backup_sites==""){
        backup_sites=$("#main-submit-sites").html(); // always filtered from all submit sites
    //alert(all_submitted_sites);
    }
    
    if(backup_sites!=""){
        $("#main-submit-sites").empty().html(backup_sites);
    }
    
    
    var output='<table width="100%" class="table_fixed"><tr>';
    
    $(".submit_sites").each(function(){
        if($(this).hasClass("group-"+group_id)){
            current_td=$(this).html();
            current_class=$(this).attr("class");
            current_id=$(this).attr("id");
            output+="<td id='"+current_id+"' class='"+current_class+"' >"+current_td+"</td>";
            counter ++;
            if (counter % 3 == 0) {
                output += "</tr><tr>";
            }
            found=true;
        }
    });
    
    while (counter % 3 != 0) {
        output+="<td class='table_cell' style='padding:5px;text-align:center'>------</td>";
        counter++;
    }


    output += "</table>";
    
    if(found){
        $("#main-submit-sites").empty().html(output);
    }
    else if(group_id=="all"){
        $("#main-submit-sites").empty().html(backup_sites);
    }
    else{
        $("#main-submit-sites").empty().html("There are no sites available under this group.");
    }
    
    // check_submitted_search_1();
    calculate_submittion_payment();
    
}

function filter_edit_sites(group_id){
    var current_td;
    var counter=0;
    var current_class;
    var current_id;
    var found=false;
    if(all_submitted_sites==""){
        all_submitted_sites=$("#site_link_details").clone();
    }
    
    if(backup_sites==""){
        backup_sites=$("#site_link_details").html(); // always filtered from all submit sites
    //alert(all_submitted_sites);
    }
    
    if(backup_sites!=""){
        $("#site_link_details").empty().html(backup_sites);
    }
    
    
    var output='<table width="100%" class="table_fixed"><tr>';
    
    $(".table_cell").each(function(){
        if($(this).hasClass("group-"+group_id)){
            current_td=$(this).html();
            current_class=$(this).attr("class");
            current_id=$(this).attr("id");
            output+="<td id='"+current_id+"' class='"+current_class+"' >"+current_td+"</td>";
            counter ++;
            if (counter % 3 == 0) {
                output += "</tr><tr>";
            }
            found=true;
        }
    });
    
    while (counter % 3 != 0) {
        output+="<td class='table_cell' style='padding:5px;text-align:center'>------</td>";
        counter++;
    }


    output += "</table>";
    
    if(found){
        $("#site_link_details").empty().html(output);
    }
    else if(group_id=="all"){
        $("#site_link_details").empty().html(backup_sites);
    }
    else{
        $("#site_link_details").empty().html("There are no sites available under this group.");
    }
    
}

function filter_report_sites(group_id){
    var current_td;
    var counter=0;
    var current_class;
    var current_id;
    var found=false;
    if(all_submitted_sites==""){
        all_submitted_sites=$("#submitted_sites").clone();
    }
    
    if(backup_sites==""){
        backup_sites=$("#submitted_sites").html(); // always filtered from all submit sites
    //alert(all_submitted_sites);
    }
    
    if(backup_sites!=""){
        $("#submitted_sites").empty().html(backup_sites);
    }
    
    
    var output='<table width="100%" class="table_fixed"><tr>';
    
    $(".table_cell").each(function(){
        if($(this).hasClass("group-"+group_id)){
            current_td=$(this).html();
            current_class=$(this).attr("class");
            current_id=$(this).attr("id");
            output+="<td id='"+current_id+"' class='"+current_class+"' >"+current_td+"</td>";
            counter ++;
            if (counter % 3 == 0) {
                output += "</tr><tr>";
            }
            found=true;
        }
    });
    
    while (counter % 3 != 0) {
        output+="<td class='table_cell' style='padding:5px;text-align:center'>------</td>";
        counter++;
    }


    output += "</table>";
    
    if(found){
        $("#submitted_sites").empty().html(output);
    }
    else if(group_id=="all"){
        $("#submitted_sites").empty().html(backup_sites);
    }
    else{
        $("#submitted_sites").empty().html("There are no sites available under this group.");
    }
    
}


function filter_submitted_sites(group_id){
    $("#report").hide();
    clear_searchmatching();
    //if(all_submitted_sites!=""){
    $("#submitted_sites").empty().html('<img src="../images/loading.gif" />');
    //$("#submitted_sites").html("");
    //  all_submitted_sites.appendTo("#submitted_sites");
    //}
    $.ajax({
        type: "get",
        url: "../ajax/ajax.php",
        data: "action=submit_report&group_id="+group_id+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#submitted_sites").html(resp);
        }
    });

}


function append_transaction(){
    $(".transactionid").each(function(){
        this.checked = checked_status;

    });
}

function filter_order_sites(profile_id){
    $.ajax({
        type: "get",
        url: "ajax/ajax.php",
        data: "action=order_site&profile_id="+profile_id+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#order_sites").html(resp);
        }
    });
}

$(document).ready(function(){
    $("#selectall").live('click', function(){
        var checked_status = this.checked;
        $(".siteid").each(function(){
            if(!$(this).is(':disabled')){
                this.checked = checked_status;
            }
        });
        calculate_submittion_payment();
    });


    $("#order_selectall").live('click',function(){
        var checked_status = this.checked;
        $(".pending_orders").each(function(){
            this.checked = checked_status;
        });
    });

    $(".submitid").live('click',function(){
        var page_rank=$("#pr").val();
        if(this.checked){
            $("#"+$(this).val()+"-pr"+page_rank).show();
        }
        else{
            $("#"+$(this).val()+"-pr"+page_rank).hide();
        }
        calculate_submittion_payment();
    });
    
    /* $(".loading_box").fancybox({
        'scrolling'		: 'no',
        'titleShow'		: false,
        'showCloseButton'	: false,
        'hideOnOverlayClick'    : false,
        'hideOnContentClick'    : false,
        'enableEscapeButton'    : false
    });*/

    $(".configure-header").live('click',function(){
        $(this).next("div").slideToggle();
        $(this).children(".setup-status").html("");
    });

//$(".loading_box").fancybox.hideActivity();
});

function sendAjaxRequest(fields,method,datatype,url){
    fields += "&rand="+Math.random();
    $.ajax({
        type: method,
        url: url,
        data: fields,
        dataType: datatype,
        success: function(resp){
            $("#response").html(resp);
        }
    });
}

function show_pagerank(page_rank){
    if(!$('#no_of_directories_radio').is(':checked')){
        $("#no_of_directories_all").attr("checked",true);
    }
    pagerank_change();
    calculate_submittion_payment();
}


function pagerank_change(){
    $(".pr_txt").hide();
    var page_rank=Number($("#pr").val());
    var pr_directories=0;
    if(page_rank!=0){
        var no_of_directories=$("#noofdirectories").val();
        //   if((no_of_directories > 0 || no_of_directories=="all") && no_of_directories!=""){
        $(".siteid").each(function(){
            $("#"+$(this).val()+"-pr"+page_rank).show();
            pr_directories=Number($("#pr"+page_rank+"-"+$(this).val()).val());
            if(this.checked){
                
                if(pr_directories==0){
                    $("#"+$(this).val()+"-check").attr("checked",false);
                    $("#"+$(this).val()+"-check").attr("disabled",true);
                    $("#"+$(this).val()+"-check").addClass("pr-remove");
                }
            }
            else{
                if($("#"+$(this).val()+"-check").hasClass("pr-remove")){
                    $("#pagerank-box").height();
                    $("#"+$(this).val()+"-pr"+page_rank).show();
                    if(pr_directories!=0){
                        $("#"+$(this).val()+"-check").attr("disabled",false);
                        $("#"+$(this).val()+"-check").attr("checked",true);
                        $("#"+$(this).val()+"-check").removeClass("pr-remove");
                    }
                }
                else{
                    $("#"+$(this).val()+"-pr"+page_rank).hide();
                }
            }
        });
        // }
        $("#page_rank_note").slideDown("slow");                                                // show page rank note
    }
    else{
        $(".siteid").each(function(){
            if($("#"+$(this).val()+"-check").hasClass("pr-remove")){
                $("#"+$(this).val()+"-check").attr("disabled",false);
                $("#"+$(this).val()+"-check").attr("checked",true);
                $("#"+$(this).val()+"-check").removeClass("pr-remove");
            }
        });
        $("#page_rank_note").slideUp("slow");                                                // show page rank note
    }
}


function get_maximum_directories(){
    var submit_pending=0;
    $(".siteid").each(function(){
        if(this.checked){
            submit_pending+=Number($("#"+$(this).val()+"-submit_pending").val());
        }
    });
    return submit_pending;
}
var maximum_price_of_all_sites=0;
function get_maximum_price(){
    var admin_price=Number($("#adminprice").val());
    var email_charges=Number($("#emailcharges").val());
    var minimum_charges=Number($("#minimumprice").val());

    var current_dir=0;
    var final_price=0;

    $(".siteid").each(function(){
        if ( !$(this).is(':disabled') ){
            current_dir=Number($("#"+$(this).val()+"-submit_pending").val());
            if($("#"+$(this).val()+"-email_handling").val()=="yes"){
                final_price += current_dir * (admin_price + email_charges);
            }
            else{
                final_price += (current_dir * admin_price);
            }
        }
    });

    if(final_price < minimum_charges)
        final_price=minimum_charges;
    
    $(".siteid").each(function(){
        if(!$(this).is(':disabled')){
            this.checked = true;
        }
    });
    maximum_price_of_all_sites=final_price.toFixed(2);

    return maximum_price_of_all_sites;
}

function get_current_price(){
    var no_of_directories=$("#noofdirectories").val();
    var admin_price=Number($("#adminprice").val());
    var email_charges=Number($("#emailcharges").val());
    var minimum_charges=Number($("#minimumprice").val());
    var page_rank=Number($("#pr").val());
    var calculation_error="";
    var no_of_sites=0;
    var email_charge=false;
    var pr_directories;
    var final_price=0;
    var total_directories=0;
    var maximum_directories=0;
    var current_sites_price=0;
    var current_dir=0;
    var selected_sites_price=0;
    //alert(maximum_directories);

    $(".payment_btn").show();
    $("#error_msg").hide();

    if(!isNaN(no_of_directories)){
        var temp_directories=0;

        $(".siteid").each(function(){
            if(this.checked){
                no_of_sites++;

                if(page_rank != 0){
                    pr_directories=Number($("#pr"+page_rank+"-"+$(this).val()).val());
                    temp_directories = (no_of_directories < pr_directories) ? no_of_directories : pr_directories;
                }
                else{
                    maximum_directories=Number($("#"+$(this).val()+"-submit_pending").val());
                    if(no_of_directories<=maximum_directories)
                        temp_directories=no_of_directories;
                    else
                        temp_directories=maximum_directories;
                }
                if($("#"+$(this).val()+"-email_handling").val()=="yes"){
                    email_charge=true;
                    final_price += temp_directories * (admin_price + email_charges);
                }
                else{
                    final_price += (temp_directories * admin_price);
                }
                total_directories += (temp_directories==0) ? 0 : Number(temp_directories);
            }
        });
        current_sites_price=final_price;
    }
    else if(no_of_directories=="all"){
        no_of_directories=0;
        no_of_sites=0;
        $(".siteid").each(function(){
            var submit_pending=Number($("#"+$(this).val()+"-submit_pending").val());
            if(this.checked){
                no_of_sites++;

                if(page_rank != 0){
                    pr_directories=Number($("#pr"+page_rank+"-"+$(this).val()).val());
                    no_of_directories = (submit_pending < pr_directories) ? submit_pending : pr_directories;
                }
                else{
                    no_of_directories = submit_pending;
                }

                if($("#"+$(this).val()+"-email_handling").val()=="yes"){
                    email_charge=true;
                    final_price += no_of_directories *(admin_price + email_charges);
                }
                else{
                    final_price += (no_of_directories*admin_price);
                }
                total_directories += (no_of_directories==0) ? 0 : Number(no_of_directories);
            }
        });

        current_sites_price=final_price;
    }
    else if(no_of_directories==""){
        $(".siteid").each(function(){
            if ( !$(this).is(':disabled') ){
                if(this.checked){
                    current_dir=Number($("#"+$(this).val()+"-submit_pending").val());
                    if($("#"+$(this).val()+"-email_handling").val()=="yes"){
                        selected_sites_price += current_dir * (admin_price + email_charges);
                    }
                    else{
                        selected_sites_price += (current_dir * admin_price);
                    }
                }
            }
        });
        current_sites_price=selected_sites_price;
        if(current_sites_price==0){
            current_sites_price=maximum_price_of_all_sites;
        }

    }
    return current_sites_price.toFixed(2);
}

function show_datepicker(current_selection){
    if(current_selection=="search_date"){
        $("#sales_datepicker").show();
        $("#sales_search_value").hide();
    }
    else{
        $("#sales_datepicker").hide();
        $("#sales_search_value").show();
    }
}

function make_order(order_id){
    var res=confirm("Are you sure you want to place an order for Order ID: "+order_id);
    if(res){
        /*    $.ajax({
        type: "get",
        url: "ajax/ajax.php",
        data: "action=make_order&order_id="+order_id+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#submit_sites").html(resp);
        }
    });*/
        window.location.href=window.website_url+"admin/admin_orders.php?action=make_order&pending_id="+order_id;
    }
}

function hide_link(link_box){
    $("#"+link_box).hide();
}
function show_link(link_box){
    $("#"+link_box).show();
}

function filter_email_sites(group_id){
    $("#email-report").hide();
    clear_searchmatching()
    $("#email_site_content").empty().html('<img src="../images/loading.gif" />');
    $.ajax({
        type: "get",
        url: "../ajax/ajax.php",
        data: "action=email_report&group_id="+group_id+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#email_site_content").html(resp);
        }
    });
}


/**
 * Function get_matching_sites()
 * @param search_box - id of the input search box
 * @param sites_table - id of the table containing site url cells
 * @param table_cell - comman class used in all table cells unser sites_table
 * @param sites_table_container -  id of the element containing sites_table
 * Note : 1. This function is applicable only for table structure
 *        2. global variable all_submitted_sites is necessary
 *        3. td id should be same as site_url
 *
 */

var all_submitted_sites="";
var backup_sites="";


//var current_row="";
//var matched_array=new Array();
//var checked_sites=new Array();
//var counter=0;

/*function get_matching_sites1(search_box,sites_table,table_cell_class,sites_table_container){
    var submit_search=$("#"+search_box).val();
    var current_td;
    var matching=false;
    var current_class;
    var current_id;
    
    get_all_checked_sites();
    display_allsubmitted_sites(sites_table_container);
    check_submitted_search();

    //var output='<table width="100%"><tr>';
    var table=$('<table>');
    table.attr("id",sites_table);
    //   var tr=$('<tr>');
    //  table.append(tr);
    if(submit_search!=""){
        $("."+table_cell_class).each(function(){
            if($(this).attr("id").match(submit_search)){
                matched_array.push($(this).attr("id"));
                counter ++;
                if(counter % 3 == 1){
                    var row=$('<tr>');
                    current_row=row;
                }

                current_td=$(this).detach();
                current_td.addClass("highlight");
                current_row.append(current_td);

                if (counter % 3 == 0) {
                    table.append(current_row);
                    current_row="";
                }

                matching=true;
            }
        });
        $("."+table_cell_class).each(function(){
            if(if_site_checked($(this).attr("id"),checked_sites) && !if_site_checked($(this).attr("id"),matched_array) ){
                if(counter % 3 == 1){
                    var row=$('<tr>');
                    current_row=row;
                }

                current_td=$(this).detach();
                current_td.addClass("highlight");
                current_row.append(current_td);

                if (counter % 3 == 0) {
                    table.append(current_row);
                    current_row="";
                }
            }
        });

        //table.append(current_row);
    }

    $("#matching-count").html("Results Found : " +counter);
    $("#matching-count").show();
    if(counter>0){
        $("#matching-count").addClass("result");
    }
    else{
        $("#matching-count").removeClass("result")
    }


    if(matching){
        if(all_submitted_sites==""){
            all_submitted_sites=$("#"+sites_table).detach();
        }
        $("#"+sites_table_container).html("");
        $("#"+sites_table_container).append(table);
         current_row="";
    }
    else{
        display_allsubmitted_sites(sites_table_container);
    }

    $("#result_area").hide();
    $("#error_area").hide();
    $('#selectall').attr('checked', false);

}*/



var matched_array=new Array();
var checked_sites=new Array();


function get_matching_sites1(search_box,sites_table,table_cell_class,sites_table_container){
    
    if(backup_sites==""){       // for grouping - make grouping independent
        backup_sites=$("#main-submit-sites").html();
    //alert(all_submitted_sites);
    }
    
    var submit_search=$("#"+search_box).val();
    var current_td;
    var counter=0;
    var matching=false;
    var match_count=0;
    var current_class;
    var current_id;
    matched_array.length=0;
    //alert("Called The Function");
        
    checked_sites=get_all_checked_sites();

    // alert(checked_sites);

    display_allsubmitted_sites(sites_table_container);
    check_submitted_search(checked_sites);
    checked_sites=get_all_checked_sites();

    var output='<table width="100%" style="margin-bottom:0px" cellpadding="0" cellspacing="0" class="table_fixed"><tr>';
    if(submit_search!=""){
        $("."+table_cell_class).each(function(){
            if($(this).attr("id").match(submit_search)){
                matched_array.push($(this).attr("id"));
                current_td=$(this).html();
                current_class=$(this).attr("class");
                current_id=$(this).attr("id");
                output+="<td id='"+current_id+"' class='highlight "+current_class+"' >"+current_td+"</td>";
                match_count++;
                counter ++;
                if (counter % 3 == 0) {
                    output += "</tr><tr>";
                }
                matching=true;
            }
        });

        $("."+table_cell_class).each(function(){
            if(if_site_checked($(this).attr("id"),checked_sites) && !if_site_checked($(this).attr("id"),matched_array) ){
                current_td=$(this).html();
                current_class=$(this).attr("class");
                current_id=$(this).attr("id");
                output+="<td id='"+current_id+"' class='"+current_class+"' >"+current_td+"</td>";
                counter ++;
                if (counter % 3 == 0) {
                    output += "</tr><tr>";
                }
            }
        });
    }

    $("#matching-count").html("Results Found : " +match_count);
    $("#matching-count").show();
    if(match_count>0){
        $("#matching-count").addClass("result");
    }
    else{
        $("#matching-count").removeClass("result")
    }



    while (counter % 3 != 0) {
        output+="<td class='table_cell' style='padding:5px;text-align:center'>------</td>";
        counter++;
    }


    output += "</table>";

    if(matching){
        if(all_submitted_sites==""){
            all_submitted_sites=$("#"+sites_table).detach();
        }
        
        $("#"+sites_table_container).html(output);
        check_submitted_search_1();
    }
    else{
        display_allsubmitted_sites(sites_table_container);
        check_submitted_search_1();
    }

    $("#result_area").hide();
    $("#error_area").hide();
    $('#selectall').attr('checked', false);
    calculate_submittion_payment();
}




function get_all_checked_sites(){
    var checked_sites=new Array();
    $(".siteid").each(function(){
        if(this.checked){
            checked_sites.push($(this).parent(".submit_sites").attr("id"));
        }
    });
    //  alert("Get Checked Sites Function");
    //  alert(checked_sites);
    return checked_sites;
}

function if_site_checked(needle,sites_array) {
    /*  alert(needle);
    alert(sites_array);*/
    if(sites_array!=""){
        var length = sites_array.length;
        for(var i = 0; i < length; i++) {
            if(sites_array[i] == needle) return true;
        }
    }
    return false;

}

function check_submitted_search(checked_sites){
    //  alert("check_submitted_search");
    $(".siteid").each(function(){
        if(if_site_checked($(this).parent(".submit_sites").attr("id"), checked_sites)){
            //  alert("checked this site");
            //  alert($(this).val());
            $(this).attr('checked',true);
        }
    });
}

function check_submitted_search_1(){
    // alert("check_submitted_search_1");
    $(".siteid").each(function(){
        if(if_site_checked($(this).parent(".submit_sites").attr("id"), checked_sites)){
            //alert("checked this site");
            //    alert($(this).val());
            $(this).attr('checked',true);
        }
    });
}


function display_allsubmitted_sites(sites_table_container){
    //   alert(all_submitted_sites);
    if(all_submitted_sites!=""){
        $("#"+sites_table_container).html("");
        all_submitted_sites.appendTo("#"+sites_table_container);
    }
}

function show_sitematching(){
    $('#site-matching').slideToggle('slow', function() {
        clear_searchmatching();
    });
}

function clear_searchmatching(){
    $("#search-txt").val("");
    $("#matching-count").hide();
}



function get_matching_sites(search_box,sites_table,table_cell_class,sites_table_container){
    
    // alert(sites_table_container);
    
    var submit_search=$("#"+search_box).val();
    var current_td;
    var counter=0;
    var matching=false;
    var current_class;
    var current_id;

    //$("#search-submit-sites").html("");
    display_allsubmitted_sites(sites_table_container);
    var output='<table width="100%" class="table_fixed"><tr>';
    if(submit_search!=""){
        $("."+table_cell_class).each(function(){
            if($(this).attr("id").match(submit_search)){
                current_td=$(this).html();
                current_class=$(this).attr("class");
                current_id=$(this).attr("id");
                output+="<td id='"+current_id+"' class='highlight "+current_class+"' >"+current_td+"</td>";
                counter ++;
                if (counter % 3 == 0) {
                    output += "</tr><tr>";
                }
                matching=true;
            }
        });
    }

    $("#matching-count").html("Results Found : " +counter);
    $("#matching-count").show();
    if(counter>0){
        $("#matching-count").addClass("result");
    }
    else{
        $("#matching-count").removeClass("result")
    }



    while (counter % 3 != 0) {
        output+="<td class='table_cell' style='padding:5px;text-align:center'>------</td>";
        counter++;
    }


    output += "</table>";

    if(matching){
        if(all_submitted_sites==""){
            all_submitted_sites=$("#"+sites_table).detach();
        //all_submitted_sites=$("#"+sites_table).html();
        //alert(all_submitted_sites);
        }
        $("#"+sites_table_container).html(output);
    }
    else{
        display_allsubmitted_sites(sites_table_container);
    }

    $("#result_area").hide();
    $("#error_area").hide();
    $('#selectall').attr('checked', false);

}

function number_of_checked_sites(){
    var no_of_sites=0;
    $(".siteid").each(function(){
        if(this.checked){
            no_of_sites++;
        }
    });
    return no_of_sites;
}

function check_if_decimalnumber(num){
    if(num == Math.round(num))
        return false;   // not decimal number
    else
        return true;   // decimal number
}

function check_no_of_dir(){
    $("#no_of_directories_radio").attr("checked",true);
}

/**
 * get the height of client window
 */

function getViewportHeight() {
    var h = 0;
    if(self.innerHeight)
        h = window.innerHeight;
    else if(document.documentElement && document.documentElement.clientHeight)
        h = document.documentElement.clientHeight;
    else if(document.body)
        h = document.body.clientHeight;

    return h;
}

$(document).ready(function(){
    var full_height=getViewportHeight();
    if($("#mask").length > 0){
        $("#mask").height(full_height);
    }
});


function toggle_user_edit_frm(){
    // $('#user-edit-form').slideToggle('slow', function() {
    $("#result_EditAccount").hide();
    $('#user-edit-form').fadeToggle("fast", "linear");
// Animation complete.
//})
}

/**
 * hide the element
 * @param container_selector id or class
 * @param container id/class value
 */

function hide_element(container_selector,container){
    var prefix_val=(container_selector == "id") ? "#" : ".";
    $(prefix_val+container).hide();
}

/**
 * show the element
 * @param container_selector id or class
 * @param container id/class value
 */

function show_element(container_selector,container){
    var prefix_val=(container_selector == "id") ? "#" : ".";
    $(prefix_val+container).show();
}


function show_transactions_frame(){
    $("#transactions-frame-container").toggle();
    $("#transactions_frame").show();
}

function show_creditshistory_frame(){
    $("#mx-frame-container").toggle();
}

function show_recurrsion_box(){
    $("#recurring-box").show();
    $("#paypal-btn").hide();
    $("#cc-btn").hide();
}

function hide_recurrsion_box(){
    $("#recurring-box").hide();
    $("#paypal-btn").show();
    $("#cc-btn").show();
}


$(document).ready(function(){
    $("#configure-apibtn").live('click',function(){
        var api_key=$("#apikey").val();
        var api_username=$("#apiusername").val();
        var api_passwd=$("#apipasswd").val();
        if(api_key ==""){
            $("#apikey").next(".error-msg").html("API key cannot be  blank");
        }
        else if(api_username==""){
            $("#apiusername").next(".error-msg").html("API Username cannot be blank");
        }
        else if(api_passwd==""){
            $("#apipasswd").next(".error-msg").html("API Password cannot be blank");
        }
        else{
            var fields="action=api_setup&api_key="+api_key+"&apiusername="+api_username+"&apipasswd="+api_passwd;
            send_setup_request(fields);
            $("#api-content").slideToggle();
        }
    });

    $("#configure-pricebtn").live('click',function(){
        var adminprice=$("#adminprice").val();
        var emailprice=$("#emailprice").val();
        var minimumprice=$("#minimumprice").val();
        if(adminprice==""){
            $("#adminprice").next(".error-msg").html("Admin price cannot be blank.");
        }
        else if(emailprice==""){
            $("#emailprice").next(".error-msg").html("Email price cannot be blank.");
        }
        else if(minimumprice==""){
            $("#minimumprice").next(".error-msg").html("Email price cannot be blank.");
        }
        else{
            var fields="action=price_setup&adminprice="+adminprice+"&emailprice="+emailprice+"&minimumprice="+minimumprice;
            send_setup_request(fields);
            $("#submission-content").slideToggle();
        }
    });

    $("#configure-2cobtn").live('click',function(){
        var sellerid=$("#sellerid").val();
        var sidusername=$("#sidusername").val();
        var sidpasswd=$("#sidpasswd").val();
        var sword=$("#sword").val();
        var demo_mode;
        var enable;
        demo_mode="no";
        /*  if($("#2co_demo_mode").is(':checked')){
            demo_mode="yes";
        }
        else{
            demo_mode="no";
        }*/
        
        if($("#2co_enable").is(':checked')) {
            enable="Yes";
        }
        else{
            enable="No";
        }
        
        //alert(demo_mode);

        if(sellerid=="" && enable=="Yes"){
            $("#sellerid").next(".error-msg").html("SellerID (VendorID) cannot be blank.");
        }
        else if(sidusername=="" && enable=="Yes"){
            $("#sidusername").next(".error-msg").html("API USERNAME cannot be blank.");
        }
        else if(sidpasswd=="" && enable=="Yes"){
            $("#sidpasswd").next(".error-msg").html("API PASSWORD cannot be blank.");
        }
        else if(sword=="" && enable=="Yes"){
            $("#sword").next(".error-msg").html("Secret Word cannot be blank.");
        }
        else{
            var fields="action=2co-setup&sellerid="+sellerid+"&sidusername="+sidusername+"&sidpasswd="+sidpasswd+"&sword="+sword+"&demo_mode="+demo_mode+"&enable="+enable;
            send_setup_request(fields);
            $("#2co-content").slideToggle();
        }

    });

    $("#configure-paypalbtn").live('click',function(){
        var paypalemail=$("#paypalemail").val();
        var enable;
        var sandbox_enable;
        
        if($("#paypal_enable").is(':checked')) {
            enable="Yes";
        }
        else{
            enable="No";
        }
        
        if($("#sandbox_enable").is(':checked')){
            sandbox_enable="Yes";
        }
        else{
            sandbox_enable="No";
        }
        
        if(paypalemail=="" && enable=="Yes"){
            $("#paypalemail").next(".error-msg").html("Paypal Email cannot be blank.");
        }
        else{
            var fields="action=paypal-setup&paypalemail="+paypalemail+"&enable="+enable+"&sandbox_enabled="+sandbox_enable;
            send_setup_request(fields);
            $("#paypal-content").slideToggle();
        }

    });
	
    $("#configure-analyticsbtn").live('click',function(){
        var analytics_id=$("#analytics_id").val();
        if(analytics_id==""){
            $("#analytics_id").next(".error-msg").html("The Google Analytics file cannot be blank.");
        }
        else{
            var fields="action=analytics-setup&analytics_id="+analytics_id;
            send_setup_request(fields);
            $("#analytics-content").slideToggle();
        }

    });

    $("#configure-generalbtn").live('click',function(){
        var supportemail=$("#supportemail").val();
        var from_name=$("#from_name").val();
        //var sendmail="";
        var sendmail=($("#sendmail:checked").length > 0) ? "yes" : "no";
        
        if(supportemail==""){
            $("#supportemail").next(".error-msg").html("Support Email cannot be blank.");
        }
        else{
            var fields="action=general_setup&supportemail="+supportemail+"&sendmail="+sendmail+"&from_name="+from_name;
            send_setup_request(fields);
            //$("#general-setup-content").slideToggle();
        }
    });
    
    $("#configure-connectionbtn").live('click',function(){
        var fsock_enabled=($("#fsock_enabled:checked").length > 0) ? "Yes" : "No";
        var ip_address=$("#ip-address").val();
        
        var fields="action=connection_setup&fsock_enabled="+fsock_enabled+"&ip_address="+ip_address;
        send_setup_request(fields);
        $("#connection-content").slideToggle();
    });
    
    
    $("#configure-passwordbtn").live('click',function(){
        var old_password=$("#old_password").val();
        var new_password=$("#new_password").val();
        var confirm_password=$("#confirm_password").val();
                
        if(old_password==""){
            $("#old_password").next(".error-msg").html("Enter your old password.");
        }
        else if(new_password==""){
            $("#new_password").next(".error-msg").html("Enter your new password.");
        }
        else if(new_password=="12345"){
            $("#new_password").next(".error-msg").html("You cannot use the default password, please use another password.");
        }
        else if(confirm_password==""){
            $("#confirm_password").next(".error-msg").html("Enter your new password again.");
        }
        else if(new_password != confirm_password){
            $("#confirm_password").next(".error-msg").html("Both the passwords did not match.");
        }        
        else{
            var fields="action=change_password&old_password="+old_password+"&new_password="+new_password+"&confirm_password="+confirm_password;
            send_setup_request(fields);
            $("#change-password-content").slideToggle();
        }
    });
    
    $("#configure-ftpconfigurebtn").live('click',function(){
      
        var error_present=false;
        var ftp_host=$("#ftp_host").val();
        var ftp_username=$("#ftp_username").val();
        var ftp_password=$("#ftp_password").val();
        var installation_path=$("#installation_path").val();
        
        if(ftp_host==""){
            $("#ftp_host").next(".error-msg").html("Please enter FTP HOST.");
            error_present=true;
        }
        if(ftp_username==""){
            $("#ftp_username").next(".error-msg").html("Please enter FTP USERNAME.");
            error_present=true;
        }
        if(ftp_password==""){
            $("#ftp_password").next(".error-msg").html("Please enter FTP PASSWORD.");
            error_present=true;
        }
        if(installation_path==""){
            $("#installation_path").next(".error-msg").html("Please enter the PATH.");
            error_present=true;
        }
        
       // var auto_update=($("#auto-update:checked").length > 0) ? "Yes" : "No";
        
        if(!error_present){
            var fields="action=ftp_settings&ftp_host="+ftp_host+"&ftp_username="+ftp_username+"&ftp_password="+ftp_password+"&installation_path="+installation_path;
            send_setup_request(fields);
        //  $("#ftp-settings-content").slideToggle();
        }
        
    });


});

function send_setup_request(fields){
    $.ajax({
        type: "post",
        url: "../ajax/admin_setup_ajax.php",
        data: fields,
        dataType: "json",
        success: function(resp){
            var resp_id=resp['id'];
            var resp_msg=resp['msg'];
            
            if(resp['status']=="success"){
                if(resp["content-id"]!="")
                    $("#"+resp["content-id"]).slideToggle();
                $("#"+resp_id).html(resp_msg);
                $(".error-msg").html("");
                
            }
            else if(resp['status']=="fail"){
                if(resp["error-id"]!=""){
                     $(".error-msg").html("");
                    $("#"+resp["error-id"]).next(".error-msg").html(resp_msg);
                }
            }
            else{
                $("#"+resp_id).html(resp_msg);
                $(".error-msg").html("");
            }
            
        }
    });
}

// test auto-ready logic - call corner before DOM is ready
$(function(){
    /*$("div#holder").corner();
                $("div#footer").corner();
                $("div.newsItem").corner();*/
    /*  $("div.curvebox").corner();?*/
    });
$(document).ready(function(){
    //Examples of how to assign the ColorBox event to elements
    /*$(".signupandlogin").colorbox({
        width:"50%",
        inline:true,
        href:"#signupandsignin"
    });*/
    });


function change_group(){
    $(".group-result").empty().html('<img src="../images/small-loading.gif" />');
    if($("#group_name").length > 0){
        var group_name=$("#group_name").val();
    }
    if($("#group_id").length > 0){
        var group_id=$("#group_id").val();
    }
    if(group_name!=""){
        $.ajax({
            type: "post",
            url: "../ajax/group_updation_ajax.php",
            data:"action=group_updation&group_id="+group_id+"&group_name="+group_name,
            dataType: "json",
            success: function(resp){
                $(".group-result").empty().html("");
                if(resp['result']){
                    $.ajax({
                        type: "post",
                        url: "../ajax/group_updation_ajax.php",
                        data:"action=populate_group_list&group_id="+resp['group_id'],
                        dataType: "text/html",
                        success: function(resp){
                            $("#group-list").html(resp);
                        }
                    });
                    $("#group-result-error").empty();
                    $("#group-result-success").html("<font color='green'>"+resp['message']+"</font>");
                    $("#group_name").val("");
                    $("#group_id").val("");
                    $("#add_group").val("Create Group");
                }
                else{
                    $("#group-result-error").html("<img width='20' height='20' align='absmiddle' src='../images/error_button_2.jpg'>&nbsp<font color='red'>"+resp['message']+"</font>");
                }
            }
        });
    }
    else{
        $("#group-result-success").empty();
        $(".group-result").empty();
        $("#group-result-error").html("<img width='20' height='20' align='absmiddle' src='../images/error_button_2.jpg'>&nbsp<font color='red'>Group Name cannot be empty</font>");
    }
}

function change_group_edit_site(){
    $(".group-result").empty().html('<img src="../images/small-loading.gif" />');
    if($("#group_name").length > 0){
        var group_name=$("#group_name").val();
    }
    if($("#group_id").length > 0){
        var group_id=$("#group_id").val();
    }
    if(group_name!=""){
        $.ajax({
            type: "post",
            url: "../ajax/group_updation_ajax.php",
            data:"action=group_updation&group_id="+group_id+"&group_name="+group_name,
            dataType: "json",
            success: function(resp){
                $(".group-result").empty().html("");
                if(resp['result']){
                    $.ajax({
                        type: "post",
                        url: "../ajax/group_updation_ajax.php",
                        data:"action=populate_group_list_edit_site&group_id="+resp['group_id'],
                        dataType: "text/html",
                        success: function(resp){
                            $("#group-list").html(resp);
                        }
                    });
                    $("#group-result-error").empty();
                    $("#group-result-success").html("<font color='green'>"+resp['message']+"</font>");
                    $("#group_name").val("");
                    $("#group_id").val("");
                    $("#add_group").val("Create Group");
                }
                else{
                    $("#group-result-error").html("<img width='20' height='20' align='absmiddle' src='../images/error_button_2.jpg'>&nbsp<font color='red'>"+resp['message']+"</font>");
                }
            }
        });
    }
    else{
        $("#group-result-success").empty();
        $(".group-result").empty();
        $("#group-result-error").html("<img width='20' height='20' align='absmiddle' src='../images/error_button_2.jpg'>&nbsp<font color='red'>Group Name cannot be empty</font>");
    }
    
}

function show_sc_box(order_id){
    //$("#"+order_id+"-expand_box").show();
    $("#"+order_id).slideDown("medium");
}

function hide_sc_box(order_id){
    $("#"+order_id).slideUp("medium");
//$("#"+order_id+"-expand_box").hide();
}

function pay_by_sc(order_id){
    var entered_amt=$("#"+order_id+"-credit_refund").val();
    var note=$("#"+order_id+"-note").val();

    if(order_id==""){
        alert("Order id cannot be empty")
    }
    else if(entered_amt=="" && entered_amt!=0){
        alert("Submission credits cannot be empty");
    }
    else{
        $.ajax({
            type: "post",
            url: "../ajax/ajax_admin_refund_sc.php",
            data:"order_id="+order_id+"&submission_amount="+entered_amt+"&note="+note+"&rand="+Math.random(),
            dataType: "json",
            success: function(resp){
                var order_id=resp['Order_id'];
                var refund_paid=resp['Refund_paid'];
                var refund_due=resp['Refund_due'];
                
                if(refund_due=="0"){
                    window.location.href=window.website_url+"admin/refund_due.php";
                }
                
                $("#"+order_id+"-paid_refund_amount").html(refund_paid);
                $("#"+order_id+"-refund_due").html(refund_due);
                $("#"+order_id+"-credit_refund").val(refund_due);
                $("#"+order_id+"-note").val("");
                $("#"+order_id).slideUp("medium");
                
            }
        });
    }
}

$(document).ready(function(){

    $(".expand-refund-details").click(function(){
        var element_id=$(this).attr("id");
        var element_details=element_id.split("-");
        var order_id=element_details[0];
        $("#"+order_id).hide();
        $("#"+order_id+"-details").html('<img src="../images/loading.gif" />');
        $("#"+order_id+"-details").slideToggle("slow");
        $.ajax({
            type: "post",
            url: "../ajax/admin_transaction_list.php",
            data:"order_id="+order_id+"&rand="+Math.random(),
            dataType: "text/html",
            success: function(resp){
                $("#"+order_id+"-details").html(resp);
            }
        });
    });

});

function process_refund(order_id){
    var payment_type=$("#"+order_id+"-payment_type").val();

    if(payment_type=="cancel_order"){
        var list_of_transactions="";
        $(".refund-transaction").each(function(){
            if(this.checked){
                var current_id=$(this).attr("id");
                var current_element=current_id.split("-");
                if(current_element[0] == order_id){
                    list_of_transactions += current_element[1] + "*";
                }
            }
        });

        if(list_of_transactions!=""){

            $.ajax({
                type: "post",
                url: "../ajax/admin_cancel_transaction.php",
                data:"order_id="+order_id+"&list_of_transactions="+list_of_transactions+"&rand="+Math.random(),
                dataType: "json",
                success: function(resp){
                    if(resp['status']=="success"){
                        window.location.href=window.website_url+"admin/refund_due.php";
                    }
                    else if(resp['status']=="fail"){
                        $("#error_area").html(resp['error_message']);
                    }
                }
            });
        }
        else{
            alert("Choose transactions to cancel order");
        }
    }
    else if(payment_type=="cancel_remaining"){
        var list_of_transactions="";
        $(".refund-transaction").each(function(){
            if(this.checked){
                var current_id=$(this).attr("id");
                var current_element=current_id.split("-");
                if(current_element[0] == order_id){
                    list_of_transactions += current_element[1] + "*";
                }
            }
        });

        if(list_of_transactions!=""){

            $.ajax({
                type: "post",
                url: "../ajax/admin_cancel_remaining_transaction.php",
                data:"order_id="+order_id+"&list_of_transactions="+list_of_transactions+"&rand="+Math.random(),
                dataType: "json",
                success: function(resp){
                    if(resp['status']=="success"){
                        window.location.href=window.website_url+"admin/refund_due.php";
                    }
                    else if(resp['status']=="fail"){
                        $("#error_area").html(resp['error_message']);
                    }
                }
            });
        }
        else{
            alert("You have not selected any transactions [select the checkboxes against the transaction ids] to process OR there are no available transactions that can be cancelled at this time.");
        }

    }
    else if(payment_type=="reduce_submission_credits"){
        $("#"+order_id+"-debit-box").slideDown("slow");
    }
    else if(payment_type=="ignore"){
        $.ajax({
            type: "post",
            url: "../ajax/admin_ignore_refund.php",
            data:"order_id="+order_id+"&status_type="+payment_type+"&rand="+Math.random(),
            dataType: "text/html",
            success: function(resp){
                window.location.href=window.website_url+"admin/refund_due.php";
            }
        });
    }
    else{
        $.ajax({
            type: "post",
            url: "../ajax/admin_refund.php",
            data:"order_id="+order_id+"&payment_type="+payment_type+"&rand="+Math.random(),
            dataType: "text/html",
            success: function(resp){
                if(resp=="Fail"){
                    alert("Action could not be processed. You would first need to process a refund from the payment gateway, either to the extent of the refund due or lesser, and then this option can be processed. If you issue a refund from the payment gateway lesser than the amount due then this option will automatically transfer the remaining balance in the form of submission credits.");
                }
                else{
                    window.location.href=window.website_url+"admin/refund_due.php";
                }
            }
        });
    }
    
}

function paid_refund_details(order_id){
    $.ajax({
        type: "post",
        url: "../ajax/admin_refund_details.php",
        data:"order_id="+order_id+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#"+order_id).hide();
            $("#"+order_id+"-paid-content").html(resp);
            $("#"+order_id+"-paid").slideDown("slow");
        }
    });
}

function hide_refund_paid_box(order_id){
    $("#"+order_id+"-paid").slideUp("slow");
}


$(document).ready(function(){
    /*$(".refund-transaction").live("click",function(){
        var current_id=$(this).attr("id");
        var element=current_id.split("-");

        var transaction_id=element[1];


        if(this.checked){
            $.ajax({
                type: "post",
                url: "../ajax/calculate_transaction_price.php",
                data:"transaction_id="+transaction_id+"&rand="+Math.random(),
                dataType: "text/html",
                success: function(resp){
                    $("#"+transaction_id+"-amount").html("$" + resp);
                }
            });
        }
        else{
            $("#"+transaction_id+"-amount").empty();
        }
    });*/
    })


function hide_debit_box(order_id){
    $("#"+order_id+"-debit-box").slideUp("slow");
}

function debit_amount(order_id){
    var debit_amount = $("#"+order_id+"-debit_amount").val();
    if(debit_amount <= 0){
        alert("Enter a valid amount!");
    }
    else{
        $.ajax({
            type: "post",
            url: "../ajax/admin_debit_credits.php",
            data:"order_id="+order_id+"&debit_amount="+debit_amount+"&rand="+Math.random(),
            dataType: "text/html",
            success: function(resp){
                window.location.href=window.website_url+"admin/refund_due.php";
            }
        });
    }
}

function check_current_action(transaction_id){
    var current_val=$("#"+transaction_id+"-action").val();
    if(current_val=="cancel_order" || current_val=="cancel_remaining" || current_val=="cancel_remaining_cron"){
        $("#"+transaction_id+"-process").attr("disabled",false);
    }
    else{
        $("#"+transaction_id+"-process").attr("disabled",true);
    }
    
}

function cancel_order(transaction_id,order_id){
    var current_action=$("#"+transaction_id+"-action").val();
    $("#"+transaction_id+"-process").attr("disabled",true);
    $.ajax({
        type: "post",
        url: "../ajax/admin_strict_cancellation.php",
        data:"list_of_transactions="+transaction_id+"&action="+current_action+"&rand="+Math.random(),
        dataType: "json",
        success: function(resp){
            if(resp['status']=="fail"){
                $("#error-msg").html(resp['error_message']);
            }
            else{
                window.location.href=window.website_url+"admin/order_details.php?order_id="+order_id;
            }
        }
    });
}

function call_adjust_submission_credits(profile_id){
    var credit_amount=$("#sc-amount").val();
    $.ajax({
        type: "post",
        url: "../ajax/adjust_submission_credits.php",
        data:"profile_id="+profile_id+"&credit_amount="+credit_amount+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#sc-response").show();
            $("#sc-response").html(resp);
        }
    });
}


$(document).ready(function(){
    $("#myaccount_contentbox_list1").mouseenter(function(){
        $("#myaccount_contentbox_list2").slideDown();
    });
    
    $("#myaccount_contentbox_listparent").mouseleave(function(){
        $("#myaccount_contentbox_list2").slideUp();
    });
    
})
    
	
function showhide(element_id){
    if(document.getElementById(element_id).className=="remove")
    {
        document.getElementById(element_id).className="";
        document.getElementById(element_id).style.display="block";
    }
    var myLayer = document.getElementById(element_id).style.display;
    if(myLayer=="none"){
        document.getElementById(element_id).style.display="";
    } else {
        document.getElementById(element_id).style.display="none";
    }
}



$(document).ready(function(){
    
    $(".template-keywords").click(function(){
        var current_keyword=$(this).html();
        //$("#template-content").append(current_keyword);
        $("#template-content").val($("#template-content").val()+current_keyword);
    //$("#subject").val($("#subject").val()+current_keyword);
    });

    $(".template-keywords-subject").click(function(){
        var current_keyword=$(this).html();
        $("#template-subject").val($("#template-subject").val()+current_keyword);
    //$("#subject").val($("#subject").val()+current_keyword);
    });

    $("#template-subject").click(function(){
        $(".template-keywords").hide();
        $(".template-keywords-subject").show();
    });

    $("#template-content").click(function(){
        $(".template-keywords-subject").hide();
        $(".template-keywords").show();
    });

});


function show_refund_log_history(){
    $("#view-order-refund-history").slideToggle();
}

function get_processing_options(){
    var alert_txt="You can take either of the following actions:   \n\n ";
    alert_txt += "1) Make a partial refund from the payment gateway (if applicable) and the amount will automatically reflect on this page, adjusting the refund due amount automatically. \n";
    alert_txt += "2) Add submission credits to the client's account equivalent to the refund amount due. You can do so by clicking on the 'Pay' link in the 'Refund Due' column. \n";
    alert_txt += "3) Cancel the remaining transactions under this order from the User/Pwd section and then all the refund options will be available \n";
    alert(alert_txt);
}

function toggle_refund_options(options_box){
    $("#"+options_box).slideToggle();
}

function change_template_status(template_id,status){
    if(status=="Active"){
        $res=confirm("Are you sure you want to change this template status to Inactive");
    }
    else{
        $res=confirm("Are you sure you want to change this template status to Active");
    }
    
    if($res){
        $.ajax({
            type: "post",
            url: "../ajax/change_template_status.php",
            data:"action_id="+template_id+"&status="+status+"&rand="+Math.random(),
            dataType: "text/html",
            success: function(resp){
                window.location.href=window.website_url+"admin/email_template.php";
            }
        });
    }
    
}

function process_pending(order_id){
    var res=confirm("Are you sure?");
    if(res){
        $.ajax({
            type: "post",
            url: "../ajax/admin_cancel_pending_order.php",
            data:"action=full_order"+"&order_id="+order_id+"&rand="+Math.random(),
            dataType: "text/html",
            success: function(resp){
                window.location.href=window.website_url+"admin/admin_orders.php";
            }
        });
    }
}

function cancel_pending_transaction(transaction_id){
    var res=confirm("Are you sure?");
    if(res){
        $.ajax({
            type: "post",
            url: "../ajax/admin_cancel_pending_order.php",
            data:"action=partial_order"+"&transaction_id="+transaction_id+"&rand="+Math.random(),
            dataType: "text/html",
            success: function(resp){
                window.location.href=window.website_url+"admin/admin_orders.php";
            }
        });
    }
}

function mark_misused_read(order_id){
    $.ajax({
        type: "post",
        url: "../ajax/admin_mark_misued_read.php",
        data:"order_id="+order_id+"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            if(resp=="success"){
                $("#misused-"+order_id).hide();
            }
        }
    });
    
}

function request_to_transfer(){
    $.ajax({
        type: "post",
        url: "../ajax/transfer_request.php",
        data:"transfer=Yes&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            $("#download_msg").html(resp);
        }
    });
}


function test_ajax_response(){
    $.ajax({
        type: "post",
        url: window.website_url+"upgrades/install_all.php",
        data:"&rand="+Math.random(),
        dataType: "text/html",
        success: function(resp){
            if(resp=="success"){
                alert("Success");
            }
        }
    });
}

function add_clicked_value(clicked_value){
    $("#clicked_value").val(clicked_value);
}

function select_custom_radio(){
    $("#custom-directory").attr("checked","checked");
}
