function changeTpl()
{
    document.template.src="images/" + document.F.tpl.value + ".gif";
}

function updateUsers()
{
    $('.onlinelist').load("/info.php");
}

function setPage(page, source)
{
    var url = "";
    var res = "";
    if (source == 'friends')
    {
	url = "/profile/inc/friends.php";
	res = "#friends";
    }

    if (source == 'gb')
    {
	url = "/profile/inc/gb.php";
	res = "#gb";
    }

    req = 'action=' + source  + '&page=' + page;

    $.ajax({
            type: "POST",
            url: url,
            data: req,
            success: function(msg)
            {
        	$(res).html(msg);
            }
    });
}

function delTag(id)
{
    if (confirm(unescape("Tag wirklich l%F6schen%3F")))
    {
        var url = '/profile/inc/tags.php';
	var req = 'action=delTag&id='+id;
    }
    
    $.ajax({
        type: "POST",
        url: url,
        data: req,
        success: function(msg)
        {
		$("#tags").html(msg);
        }
    });
}

function addTag(catid)
{
    var url = '/profile/inc/tags.php';
    var tag = $('#tag' + catid).val();
    var req = 'action=addTag&catid=' + catid + '&tag=' + escape(tag);

    $.ajax({
        type: "POST",
        url: url,
        data: req,
        success: function(msg)
        {
		$("#tags").html(msg);
        }
    });
}


function saveExt()
{
    var oFCKeditor = FCKeditorAPI.GetInstance("extendedcontent");
    var content = oFCKeditor.GetHTML(true );
    var url = '/profile/inc/extended.php';
    var req = 'action=saveExt&content=' + escape(content);
    $.ajax({
        type: "POST",
        url: url,
        data: req,
        success: function(msg)
        {
		$("#extended").html(msg);
        }
    });
}

function saveGB()
{
    var private=0;
    if ( $("#private:checked").length > 0)
	private=1;

    var oFCKeditor = FCKeditorAPI.GetInstance("gbcontent");
    var content = oFCKeditor.GetHTML(true );
    var url = '/profile/inc/gb.php';
    var req = 'action=gb&content=' + escape(content) + "&private=" + private;
    
    $.ajax({
        type: "POST",
        url: url,
        data: req,
        success: function(msg)
        {
	    $("#gb").html(msg);
        }
    });
}


function delGb(id, page)
{
    if (confirm(unescape("Eintrag wirklich l%F6schen%3F")))
    {
        var url = '/profile/inc/gb.php';
        var req = 'action=del&id='+id + '&idx=' + page;
	$.ajax({
    	    type: "POST",
    	    url: url,
    	    data: req,
    	    success: function(msg)
    	    {
		$("#gb").html(msg);
    	    }
	});
    }
}

function showComments(id, link, cnt)
{
    $("#votecomment" + id).toggle();
    if ( $("#votecomment" + id + ":hidden").length > 0)
    {
        link.innerHTML = cnt + ' Kommentar(e) anzeigen';
    }
    else
        link.innerHTML = 'Kommentare ausblenden';

}

function chkUser()
{
    var user = document.getElementById("username").value;
    window.open('/profile/chkuser.php?un=' + user, '', 'width=420,height=70');
}

function send()
{
    document.F.pw.value=MD5(document.F.pw1.value);
    document.F.pw1.value='';
    return true;
}


function deleteImage(id)
{
    var c = confirm(unescape("Bild wirklich l%F6schen%3F"));
    if (c == true)
	window.location.href = '/galerie/delete.php?id=' + id;

}

function checkFields()
{
    var x = document.upload_form.desc.value;
    if (x.length == 0)
    {
	alert('Bitte gib eine Kurzbeschreibung ein')
	return false;
    }
    else
	return true;
}


function deleteMail(folder, id)
{
    var ok = confirm(unescape("Nachricht wirklich l%F6schen%3F"));
    if (ok == true)
	window.location.href = '/mail/delete-' + folder + '-'+ id + '.html';
}

