
function validateInappropriateForm()
    {
    value=$("inappmulti").value;
    if (value=="")
        {
        alert("Please select your reason for flagging this Kimi as inappropriate.");
        return false;
        }
    else
        {
        return confirm("Please only flag Kimis that are truely inappropriate. We monitor abuse of the inappropriate flagging system.\n\nAre you sure this kimi is "+value+"?");
        }
    };

function affilateAjaxFunction( affil_url_id, kimi_msid )
    {
    $("affil_url_id").disabled = true;
    $("affil_status").innerHTML = '&nbsp;';
    url='/protected/set_affil_url?affil_url_id='+affil_url_id+'&kimi_msid='+kimi_msid;
    alert("url="+url);
    ajaxExecFunction
        (
        url,
        function(URL,response)
            {
            alert(URL);
            valuesArray = response.split("|");

            response = valuesArray[0];
            urlTitle = valuesArray[1];

            $("affil_status").innerHTML = '';
            $("affil_status").innerHTML = response;
            $("affil_url_id").disabled = false;

            if( urlTitle == '' )  {titleStr = '';}
            else                  {titleStr = 'title="'+urlTitle+'"';}

            }
        );
    };


function submitAndPublish() {document.kimiForm.publishToo.value='true';document.kimiForm.submit();};
function submitAndFeature(secs) {document.kimiForm.feature.value=secs;document.kimiForm.submit();};

function toggle_flag_content_ui()   {swapDisplay2("CenterContent","flagContentHTML")};
function toggle_stats_ui()          {swapDisplay1("stats")};
function toggle_tags_help_ui()      {swapDisplay1("tagsHelp")};
function toggle_categories()        {swapDisplay1("categories")};

//******************************
// Voting
//******************************

//When the user mouses over the stars, preview what their star-rating would look like if they clicked
function PreviewStars(n)
    {
    av_rating=getAjaxVar("av_rating")*1;
    user_rating=getAjaxVar("user_rating")*1;
    if (!getAjaxBoolVar("user_can_rate"))
        {
        if (!getAjaxBoolVar("supress_errors"))
            swapOnVisibility("rating_error","rating_count");
        return;
        }
    var i=0;
    for(i=1;i<=5;i++)
        {
        var d = $("star"+i);
        var num=0;
        if (i*2<=av_rating+1) num=1;
        if (i*2<=av_rating) num=2;

        var s="";
        if (i<=n) s="s";
        d.src="/images/star"+num+s+".gif";
        }
    };

//When the user moves their mouse away from the stars, restore the initial display of the stars
function LoginToRate()
  {
  swapOnVisibility("rating_error","rating_count");
  }

function RestoreStars()
    {
    av_rating=getAjaxVar("av_rating")*1;
    user_rating=getAjaxVar("user_rating")*1;
    swapOffVisibility("rating_error","rating_count");
    var i=0;
    for(i=1;i<=5;i++)
        {
        var d = $("star"+i);
        var num=0;
        if (i*2<=av_rating+1) num=1;
        if (i*2<=av_rating) num=2;

        var s="";
        if (i<=user_rating) s="s";
        d.src="/images/star"+num+s+".gif";
        }
    };

//When the users clicks on the stars, do an ajax update post to the database
function ClickStars(n,kimi_id)
    {
    if (getAjaxBoolVar("login_to_rate"))         {window.location="/main/new_user?redirect=/main/view_kimi/"+kimi_id;return;}
    if (!getAjaxBoolVar("user_can_rate"))         return;

    setAjaxVar("user_rating",n);
    ajaxSwap("/protected/rate/"+kimi_id+"?rating="+n,"rating_saving","rating_count",true);

    //setAjaxBoolVar("user_can_rate",false);

    //supress all further star error messages until a new _view_kimi_partial is loaded.
    //I would prefer to suppress the errors until the user moves the mouse away from the stars, a certain amount of time has passed, the ajax operation has completed, THEN re-enable the "already rated" error message.
    setAjaxBoolVar("supress_errors",true);
    };

function prompt_set_title(kimi_id,current_title,update_tag)
    {
    new_title=prompt("Edit Kimi Title", current_title);
    if (new_title==null) return;
    url="/protected/set_title/"+kimi_id+"?title="+escape(new_title);
    ajaxExecFunction
        (
        url,
        function(URL,response)
            {
            if (response=="success")
                update_tag.innerHTML=new_title;
            else
                {
                alert(response);
                prompt_set_title(kimi_id,new_title,update_tag);
                }
            }
        );
    };

function prompt_set_description(kimi_id,current_description,update_tag)
    {
    new_desc=prompt("Edit Kimi Description", current_description);
    if (new_desc==null) return;
    url="/protected/set_description/"+kimi_id+"?description="+escape(new_desc);
    ajaxExecFunction
        (
        url,
        function(URL,response)
            {
            if (response=="success")
                update_tag.innerHTML=new_desc;
            else
                {
                alert(response);
                prompt_set_description(kimi_id,new_desc,update_tag);
                }
            }
        );
    };

