var czpf_button_lockdown = false;
var czpf_button_lockdown_open = false;
var czpf_social_save = '';
var czpf_scroll_lockdown_showmore = false;
var czpf_scroll_lockdown_animation = false;
var czpf_button_lockdown_tmp_this = '';
var czpf_button_lockdown_tmp_save = '';
var czpf_button_lockdown_tmp_savepos = '';
var czpf_page = 1;
var czpf_paddingForMobile = 0;
var connections_type_czpf = new uh_social_connection();

jQuery(document).ready(function($){
	if(jQuery("#cz_groups_tmp").length != 0 && jQuery("#cz_groups").length != 0) {
	  czpf_fn_shortcode('#cz_groups_tmp','#cz_groups');
	}
	if(jQuery("#cz_profile_tmp").length != 0 && jQuery("#cz_profile").length != 0) {
	  czpf_fn_shortcode('#cz_profile_tmp','#cz_profile');
	}
	if(jQuery("#cz_member_tmp").length != 0 && jQuery("#cz_members").length != 0) {
	  czpf_fn_shortcode('#cz_member_tmp','#cz_members');
	}
});


function czpf_fn_shortcode(tmp_from,tmp_to) {
	jQuery(document).ready(function($){
		jQuery(tmp_to).html(jQuery(tmp_from).html());
		jQuery(tmp_from).remove(); 
		
		jQuery("#cz_profile.div_czpf .czpf_edit_box input").keyup(function(event){
		    if(event.keyCode == 13 && czpf_button_lockdown_open){
		    	czpf_fn_edit_object(czpf_button_lockdown_tmp_this,czpf_button_lockdown_tmp_save,czpf_button_lockdown_tmp_savepos);
		    	jQuery(".ui-autocomplete").hide();
		    }
		});		
		
		jQuery("#cz_groups.div_czpf .czpf_edit_box input").keyup(function(event){
		    if(event.keyCode == 13 && czpf_button_lockdown_open){
		    	czpf_fn_edit_object_groups(czpf_button_lockdown_tmp_this,czpf_button_lockdown_tmp_save,czpf_button_lockdown_tmp_savepos);
		    	jQuery(".ui-autocomplete").hide();
		    }
		});	
		
		
		
		
		setTimeout(function() {
			jQuery(tmp_from).remove(); 
			czpf_resize();

			jQuery("#avatarchange").uploadFile({
				url:"/?czpf_data=true&czpf_fn=upload_images_avatar",
				fileName:"myfile",
				maxFileSize:1024*10000,
				allowedTypes:"jpeg,jpg,png,gif",
				onSubmit:function(files)
				{
					jQuery('.czpf_avatar .editble.czpficon-pencil').addClass('loading');
				},
				onSuccess:function(files,data,xhr)
				{
					jQuery('.czpf_avatar').css('background-image','url(\''+data+'\')');
					jQuery('.czpf_avatar .editble.czpficon-pencil').removeClass('loading');
				},
				onError: function(files,status,errMsg)
				{
					alert('A js Error has occurred');
					jQuery('.czpf_avatar .editble.czpficon-pencil').removeClass('loading');
				}
			});	
			  
			jQuery("#cz_groups #groupfileuploader").uploadFile({
				url:"/?czpf_data=true&czpf_fn=upload_images_group",
				fileName:"myfile",
				maxFileSize:1024*10000,
				multiple:false,
				showProgress:true,
				allowedTypes:"jpeg,jpg,png,gif",
				onSubmit:function(files)
				{
					jQuery(".div_czpf .rhc_groups_main_data_upload_thumbnail .ajax-file-upload-progress-fake").hide();
				},
				onSuccess:function(files,data,xhr)
				{
					var res = data.split("|"); 
					jQuery(".div_czpf .rhc_groups_main_data_upload_thumbnail .ajax-file-upload").css('background-image',"url('"+res[0]+"')");
					jQuery(".div_czpf .rhc_groups_main_data_upload_thumbnail #images_check").val(res[1]);
				},
				onError: function(files,status,errMsg)
				{
					jQuery(".div_czpf .rhc_groups_main_data_upload_thumbnail .ajax-file-upload-progress-fake").show();
				}
			});				
			
			

		}, 50);
		
		
		setTimeout(function() { 
			czpf_scroll_init();
		}, 450);
		
		
		 jQuery(".div_czpf input[data-provide='typeahead']" ).each(function(){
		 	var datasource= JSON.parse(jQuery(this).attr('data-source'));
		 
			   jQuery(this).autocomplete({
				source: datasource,
				minLength : 3,
			 });
		 });
		jQuery(tmp_to).delay(200).show();
		
		if(jQuery(".div_czpf .buttombuttontop .active").parent().parent().find('.numbercount').attr('data-count') > 10){
			jQuery('.div_czpf .more_items_div').show();
		}
		
		if(parseFloat(jQuery(".div_czpf #counter").html()) > parseFloat(jQuery(".div_czpf #nrprcounter").html())){
			jQuery('.div_czpf .more_items_div_profile').show();
		}
		
		czpf_avatar_show_profile();
		czpf_avatar_show(jQuery(".div_czpf .buttombuttontop .active").parent().attr('id'));
		
		
		jQuery('#cz_profile').find('.rowobject').not('.bottomcontainer').each(function (){
		
			var n = jQuery(this).find('.ob_s_c').length;
			if (n <= 0) {
				jQuery(this).hide();
			}
		});
		
		
		
		jQuery('#cz_members.div_czpf #memebersprofil_buttons a').click(czpf_memberprofile_pz);
		jQuery('#cz_groups.div_czpf #memebersprofil_buttons a').click(czpf_membergroups_pz);		
    })	
}

jQuery(document).scroll(function(){ czpf_scroll_init(); });

jQuery(document).ready(function($){
	jQuery( window ).resize(czpf_resize);
	
});



function czpf_fn_show_groups_register(){
	jQuery('.div_czpf .rhc_groups_bg #sub').val('');
	jQuery('.div_czpf .rhc_groups_bg #content').val('');
	jQuery('.div_czpf .rhc_groups_bg #submitall').removeAttr('checked');


	jQuery('.div_czpf .rhc_groups_bg .rhc_groups_main_data_upload_thumbnail .ajax-upload-dragdrop .ajax-file-upload').css('background-image','');
	
	jQuery('.div_czpf .rhc_groups_bg .rhc_groups_main_data_upload_thumbnail .ajax-file-upload-statusbar').remove();
	jQuery('.div_czpf .rhc_groups_bg .rhc_groups_main_data_upload_thumbnail .ajax-file-upload-progress-fake').show();
	
	jQuery('.div_czpf .rhc_groups_bg .rhc_groups_main_data_upload_thumbnail .images_check').val('');

	jQuery('.div_czpf .rhc_groups_bg').css({ opacity: 0.0 }).show().fadeTo( "slow" , 1.0);
	jQuery('.div_czpf .rhc_groups_inner').css({ opacity: 0.0 }).show().delay(500).fadeTo( "slow" , 1.0);
}

function czpf_fn_hide_groups_register(){
	jQuery('.div_czpf .rhc_groups_inner').css({ opacity: 1.0 }).show().fadeTo( "slow" , 0.0);
	jQuery('.div_czpf .rhc_groups_bg').css({ opacity: 1.0 }).show().delay(500).fadeTo( "slow" , 0.0, function(){
		jQuery(this).hide();
	});
}

function czpf_fn_save_groups_register(){
	if(czpf_button_lockdown == false){

		var tmp_title = jQuery('.div_czpf .rhc_groups_bg #sub').val();
		var tmp_content = jQuery('.div_czpf .rhc_groups_bg #content').val();
		var tmp_check = jQuery('.div_czpf .rhc_groups_bg #submitall').is(':checked');
		var tmp_img = jQuery('.div_czpf .rhc_groups_bg .rhc_groups_main_data_upload_thumbnail #images_check').val();
	
	
		if(tmp_title == undefined || tmp_title == 'undefined' || tmp_title == ''){
			alert('Please input a title');
			return false;
		}
		
		if(tmp_content == undefined || tmp_content == 'undefined' || tmp_content == ''){
			alert('Please input a content text');
			return false;
		}
		
		if(tmp_img == undefined || tmp_img == 'undefined' || tmp_img == ''){
			alert('Please upload a img');
			return false;
		}
		
		tmp_content = tmp_content.replace(/\n/g, '<br />');

		jQuery('.div_czpf .rhc_groups_inner2 #loading').css({ opacity: 0.0 }).show().fadeTo( "slow" , 1.0);

		czpf_button_lockdown = true;

		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=groups_register", { 'tmp_title': tmp_title,'tmp_content':tmp_content,'tmp_check':tmp_check,'tmp_img':tmp_img}, function( data ) {
			if(data.R != 'OK'){
				alert(data.MSG);
			} else {
				czpf_fn_hide_groups_register();
				czpf_button_lockdown = false;
				czpf_page = 0;
				czpf_fn_scroll_load_groups();
			}
			czpf_button_lockdown = false;
			jQuery('.div_czpf .rhc_groups_inner2 #loading').css({ opacity: 1.0 }).show().fadeTo( "slow" , 0.0,function(){
				jQuery(this).hide();
			});
		}, "json");
	}
	
}

function czpf_group_request_approved(tmp_this,tmp_post,tmp_user_id) {
	if(czpf_button_lockdown == false){
		
		jQuery(tmp_this).addClass('czpf_avatar_overlay_loading_small');

		czpf_button_lockdown = true;
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=group_approved_memeber", { 'tmp_post': tmp_post,'tmp_user_id':tmp_user_id}, function( data ) {
			if(data.R != 'OK'){
				alert(data.MSG);
			} else {
			
			
				jQuery(tmp_this).removeClass('czpf_avatar_overlay_loading_small');
				
				jQuery(tmp_this).parent().parent().find('.remove_heart').remove();
				
				jQuery(tmp_this).parent().parent().find('.show_heart').removeClass('czpficon-uniE2A4').addClass('czpficon-uni6C').attr('onclick',"czpf_group_request_remove(this,"+tmp_post+","+tmp_user_id+")")
				jQuery(tmp_this).parent().parent().appendTo("#cz_groups.div_czpf #approvemembers");
				
				jQuery("#cz_groups.div_czpf #approvemembers .clear").remove();
				jQuery("#cz_groups.div_czpf #approvemembers").append('<div class="clear"></div>');
				
				jQuery("#cz_groups.div_czpf #approvemembers .pending").removeClass('pending');

				tmp_count = jQuery("#cz_groups.div_czpf #requestmembers .commentboxs").length;
				
				if(tmp_count <= 0){
					jQuery("#cz_groups.div_czpf #requestmembers").remove();
					jQuery("#cz_groups.div_czpf #approvemembers h2").remove();
				}
				
			}
			czpf_button_lockdown = false;
		}, "json");
	}	
	
}

function czpf_group_request_remove(tmp_this,tmp_post,tmp_user_id) {
	if(czpf_button_lockdown == false && confirm("Are you sure you want to remove this member?")){
		
		jQuery(tmp_this).addClass('czpf_avatar_overlay_loading_small');

		czpf_button_lockdown = true;
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=group_remove_memeber", { 'tmp_post': tmp_post,'tmp_user_id':tmp_user_id}, function( data ) {
			if(data.R != 'OK'){
				alert(data.MSG);
			} else {
				jQuery(tmp_this).parent().parent().remove();
			}
			czpf_button_lockdown = false;
		}, "json");
	}
}

function czpf_group_request_add(tmp_this,tmp_post,tmp_user_id) {
	if(czpf_button_lockdown == false){
		
		jQuery(tmp_this).addClass('czpf_avatar_overlay_loading_small');

		czpf_button_lockdown = true;
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=group_add_memeber", { 'tmp_post': tmp_post,'tmp_user_id':tmp_user_id}, function( data ) {
			if(data.R != 'OK'){
				alert(data.MSG);
			} else {
				jQuery(tmp_this).removeClass('czpf_avatar_overlay_loading_small');
				jQuery(tmp_this).find('.img_avatar_obj').html(data.STATUS);
			}
			czpf_button_lockdown = false;
		}, "json");
	}	
}





function czpf_membergroups_pz(){
	
	jQuery('.div_czpf #memebersprofil_buttons li').removeClass('active');
	jQuery(this).parent().addClass('active');
	jQuery('.more_items_div_profile').hide();
	czpf_page = 0;
	czpf_fn_scroll_load_groups();
	return false;
}


function czpf_memberprofile_pz(){
	
	jQuery('.div_czpf #memebersprofil_buttons li').removeClass('active');
	jQuery(this).parent().addClass('active');
	jQuery('.more_items_div_profile').hide();
	czpf_page = 0;
	czpf_fn_scroll_load_memebers();
	return false;
}


function czpf_scroll_init(){
		if(jQuery('#cz_groups').is(':visible')){
			if (window.mobile) czpf_paddingForMobile = 1000;
			
			var more_items_div_profile = jQuery('.div_czpf .more_items_div_profile').offset();
			
			if(more_items_div_profile != undefined){
				if ( jQuery(document).scrollTop() >= more_items_div_profile.top - jQuery(window).height()+300-czpf_paddingForMobile && jQuery('.div_czpf .more_items_div_profile').is(':visible') && !czpf_scroll_lockdown_showmore){
					czpf_scroll_lockdown_showmore = true;
					czpf_fn_scroll_fadingeffect_groups();
				}
			}
		}	
		
		if(jQuery('#cz_members').is(':visible')){
			if (window.mobile) czpf_paddingForMobile = 1000;
			
			var more_items_div_profile = jQuery('.div_czpf .more_items_div_profile').offset();
			
			if(more_items_div_profile != undefined){
				if ( jQuery(document).scrollTop() >= more_items_div_profile.top - jQuery(window).height()+300-czpf_paddingForMobile && jQuery('.div_czpf .more_items_div_profile').is(':visible') && !czpf_scroll_lockdown_showmore){
					czpf_scroll_lockdown_showmore = true;
					czpf_fn_scroll_fadingeffect_members();
				}
			}
		}

		if(jQuery('#cz_profile').is(':visible')){
				
			var czpf_buttombuttontop = jQuery('.div_czpf .buttombuttontop').offset();
			var czpf_more_items_div = jQuery('.div_czpf .more_items_div').offset();
			
			
			
			if (window.mobile) czpf_paddingForMobile = 1000;
			
			if(typeof(czpf_more_items_div) != undefined && czpf_more_items_div != undefined){
				if ( jQuery(document).scrollTop() >= czpf_more_items_div.top - jQuery(window).height()+300-czpf_paddingForMobile && jQuery('.div_czpf .more_items_div').is(':visible') && !czpf_scroll_lockdown_showmore){
					czpf_scroll_lockdown_showmore = true;
					czpf_fn_scroll_fadingeffect();
				}
			}
	

				
			if(typeof(czpf_buttombuttontop) != undefined && czpf_buttombuttontop != undefined){
				if ( jQuery(document).scrollTop() >= czpf_buttombuttontop.top - jQuery(window).height()+100-czpf_paddingForMobile && !czpf_scroll_lockdown_animation){
					czpf_scroll_lockdown_animation = true;
						jQuery('.div_czpf .buttombuttontop .numbercount:eq(0)').animateNumber(jQuery('.div_czpf .buttombuttontop .numbercount:eq(0)').attr('data-count'),{duration:4000,floatStepDecimals:1,floatEndDecimals:1,animateOpacity:false});
	
						setTimeout(function() {
							jQuery('.div_czpf .buttombuttontop .numbercount:eq(1)').animateNumber(jQuery('.div_czpf .buttombuttontop .numbercount:eq(1)').attr('data-count'),{duration:4000,floatStepDecimals:1,floatEndDecimals:1,animateOpacity:false});
						}, 200);
						
						setTimeout(function() {
							jQuery('.div_czpf .buttombuttontop .numbercount:eq(2)').animateNumber(jQuery('.div_czpf .buttombuttontop .numbercount:eq(2)').attr('data-count'),{duration:4000,floatStepDecimals:1,floatEndDecimals:1,animateOpacity:false});
						}, 400);
						
						setTimeout(function() {
							jQuery('.div_czpf .buttombuttontop .numbercount:eq(3)').animateNumber(jQuery('.div_czpf .buttombuttontop .numbercount:eq(3)').attr('data-count'),{duration:4000,floatStepDecimals:1,floatEndDecimals:1,animateOpacity:false});
						}, 600);
						
						setTimeout(function() {
							jQuery('.div_czpf .buttombuttontop .numbercount:eq(4)').animateNumber(jQuery('.div_czpf .buttombuttontop .numbercount:eq(4)').attr('data-count'),{duration:4000,floatStepDecimals:1,floatEndDecimals:1,animateOpacity:false});
						}, 800);
				}
			}
		}
}

function czpf_fn_scroll_fadingeffect_groups(){
		if(jQuery('.div_czpf .commentboxs:not(:visible)').length > 0){
			setTimeout( function(){
				czpf_scroll_lockdown_showmore = false;
			}, 300 );
		} else {
		
			var tmp_number = 0;
			
			if(jQuery('.div_czpf .commentboxs').length > 0){
				tmp_number += jQuery('.div_czpf .commentboxs').length;
			}

			tmp_number = parseFloat(tmp_number);
			tmp_check = parseFloat(jQuery(".div_czpf #counter").html());


			if(tmp_number >= tmp_check){
				 jQuery('.div_czpf .more_items_div_profile').hide();
			} else {
				czpf_fn_scroll_load_groups();
			}		
		}
}


function czpf_fn_scroll_load_groups(){
	czpf_page++;
	if(czpf_page == 1){
		jQuery('#cz_groups #comdata').css('opacity','1.0').fadeTo(200,0.0,function(){
			jQuery('#cz_groups #comdata').html('<div style="text-align: center; z-index: 200; padding-left: 50%; position: relative; margin-top: 40px;"><div class="bigsize loading"></div></div>');
			
			jQuery('#cz_groups #comdata').fadeTo(200,1.0);
			czpf_fn_scroll_load_groups_step2();
		})
	} else {
		czpf_fn_scroll_load_groups_step2();
	}
}


function czpf_fn_scroll_load_groups_step2(){
		var temp_sort_object = jQuery('.div_czpf #memebersprofil_buttons li.active a').attr('data_text');
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=update_list_groups", { 'paged': czpf_page,'sort_object':temp_sort_object }, function( DATARETURN ) {
			if(czpf_page == 1){
				jQuery('#cz_groups #comdata').fadeTo(200,0.0,function(){
					czpf_fn_scroll_load_groups_step3(DATARETURN);			
				})
			} else {
				czpf_fn_scroll_load_groups_step3(DATARETURN);
			}
		}, "json");
}

function czpf_fn_scroll_load_groups_step3(DATARETURN) {
	czpf_scroll_lockdown_showmore = false;
				
	if(czpf_page == 1){
		jQuery('#cz_groups #comdata').html('');
	}
	
	jQuery('#cz_groups #comdata').append(DATARETURN.data);
	jQuery('#cz_groups #comdata').fadeTo(200,1.0);
	if(czpf_page == 1){
		czpf_avatar_show_profile();
		if(parseFloat(jQuery(".div_czpf #counter").html()) > parseFloat(jQuery(".div_czpf #nrprcounter").html())){
			jQuery('.div_czpf .more_items_div_profile').show();
		} else {
			jQuery('.div_czpf .more_items_div_profile').hide();
		}
	} else {
			var tmp_number = 0;
			
			if(jQuery('.div_czpf .commentboxs').length > 0){
				tmp_number += jQuery('.div_czpf .commentboxs').length;
			}

			tmp_number = parseFloat(tmp_number);
			tmp_check = parseFloat(jQuery(".div_czpf #counter").html());

			if(tmp_number >= tmp_check){
				 jQuery('.div_czpf .more_items_div_profile').hide();
			}
	}
	
	czpf_avatar_show_profile();

}


function czpf_fn_scroll_fadingeffect_members(){
		//jQuery('.div_czpf .commentboxs:not(:visible)').eq(0).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 200);

		if(jQuery('.div_czpf .commentboxs:not(:visible)').length > 0){
			setTimeout( function(){
				czpf_scroll_lockdown_showmore = false;
			}, 300 );
		} else {
		
			var tmp_number = 0;
			
			if(jQuery('.div_czpf .commentboxs').length > 0){
				tmp_number += jQuery('.div_czpf .commentboxs').length;
			}

			tmp_number = parseFloat(tmp_number);
			tmp_check = parseFloat(jQuery(".div_czpf #counter").html());


			if(tmp_number >= tmp_check){
				 jQuery('.div_czpf .more_items_div_profile').hide();
			} else {
				czpf_fn_scroll_load_memebers();
			}		
		}
}


function czpf_fn_scroll_load_memebers(){
	czpf_page++;
	if(czpf_page == 1){
		jQuery('#cz_members #comdata').css('opacity','1.0').fadeTo(200,0.0,function(){
			jQuery('#cz_members #comdata').html('<div style="text-align: center; z-index: 200; padding-left: 50%; position: relative; margin-top: 40px;"><div class="bigsize loading"></div></div>');
			
			jQuery('#cz_members #comdata').fadeTo(200,1.0);
			czpf_fn_scroll_load_memebers_step2();
		})
	} else {
		czpf_fn_scroll_load_memebers_step2();
	}
}


function czpf_fn_scroll_load_memebers_step2(){
		var temp_sort_object = jQuery('.div_czpf #memebersprofil_buttons li.active a').attr('data_text');
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=update_list_members", { 'paged': czpf_page,'sort_object':temp_sort_object }, function( DATARETURN ) {
			if(czpf_page == 1){
				jQuery('#cz_members #comdata').fadeTo(200,0.0,function(){
					czpf_fn_scroll_load_memebers_step3(DATARETURN);			
				})
			} else {
				czpf_fn_scroll_load_memebers_step3(DATARETURN);
			}
		}, "json");
}

function czpf_fn_scroll_load_memebers_step3(DATARETURN) {
	czpf_scroll_lockdown_showmore = false;
				
	if(czpf_page == 1){
		jQuery('#cz_members #comdata').html('');
	}
	
	jQuery('#cz_members #comdata').append(DATARETURN.data);
	jQuery('#cz_members #comdata').fadeTo(200,1.0);
	if(czpf_page == 1){
		czpf_avatar_show_profile();
		if(parseFloat(jQuery(".div_czpf #counter").html()) > parseFloat(jQuery(".div_czpf #nrprcounter").html())){
			jQuery('.div_czpf .more_items_div_profile').show();
		} else {
			jQuery('.div_czpf .more_items_div_profile').hide();
		}
	} else {
			var tmp_number = 0;
			
			if(jQuery('.div_czpf .commentboxs').length > 0){
				tmp_number += jQuery('.div_czpf .commentboxs').length;
			}

			tmp_number = parseFloat(tmp_number);
			tmp_check = parseFloat(jQuery(".div_czpf #counter").html());

			if(tmp_number >= tmp_check){
				 jQuery('.div_czpf .more_items_div_profile').hide();
			}
	}
	
	czpf_avatar_show_profile();

}


function czpf_avatar_show_profile(){
		var tmp_count = jQuery('.div_czpf .commentboxs:not(:visible)').length;
	
		for(var b=0;b<tmp_count;b++){
			jQuery('.div_czpf .commentboxs:not(:visible)').eq(0).delay(b*200).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 300);
		}
		
}


function czpf_fn_scroll_fadingeffect(){
		jQuery('.div_czpf .extrainfo .commentboxs:not(:visible)').eq(0).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		jQuery('.div_czpf .extrainfo .commentboxs2:not(:visible)').eq(0).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		
		if(jQuery('.div_czpf .extrainfo .commentboxs:not(:visible)').length > 0 || jQuery('.div_czpf .extrainfo .commentboxs2:not(:visible)').length > 0 ){
			setTimeout( function(){
				czpf_scroll_lockdown_showmore = false;
			}, 100 );
		} else {
		
			var tmp_number = 0;
			
			if(jQuery('.div_czpf .extrainfo .col-front-12 .commentboxs').length > 0){
				tmp_number += jQuery('.div_czpf .extrainfo .col-front-12 .commentboxs').length;
			}
			if(jQuery('.div_czpf .extrainfo .col-front-12 .commentboxs1').length > 0){
				tmp_number += jQuery('.div_czpf .extrainfo .col-front-12 .commentboxs1').length;
			}
			if(jQuery('.div_czpf .extrainfo .col-front-12 .commentboxs2').length > 0){
				tmp_number += jQuery('.div_czpf .extrainfo .col-front-12 .commentboxs2').length;
			}
			
			
			tmp_number = parseFloat(tmp_number);
			tmp_check = parseFloat(jQuery(".div_czpf .buttombuttontop .active").parent().parent().find('.numbercount').attr('data-count'));

			if(tmp_number >= tmp_check){
				 jQuery('.div_czpf .more_items_div').hide();
			} else {
				czpf_fn_scroll_load();
			}
		
		
					
		}
}



function czpf_fn_scroll_load(){
	czpf_page++;
	
	jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=update_list", { 'paged': czpf_page,tmp_site_user:jQuery(".div_czpf .buttombuttontop .active").parent().attr('data-userid'),'object_type':jQuery(".div_czpf .buttombuttontop .active").parent().attr('id')}, function( DATARETURN ) {
		czpf_scroll_lockdown_showmore = false;
		 
		if(DATARETURN.buttonobject == 'show_postevents'){
			jQuery('.div_czpf .extrainfo .col-front-12.ex1').append(DATARETURN.data1);
			jQuery('.div_czpf .extrainfo .col-front-12.ex2').append(DATARETURN.data2);	
		} else {
			jQuery('.div_czpf .extrainfo .col-front-12.ex1').append(DATARETURN.data1);
		}
		
		czpf_fn_scroll_fadingeffect();
	}, "json");
	
	
	
	//
}

function czpf_connect(){
	if(czpf_button_lockdown == false){
		czpf_button_lockdown = true;
		jQuery('.div_czpf.backscreenblack .div_loading_box').show();
		var extradata = {
		    postID:0,
		    connectionType:czpf_social_save
		}; 
		
		connections_type_czpf.loginby(czpf_social_save,'czpf_connect_done','');
		czpf_button_lockdown = false;
	}
}

function czpf_connect_remove(){
	if(czpf_button_lockdown == false){
		czpf_button_lockdown = true;
		
		jQuery('.div_czpf.backscreenblack .div_loading_box').show();
		
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=remove_social_link", { 'remove_social': czpf_social_save}, function( data ) {
			jQuery('.div_czpf .czpf_'+czpf_social_save).removeClass('czpf_active_white');
			czpf_button_lockdown = false;
			czpf_fn_social_hidebox();
			jQuery('.div_czpf.backscreenblack .div_loading_box').hide();
		});
	}
}

function czpf_connect_done(facebookdata,tmp_data,datatype){
	var tmp_url ='';
	var tmp_email = '';
	
	if(czpf_social_save == 'facebook'){
		tmp_url = facebookdata.link;
		tmp_email = facebookdata.username+'@facebook.com';
	} else if(czpf_social_save == 'twitter'){
		tmp_url = 'https://twitter.com/'+ facebookdata.screen_name;
		tmp_email = '@'+facebookdata.screen_name;
		facebookdata.link = tmp_url;
	} else if(czpf_social_save == 'googleplus'){
		tmp_url = facebookdata.url;
		facebookdata.link = tmp_url;
		tmp_email = '@'+facebookdata.id;
	} else if(czpf_social_save == 'linkedin'){
		tmp_url = facebookdata.publicProfileUrl;
		facebookdata.link = tmp_url;
		tmp_email = '@'+facebookdata.id;
	}

	jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=save_social_link", { 'save_social': czpf_social_save,'email':tmp_email,'url': tmp_url, 'id':facebookdata.id}, function( data ) {
		jQuery('.div_czpf .czpf_'+czpf_social_save).addClass('czpf_active_white');
		jQuery('.div_czpf .czpf_'+czpf_social_save + ' #user_show').html(facebookdata.link);
		czpf_button_lockdown = false;
		czpf_fn_social_hidebox();	
		jQuery('.div_czpf.backscreenblack .div_loading_box').hide();
	});
}



// ------- resize --------

function czpf_resize(){
	czpf_avatar_resize();
	czpf_facebook_mobil_resize();
}


function czpf_avatar_resize(){
	jQuery('.div_czpf .czpf_avatar').each(function(){
		jQuery(this).height(jQuery(this).width()).css('margin-left',(-jQuery(this).width()/2)+'px');
		jQuery(this).parent().find('.czpf_avatar_overlay').width((jQuery(this).width()-10)).height(jQuery(this).width()-10).css('margin-left',((-jQuery(this).width()/2)+4)+'px').css('line-height',(jQuery(this).width()-10)+'px');

	});
}




function czpf_facebook_mobil_resize(){
	var tmp = jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_facebook').length;
		tmp += jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_twitter').length;
		tmp += jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_googleplus').length;
		tmp += jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_linkedin').length;
		
		if(tmp > 0 && jQuery( window ).width() < 700){		
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_facebook').width((100/tmp)+'%');
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_twitter').width((100/tmp)+'%');
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_googleplus').width((100/tmp)+'%');
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_linkedin').width((100/tmp)+'%');
			
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_facebook').height('50px');
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_twitter').height('50px');
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_googleplus').height('50px');
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_linkedin').height('50px');
		} else {
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_facebook').width(50);
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_twitter').width(50);
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_googleplus').width(50);
			jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_linkedin').width(50);

			if(tmp > 0){
				var tmph = jQuery('.div_czpf .rowobject:nth-child(1)').height();
				
				jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_facebook').height((tmph/tmp)+'px');
				jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_twitter').height((tmph/tmp)+'px');
				jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_googleplus').height((tmph/tmp)+'px');
				jQuery('.div_czpf .rowobject:nth-child(1) div:nth-child(3).col-front-1.singleobject:nth-child(3) .czpf_linkedin').height((tmph/tmp)+'px');	
			}	
		}
}

function czpf_friend_check(tmp_this,tmp_login_user,tmp_site_user,tmp_check){
	if(czpf_button_lockdown == false){
		if(tmp_check){
			jQuery(tmp_this).addClass('czpf_avatar_overlay_loading_small');
		} else {
			jQuery(tmp_this).addClass('czpf_avatar_overlay_loading');
		}
		
	
		czpf_button_lockdown = true;
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=friend_status_change", { 'tmp_login_user': tmp_login_user,'tmp_site_user':tmp_site_user}, function( data ) {
			if(data.R != 'OK'){
				alert(data.MSG);
			} else {
				if(tmp_check){
					jQuery(tmp_this).removeClass('czpf_avatar_overlay_loading_small').addClass('czpf_avatar_overlay_done_small');
				} else {
					jQuery(tmp_this).removeClass('czpf_avatar_overlay_loading').addClass('czpf_avatar_overlay_done');
				}

				if(!tmp_check){
					setTimeout( function(){
						if(data.status == "true"){
							
							jQuery(tmp_this).hide().delay(2000).removeClass('czpf_avatar_overlay_done').removeClass('fui-heart').addClass('czpficon-heart-broken');
						} else {
							jQuery(tmp_this).hide().delay(2000).removeClass('czpf_avatar_overlay_done').removeClass('czpficon-heart-broken').addClass('fui-heart');
						}
						setTimeout( function(){
						jQuery(tmp_this).show();
						}, 800 );
					}, 2000 );
				} else {
					jQuery('.numbercount.show_friends_icon').attr('data-count',(parseFloat(jQuery('.numbercount.show_friends_icon').attr('data-count'))+1)).html((parseFloat(jQuery('.numbercount.show_friends_icon').attr('data-count'))));
					czpf_bottom_button_reload('show_friends',tmp_login_user);
				}
				
			}

			
			czpf_button_lockdown = false;
		}, "json");
	}
}


function czpf_fn_social_hidebox(){
	jQuery('.div_czpf.backscreenblack .socail_alert').attr('style','').show().css('opacity','1.0').animate({
      marginTop: '-=40',
      opacity: 0.0
    }, 500,function(){
	    jQuery('.div_czpf.backscreenblack .socail_alert').hide();
    });
    
    jQuery('.div_czpf.backscreenblack').delay(400).fadeTo('slow',0.0,function(){
	    jQuery('.div_czpf.backscreenblack').hide();
	    jQuery('.div_czpf.backscreenblack .div_loading_box').hide();
    })
    
    czpf_social_save = '';
}

function czpf_fn_social_showbox(tmp_this,tmp_object){
	jQuery('.div_czpf.backscreenblack .socail_alert').delay(400).attr('style','margin-top: -155px').show().css('opacity','0.0').animate({
      marginTop: '+=40',
      opacity: 1.0
    }, 500);
    
    if(jQuery(tmp_this).hasClass('czpf_active_white')){
	    jQuery('.div_czpf .socail_alert .removeclick').show();
	    jQuery('.div_czpf .socail_alert .socialseelink').show();
	    jQuery('.div_czpf .socail_alert .sociallink').hide();
	    
    } else {
		jQuery('.div_czpf .socail_alert .removeclick').hide(); 
	    jQuery('.div_czpf .socail_alert .socialseelink').hide();
	    jQuery('.div_czpf .socail_alert .sociallink').show();
    }
    
    czpf_social_save = tmp_object;
    
    var text_temp = jQuery('.div_czpf .socail_alert').attr('data-text');
    text_temp = text_temp.replace('[social]', czpf_social_save);
    
    jQuery('.div_czpf .socail_alert p').html(text_temp);
    jQuery('.div_czpf.backscreenblack').show().css('opacity','0.0').fadeTo('slow',1.0);
}




function czpf_fn_social_link_me(){
	var tmp_var = jQuery('.div_czpf .czpf_'+czpf_social_save + ' #user_show').html();
	window.location.href = tmp_var;
}


function czpf_fn_social_link(tmp_this){
	var tmp_var = jQuery(tmp_this).find('#user_show').html();
	window.location.href = tmp_var;
}


function czpf_fn_edit_object_groups(tmp_this,tmp_save,tmp_savepos){
	if(czpf_button_lockdown == false){
		czpf_button_lockdown = true;
	if(jQuery(tmp_this).parent().find('#user_show').is(':visible')){
		if(!czpf_button_lockdown_open){
			czpf_button_lockdown_open = true
			czpf_button_lockdown_tmp_this = tmp_this;
			czpf_button_lockdown_tmp_save = tmp_save;
			czpf_button_lockdown_tmp_savepos = tmp_savepos;
			
			jQuery(tmp_this).parent().find('#czpf_edit_box').css('left','0px');
			jQuery(tmp_this).parent().find('#czpf_edit_box input,#czpf_edit_box textarea').css('font-size',jQuery(tmp_this).parent().find('#user_show').css('font-size'));
	
			if(tmp_save == 'post_content'){
				jQuery(tmp_this).parent().css('height','250px');
				tmp_value = jQuery(tmp_this).parent().find('#user_edit').val();
				tmp_value = tmp_value.replace(/\<br \/\>/g,'\n');
				jQuery(tmp_this).parent().find('#user_edit').val(tmp_value);
			}

			jQuery(tmp_this).parent().find('.editble').removeClass('czpficon-pencil').addClass('fui-exit'); 
			jQuery(tmp_this).parent().find('#user_show').hide();
			jQuery(tmp_this).parent().find('#czpf_edit_box').show();
		}
		czpf_button_lockdown = false;
	} else {
	
		var tmp_value = '';
		
		if(tmp_save == 'post_content'){
			tmp_value = jQuery(tmp_this).parent().find('#user_edit').val();
			
			tmp_value = tmp_value.replace(/\n/g, '<br />');
		} else {
			tmp_value = jQuery(tmp_this).parent().find('#user_edit').val();
		}
	
		jQuery(tmp_this).parent().find('#user_show').html(tmp_value);
		jQuery(tmp_this).addClass('loading');
		
	
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=save_group_info", { 'tmp_save': tmp_save,'tmp_postid':tmp_savepos,'tmp_value':tmp_value}, function( data ) {
				jQuery(tmp_this).parent().find('.editble').addClass('czpficon-pencil').removeClass('fui-exit').removeClass('loading'); 
				
				if(data.R != 'OK'){
					jQuery(tmp_this).parent().find('.editble').removeClass('czpficon-pencil').addClass('fui-exit');
					alert(data.MSG); 
				} else {
					jQuery(tmp_this).parent().find('#user_show').show();
					jQuery(tmp_this).parent().find('#czpf_edit_box').hide();
					czpf_button_lockdown_open = false;
					if(tmp_save == 'post_content'){
						jQuery(tmp_this).parent().css('height','auto');
					}
				}
				czpf_button_lockdown = false;
			}, "json");
	}
	}
}






function czpf_fn_edit_object(tmp_this,tmp_save,tmp_savepos){
	if(czpf_button_lockdown == false){
		czpf_button_lockdown = true;
	if(jQuery(tmp_this).parent().find('#user_show').is(':visible')){
		if(!czpf_button_lockdown_open){
			czpf_button_lockdown_open = true
			czpf_button_lockdown_tmp_this = tmp_this;
			czpf_button_lockdown_tmp_save = tmp_save;
			czpf_button_lockdown_tmp_savepos = tmp_savepos;
			
			if(jQuery(tmp_this).parent().find('.icon_extra').hasClass('no-icon')){
				jQuery(tmp_this).parent().find('#czpf_edit_box').css('left','0px');
			};
			jQuery(tmp_this).parent().find('#czpf_edit_box input,#czpf_edit_box textarea').css('font-size',jQuery(tmp_this).parent().find('#user_show').css('font-size'));
	
			if(tmp_save == 'description'){
				jQuery(tmp_this).parent().css('height','250px');
				tmp_value = jQuery(tmp_this).parent().find('#user_edit').val();
				tmp_value = tmp_value.replace(/\<br \/\>/g,'\n');
				jQuery(tmp_this).parent().find('#user_edit').val(tmp_value);
			}
			
			if(tmp_save == 'full_name'){
				jQuery(tmp_this).parent().css('height','45px');
			}
	
	 
			jQuery(tmp_this).parent().find('.editble').removeClass('czpficon-pencil').addClass('fui-exit'); 
			jQuery(tmp_this).parent().find('#user_show').hide();
			jQuery(tmp_this).parent().find('#czpf_edit_box').show();
		}
		czpf_button_lockdown = false;
	} else {
	
		var tmp_value = '';
		

		if(tmp_save == 'contry' || tmp_save == 'lang' || tmp_save == 'state' ){	
			var datasource= JSON.parse(jQuery(tmp_this).parent().find('.czpf_edit_box input').attr('data-source'));
			var tmp_string = jQuery(tmp_this).parent().find('.czpf_edit_box input').val().toLowerCase();
			
			datasource = datasource.map(function(elem) { return elem.toLowerCase(); }); 
			
			var found = jQuery.inArray(tmp_string,datasource) > -1;
		
			if(!found){
				jQuery(tmp_this).parent().find('.czpf_edit_box input').addClass('haserror');
				czpf_button_lockdown = false;
				return false;
			} else {
				jQuery(tmp_this).parent().find('.czpf_edit_box input').removeClass('haserror');
				tmp_value = jQuery(tmp_this).parent().find('.czpf_edit_box input').val().toLowerCase();
			}
		} else if(tmp_save == 'age'){
			tmp_value = jQuery(tmp_this).parent().find('.czpf_edit_box input').val();
		} else if(tmp_save == 'description'){
			tmp_value = jQuery(tmp_this).parent().find('#user_edit').val();
			
			tmp_value = tmp_value.replace(/\n/g, '<br />');
		} else {
			tmp_value = jQuery(tmp_this).parent().find('#user_edit').val();
		}
	
		jQuery(tmp_this).parent().find('#user_show').html(tmp_value);
		jQuery(tmp_this).addClass('loading');
		
	
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=save_tag_info", { 'tmp_save': tmp_save,'tmp_savepos':tmp_savepos,'tmp_value':tmp_value,'tmp_object':jQuery(tmp_this).parent().attr('data-obj')}, function( data ) {
				jQuery(tmp_this).parent().find('.editble').addClass('czpficon-pencil').removeClass('fui-exit').removeClass('loading'); 
				
				if(tmp_save == 'full_name'){
					jQuery(tmp_this).parent().css('height','auto');
				}				
				
				if(data.R != 'OK'){
					alert(data.MSG);
				} else {
					jQuery(tmp_this).parent().find('#user_show').show();
					jQuery(tmp_this).parent().find('#czpf_edit_box').hide();
					czpf_button_lockdown_open = false;
					if(tmp_save == 'description'){
						jQuery(tmp_this).parent().css('height','auto');
					}
				}
				czpf_button_lockdown = false;
			}, "json");
	}
	}
}

function czpf_replace_textarea(tmp_this){

	var tmpss = jQuery(tmp_this).parent().find('textarea');
	var start_tmp = jQuery(tmpss)[0].selectionStart;
	var slut_tmp = jQuery(tmpss)[0].selectionEnd;

    if((start_tmp < 1 && slut_tmp < 1) || (start_tmp == slut_tmp) ){
    	return false;
    
  	} else if(jQuery(tmp_this).hasClass('bold')){
        jQuery(tmpss).val(
        jQuery(tmpss).val().substring(0, start_tmp)+'<b>'+
        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'</b>'+
        jQuery(tmpss).val().substring(slut_tmp)
        );
  	} else if(jQuery(tmp_this).hasClass('italic')){
        jQuery(tmpss).val(
        jQuery(tmpss).val().substring(0, start_tmp)+'<i>'+
        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'</i>'+
        jQuery(tmpss).val().substring(slut_tmp)
        );
  	} else if(jQuery(tmp_this).hasClass('link')){
  	
		var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
		
		  if(!regexp.test(jQuery(tmpss).val().substring(start_tmp, slut_tmp))) {
	        jQuery(tmpss).val(
	        jQuery(tmpss).val().substring(0, start_tmp)+'<a href="">'+
	        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'</a>'+
	        jQuery(tmpss).val().substring(slut_tmp)
	        );
		  } else {
	        jQuery(tmpss).val(
	        jQuery(tmpss).val().substring(0, start_tmp)+'<a href="'+
	        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'">'+
	        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'</a>'+
	        jQuery(tmpss).val().substring(slut_tmp)
	        );
		  }
  	} else if(jQuery(tmp_this).hasClass('em')){
        jQuery(tmpss).val(
        jQuery(tmpss).val().substring(0, start_tmp)+'<em>'+
        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'</em>'+
        jQuery(tmpss).val().substring(slut_tmp)
        );
  	} else if(jQuery(tmp_this).hasClass('sub')){
        jQuery(tmpss).val(
        jQuery(tmpss).val().substring(0, start_tmp)+'<sub>'+
        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'</sub>'+
        jQuery(tmpss).val().substring(slut_tmp)
        );
  	} else if(jQuery(tmp_this).hasClass('sup')){
        jQuery(tmpss).val(
        jQuery(tmpss).val().substring(0, start_tmp)+'<sup>'+
        jQuery(tmpss).val().substring(start_tmp, slut_tmp)+'</sup>'+
        jQuery(tmpss).val().substring(slut_tmp)
        );
  	}
}


function czpf_avatar_show(tmp_var){
	if(tmp_var == 'show_rating') {
		var tmp_count = jQuery('.extrainfo.show_rating .commentboxs:not(:visible)').length;
	
		for(var b=0;b<tmp_count;b++){
			jQuery('.extrainfo.show_rating .commentboxs:not(:visible)').eq(0).delay(b*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}
		
	} else if(tmp_var == 'show_pastevents') {
		var tmp_count = jQuery('.extrainfo.show_pastevents .commentboxs:not(:visible)').length;
	
		for(var b=0;b<tmp_count;b++){
			jQuery('.extrainfo.show_pastevents .commentboxs:not(:visible)').eq(0).delay(b*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}
		
	} else if(tmp_var == 'show_upcoming') {
		var tmp_count = jQuery('.extrainfo.show_upcoming .commentboxs:not(:visible)').length;
	
		for(var b=0;b<tmp_count;b++){
			jQuery('.extrainfo.show_upcoming .commentboxs:not(:visible)').eq(0).delay(b*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}
		
	} else if(tmp_var == 'show_postevents'){
		var tmp_count = jQuery('.extrainfo.show_postevents .commentboxs:not(:visible)').length;
	
		for(var b=0;b<tmp_count;b++){
			jQuery('.extrainfo.show_postevents .commentboxs:not(:visible)').eq(0).delay(b*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}
		
		var tmp_count2 = jQuery('.extrainfo.show_postevents .commentboxs2:not(:visible)').length;
	
		for(var c=0;c<tmp_count2;c++){
			jQuery('.extrainfo.show_postevents .commentboxs2:not(:visible)').eq(0).delay(c*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}									
	} else if(tmp_var == 'show_friends'){
		var tmp_count = jQuery('.extrainfo.show_friends .commentboxs1:not(:visible)').length;
	
		for(var b=0;b<tmp_count;b++){
			jQuery('.extrainfo.show_friends .commentboxs1:not(:visible)').eq(0).delay(b*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}
		
		var tmp_count2 = jQuery('.extrainfo.show_friends .commentboxs2:not(:visible)').length;
	
		for(var c=0;c<tmp_count2;c++){
			jQuery('.extrainfo.show_friends .commentboxs2:not(:visible)').eq(0).delay(c*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}	
		
		var tmp_count3 = jQuery('.extrainfo.show_friends .commentboxs:not(:visible)').length;
	
		for(var d=0;d<tmp_count3;d++){
			jQuery('.extrainfo.show_friends .commentboxs:not(:visible)').eq(0).delay(d*400).show().css('opacity',0.0).animate({opacity: 1.0,marginTop: "-=100px"}, 500);
		}			
										
	}
}

function czpf_gotolink(tmp_link){
	window.location.href = tmp_link;
}


function czpf_bottom_button_reload(tmp_var,tmp_site_user){
	jQuery('.div_czpf .bottomcontainer .extrainfo').slideUp(500,function(){
		jQuery('.div_czpf .bottomcontainer .extrainfo').html('<div style="width: 100%; text-align: center;"><div class="bigsize loading"></div></div>');
		jQuery('.div_czpf .bottomcontainer .extrainfo').slideDown(500);
		jQuery('.div_czpf .more_items_div').hide();
	
		jQuery('.div_czpf .bottomcontainer .extrainfo').attr('class','').addClass('extrainfo').addClass(jQuery('.div_czpf .buttombuttontop .buttombutton .active').parent().attr('id'))
		jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=get_button_data&paged=1", { 'paged': 1,'czbutton':jQuery('.div_czpf .buttombuttontop .buttombutton .active').parent().attr('id'),'tmp_site_user':tmp_site_user}, function( data ) {
			if(data.R != 'OK'){
				alert(data.MSG);
				czpf_button_lockdown = false;
			} else {
				if(data.paged == 1){
					jQuery('.div_czpf .bottomcontainer .extrainfo').slideUp(500,function(){
						jQuery('.div_czpf .bottomcontainer .extrainfo').html(data.data1);
						jQuery('.div_czpf .bottomcontainer .extrainfo').slideDown(500,function(){
								czpf_avatar_show(tmp_var);
								czpf_page = 1;
								
								tmp_number = parseFloat(10);
								tmp_check = parseFloat(jQuery(".div_czpf .buttombuttontop .active").parent().parent().find('.numbercount').attr('data-count'));
					
								if(tmp_number < tmp_check){
									 jQuery('.div_czpf .more_items_div').show();
								} else {
									 jQuery('.div_czpf .more_items_div').hide();
								}
								
								
						});
						czpf_button_lockdown = false;
					});
				}
			}
		}, "json");
				
	});
}


function czpf_bottom_button(tmp_this,tmp_var,tmp_site_user){
	if(!jQuery(tmp_this).find('div').hasClass('active') && czpf_button_lockdown == false){
		czpf_button_lockdown = true;
		jQuery('.div_czpf .buttombuttontop .buttombutton .active').removeClass('active');
		jQuery(tmp_this).find('div').addClass('active');
		
		jQuery('.div_czpf .bottomcontainer .extrainfo').slideUp(500,function(){
			jQuery('.div_czpf .bottomcontainer .extrainfo').html('<div style="width: 100%; text-align: center;"><div class="bigsize loading"></div></div>');
			jQuery('.div_czpf .bottomcontainer .extrainfo').slideDown(500);
			jQuery('.div_czpf .more_items_div').hide();
		
			jQuery('.div_czpf .bottomcontainer .extrainfo').attr('class','').addClass('extrainfo').addClass(jQuery('.div_czpf .buttombuttontop .buttombutton .active').parent().attr('id'))
			jQuery.post( CZPF.ajaxurl + "/?czpf_data=true&czpf_fn=get_button_data&paged=1", { 'paged': 1,'czbutton':jQuery('.div_czpf .buttombuttontop .buttombutton .active').parent().attr('id'),'tmp_site_user':tmp_site_user}, function( data ) {
				if(data.R != 'OK'){
					alert(data.MSG);
					czpf_button_lockdown = false;
				} else {
					if(data.paged == 1){
						jQuery('.div_czpf .bottomcontainer .extrainfo').slideUp(500,function(){
							jQuery('.div_czpf .bottomcontainer .extrainfo').html(data.data1);
							jQuery('.div_czpf .bottomcontainer .extrainfo').slideDown(500,function(){
									czpf_avatar_show(tmp_var);
									czpf_page = 1;
									
									tmp_number = parseFloat(10);
									tmp_check = parseFloat(jQuery(".div_czpf .buttombuttontop .active").parent().parent().find('.numbercount').attr('data-count'));
						
									if(tmp_number < tmp_check){
										 jQuery('.div_czpf .more_items_div').show();
									} else {
										 jQuery('.div_czpf .more_items_div').hide();
									}
									
									
							});
							czpf_button_lockdown = false;
						});
					}
				}
			}, "json");
					
		});
	}
}