// JavaScript Document

var data;
var lim_aktifitas = 0;
var lim_komentar = 0;
var lim_teman = 0;
var teman_process = 0;
var aktifitas_process = 0;
var mood_process = 0;
var tipe = 0;

$.postJSON = function(url, data, callback) {
	$.post(url, data, callback, "json");
};

function gabung_group(pid,gid,gnama,mid,mnama,inv) {
	$('#out-'+pid).html('<img src="'+url+'images/loading.gif" />');
	$(document).ready(function() {
		$('#out-'+pid).load(url+"groupyit/approve_gr_request", {pid:pid,gid:gid,gnama:gnama,mid:mid,mnama:mnama,inv:inv}, 
			function(data){
				$('#out-'+pid).html('Anda telah bergabung');
			});
	});
}

function tolak_group(pid,gid,gnama,mid,mnama,inv) {
	$('#out-'+pid).html('<img src="'+url+'images/loading.gif" width="32" />');
	$(document).ready(function() {
		$('#out-'+pid).load(url+"groupyit/ignore_gr_request", {pid:pid,gid:gid,gnama:gnama,mid:mid,mnama:mnama,inv:inv}, 
			function(data){
				$('#idout-'+pid).fadeOut();
			});
	});
}

function hapus_foto(pid) {
		if(pid!="") {
			$('#outnav-'+pid).hide();
			$('#outmg-'+pid).html('<img src="'+url+'images/loading.gif" width="32" />');
			$(document).ready(function() {
				$('#outmg-'+pid).load(url+"groupyit/hapus_foto", {pid:pid}, 
					function(data){
						$('#outmg-'+pid).html('');
						$('#fotoalbum-'+pid).fadeOut();		
						
						window.location.reload();
					});
			});
		} else {
			parent.location=url+'login';
		}
	}

function hapus_album(pid, mid) {
		if(pid!="") {
			//$('#outnav-'+pid).hide();
			$('#outmg-'+pid).html('<img src="'+url+'images/loading.gif" />');
			$(document).ready(function() {
				$('#outmg-'+pid).load(url+"groupyit/hapus_album", {pid:pid,mid:mid}, 
					function(data){
						$('#outmg-'+pid).html('');
						$('#album-'+pid).fadeOut();
						window.location.reload();
					});
			});
		} else {
			parent.location=url+'login';
		}
	}

function latest(mid, mcolor) {
		$('#btn_insmood').html('<img src="'+url+'images/loading.gif" />');
		$(document).ready(function() {
			$('#btn_insmood').load(url+"groupyit/insert_mood", {testinput_pre: $('#moodinput_pre').val(),testinput: $('#moodinput').val(), mcolor:mcolor, getmoody:$('#getmoody').val() }, 
				function(data){
					$('#lastmood').html(data);
					$('#btn_insmood').html('<input name="input" type="submit" value="Ganti Mood" onclick="latest('+mid+', document.getElementById(\'color1\').value); return false;" />');
					$('#moodinput_pre').val('');
					$('#moodinput').val('');
					$("#moodinput").fieldtag({standardText:"What's happening?...", markedClass:'taggedx'});
					$('#moodyicon').html('');
					$('#getmoody').val('');
					if(data != 'Masukkan aktivitas kamu saat ini.') {
						lim_aktifitas = 0;
						updatelist(mid);
					}
				});
		});
	}

function remove(idx, mood) {		
		$(document).ready(function() {
			$("#log-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#load-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/remove_log", {tid: idx }, 
				function(){		
					$("#log-"+idx).css({backgroundColor: '#ffffcc'});
					$("#log-"+idx).fadeOut(1200);
				});
		});
	}

function remove_comm(idx) {		
		$(document).ready(function() {
			$("#kom-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#nokom-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/remove_comm", {tid: idx }, 
				function(){		
					$("#kom-"+idx).css({backgroundColor: '#ffffcc'});
					$("#kom-"+idx).fadeOut(1200);
				});
		});
	}
	
	function remfotocomm(idx, pic, idname) {		
		$(document).ready(function() {
			$("#idremovebox-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#idremove-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/remove_fotocomm", {tid: idx, pic:pic, idname:idname }, 
				function(data){		
					//$("#idremovebox-"+idx).css({backgroundColor: '#ffffcc'});
					//$("#idremovebox-"+idx).fadeOut(1200);
					$("#idremovebox-"+idx).html(data);
				});
		});
	}
	
	
	var data;

function updatefoto_comm(fid) {
		$('#fotoComm').html($("#fotoComm").html());
		$(document).ready(function() {
			$('#fotoComm').load(url+"groupyajax/list_album_foto_comm", {fid:fid }, 
				function(){
					$('#fotoComm').html(data);
				});
		});
	}
	
function latestFotoComm(mid, currentimage) {
		$('#btn_fotocomm').html('<span class="loadingbox">&nbsp;</span>');
		$(document).ready(function() {
			$.postJSON(url+'groupyit/insert_fotocomm', {textComm: $('#textComm').val(), aid:album, mid:mid, murl:murl,fid:foto }, 
				function(data){
					$('#terbaruFotoComm').append('<div class="clearfix item listcommforum" style="text-align:left" id="idremovebox-'+data.id+'" ><div class="commremove" id="idremove-'+data.id+'"><a href="javascript:void 0" onclick="if(confirm(\'Apakah anda yakin untuk menghapus komentar ini?\')) remfotocomm('+data.id+', \'i/m/'+data.member_id+'/m32'+data.member_foto_ext+'\', \''+data.member_name+'\'); else return false;">hapus</a></div><div class="commforumleft"><img src="'+url+'i/m/'+data.member_id+'/m32'+data.member_foto_ext+'" align="left" border="0" /><a href="'+url+'profil/'+data.member_url+'"><strong>'+data.member_name+'</strong></a><br />'+data.member_foto_comm_date+'</div><div class="commforum">'+ data.member_foto_comm_isi +'</div></div>');
					$('#btn_fotocomm').html('<input type="button" name="kirimkom" value="Kirim Komentar" class="b-submitbig" onclick="latestFotoComm('+mid+', \''+currentimage+'\'); return false;" />');
					$('#textComm').val('');
					$("#textComm").fieldtag({standardText:"Isikan komentar di sini...", markedClass:'taggedx'});
					$('#jmlkomentar').html(parseFloat($('#jmlkomentar').html())+1);
				});
		});
	}
	
	
function updatelist(mid) {
	if(aktifitas_process == 0) {
		aktifitas_process = 1;
		if(lim_aktifitas == 0) { $('#updatelist').html(''); }
		
		$('#aktifitas_loader').html('<img src="'+url+'images/loading.gif" />');
		
		$(document).ready(function() {
			$('#aktifitas_loader').load(url+"groupyajax/list_log", {mid: mid, page: lim_aktifitas, public:0, tipe:tipe }, 
				function(data){
					$('#updatelist').append(data);
					$('#aktifitas_loader').html("");
					$('#viewolder-'+(lim_aktifitas-1)).remove();
					aktifitas_process = 0;
					lim_aktifitas++;
					/*
					if(lim_aktifitas == max_aktifitas) { 
						$('#more_aktifitas').html('&nbsp;'); 
					} else {
						$('#more_aktifitas').html('<img src="'+url+'images/arrow-down.gif" />&nbsp;<a href="javascript:void 0" onclick="updatelist(mid)">Aktifitas selanjutnya</a>');		
					}
					*/
					//document.getElementById('testinput').value = '';
				});
		});
	}
}
	
	function updatealbum(mid) {
		$('#album_loader').html('<img src="'+url+'images/loading.gif" />');
		$('#updatealbum').html('');
		$(document).ready(function() {
				$('#updatealbum').load(url+"groupyajax/list_album", {mid: mid,murl:murl }, 
				function(data){
					$('#updatealbum').html(data);
					$('#album_loader').html('');
				});
		});
	}
	
	
	
	function scrollto_yibbi() {
		$.scrollTo('#uptop',{
									vertical:true,
									speed:800
									});	
	}
	
	
	
	function scrollup() {	
		$.scrollTo('#uptop',{
					vertical:true,
					speed:800
					});
	}
	
	var options13 = { 
        beforeSubmit:  showRequest13,  // pre-submit callback 
        success:       showResponse13,
		dataType:  "json"
		
    }; 
	
	$(document).ready(function() { 
  
	$("#kategori").change(function() {
				$("#noteloading").html('&nbsp;<img align="texttop" hspace="5" src="'+url+'images/loading_circle.gif" />');
				var obj = $(this);
        var src = $("option:selected", this).val();
				obj.attr('disabled','disabled');
				$.post(url+"groupyajax/get_notes", {val:src }, 
				function(data){
					$('#notecontent').html(data);
					obj.removeAttr('disabled');
					$("#noteloading").html('');
				});
    });


	var options2 = { 
        target:        '#output2',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest2,  // pre-submit callback 
        success:       showResponse2,      // clear all form fields after successful submit 
        resetForm: true     
    }; 
	
	var options3 = { 
        beforeSubmit:  showRequest3,  // pre-submit callback 
        success:       showResponse3,
		resetForm:true
    }; 
	
	
	
	var options5 = { 
        beforeSubmit:  showRequest5,  // pre-submit callback 
        success:       showResponse5
    }; 
	
	var options6 = { 
        beforeSubmit:  showRequest6,  // pre-submit callback 
        success:       showResponse6
    }; 
	
	var options7 = { 
        beforeSubmit:  showRequest7,  // pre-submit callback 
        success:       showResponse7
    }; 
	
	var options3a = { 
        beforeSubmit:  showRequest3a,  // pre-submit callback 
        success:       showResponse3a,
		resetForm:  true
    }; 
 	
	var options_undang = { 
        beforeSubmit:  showRequest_undang,  // pre-submit callback 
        success:       showResponse_undang,
		resetForm:  true
    }; 
	
	
    // bind form using 'ajaxForm' 
	$('#form_uploadfoto').ajaxForm(options2); 
	$('#form_undang').ajaxForm(options_undang); 
	$('#form_fotoprofil').ajaxForm(options3); 
	$('#form_editfoto').ajaxForm(options5); 
	$('#form_editalbum').ajaxForm(options6); 
	$('#form_addalbum').ajaxForm(options7); 
	$('#form_tagteman').ajaxForm(options3a); 
	
	
	$('#moodyicon').mouseover(function() {		
		$('#moodyrem').show();
	});
	$('#moodyicon').mouseout(function() {		
		$('#moodyrem').hide();
	});
	
	$('#moodyrem').mouseover(function() {		
		$('#moodyrem').show();
	});
	$('#moodyicon').mouseout(function() {		
		$('#moodyrem').hide();
	});
	
	$('#NoteAddForm').submit(function() {
		$(this).ajaxSubmit(options13); 
		return false; 
	});
}); 

function addRowNoteReply(nid) {
	$(document).ready(function() {
			$.post(url+"groupyajax/updateNoteReply", {nid:nid }, 
				function(data){
					$('#reply_show').append(data);
				});
		});
}

function addRowB2WReply(nid) {
	$(document).ready(function() {
			$.post(url+"groupyajax/updateB2WReply", {nid:nid }, 
				function(data){
					$('#reply_show').append(data);
				});
		});
}

function showRequest_undang(formData, jqForm, options_undang) { 
    var queryString = $.param(formData); 
 	$('#form_undang').css('display','none');
	$('#ann').css('display','');
	$('#email_undangan').html('');
    return true; 
} 


// post-submit callback 
function showResponse_undang(responseText, statusText)  { 
	if(responseText == 0) {
		$('#form_undang').css('display','');
		$('#ann').css('display','none');
	} else if(responseText == 1) {
		$('#email_undangan').html('<div class="postgagal">Autentikasi gagal. Pastikan email dan password yang anda miliki adalah valid, kemudian coba kembali beberapa saat lagi.</div>');
		$('#form_undang').css('display','');
		$('#ann').css('display','none');
	} else if(responseText == 2) {
		$('#email_undangan').html('<div class="postgagal">Gagal mengambil Buku Alamat Anda. Silakan coba kembali beberapa saat lagi.</div>');
		$('#form_undang').css('display','');
		$('#ann').css('display','none');
	} else if(responseText == 3) {
		$('#email_undangan').html('<div class="postgagal">Email dan Password tidak boleh kosong.</div>');
		$('#form_undang').css('display','');
		$('#ann').css('display','none');
	} else {
		window.location.href= url+'undangteman/daftaremail/'+responseText.substr(1,responseText.length);
		//window.location.reload();
	}
}

function showRequest3a(formData, jqForm, options3a) { 
    var queryString = $.param(formData); 
 	$('#id_tagteman').html('<span class="loadingbox">&nbsp;</span>');
    return true; 
} 


// post-submit callback 
function showResponse3a(responseText, statusText)  { 
	evt =responseText.split('|');
	if(evt[0] == "1")	{
		$('#output3a').html('');	
		$('#tagteman').dialog("close"); 
		if(evt[1] != "") {
			$('#tt-'+evt[1]).html(evt[2]);
			$('#tt-'+evt[1]).addClass('tagteman_tab');
		} else {
			$('#tt-'+evt[1]).addClass('tagteman_tab');	
		}
	} else {
		$('#output3a').html(responseText);	
	}
	$('#id_tagteman').html('<div id="id_tagteman"><input type="submit" name="button2" id="button2" class="b-submitbig" value="Simpan" />');
}



function showRequest2(formData, jqForm, options) { 
    var queryString = $.param(formData); 
 	//$('#output1').html('<img src="'+url+'images/loading.gif" width="18" />');
	$('#btn_uploadfoto').html('<span class="loadingbox">&nbsp;</span>');
	//scrollup();
    return true; 
} 
 
// post-submit callback 
function showResponse2(responseText, statusText)  { 
	evt =responseText.split('|');
	if(evt[0] == "1")	{
		parent.location=url+'edit-album/'+murl+'/'+evt[1];
	} else {
		$('#output2').html(responseText);
		$('#btn_uploadfoto').html('<input type="submit" value="Upload Foto" name="submit" class="b-submitbig" />');
	}
	
	
}

function showRequest3(formData, jqForm, options) { 
    var queryString = $.param(formData); 
 	$('#id_fotoprofil').html('<span class="loadingbox">&nbsp;</span>');
    return true; 
} 

 
// post-submit callback 
function showResponse3(responseText, statusText)  { 
	evt =responseText.split('|');
	if(evt[0] == "1")	{
		$('#output3').html('');	
		//parent.tb_remove();
		parent.document.getElementById('fotodiri').src=evt[1];
	} else {
		$('#output3').html(responseText);	
	}
	$('#id_fotoprofil').html('<input type="submit" name="button2" id="button2" class="b-submitbig" value="Ganti Foto" />&nbsp;<input type="button" name="button3" id="button3" value="Cancel" onclick="tb_remove(); return false;" class="b-submitbig" />');
}

function showRequest5(formData, jqForm, options) { 
    var queryString = $.param(formData); 
	$('#btn_editfoto').html('<img src="'+url+'images/loading.gif" alt="loading" width="25" align="absmiddle" />  Saving, please wait...');
    return true; 
} 
 
// post-submit callback 
function showResponse5(responseText, statusText)  { 
	evt = responseText.split('|');
	if(evt[0] == "1") { 
		$('#output5').html('<div class="postsukses">Data foto telah diperbaharui</div>');
		//$('#form_editfoto').hide();
		parent.location = url+'profil/foto/'+evt[1];
		//updatealbum_foto(mid, evt[1], evt[2]);
		//parent.document.getElementById('id_editFoto').src=url+evt[1];
		/*
		if(evt[1] == "0") {
			
		} else {
			
		}
		*/
	} else {
		$('#output5').html('<div class="postsukses">'+responseText+'</div>');	
	}
	$('#btn_editfoto').html('<input type="image" src="'+url+'images/b-save.gif" value="UPLOAD FOTO" />&nbsp;<input type="image" src="'+url+'images/b-galeri-foto.gif" name="button3" value="Cancel" onclick="parent.location=\''+url+'profilku/foto\';return false;" />');
} 

function showRequest6(formData, jqForm, options) { 
   var queryString = $.param(formData); 
 	$('#btn_savealbum').html('<span class="loadingbox">&nbsp;</span>');
    return true; 
} 
 
// post-submit callback 
function showResponse6(responseText, statusText)  {
	evt = responseText.split('|');
	if(evt[0] == "1") {
		$('#output2').html('');
		
		parent.location=url+'edit-album/'+murl+'/'+evt[1];
	} else {
		$('#output2').html(responseText);
	}
	$('#btn_savealbum').html('<input type="image" src="'+url+'images/b-save.gif" value="Simpan Info Album" />');
} 

function showRequest7(formData, jqForm, options7) { 
    var queryString = $.param(formData); 
 	//$('#output1').html('<img src="'+url+'images/loading.gif" width="18" />');
	$('#btn_savealbum').html('<span class="loadingbox">&nbsp;</span>');
	//scrollup();
    return true; 
} 
 
// post-submit callback 
function showResponse7(responseText, statusText)  { 
	evt =responseText.split('|');
	if(evt[0] == "1")	{
		parent.location=url+'edit-album/'+murl+'/'+evt[1];
	} else {
		$('#output2').html(responseText);
		$('#btn_savealbum').html('<input type="submit" value="Simpan" class="b-submitbig" />&nbsp;<input type="button" value="Batal" onclick="history.go(-1); return false" class="b-submitbig" />');
	}
	
	
} 

function showRequest8(formData, jqForm, options8) { 
    var queryString = $.param(formData); 
	$('#btnkirim-'+formData[1].value).html('<span class="loadingboxsmall">&nbsp;</span>');
	//scrollup();
    return true; 
} 
 
// post-submit callback 
function showResponse8(data)  { 
	if(data.return_status == 1) {
		$('#listcomm-'+data.id).append('<div class="clearfix item listcommforum" style="text-align:left" id="idmoodcomm-'+data.reply_id+'" ><div class="commremove" id="idmoodcomm2-'+data.reply_id +'"><a href="javascript:void 0;" onclick="remmoodcomm('+data.reply_id+', \''+data.member_name+'\', \'i/m/'+data.member_id+'/m32'+data.member_foto_ext+'\')">hapus</a></div><div class="commforumleft"><img src="'+url+'i/m/'+data.member_id +'/m32'+data.member_foto_ext+'" align="left" border="0" /><a href="'+url+'profil/'+ data.member_url +'"><strong>'+ data.member_name +'</strong></a><br />'+data.reply_date+'</div><div class="commforum2">'+data.reply_pesan+'</div></div>');
		$('#isipesan-'+data.id).val('');
		$('#jmlkomentar-'+data.id).html(data.reply_tot);
		$('.warnmoodcomm').html('');
	} else {
		$('.warnmoodcomm').html('<div class="postgagal">Isi komentar tidak boleh kosong...</div>');
	}
	$('#btnkirim-'+data.id).html('<input name="kirim" type="submit" id="kirim" value="Kirim" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: void 0" onclick="hidecomm(\'#moodcomm-'+data.id+'\')">Tutup</a>');
	
	
}

function showRequest8a(formData, jqForm, options8a) { 
    var queryString = $.param(formData); 
	$('#btnreply-'+formData[1].value).html('<span class="loadingboxsmall">&nbsp;</span>');
	//scrollup();
    return true; 
} 
 
// post-submit callback 
function showResponse8a(data)  { 
	if(data.return_status == 1) {
		//$('#listreply-'+data.id).append('<div class="listcommitem"><img align="left" src="'+url+'/i/m/'+data.member_id+'/m32'+data.member_foto_ext+'" width="21" /><div class="listcomm"><small><a href="'+url+'profil/'+data.member_url+'"><strong>'+data.member_name+'</strong></a> &bull; '+data.reply_date+'</small><p>'+data.reply_pesan+'</p></div></div>');
		$('#listreply-'+data.id).append('<div class="clearfix item listcommforum" style="text-align:left" id="idcommreply-'+data.reply_id+'" ><div class="commremove" id="idcommreply2-'+data.reply_id +'"><a href="javascript:void 0;" onclick="remcommreply('+data.reply_id+', \''+data.member_name+'\', \'i/m/'+data.member_id+'/m32'+data.member_foto_ext+'\')">hapus</a></div><div class="commforumleft"><img src="'+url+'i/m/'+data.member_id +'/m32'+data.member_foto_ext+'" align="left" border="0" /><a href="'+url+'profil/'+ data.member_url +'"><strong>'+ data.member_name +'</strong></a><br />'+data.reply_date+'</div><div class="commforum2">'+data.reply_pesan+'</div></div>');
		$('#isireply-'+data.id).val('');
		$('#jmlreply-'+data.id).html(data.reply_tot);
		$('.warnreply').html('');
	} else {
		$('.warnreply').html('<div class="postgagal">Isi komentar tidak boleh kosong...</div>');
	}
	$('#btnreply-'+data.id).html('<input name="kirim" type="submit" id="kirim" value="Kirim" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: void 0" onclick="hidecomm(\'#replycomm-'+data.id+'\')">Tutup</a>');
}

function showRequest8b(formData, jqForm, options8b) { 
    var queryString = $.param(formData); 
	$('#btngreply-'+formData[1].value).html('<span class="loadingboxsmall">&nbsp;</span>');
	//scrollup();
    return true; 
} 
 
// post-submit callback 
function showResponse8b(data)  { 

	if(data.return_status == 1) {
		$('#listgreply-'+data.id).append('<div class="clearfix item listcommforum" style="text-align:left" id="idcommgreply-'+data.reply_id+'" ><div class="commremove" id="idcommgreply2-'+data.reply_id +'"><a href="javascript:void 0;" onclick="remcommgreply('+data.reply_id+', \''+data.member_name+'\', \'i/m/'+data.member_id+'/m32'+data.member_foto_ext+'\', gid)">hapus</a></div><div class="commforumleft"><img src="'+url+'i/m/'+data.member_id +'/m32'+data.member_foto_ext+'" align="left" border="0" /><a href="'+url+'profil/'+ data.member_url +'"><strong>'+ data.member_name +'</strong></a><br />'+data.reply_date+'</div><div class="commforum2">'+data.reply_pesan+'</div></div>');
		$('#isigreply-'+data.id).val('');
		$('#jmlgreply-'+data.id).html(data.reply_tot);
		$('.warngreply').html('');
	} else {
		$('.warngreply').html('<div class="postgagal">Isi komentar tidak boleh kosong...</div>');
	}
	$('#btngreply-'+data.id).html('<input name="kirim" type="submit" id="kirim" value="Kirim" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: void 0" onclick="hidecomm(\'#replygcomm-'+data.id+'\')">Tutup</a>');
}

function showRequest8c(formData, jqForm, options8c) { 
    var queryString = $.param(formData); 
	$('#btnttreply-'+formData[1].value).html('<span class="loadingboxsmall">&nbsp;</span>');
	//scrollup();
    return true; 
} 
 
// post-submit callback 
function showResponse8c(data)  { 
	if(data.return_status == 1) {
		$('#listttreply-'+data.id).append('<div class="clearfix item listcommforum" style="text-align:left" id="idcommttreply-'+data.reply_id+'" ><div class="commremove" id="idcommttreply2-'+data.reply_id +'"><a href="javascript:void 0;" onclick="remcommttreply('+data.reply_id+', \''+data.member_name+'\', \'i/m/'+data.member_id+'/m32'+data.member_foto_ext+'\')">hapus</a></div><div class="commforumleft"><img src="'+url+'i/m/'+data.member_id +'/m32'+data.member_foto_ext+'" align="left" border="0" /><a href="'+url+'profil/'+ data.member_url +'"><strong>'+ data.member_name +'</strong></a><br />'+data.reply_date+'</div><div class="commforum2">'+data.reply_pesan+'</div></div>');
		$('#isittreply-'+data.id).val('');
		$('#jmlttreply-'+data.id).html(data.reply_tot);
		$('.warnttreply').html('');
	} else {
		$('.warnttreply').html('<div class="postgagal">Isi komentar tidak boleh kosong...</div>');
	}
	$('#btnttreply-'+data.id).html('<input name="kirim" type="submit" id="kirim" value="Kirim" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: void 0" onclick="hidecomm(\'#replytt-'+data.id+'\')">Tutup</a>');
}

function showRequest8d(formData, jqForm, options8d) { 
    var queryString = $.param(formData); 
	$('#btnfpreply-'+formData[1].value).html('<span class="loadingboxsmall">&nbsp;</span>');
	//scrollup();
    return true; 
} 
 
// post-submit callback 
function showResponse8d(data)  { 
	if(data.return_status == 1) {
		$('#listfpreply-'+data.id).append('<div class="clearfix item listcommforum" style="text-align:left" id="idcommfpreply-'+data.reply_id+'" ><div class="commremove" id="idcommfpreply2-'+data.reply_id +'"><a href="javascript:void 0;" onclick="remcommfpreply('+data.reply_id+', \''+data.member_name+'\', \'i/m/'+data.member_id+'/m32'+data.member_foto_ext+'\')">hapus</a></div><div class="commforumleft"><img src="'+url+'i/m/'+data.member_id +'/m32'+data.member_foto_ext+'" align="left" border="0" /><a href="'+url+'profil/'+ data.member_url +'"><strong>'+ data.member_name +'</strong></a><br />'+data.reply_date+'</div><div class="commforum2">'+data.reply_pesan+'</div></div>');
		$('#isifpreply-'+data.id).val('');
		$('#jmlfpreply-'+data.id).html(data.reply_tot);
		$('.warnfpreply').html('');
	} else {
		$('.warnfpreply').html('<div class="postgagal">Isi komentar tidak boleh kosong...</div>');
	}
	$('#btnfpreply-'+data.id).html('<input name="kirim" type="submit" id="kirim" value="Kirim" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: void 0" onclick="hidecomm(\'#replyfp-'+data.id+'\')">Tutup</a>');
}
	function sendMoodComm(mid) {
		$('#btn_sendcomm').html('<span class="loadingbox">&nbsp;</span>');
		$(document).ready(function() {
			$.postJSON(url+"groupyit/insert_moodcomm", {textComm: $('#comm_text').val(), mid:mid }, 
				function(data){
					$('#newmoodcomm').html('<div class="clearfix item"  style="background-color: #ffffcc"><div class="i-foto32"><a href="'+url+'profil/'+ data.member_url +'" style="background:url('+url+'i/m/'+data.member_id +'/m32'+data.member_foto_ext+') center no-repeat;"><img src="'+url+'images/blank32.png" alt="" width="32" height="32" border="0" /></a></div><div class="i-entry"><a href="'+url+'profil/'+ data.member_url +'"><strong>'+ data.member_name +'</strong></a><p>'+ data.group_comm_isi +'&nbsp;<small class="abu2">'+ data.group_comm_date +'</small></p></div></div>');
					$('#btn_sendcomm').html('<input name="input" type="image" src="'+url+'images/b-kirim.gif" onclick="sendMoodComm(mid); return false;" />');
					$('#comm_text').val('Tulis coretan di sini...');
					//mood_process = 0;
					//lim_komentar = 0;
					//updatemood_comm(mid);					
				});
		});
	}
	
	function updatemood_comm(mid) {
		$('#newmoodcomm').html('');
		if(mood_process == 0) {
			mood_process = 1;
			if(lim_komentar == 0) { $('#moodcomm').html(''); }
			$('#komentar_loader').html('<img src="'+url+'images/loading.gif" />');
			$(document).ready(function() {
				$('#komentar_loader').load(url+"groupyajax/list_mood_comm", {mid:mid, page:lim_komentar }, 
					function(data){		
						$('#moodcomm').append(data);
						$('#komentar_loader').html('');
						mood_process = 0;
						
						
						lim_komentar++;
						if(lim_komentar == max_komentar) { 
							$('#more_komentar').html('&nbsp;'); 
						} else {
							$('#more_komentar').html('<img src="'+url+'images/arrow-down.gif" />&nbsp;<a href="javascript:void 0" onclick="updatemood_comm(mid)">Komentar selanjutnya</a>');		
						}
						//document.getElementById('testinput').value = '';
					});
			});
		}
	}
	
	
	function jadi_teman(pid,tid) {
		
		if(pid!="") {
			$('#out-'+pid).html('<img src="'+url+'images/loading.gif" width="32 />');
			$(document).ready(function() {
				$('#out-'+pid).load(url+"groupyit/approve_fr_request", {pid:pid,tid:tid}, 
					function(data){
						$('#out-'+pid).html('<span class="small_v2">*berteman</span>');
						//$('#out-'+pid).html(data);
					});
			});
		} else {
			parent.location=url+'login';
		}
	}
	
	function tidakjadi_teman(pid,tid) {
		if(pid!="") {
			$('#out-'+pid).html('<img src="'+url+'images/loading.gif" width="32" />');
			$(document).ready(function() {
				$('#out-'+pid).load(url+"groupyit/ignore_fr_request", {pid:pid,tid:tid}, 
					function(data){
						$('#box-'+pid).fadeOut();
						//$('#out-'+pid).html(data);
					});
			});
		} else {
			parent.location=url+'login';
		}
		
	}
	
	function hapus_teman(pid,tid,pnama) {
		if(pid!="") {
			$('#out-'+pid).html('<img src="'+url+'images/loading.gif" />');
			$(document).ready(function() {
				$('#out-'+pid).load(url+"groupyit/remove_fr", {pid:pid,tid:tid,pnama:pnama}, 
					function(data){
						$('#box-'+pid).fadeOut();
						
					});
			});
		} else {
			parent.location=url+'login';
		}
	}
	
	function hapusnote(nid,mnama) {
		if(nid > 0) {
			$(document).ready(function() {
				$("#idremovebox-"+nid).css({backgroundColor: '#f9f9f9'});
				$("#idremove-"+nid).html('<img src="'+url+'images/loading.gif" width="48" align="absmiddle" />');
				$.post(url+"groupyit/hapusnote", {nid: nid }, 
					function(data){		
						parent.location=url+'note/'+mnama;
					});
			});
		} 
	}
	
	function hidecomm(comp) {
		$(comp).hide();
	}
	
	function moodcomment(pid, tot, tid) {
		//if ($('#moodcomm-'+pid).is(":hidden")) {
			$('#moodcomm-'+pid).show().html('<img src="'+url+'images/loading.gif" width="38" />');
			$(document).ready(function() {
				$('#moodcomm-'+pid).load(url+"groupyajax/komentarmood", {pid:pid, tot:tot, mid:tid }, 
					function(data){		
						$('#moodcomm-'+pid).html(data);
					});
			});
		 // } else {
			//$('#moodcomm-'+pid).hide();
		  //}
	}
	
	function commreply(pid, tot, tid) {
		//if ($('#replycomm-'+pid).is(":hidden")) {
			$('#replycomm-'+pid).show().html('<img src="'+url+'images/loading.gif" width="38" />');
			$(document).ready(function() {
				$('#replycomm-'+pid).load(url+"groupyajax/replycomm", {pid:pid, tot:tot, mid:tid }, 
					function(data){		
						$('#replycomm-'+pid).html(data);
					});
			});
		  //} else {
			//$('#replycomm-'+pid).hide();
		 // }
	}
	
	$(document).ready(function(){
		$('#editPassword').click(function () {
		  if ($("#form_password").is(":hidden")) {
			$("#form_password").slideDown("slow");
		  } else {
			$("#form_password").slideUp("slow");
		  }
		});
		
		$('#editPassword2').click(function () {
		  if ($("#form_password").is(":hidden")) {
			$("#form_password").slideDown("slow");
		  } else {
			$("#form_password").slideUp("slow");
		  }
		});
		
		$('#idfilter').click(function () {
		  if ($("#boxfilter").is(":hidden")) {
			$("#boxfilter").slideDown("fast");
			$("#capaktifitas").addClass("greyborder");
			$('#idfilter').removeClass("lk-unselected");
			$('#idfilter').addClass("lk-selected");
			
		  } else {
			$("#boxfilter").slideUp("fast");
			$("#capaktifitas").removeClass("greyborder");
			$('#idfilter').removeClass("lk-selected");
			$('#idfilter').addClass("lk-unselected");
		  }
		});
		
		
		
  });
	
	function loadgaleri(foto,album) {
		/*
		$.scrollTo('.upme',{
					vertical:true,
					speed:800
					});
		*/
	$('#imgmap').remove();
	 $('#loader').removeClass('loadex').addClass('loading');
	 $('#tern').remove();
	 $('.note').remove();
	 
	 $(document).ready(function(){
		$.postJSON(url+'member_album/initgaleri', { foto: foto, aid:album, mid:mid },
			function(data){
				var img = new Image();
				
				$(img).load(function () {
					//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
					$(this).hide();
					$(img).attr("id", "tern");  
					$('#loader').css("height", data.imgheight+"px");  
					$('#loader').css("width", data.imgwidth+"px");  
					$('#loader').removeClass('loading').addClass('loadex').append(this);
					$(this).fadeIn();
					
					$('#fotopos').html(' &bull; '+data.imgpos+' / ');
					$('#fotototal').html(data.imgtotal+' &bull; ');
					
					if(data.imgprev != "") 
						$('#fotoprev').html('<a href="javascript:void 0;" onclick="loadgaleri('+data.imgprev+','+album+')" id="prevfoto">&laquo; Sebelumnya</a>');
					else 
						$('#fotoprev').html("");
						
					if(data.imgnext != "") 
						$('#fotonext').html('<a href="javascript:void 0;" onclick="loadgaleri('+data.imgnext+','+album+')" id="nextfoto">Berikutnya &raquo;</a>');
					else 
						$('#fotonext').html("");
					
					//$('#idpermalink').val(data.urlimgfile);
					$('#jmlkomentar').html(data.imgkomentar);
					$('#fotodesc').html(data.fotodesc);
					updatefoto_comm(data.imgid);
					
					gantifoto(data.imgid);
					$('#tern').imgNotes(data.fotonote);
				}).error(function () {
					// notify the user that the image could not be loaded
				}).attr({
						src: data.imgfile, 
						width:data.imgwidth,
						height:data.imgheight,
						id:'imgmap'
					
				});
			});
		});
}

function remnotecomm(evt) {
	$(document).ready(function() {
		$("#idremovebox-"+evt).css({backgroundColor: '#f9f9f9'});
		$("#idremove-"+evt).html('<img src="'+url+'images/loading.gif" width="32" />');
		$.post(url+"groupyit/remove_notereply", {tid: evt}, 
			function(){		
				$("#idremovebox-"+evt).css({backgroundColor: '#ffffcc'});
				$("#idremovebox-"+evt).fadeOut(1200);
			});
	});
}

function remmoodcomm(idx, idname, pic) {		
		$(document).ready(function() {
			$("#idmoodcomm-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#idmoodcomm2-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/removecomm", {tid: idx, mode:'mood', idname:idname, pic:pic }, 
				function(data){		
					$("#idmoodcomm-"+idx).html(data);
				});
		});
	}
	
	function remcommreply(idx, idname, pic) {		
		$(document).ready(function() {
			$("#idcommreply-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#idcommreply2-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/removecomm", {tid: idx, mode:'comm', idname:idname, pic:pic }, 
				function(data){		
					$("#idcommreply-"+idx).html(data);
				});
		});
	}
	
	function remcommgreply(idx, idname, pic, gid) {		
		$(document).ready(function() {
			$("#idcommgreply-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#idcommgreply2-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/removegcomm", {tid: idx, mode:'comm', idname:idname, pic:pic, gid:gid }, 
				function(data){		
					$("#idcommgreply-"+idx).html(data);
				});
		});
	}
	
	
	function remcommttreply(idx, idname, pic) {		
		$(document).ready(function() {
			$("#idcommttreply-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#idcommttreply2-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/removettcomm", {tid: idx, mode:'comm', idname:idname, pic:pic }, 
				function(data){		
					$("#idcommttreply-"+idx).html(data);
				});
		});
	}
	
	function remcommfpreply(idx, idname, pic) {		
		$(document).ready(function() {
			$("#idcommfpreply-"+idx).css({backgroundColor: '#f9f9f9'});
			$("#idcommfpreply2-"+idx).html('<img src="'+url+'images/loading.gif" width="32" />');
			$.post(url+"groupyit/removefpcomm", {tid: idx, mode:'comm', idname:idname, pic:pic }, 
				function(data){		
					$("#idcommfpreply-"+idx).html(data);
				});
		});
	}
	
	
	function commgreply(pid, tot, tid, gid) {
		//if ($('#replygcomm-'+pid).is(":hidden")) {
			$('#replygcomm-'+pid).show().html('<img src="'+url+'images/loading.gif" width="32" />');
			$(document).ready(function() {
				$('#replygcomm-'+pid).load(url+"groupyajax/replygcomm", {pid:pid, tot:tot, mid:tid, gid:gid }, 
					function(data){		
						$('#replygcomm-'+pid).html(data);
					});
			});
		 // } else {
			//$('#replygcomm-'+pid).hide();
		  //}
	}
	
	function commtagteman(pid) {
		//if ($('#replytt-'+pid).is(":hidden")) {
			$('#replytt-'+pid).show().html('<img src="'+url+'images/loading.gif" width="32" />');
			$(document).ready(function() {
				$('#replytt-'+pid).load(url+"groupyajax/replytt", {pid:pid}, 
					function(data){		
						$('#replytt-'+pid).html(data);
					});
			});
		//  } else {
			//$('#replytt-'+pid).hide();
		  //}
	}
	
	function commfp(pid, mid) {
		//if ($('#replyfp-'+pid).is(":hidden")) {
			$('#replyfp-'+pid).show().html('<img src="'+url+'images/loading.gif" width="32" />');
			$(document).ready(function() {
				$('#replyfp-'+pid).load(url+"groupyajax/replyfp", {pid:pid, mid:mid}, 
					function(data){		
						$('#replyfp-'+pid).html(data);
					});
			});
		 // } else {
			//$('#replyfp-'+pid).hide();
		 // }
	}
	var moodyshow=0;
	var moodyshowtrue=0;
	
	
	function setmoody(evt) {
		$('#moodyicon').html('<img src="'+url+'images/moody/'+evt+'" align="left" />');
		$('#getmoody').val(evt);
		$('#moodydiag').dialog('close');
	}
	
	function removemoody() {
		$('#moodyicon').html('');
		$('#moodyrem').hide();
		$('#getmoody').val('');
	}
	
	function setmylog(evt) {
		
		$('#tipelog-0').removeClass("lk-selected");
		$('#tipelog-1').removeClass("lk-selected");
		$('#tipelog-2').removeClass("lk-selected");
		$('#tipelog-3').removeClass("lk-selected");
		
		$('#tipelog-0').addClass("lk-unselected");
		$('#tipelog-1').addClass("lk-unselected");
		$('#tipelog-2').addClass("lk-unselected");
		$('#tipelog-3').addClass("lk-unselected");
		
		$('#tipelog-'+evt).addClass("lk-selected");
		
		tipe = evt;
		lim_aktifitas = 0;
		updatelist(mid);	
	}
	
	function friendRequest(mid,pid,cid) {
		if(cid!="") {
			$('#'+pid).html('<a href="#"><img border="0" src="'+url+'images/loading.gif" width="32" /></a>');
			$(document).ready(function() {
				$('#'+pid).load(url+"groupyit/friend_request", {mid:mid,pid:pid}, 
					function(data){
						$('#'+pid).html('');
						alert('Terima kasih, Permintaan anda menjadi teman sedang menunggu persetujuan.');
						
					});
			});
		} else {
			parent.location=url+'login';
		}
	}
	
function showRequest13(formData, jqForm, options13) { 
    var queryString = $.param(formData);
	$('#btnsubmit').html('<span class="loadingbox">&nbsp;</span>');
    return true; 
} 
 
// post-submit callback 
function showResponse13(data)  {
	if(data.return_status == 1) {
		notes.push({nid:data.nid, x1: data.x1, y1: data.y1, width:data.width,height:data.height,note:data.note});
		$('.note').remove();
		$('#tern').imgNotes();
		$('#idnote').append('<div id="idnote-'+data.nid+'">'+data.note+'&nbsp;<span id="idnotex-'+data.nid+'"><small><a href="javascript:void 0;" onclick="if(confirm(\'Apakah anda yakin untuk menghapus Catatan Foto ini?\')) removenote('+data.nid+','+data.fid+'); else return false;">hapus</a></small></span></div>');
		closenote();
	} else {
		$("#warn13").html('<div class="postgagal">Catatan foto tidak boleh kosong.</div>');
	}
	
	$('#btnsubmit').html('<input type="submit" value="Submit" /> &nbsp;<input type="button" value="Cancel" id="cancelnote" onclick="closenote();" >');
} 

function removenote(evt, evt2) {
		$('#idnotex-'+evt).html('<img src="'+url+'images/loading.gif" width="32" />');
		$(document).ready(function() {
			$('#idnote-'+evt).load(url+"groupyit/m_remfotonote", {nid:evt, fid:evt2, mid:mid}, 
				function(data){	
					if(data==1) {
						$('#idnote-'+evt).remove();
						$('#notebox-'+evt).remove();
					} else {
						$('#idnotex-'+evt).html('<a href="javascript:void 0;" onclick="removenote('+evt+','+evt2+')">hapus</a>');
					}
				});
		});
	}
	
function getkota(evt, evt2) {
	$('#isikota').html('<img src="'+url+'images/loading.gif" width="32" />');
	$(document).ready(function() {
		$('#isikota').load(url+"groupyajax/kota", {cid:evt,kid:evt2}, 
			function(data){	
				$('#isikota').html(data);
			});
	});
}

function note_rate(evt,evt2) {
	$.post(url+"groupyit/rate_note", {evt:evt, evt2:evt2}, 
		function(data){	
			if(data!=0) {
				window.location.reload();
			} 
		});
}
