﻿// comments

function commentsShow(moduleId, req, params){
    new Insertion.Bottom('comments'+moduleId+'_'+params.parentId, req.responseText);
}

function commentsAdd(active, id, allowAnon, isUserAnon, withTitle, parentId, showWeb){
    var frm = $('commentForm'+id);
    if(frm)
        frm.remove();
    var str = '<div class="commentForm" id="commentForm'+id+'"><form action="#" onsubmit="runModuleMethod(\'Comments\','+id+',\'SaveComment\',$(this).serialize(true),commentSaved); return false;">';
    if (!allowAnon && isUserAnon){
        str += 'Buraya yorum yazabilmek için üye olmanız gerekmektedir. Zaten üye iseniz oturum açınız.';
    }
    else{
        if (isUserAnon){
            str += 'Nick<br/>';
            str += '<input type="text" name="nick"/><br/>';
            if(showWeb){
                str += 'Web<br/>';
                str += '<input type="text" name="web"/><br/>';
            }
        }
        if (withTitle) {
            str += 'Başlık<br/>';
            str += '<input type="text" name="title"/><br/>';
        }
        str += 'Metin<br/>';
        str += '<textarea name="text"></textarea><br/>';
        str += '<input type="hidden" name="parentId" value="'+parentId+'"/>';
        str += '<div style="text-align:right"><input type="button" value="Vazgeç" onclick="$(\'commentForm'+id+'\').remove()"/><input type="submit" value="Gönder"/></div>';
    }
    str += '</form></div>';
    
    new Insertion.Bottom('comments'+id+'_'+parentId, str);
    $('commentForm'+id).scrollTo();
}

function commentSaved(moduleId, req, params){
    $('commentForm'+moduleId).remove();
    new Insertion.Bottom('comments'+moduleId+'_'+params.parentId, req.responseText);
}

// tavsiye et

function recommend(moduleId){
    var str = '<div class="tavsiyeForm" style="display:none" id="recommendForm'+moduleId+'">';
    str += '<div class="title">Tavsiye edin</div>';
    str += '<form action="#" onsubmit="runModuleMethod(\'ContentTools\','+moduleId+',\'SendMail\',$(this).serialize(true),recommended); return false;">';

    str += 'Adınız<br/>';
    str += '<input type="text" name="ad1"/><br/>';
    str += 'E-Posta adresiniz<br/>';
    str += '<input type="text" name="email1"/><br/><br/>';

    str += 'Arkadaşınızın adı<br/>';
    str += '<input type="text" name="ad2"/><br/>';
    str += 'Arkadaşınızın e-posta adresi<br/>';
    str += '<input type="text" name="email2"/><br/><br/>';

    str += '<input type="hidden" name="link" value="'+location.href+'"/>';
    
    str += '<input type="button" value="Vazgeç" onclick="$(\'recommendForm'+moduleId+'\').remove()"/><input type="submit" value="Gönder"/>';

    str += '</form></div>';

    new Insertion.Bottom("ContentTools_"+moduleId, str);
    var f = $('recommendForm'+moduleId);
    f.setStyle({
        width: 300,
        position:'absolute',
        top: 200,
        left: 200
    });
    //Effect.Grow(f);
    f.show();
}
function recommended(moduleId, req, params){
    if(req.responseText.startsWith('HATA:')) {
        alert(req.responseText);
    } else {
        $('recommendForm'+moduleId).remove();
        alert(req.responseText);
    }
}
// membership
function passwordSent(moduleId, req, params){
    alert(req.responseText);
}
function codeSent(moduleId, req, params){
    alert(req.responseText);
}