function sajax(controller,ajax_reply,indicator){
	//$("#"+ajax_reply).html('<img src="/images/indicator.gif" width="16" height="16" alt="" />');
	if(indicator!=""){
		$("#"+indicator).show();
		$("#"+indicator).html('<img src="/images/indicator.gif" width="16" height="16" alt="" />');
	}
	$.ajax({
		type: "GET",
		url: controller,
		cache: false,
		success: function(html){
			$("#"+ajax_reply).html(html);
			if(indicator!=""){
				edLoad(indicator);
			}
		},
		error:function(){
			$("#"+ajax_reply).html('error');
		}
	});
}
function pajax(controller,ajax_reply,indicator){
	//$("#"+ajax_reply).html('<img src="/images/indicator.gif" width="16" height="16" alt="" />');
	if(indicator!=""){
		$("#"+indicator).html('<img src="/images/indicator.gif" width="16" height="16" alt="" />');
	}
	$.ajax({
		type: "GET",
		url: controller,
		cache: false,
		success: function(html){
			$("#"+ajax_reply).html(html);			
		},
		error:function(){
			$("#"+ajax_reply).html('error');
		}
	});
}
function fandf(controller,ajax_reply){
	$.ajax({
		type: "GET",
		url: controller,
		cache: false,
		success: function(html){
			$("#"+ajax_reply).html(html);			
		},
		error:function(){
			$("#"+ajax_reply).html('error');
		}
	});
}
function reply(un){
	$("input[name='in_reply_un']").val(un);
	$("textarea#comment").attr("value", '@'+un+" ");	
	//$("textarea#comment").focus('last');
}
function vup(obj){
	//alert(obj);
	var param = obj.split("-");
	sajax("/home/vote/"+param[1],"vnode"+param[0]);
	$("#vdesnode"+param[0]).html('<span><img src="/images/liked.jpg" width="22" height="23" alt="Бағалап қойдыңыз" /></span>');
}
function vsave(obj){
	//alert(obj);
	//var param = obj.split("-");
	$("#savenode"+obj).html('<span>Күтіңіз...</span>');
	sajax("/home/savemystory/"+obj,"savenode_container"+obj);
	
}
function vunsave(obj){
	//var param = obj.split("-");
	$("#savenode"+obj).html('<span>Күтіңіз...</span>');
	sajax("/home/unsavemystory/"+obj,"savenode_container"+obj);
	
}
function vunmixx(obj){
	//alert(obj);
	//var param = obj.split("-");
	$("#unmixxnode"+obj).html('<span>Күтіңіз...</span>');
	sajax("/home/unmixx/"+obj,"unmixxnode_container"+obj);	
}
function vupmixx(obj){
	//var param = obj.split("-");
	$("#unmixxnode"+obj).html('<span>Күтіңіз...</span>');
	sajax("/home/upmixx/"+obj,"unmixxnode_container"+obj);
}
function stLoad(divid,ajax_reply,img){
	if(ajax_reply!="") {
		$("#"+ajax_reply).fadeOut(1000);
	}
	$("#"+divid).show();	
	if(img==true){
		$("#"+divid).html('<img src="/images/indicator.gif" width="16" height="16" alt="" />');
	}
}
function edLoad(divid){
	$("#"+divid).hide();	
}
$(document).ready(function()
{
	$("#first_sign input[name='user_type']").click(function() {
		var goxxx = $(this).attr('id');
		if(goxxx=='new_user'){
			$("#new_user_layout").show();
			$("#already_user_layout").hide();
		}else{
			$("#new_user_layout").hide();
			$("#already_user_layout").show();
		}			
	});
	// REMOVE FRIEND
	$("a[name=remove_friend]").click(function(){
		var un = $(this).attr('id');	
		if(confirm(" Дос қатарынан шынымен өшіресіз ба?")){
			pajax('/member/unfriend/' + un,'remove_friend_'+un,'remove_friend_'+un);
		}
	});
	// ADD FRIEND
	$("a[name=add_friend_list]").click(function(){
		var un = $(this).attr('id');				
		pajax('/member/addfriend/' + un,'add_friend_'+un,'add_friend_'+un);
	});	
	// ACTIVE FRIEND
	$("a[name=active_friend]").click(function(){
		var un = $(this).attr('id');			
		pajax('/member/activefriend/' + un,'active_friend_'+un,'active_friend_'+un);
	});	
	$("#search_button").click(function() {
		if($("input[@name='keyword']").val() != 'Іздеу...' && $("input[@name='keyword']").val() != '') $("form[@name='search']").submit();
	});
	$("#morelink").click(function(){
		$(".other_menu").toggle();
	});
	
	$("#ttl").mouseover(function() {
		$("#sub-" + $(this).attr('id')).show();
		return false;
	});
	$("#ttl").mouseout(function() {
		$("#sub-" + $(this).attr('id')).hide();
		return false;
	});
	
	$(".menushopdetail").click(function() {
		$("#sub_" + $(this).attr('id')).toggle(200);
		return false;
	});
	
	$("#tab10").click(function(){
		$(this).removeClass('tabb');
		$(this).addClass('tabb-sel');
		$("#tab20").removeClass('tabb-sel');
		$("#tab20").addClass('tabb');
		
		$("#s_tab10").show();		
		$("#m_tab10").hide();
		return false;
	});
	$("#tab20").click(function() {
		$(this).removeClass('tabb');
		$(this).addClass('tabb-sel');
		$("#tab10").removeClass('tabb-sel');
		$("#tab10").addClass('tabb');
		
		$("#s_tab10").hide();
		$("#m_tab10").show();
		return false;
	});

});

