﻿var RefreshTime = 1000;
function Logout() {
    var code = new Array();
    code.push('logout');
    code.push('logout'); 
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function TellMe(id) {
    opop(id, 'ajax', 'TellMe', 'Benden haberdar olsun.', ImageType, 500, 100);
}
function spresent(id) {
    opop(id, 'ajax', 'spresent', 'Hediye gönder.', ImageType, 500, 100);
}
function TellAFriend(id) {
    opop(id, 'ajax', 'TellAFriend', 'Paylaşmak istediğim kişiler.', ImageType, 500, 100);
}

function SpamThis(page) {
    opop(page, 'ajax', 'SpamThis', 'Bu sayfada sakıncalı unsurlar var.', ImageType, 500, 100);
}
function rreq(id, type) {
    if (type == '1') {
        atyr(id);
    }
    if (type == '2') {
        atfrn(id);
    }

}
function decreq(id, type) {
    var code = new Array();
    code.push('decreq');
    code.push(id);
    code.push(type);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function dreq(id) {
    var code = new Array();
    code.push('dreq');
    code.push(id); 
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function TellThis() {
    var code = new Array();
    code.push('share');
    code.push(document.getElementById('tellaboutId').value); 
    code.push(document.getElementById('selectedUsers').value); 
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function TellAboutMe(to) {
    var code = new Array();
    code.push('tellme');
    code.push(to); 
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function Spam() {
    var code = new Array();
    code.push('spam');
    code.push(document.getElementById('spamAdress').value);
    code.push(document.getElementById('spamType').selectedIndex);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function SendPresent() {
    var code = new Array();
    code.push('spresent');
    code.push(selectedPresent);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function opage(page, id, parent) {
    if (page == 'logout') {
        document.location = '../../Pages/Enter/';
    }
    if(id==null ) { 
        if (page == 'home') {
            document.location = '../../Pages/YY000/Default.aspx';
        }
        
        else if(page == 'account')
        {
            document.location = '../../Pages/YY000/Account.aspx';
        }
        else if(page == 'freq')
        {
            document.location = '../../Pages/YY000/Request.aspx?tip=arkadas';
        }
        else if(page == 'yreq')
        {
            document.location = '../../Pages/YY000/Invitation.aspx?tip=yillik';
        }
        else if(page == 'yureq')
        {
            document.location = '../../Pages/YY000/Request.aspx?tip=yillik';
        }
        else if (page == 'profile') {
            document.location = '../../Pages/YY000/OwnerProfile.aspx';
        }

        else if(page == 'diary')
        {
            document.location = '../../Pages/YY000/Diaries.aspx';
        }

        else if (page == 'beforemessage')
        {
            document.location = '../../Pages/YY000/Messages.aspx?tip=gecmistengelen';
        }
        else if(page == 'messages')
        {
            document.location = '../../Pages/YY000/Messages.aspx';
        }
         else if(page == 'EditProfile')
        {
            document.location = '../../Pages/YY000/OwnerProfile.aspx';

        } 
        else if (page == 'invitetosite') {
            document.location = '../../Pages/Enter/InviteToSite.aspx';
        }
      
    }
    else {
        if (page == 'invitetoyearbook') {
            document.location = '../../Pages/YY002/InviteToYearBook.aspx';
        } else if(page == 'profile') {
            document.location = '../../Pages/YY000/Profile.aspx?Id='+id;
        } else if (page == 'events') {
            document.location = '../../Pages/YY000/Events.aspx?user=' + id;
        } else if (page == 'mailcontrol') {
            document.location = '../../Pages/Enter/MailControl.aspx?id='+id;
        }
        else if (page == 'home') {
            document.location = '../../Pages/YY000/Home.aspx?Id=' + id;
        }
        else if (page == 'user') {
            document.location = '../../Pages/Enter/User.aspx?Id=' + id;
        }
        else if (page == 'YearBookAlbum') {
            document.location = '../../Pages/YY000/ViewFile.aspx?FolderType=YearBookAlbum&YearBook='+parent+'&Id=' + id;
        }
        else if (page == 'yearbookmessages') {
            document.location = '../../Pages/YY002/Messages.aspx?YearBook='+ id;
        }
        else if (page == 'yearbookusers') {
        document.location = '../../Pages/YY002/YearBookUsers.aspx?YearBook=' + id;
        }
        else if (page == 'yearbookevents') {
        document.location = '../../Pages/YY002/Events.aspx?YearBook=' + id;
        }
        else if (page == 'yearbookteachers') {
        document.location = '../../Pages/YY002/Teachers.aspx?YearBook=' + id;
        } 
        else if (page == 'photos') {
            document.location = '../../Pages/YY000/Album.aspx?User=' + id;
        }
        else if (page == 'searchresult') {
            document.location = '../../Pages/YY000/Result.aspx?search=' + id;
        }
    }
}
function SearchString(value) {


}
function userinvited(link) {
    alert('');
    document.getElementById(link).href = '';
    document.getElementById(link).innerHTML = 'Bu kullanıcıya davet gönderdiniz.';
}
function Invite(inviteTo, inviteType, sender,record, params) {
    var code = new Array();
    code.push('invite');
    code.push(inviteTo);
    code.push(inviteType);
    code.push(sender);
    code.push(record);
    code.push(params);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function userinvited(link) {
    var el = document.getElementById(link);
    el.innerHTML = "Bu kullanıcıyı bu yıllığa davet ettiniz.";
}
function invres(group,page,record) {
    if (page == "yearbook") {
        document.location = '../../Pages/YY002/InviteToYearBookResult.aspx?yearbook='+record+'&group='+group;
    }
    if (page == "site") {
        document.location = '../../Pages/YY000/InviteToSiteResult.aspx?yearbook=' + record + '&group=' + group;
    }
    if (page == "group") {
        document.location = '';
    }
    if (page == "schooll") {
        document.location = '';
    }
    if (page == "diary") {
        document.location = '';
    }
}
function ainv(type, id) {

    var code = new Array();
    code.push('ainv');

    code.push(id); 
      code.push(type);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function ncom(parent,id,type) {
    var pa = document.getElementById(parent);
    var yorum = Control.GetControlInControl(pa, 'Comment');
    //var id = BaseListControl.GetItemInfo(document.getElementById('ItemInfo' + parent), 'id');
    var code = new Array();
    code.push('ncom');
    code.push(id);
    code.push(type);
    code.push(parent);
    code.push(yorum.value);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
    yorum.value = '';
    yorum.innerHTML = '';
}

function acom(id, values, itemId) {
    BaseListControl.AddItem(id,'yorum',values,itemId,'','','','1','true','false','Image/',false);
}

function dcom(id) {

}

function rcom(id) {

}

function rmes(id) {
    var code = new Array();
    code.push('rmes');
    code.push(id);
    code.push('MesajListesi');
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function dmes(id,element) {
    var code = new Array();
    code.push('dmes');
    code.push(id);
    code.push(element);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function nevn(parent, id, source, writerNote, time, header, description, image,obj, eventType) {
 var code = new Array();
    code.push('nevn');
    code.push(parent);
    code.push(id);
    code.push(source);
    code.push(header);
    code.push(description);
    code.push(String.ClearChars(image));
    code.push(eventType);
    code.push(String.ClearChars(obj));
    code.push(writerNote); 
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function aevn(id, type, itemId, date, source, writerNote, header, description, image, writer, writerImage, time, point, position, checked, locked) {
    BaseListControl.AddItem(id, type, 'r:rw' + itemId + 'c:clm' + date + 'c:clm' + type + 'c:clm' + description + 'c:clm' + header + 'c:clm' + image + 'c:clm' + source + 'c:clm' + time + 'c:clm' + point + 'c:clm' + writer + 'c:clm' + writerImage + 'c:clm' + writerNote + 'r:rw', itemId, '', '', '', position, checked, locked, '');
}

function devn(id)
{ }

function revn(id)
{ }

function nart(parent, id,aparent) {
    var text = Control.GetControlInControl(document.getElementById(id), 'ContentInput');
    if (text.value != null && text.value != "" && text.value != undefined && text.value.length > 0) {
        var code = new Array();
        code.push('nart');
        code.push(parent);
        code.push(id);
        code.push('');
        code.push('');
        code.push('');
        code.push('');
        code.push(text.value);
        code.push(0);
        code.push(true);
        code.push(false);
        code.push(aparent);
        code.push(0);
        code.push(document.getElementById('CurrentYearBook').value);
        Ajax.AddCode(ListData.GetRow(code));
        Ajax.SendCode();
              
    }

}
function gart(cnt, id) {
    var code = new Array();
    code.push('gart');
    code.push(cnt);
    code.push(id);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function aart(parent, id, itemId, date, writer, writerImage, content, position, checked, locked, articleParent, count) {
    BaseListControl.AddItem(id, 'article', 'r:rw' + itemId + 'c:clm' + date + 'c:clm' + writer + 'c:clm' + writerImage + 'c:clm' + content + 'r:rw', itemId, '', '', '', position, checked, locked, '','',count);
}
function nmes()
{
    var code = new Array();
    code.push('nmes');
    code.push(messageType);
    code.push(document.getElementById('MesajGidecekler').value);
    code.push(document.getElementById('txtKonu').value);
    code.push(document.getElementById('MesajinTarihi').value);
    code.push(document.getElementById('MesajinSaati').value);
    code.push(document.getElementById('txtMesaj').value);
    code.push(document.getElementById('MessageType').value);
    code.push(document.getElementById('MessageId').value);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function atfrn(to) {
    var code = new Array();
    code.push('atfrn');
    code.push(to);  
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function eedu(edu, req) { 
    
}
function atyr(to) {
    var code = new Array();
    code.push('atyr');
    code.push(to);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function ddiary(id) {
    var code = new Array();
    code.push('ddiary');
    code.push(id);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}

function rdiary(id) {
    var code = new Array();
    code.push('rdiary');
    code.push(id);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
    BaseListControl.RemoveItem('Gunluklerim', id);
}
function nfreq(to,link) {
    var code = new Array();
    code.push('nfreq');
    code.push(to);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
    document.getElementById(link).innerHTML = 'Arkadaşlık isteğiniz beklemede';
    document.getElementById(link).href = '';
    
    
}

function nyreq(to,link) {
    var code = new Array();
    code.push('nyreq');
    code.push(to);
    Ajax.AddCode(ListData.GetRow(code));
    document.getElementById(link).innerHTML = 'Katılma isteğiniz beklemede';
    document.getElementById(link).href = '';
    
}

function gmes(id) {
    var code = new Array();
    code.push('gmes');
    code.push(id);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function smes(to) {
    opop(to, 'ajax', 'newmessage', to, '', 500, 200);
}

function list(user, type) {
    opop(user, 'ajax', type, user, '', 500, 200);
}
function LoadImage(ImageType) {
    try {
        var yb = document.getElementById('CurrentYearBook').value;
    }
    catch (ex) {

    } 
    
//    var text = '<iframe src="../../Pages/YY000/UploadImage.aspx?FileType=' + ImageType+'&yearbook='+yb+ ' width="600px" frameborder="no" name="resim" scrolling="yes" id="resim" style="height: 300px"></iframe>';
//   opop('LoadImage','static', 'ImageUpload', 'Resim Yükle', text, 820, 420);
    window.open("http://localhost:12592/YuzYillikCom/Pages/YY000/UploadImage.aspx?FileType=" + ImageType+"&yearbook="+yb, "resim", "width=600, height=400, scrollbars=yes, resizable=yes ");
//    if (ImageType == 'TeacherImage') {
    //   
     // opop('hdnImageId', 'ajax', 'LoadImage', 'Öğretmen Resmi Yükle', ImageType, 820, 420);
//    }
//    if (ImageType  == 'SchoollAlbumImage') {
//        opop(1, 'ajax', 'LoadImage', 'Okul Albümü Resmi Yükle', ImageType, 820, 420);
//    }
//    if (ImageType  == 'YearBookAlbumImage') {
//        opop(1, 'ajax', 'LoadImage', 'Yıllık Albümü Resmi Yükle', ImageType, 820, 420);
//    }
//    if (ImageType  == 'ProfileImage') {
//        opop(1, 'ajax', 'LoadImage', 'Profil Resmi Yükle', ImageType, 820, 420);
//    }
//    if (ImageType == 'EventImage') {
//        opop(1, 'ajax', 'LoadImage', 'Paylaşmak için bir resim yükle', ImageType, 820, 420);
//    }
}
function waydn(words) {
    var code = new Array();
    code.push('waydn');
    code.push(words);
    Ajax.AddCode(ListData.GetRow(code));
    Ajax.SendCode();
}
function swaydn(words) {
    document.getElementById('waydtext').innerHTML = words;
}
function setImageId() {
    var frame = document.getElementById('frmFile');
    frame.contentWindow.SaveImage();
    var rid = frame.contentWindow.document.getElementById('RId').value;
    var type = frame.contentWindow.document.getElementById('RType').value;
    var address = frame.contentWindow.document.getElementById('IAddress').value;
try {
    document.getElementById(type + 'hdnImageId').value = imgid;
    document.getElementById('hdnImageId').value = imgid;
    document.getElementById('ShareImage').src = address;
 }
 catch(ex)
 { }
  
}

function ucusrpimg(address) {
    try
    {
        document.getElementById('ProfileImageImage').src = address;
    }
    catch(ex) 
    {
    }
}

function ucyrimg(address) {
    try {
        document.getElementById('YearBookAlbumImageImage').src = address;
    }
    catch (ex) {
    }
}
 
function ucscimg(address) {
    try
    {
        document.getElementById('SchoollAlbumImageImage').src = address;
    }
    catch(ex) 
    {
    }
}

 function ayteac(id, name, lesson, image, description, liste) {
    var List = document.getElementById(liste);
    var desc = "Branş : " + lesson + " <br> Hakkında : " + description;
    BaseListControl.AddItem(liste,'usersmalllist', 'r:rw' + id + 'c:clm' + name + 'c:clm' + image + 'c:clm' + desc + 'r:rw',id, '', '', '', 0, 'false', 'false', '','',10);
    
}
function nyteac(AddContainer, List) {
    var container = document.getElementById(AddContainer);
    var Ad = Control.GetControlInControl(container, 'txtOgretmenAd').value;
    var Soyad = Control.GetControlInControl(container, 'txtOgretmenSoyad').value;
    var Brans = Control.GetControlInControl(container, 'txtOgretmenBrans').value;
    var Aciklama = Control.GetControlInControl(container, 'txtOgretmenAciklama').value;
    var ImageId = Control.GetControlInControl(container, 'hdnImageId').value;
    var YearBookId = document.getElementById('CurrentYearBook').value;
    var code = new Array();
    code.push('ayteac');
    code.push(Ad);
    code.push(Soyad);
    code.push(Brans);
    code.push(Aciklama);
    code.push(ImageId);
    code.push(YearBookId);
    code.push(List);
    var codes = ListData.GetRow(code);
    Ajax.AddCode(codes);
    Ajax.SendCode();
}
function readmessage(id) {
    var code = new Array();
    code.push('readmessage'); 
    code.push(id);
    var codes = ListData.GetRow(code);
    Ajax.AddCode(codes);
    Ajax.SendCode();
}
function edityearbookuserinformation() {
    opop('', 'ajax', 'edityearbookuserinformation', document.getElementById('CurrentYearBook').value, '', 400, 100);
}
function ucyuinfo(yearbook, name, phone, mail,lakap,not) {
    document.getElementById('YearBookUserName').innerHTML = name;
    document.getElementById('YearBookUserPhone').innerHTML = phone;
    document.getElementById('YearBookUserMail').innerHTML = mail;
    document.getElementById('YearBookUserNick').innerHTML = lakap;
    document.getElementById('YearBookUserNote').innerHTML = not;
    
}
function syuinfo() {
    var adSoyad = document.getElementById('txtAdSoyad').value;
    var tel = document.getElementById('txtTelefon').value;
    var mail = document.getElementById('txtMail').value;
    var lakap = document.getElementById('txtLakap').value;
    var not = document.getElementById('txtNot').value;
    var code = new Array();
    code.push('syuinfo');
    code.push(document.getElementById('CurrentYearBook').value);
    code.push(adSoyad);
    code.push(tel);
    code.push(mail);
    code.push(lakap);
    code.push(not);
    
    var codes = ListData.GetRow(code);
    Ajax.AddCode(codes);
    Ajax.SendCode();

}
function cimg(file,folder, x, y, w, h,dw,dh,type,record) {
    var code = new Array();
    code.push('cimg');
    code.push(file);
    code.push(folder);
    code.push(x);
    code.push(y);
    code.push(w);
    code.push(h);

    code.push(dw);
    code.push(dh);
    code.push(type);
    code.push(record);
    
    var codes = ListData.GetRow(code);
    Ajax.AddCode(codes);
    Ajax.SendCode();
}
function cimgc(type,rid,id, address) {
//    var frame = document.getElementById('frmFile');
//    frame.contentWindow.document.getElementById('IId').value = id;
//    frame.contentWindow.document.getElementById('IAddress').value = address;
    if (type == '0') {
        var code = new Array();
        code.push('ucusrpimg');
        code.push(id);
        code.push(address);
        var codes = ListData.GetRow(code);
        Ajax.AddCode(codes);
        Ajax.SendCode();
    }
    if (type == '1') {
        var code = new Array();
        code.push('ucyrimg');
        code.push(rid);
        code.push(id);
        code.push(document.getElementById('CurrentYearBook').value);
        code.push(address);
        var codes = ListData.GetRow(code);
        Ajax.AddCode(codes);
        Ajax.SendCode();
    }

    if (type == '2') {
        var code = new Array();
        code.push('ucscimg');
        code.push(rid);
        code.push(id);
        code.push(document.getElementById('CurrentYearBook').value);
        code.push(address);
        var codes = ListData.GetRow(code);
        Ajax.AddCode(codes);
        Ajax.SendCode();
    }

    if (type == '10') { 
            document.getElementById('hdnImageId').value = id;
    
        var code = new Array();
        code.push('tcimg');
        code.push(rid);
        code.push(id);
        code.push(document.getElementById('CurrentYearBook').value);
        code.push(address);
        var codes = ListData.GetRow(code);
        Ajax.AddCode(codes);
        Ajax.SendCode();
    }
}
function opop(id,type,key,toOwnerHeader,dateTypeText,width,height) {
 if(type=='ajax')
 {
        var code =  new Array();
        code.push(key);
        code.push(id);
        code.push(width);
        code.push(height);
        code.push(toOwnerHeader);
        code.push(dateTypeText);
       var codes= ListData.GetRow(code);
       Ajax.AddCode(codes);
       Ajax.SendCode();
 }
 else {
     Loading.StopAll();
        Popup.Open(id,width,height,toOwnerHeader,dateTypeText,false,false,false,false,false,false,false,false,false,false,false,'','');
    }
}
function sminfo(id, type, key, toOwnerHeader, dateTypeText, width, height) {
    opop(id, type, key, toOwnerHeader, dateTypeText, width, height);
}
function RunJustCommand(Command) {
    var code = new Array();
    code.push(Command);
    code.push(""); 
    var codes = ListData.GetRow(code);
    Ajax.AddCode(codes);
}
function ClientControl() {
    RunJustCommand('gomes');
    RunJustCommand('gousr');
    RunJustCommand('gmes');
    RunJustCommand('gevn');
    RunJustCommand('gnotice');
    RunJustCommand('greq');
    RunJustCommand('control');
    Ajax.SendCode();
}
function control() {
    setTimeout('ClientControl()', RefreshTime);
}
function gwevn(val) {
    var code = new Array();
    code.push('gwevn');
    code.push(val);
    var codes = ListData.GetRow(code);
    Ajax.AddCode(codes);
}
function swevn(value) {
    var evn = document.getElementById('EventFromWeb');
    evn.innerHTML = value;
 }
function AjaxPopup(values) {
    Loading.StopAll();
    var code ='';
    var okButton=false;
    var sendButton=false;
    var cancelButton=false;
    var acceptButton = false;
    if (values[0] == 'deletediary') {
        code = 'rdiary(\'' + values[1] + '\')';
        acceptButton = true;
        cancelButton = true;
    } 
     
     if (values[0] == 'readdiary') {
         code = ''; 
         okButton = true;
     }
     if(values[0]=='newmessage')
{
    code='nmes()';
    sendButton=true;
    cancelButton=true;
}

if (values[0] == 'friendlist') {
    code = '';
    okButton = true;
    values[4] = 'Arkadaşlarınız';
}

if (values[0] == 'LoadImage') {
    code = 'setImageId()';
    cancelButton = true;
    okButton = true;
}


if (values[0] == 'TellAFriend') {
    code = 'TellThis()';
    cancelButton = true;
    okButton = true;
}

if (values[0] == 'TellMe') {
    code = 'TellAboutMe()';
    cancelButton = true;
    okButton = true;
}

if (values[0] == 'SpamThis') {
    code = 'Spam()';
    cancelButton = true;
    okButton = true;
}
if (values[0] == 'spresent') {
    code = 'SendPresent()';
    cancelButton = true;
    okButton = true;
}

if (values[0] == 'decreq') {
    code = "dreq('" + values[1] + "')";
    cancelButton = true;
    okButton = true;
}
    if(values[0]=='yearbooklist')
    {
    code='';
    okButton=true;
    }
    if(values[0]=='albumlist')
    {
    code='';
    okButton=true;
    }
    if(values[0]=='bloglist')
    {
        code='';
        okButton=true;
    }
    if(values[0]=='messagelist')
    {
        code='';
        okButton=true;
    }
    if(values[0]=='sendfriendrequest')
    {
        code = "nfreq('" + values[1] + "','" + values[6] + "')";
        sendButton=true;
        cancelButton = true;
        okButton = false;
    }
    if(values[0]=='sendyearbookrequest')
    {
        code = "nyreq('" + values[1] + "','" + values[6] + "')";
        acceptButton=true;
        cancelButton=true;
    }

    if (values[0] == 'eedu') {
        code = "opop('sendyearbookrequest', 'ajax', 'sendyearbookrequest','" + values[6] + "', '" + values[7] + "', '500', '100');";
        acceptButton = true;
        cancelButton = true;
    }
    
    if (values[0] == 'edityearbookuserinformation') {
        code = 'syuinfo()';
        okButton = true;
        cancelButton = true;
    }
    if (values[0] == 'information') {
        cancelButton = false;
        acceptButton = false;
        
    code='';
    okButton=true;
    }
    if(values[0]=='warning')
    {
    code='';
    okButton=true;
    }

    if (values[0] == 'rmes') {
        code = 'dmes(\''+values[6]+'\',\''+values[7]+'\');';
        acceptButton = true;
        cancelButton = true;
    }
    
     Popup.Open(values[1],values[2],values[3],values[4],values[5],okButton,cancelButton,acceptButton,false,false,false,false,false,false,sendButton,true,code,''); 
}
