// JavaScript Document

jQuery.noConflict();
var selectedDay=0;
var onlineTimer = 0;
jQuery(document).ready(function(){
    jQuery(document).find('*').focus(function(){
        this.hideFocus=true;
    });
    
    jQuery('.profile_view').bind('click', profileViewclick);
    jQuery('.profile_view_list').children('li').bind('click', profileViewclick);
    
/*
    code for online user
*/   

    if(jQuery('#ping').length){
        sendOnlineStatus();
    }

    jQuery(document).blur(function(){
        onlineTimer =  setTimeout("setpingtype(2)", 10000);
    });
    
    jQuery(document).focus(function(){
        setpingtype(1);
        clearTimeout(onlineTimer);
    });
    
//	jQuery('.googleadswrapper').hide();
   
    
    jQuery('#search_text_in_box').focus(function(){
		jQuery('#hidden_search_box').slideDown();//.css({left : '815px', top :  '78px'})
	});
	jQuery('#search_text_in_box').blur(function(){ 
		jQuery('#original_search_input').val(jQuery('#search_text_in_box').val());		
	});	
	jQuery('#page').click(close_search_div);
	jQuery('#page').focus(close_search_div);
	jQuery('#search_within_id').click(function(){
		jQuery('.search_within').attr('checked', jQuery('#search_within_id').attr('checked'));
	});
	
	jQuery('.login_button2').click(function(){
		var obj = jQuery(this).parent().prev();
		jQuery.post(jQuery(this).attr('href'), '', function(data){
			jQuery('.login2').parent().slideUp();
			jQuery(obj).html(data);
			jQuery(obj).slideDown();
		});
		return false;
	});
	
	/*jQuery('.prosubfield .mid .button').click(function(){
		if(jQuery('.prosubfield .mid #friends_category')){
			if(jQuery('.prosubfield .mid #friends_category').val() == 'SELECT_CATEGORY'){
				jQuery('.mid .msg_error').html('Please select category.').css('float','right').show();
				return false;
			}
		}	   
		if(jQuery(this).prev().prev().find('#wall_photo').val())
			return true;
		if(jQuery("#msg_post_form #msg_text").val().replace(' ',"").length < 1){
			jQuery('.mid .msg_error').html('Please enter message.').css('float','right').show();
			return false;
		}
		
		jQuery(this).hide();
		jQuery('#spanButton').show();
		jQuery('#image_error').hide();
		jQuery('.mid .msg_error').hide();
		jQuery.post('/main/postMsg',jQuery('#msg_post_form').serialize(),function(data){	
				jQuery('.msg_content').html(data);
				jQuery('#msg_text').val('');
				jQuery('#spanButton').hide();
				jQuery('#wallSubmit').show();
				
		});
		return false;
	});*/

	
	if(jQuery(document).height() > jQuery('.maincontainer').height()){
		if(jQuery('.midcontentwrapper').length > 1){
			jQuery('.midcontentwrapper').eq(1).height((jQuery(document).height()- 199)+'px');
		}
		else{
			jQuery('.midcontentwrapper').children('.text_content').length>0?jQuery('.midcontentwrapper').children('.text_content').eq(0).height((jQuery(document).height()- 199)+'px'):'';
		}
	}
	
	jQuery('#submit_ajax_search').click(function(){
        jQuery('#invite_tab').css('display','none');
        if(jQuery('#friendsCategorySelect').length)
            jQuery('#friendsCategorySelect').val('ALL');
		searchAjax(1);
	});	
	
	jQuery('#invite_friends_tab').click(function(){invitecall();});
	
	jQuery('.sort_column').click(function(){
		var sort_var = jQuery(this).html().toLowerCase();
		var order =  jQuery('#sortBy').val()==sort_var?(jQuery(this).next().val()=='asc'?'desc':'asc'):'asc';
		
		if(sort_var =='distance')
		{
			if(order=='asc' && jQuery(this).next().val()=='' ) 
			{
				order ='desc';
			}
		}
		
		var img_tag1 ='<img src="/images/wharrow_down.gif" class="img_tag"  alt="arrow"/>';
		var img_tag2 ='<img src="/images/wharrow_up.gif" class="img_tag" alt="arrow"/>';
		var img_tag3 ='<img src="/images/addeventicon_header.gif" class="img_tag" alt="arrow"/>';
		
		/*view settings*/
		jQuery('.assending').removeClass('assending');
		jQuery(this).parent().parent().addClass('assending');
		jQuery('.img_tag').remove();
		
		jQuery('#orderBy').val(order);
		jQuery('#sortBy').val(sort_var);
		jQuery(this).next().val(jQuery('#orderBy').val());
		jQuery(this).parent().next().html(img_tag3);
		searchAjax(order=='asc'?img_tag2:img_tag1);
		return false;
	});
	
	jQuery('.sort_column_group_member').click(function(){
		var sort_var = jQuery(this).html().toLowerCase();
		var order = jQuery('#sortBy').val()==sort_var?(jQuery(this).next().val()=='asc'?'desc':'asc'):'asc';
		var img_tag1 ='<img src="/images/wharrow_down.gif" class="img_tag"  alt="arrow"/>';
		var img_tag2 ='<img src="/images/wharrow_up.gif" class="img_tag" alt="arrow"/>';
		var img_tag3 ='<img src="/images/addeventicon_header.gif" class="img_tag" alt="arrow"/>';
		
		/*view settings*/
		jQuery('.assending').removeClass('assending');
		jQuery(this).parent().parent().addClass('assending');
		jQuery('.img_tag').remove();
		
		jQuery('#orderBy').val(order);
		jQuery('#sortBy').val(sort_var);
		jQuery(this).next().val(jQuery('#orderBy').val());
		jQuery(this).parent().next().html(img_tag3);
		searchAjaxGroup(order=='asc'?img_tag2:img_tag1);
		return false;
	});
	
jQuery('.sort_column_name').click(function(){
		var sort_var = jQuery(this).html().toLowerCase();
		var order =  jQuery('#sortBy').val()==sort_var?(jQuery(this).next().val()=='asc'?'desc':'asc'):'asc';
		if(sort_var =='distance')
		{
			if(order=='asc' && jQuery(this).next().val()=='')
			{
				order ='desc';
			}
			else
			{
				order ='asc';
			}
		}
				
		var img_tag1 ='<img src="/images/wharrow_down.gif" class="img_tag"  alt="arrow"/>';
		var img_tag2 ='<img src="/images/wharrow_up.gif" class="img_tag" alt="arrow"/>';
		var img_tag3 ='<img src="/images/addeventicon_header.gif" class="img_tag" alt="arrow" />';
		
		/*view settings*/
		jQuery('.assending').removeClass('assending');
		jQuery(this).parent().parent().addClass('assending');
		jQuery('.img_tag').remove();
		
		jQuery('#orderBy').val(order);
		jQuery('#sortBy').val(sort_var);
		jQuery(this).next().val(jQuery('#orderBy').val());
		jQuery(this).parent().next().html(img_tag3);
		searchAjaxAdvance(order=='asc'?img_tag2:img_tag1);
		return false;
	});

jQuery('.sort_column_group').click(function(){
		var sort_var = jQuery(this).html().toLowerCase();
		var order =  jQuery('#sortBy').val()==sort_var?(jQuery(this).next().val()=='asc'?'desc':'asc'):'asc';
		var img_tag1 ='<img src="/images/wharrow_down.gif" class="img_tag"  alt="arrow"/>';
		var img_tag2 ='<img src="/images/wharrow_up.gif" class="img_tag" alt="arrow"/>';
		var img_tag3 ='<img src="/images/addeventicon_header.gif" class="img_tag" alt="arrow"/>';
		
		/*view settings*/
		jQuery('.assending').removeClass('assending');
		jQuery(this).parent().parent().addClass('assending');
		jQuery('.img_tag').remove();
		
		jQuery('#orderBy').val(order);
		jQuery('#sortBy').val(sort_var);
		jQuery(this).next().val(jQuery('#orderBy').val());
		jQuery(this).parent().next().html(img_tag3);
		searchAjaxAdvanceGroup(order=='asc'?img_tag2:img_tag1);
		return false;
	});
jQuery('.sort_column_class').click(function(){
		var sort_var = jQuery(this).html().toLowerCase();
		var order =  jQuery('#sortBy').val()==sort_var?(jQuery(this).next().val()=='asc'?'desc':'asc'):'asc';
		var img_tag1 ='<img src="/images/wharrow_down.gif" class="img_tag"  alt="arrow"/>';
		var img_tag2 ='<img src="/images/wharrow_up.gif" class="img_tag" alt="arrow"/>';
		var img_tag3 ='<img src="/images/addeventicon_header.gif" class="img_tag" alt="arrow" />';
		
		/*view settings*/
		jQuery('.assending').removeClass('assending');
		jQuery(this).parent().parent().addClass('assending');
		jQuery('.img_tag').remove();
		
		jQuery('#orderBy').val(order);
		jQuery('#sortBy').val(sort_var);
		jQuery(this).next().val(jQuery('#orderBy').val());
		jQuery(this).parent().next().html(img_tag3);
		searchAjaxAdvanceClass(order=='asc'?img_tag2:img_tag1);
		return false;
	});

	jQuery('#a_plus').click(function(){
		if(jQuery.browser.mozilla)
			alert('This functionality not available for Mozilla. You can try with Ctrl+ or Ctrl-');
		else
			zoomin();
	});
	
	jQuery('#a_minus').click(function(){
		if(jQuery.browser.mozilla)
			alert('This functionality not available for Mozilla. You can try with Ctrl+ or Ctrl-');
		else
			zoomout();
	});
	
	jQuery('#children_1').click(function(){
		jQuery('#child_info').find('input').each(function(i){
			jQuery(this).attr('disabled',true);
		});
		jQuery('#child_info').find('a').hide();
	});
	jQuery('#children_0').click(function(){
		jQuery('#child_info').find('input').each(function(i){
			jQuery(this).removeAttr('disabled');
		});
		jQuery('#child_info').find('a').show();
	});
	
	jQuery('.user_personal_menu > li').mouseover(function(){
		jQuery(this).children().show();
	});
	
	jQuery('.user_personal_menu > li').mouseout(function(){
		jQuery(this).children().hide();
	});
	
	jQuery('#zipsearch_form').submit(function(){
		mask_div = Builder.node('div', {id: 'mask'});
		jQuery('body').append(mask_div);
		jQuery.post('/main/zipsearch', jQuery(this).serialize(), function(data){
			jQuery('#popover_td').html(data);
			jQuery('#popover_td').show();
		});
		return false;
	});		

	jQuery('#select').click(selects);
	jQuery('#selectMy').click(selectmy);
	jQuery('#searchby_wrapper').click(searchby_wrapper);	
	jQuery('#searchby_wrapper_our').click(searchby_wrapper_our);
//	jQuery('#list3').accordion();
						   
	jQuery('#morepage').click(functionmore);
	
	/*jQuery('#moremessage').click(function()
								{
									var Ident="";
									var dataString="";
									dataString='pageY=10&ajaxcall1=y';
									 jQuery.post('/nebhelp/index',dataString,
									 function(data){
										jQuery("#helpyou").html(data.star1);  
										jQuery('.delet').unbind('click',funct);
										jQuery('.delet').bind('click',funct);
									 }, "json");
									 });*/
	jQuery('#ourmoremessage').click(ourfunction);
	jQuery('.delet').click(funct);
	jQuery('.ourdelet').click(functio);
	jQuery('.ourclose').click(functionclose);
	jQuery('#cratedon').click(cratedon);
	jQuery('#username').click(username);
	jQuery('#subjectheader').click(subjectheader);
	jQuery('#cratedonour').click(cratedonour);
	jQuery('#usernameour').click(usernameour);
	jQuery('#subjectheaderour').click(subjectheaderour);
		//onlineUser();
	//jQuery('input[name="selecttable"]').click(selecttable);
	jQuery('#check_mygroup').click(function(){
												jQuery('#invite_tab').css('display','none');
												jQuery('#check_megawall .select').removeClass('select');
												jQuery('#check_invitegroup .select').removeClass('select');
												jQuery('#check_mygroup').addClass('selected_tab');
												jQuery('#megawall_tab').css('display','none');
												jQuery('#mygroup_tab').css('display','block');
												jQuery('#check_invitegroup').unbind('click',check_invitegroup);
												jQuery('#check_invitegroup').bind('click',check_invitegroup);
												jQuery('#check_megawall').removeClass('selected_tab');
												jQuery('.searchby_wrapper').show();
			
	});
	jQuery('#check_megawall').click(function(){
                                                jQuery('.searchby_wrapper').hide();
												jQuery('#invite_tab').css('display','none');
												jQuery('#check_mygroup .select').removeClass('select');
												jQuery('#check_invitegroup .select').removeClass('select');
												jQuery('#check_megawall').addClass('selected_tab');
												jQuery('#mygroup_tab').css('display','none');
												jQuery('#megawall_tab').css('display','block');
												jQuery('#check_invitegroup').unbind('click',check_invitegroup);
												jQuery('#check_invitegroup').bind('click',check_invitegroup);
												jQuery('#check_mygroup').removeClass('selected_tab');
												setReadStatus_Wall();										
			
	});
	jQuery('#check_invitegroup').click(check_invitegroup);
	jQuery('.prosubfield_mega .mid .button').click(function(){
			if(jQuery(this).prev().prev().find('#wall_photo').val())
			return true;
		
		if(jQuery("#msg_text").val().replace(' ',"").length < 1){
			jQuery('.mid .msg_error').show();
			return false;
		}
		if(jQuery('#group_receive').val()==''){
			jQuery('.mid .msg_error1').show();
			return false;
		}
		jQuery('#image_error').hide();
		jQuery('.mid .msg_error').hide();
		jQuery('.mid .msg_error1').hide();
			
	});
	
	jQuery('.edit_photo_class').click(function(){
			
			var id = (jQuery(this).attr('id').split('_'));
			//alert(id[2]);
			//explode()
			jQuery('#'+id[2]).hide();
			jQuery('#photoalbuicon_'+id[2]).hide();
			jQuery('#edit_photo_title_'+id[2]).show();
			jQuery('#headingname_'+id[2]).hide();
								
	});
	
	jQuery('#add_description').click(function(){
			jQuery('#add_desc_field').show();
			jQuery('#add_description').hide();
			//jQuery('#photo_desc').show();
													   
	});
	
	jQuery('#edit_description').click(function(){
											  // alert(1);
			jQuery('#add_desc_field').show();
			jQuery('#photo_desc').hide();
			jQuery('#cancel_desc').show();
			jQuery('#photo_desc_title').hide();
	});
	jQuery('#cancel_desc').click(function(){
			jQuery('#add_desc_field').hide();
			jQuery('#photo_desc').show();
			jQuery('#cancel_desc').hide();
	});
	
	jQuery('#classifiedjobs').click(function(){
		jQuery('#classified_jobs').show();
		jQuery('#jobs').show();
		jQuery('#productLeadType').hide();
		jQuery('#productCategory').hide();
		jQuery('#serviceLeadType').hide();
		jQuery('#serviceCategory').hide();
		jQuery('.test').hide();
		jQuery('.company_name_div').show();
		jQuery('#company_name').show();
		jQuery('#other_category').hide();
		//alert(1);
 	 });
	
	jQuery('#service').click(function(){
			change_div();		

	});
	
	jQuery('#product').click(function(){
			change_div();
	});
	
	jQuery('.edit_group_desc').click(function(){
		jQuery("#group_description").hide();
		jQuery('.group_desc').show();
	});
	
	jQuery('#new_groups').click(function(){recommendedgroups();});
	
	
});

function change_div()
{
		jQuery('.test').show();
		jQuery('.company_name_div').hide();
		jQuery('#company_name').hide();
}

function change()
{
			if(jQuery(this).find(":selected").text() == 'Jobs')
			{
				//jQuery.post( '/sfClassifieds/getJobCategories', function(data){jQuery('#productCategory').html(data);} );
					//return false;
				//		
				jQuery('#productCategory').hide();
				jQuery('#serviceCategory').hide();
				jQuery('#jobs').show();
				jQuery('#label_company_name').show();
				jQuery('#company_name').show();
				
				jQuery('#label_price').hide();				
				jQuery('#label_model').hide();				
				jQuery('#label_manufacture').hide();
				jQuery('#manufactures').hide();
				jQuery('#model').hide();
				jQuery('#price').hide();
			}
			else
			{
				jQuery('#productCategory').show();
				//jQuery('#serviceCategory').show();
				jQuery('#jobs').hide();
				jQuery('#label_company_name').hide();
				jQuery('#company_name').hide();
				
				jQuery('#label_price').show();				
				jQuery('#label_model').show();				
				jQuery('#label_manufacture').show();
				jQuery('#manufactures').show();
				jQuery('#model').show();
				jQuery('#price').show();
			}
}
function executeWhenFinished(id)
{
		jQuery('#'+id).show();
		jQuery('#edit_photo_title_'+id).hide();
		jQuery('#loading_'+id).hide();
		jQuery('#delete_photo_'+id).show();
		jQuery('#headingname_'+id).show();
}

function executeWhenComplete()
{
	jQuery('#add_desc_field').hide();
	jQuery('#photo_desc').html(jQuery('#photo_description').val());
	jQuery('#photo_desc').show();
	//alert(jQuery('#photo_description').val());
	jQuery('#user_actions').show();
	jQuery('#cancel_desc').hide();
}


function validateme(id)
{
	var str = jQuery('#input_photo_title'+id).val();
	if(!jQuery.trim(str))
	{
		jQuery('#err_'+id).show();
		return false;
	}
		jQuery('#err_'+id).hide();
return true;
}
function item_loading(id)
{
	jQuery('#loading_'+id).show();
	jQuery('#delete_photo_'+id).hide();

}
function getSelectedVal(html, val){
		if(html.indexOf(val)< 0)
			return false;
		html=html.substr(html.indexOf(val)+ val.length);		
		html=html.substr(0,html.indexOf('</'));
		if(html.indexOf(">")>-1)
			html=html.substr(html.indexOf('>')+1);
		
		return html;
	}

var select_country = function(){												  
			var txt=getSelectedVal(jQuery(this).html(), jQuery(this).val());
			jQuery('#country').val(txt);
	}
function postInviteForm(){
	jQuery.post( '/inviter/selectContacts', jQuery('#invite_friend_submit').serialize(), function(data){jQuery('#invite_friends_content').html(data);} );
	return false;
}

var check_invitegroup=function(){
			jQuery('#check_megawall .select').removeClass('select');
			jQuery('#check_mygroup .select').removeClass('select');
			jQuery('#check_invitegroup span').addClass('select');
			jQuery('#mygroup_tab').css('display','none');
			jQuery('#megawall_tab').css('display','none');
			jQuery('#invite_tab').css('display','block');
			var custom_url='/groups/addGroupRequest';	
			jQuery.post( custom_url + jQuery('#search_people').serialize(),
			function(data){
				jQuery('#invite_tab').html(data);
				
			});
												
				
	}
function sendInviteSuccess(){
	jQuery.post('/inviter/sendMail', jQuery('#invite_friend_success_submit').serialize(), function(data){jQuery('#invite_friends_content').html(data);});
	return false;
}

function accoud_click(){
	jQuery('.content_accord').hide();
	if(jQuery('.content_accord').length > 1)
		jQuery('.content_accord').eq(0).show();
	jQuery('.accordian_ul li').click(function(){
		jQuery('.content_accord').slideUp();
		jQuery(this).children('.content_accord').slideDown();		
	});	
}

var close_search_div = function(e){
								   var t_id= e.target.id;
								   if(t_id != 'search_text_in_box')
								   jQuery('#hidden_search_box').slideUp();
								   }
var subjectheaderour = function(){
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4 || jQuery("#morour").val()=="DES")
										dataString='ourpage=10&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val()+'&sort=subjectheader&sortby='+jQuery("#subjectheaderchild").val();
									else
										dataString='ourpage=4&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val()+'&sort=subjectheader&sortby='+jQuery("#subjectheaderchild").val();
									jQuery.post('/nebhelp/index',dataString,
									 function(data){
										jQuery("#helpour").html(data); 
										changebind();
										arrow();
										if(jQuery("#subjectheaderchild").val()=="ASC")
										{
											
											jQuery("#subjectheaderchild").val("DES");
											jQuery("#descriptionup").css("display","block");
										}
										else
										{
											jQuery("#subjectheaderchild").val("ASC");
											jQuery("#descriptiondown").css("display","block");
										}
										
									 });
									
	
	
								}
var cratedonour = function(){
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4 || jQuery("#morour").val()=="DES")
										dataString='ourpage=10&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val()+'&sort=cratedon&sortby='+jQuery("#cratedonchild").val();
									else
										dataString='ourpage=4&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val()+'&sort=cratedon&sortby='+jQuery("#cratedonchild").val();
									 jQuery.post('/nebhelp/index',dataString,
									 function(data){
										jQuery("#helpour").html(data); 
										changebind();
										arrow();
										if(jQuery("#cratedonchild").val()=="ASC")
										{
											jQuery("#cratedonchild").val("DES");
											jQuery("#Categoryup").css("display","block");
										}
										else
										{
											jQuery("#cratedonchild").val("ASC");
											jQuery("#Categorydown").css("display","block");
											
										}
									 });
	
	
								}

var usernameour = function(){
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4 || jQuery("#morour").val()=="DES")
										dataString='ourpage=10&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val()+'&sort=username&sortby='+jQuery("#usernamechild").val();
									else
										dataString='ourpage=4&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val()+'&sort=username&sortby='+jQuery("#usernamechild").val();
									 jQuery.post('/nebhelp/index',dataString,
									 function(data){
										jQuery("#helpour").html(data);  
										changebind();
										arrow();
										if(jQuery("#usernamechild").val()=="ASC")
										{
											jQuery("#usernamechild").val("DES");
											jQuery("#neighborup").css("display","block");
										}
										else
										{
											jQuery("#usernamechild").val("ASC");
											jQuery("#neighbordown").css("display","block");
										}
									 });
																
	
	
								}

var subjectheader = function(){
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4 || jQuery("#mor").val()=="DES")
										dataString='page=10&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val()+'&sort=subjectheader&sortby='+jQuery("#subjectheaderchild").val();
									else
										dataString='page=4&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val()+'&sort=subjectheader&sortby='+jQuery("#subjectheaderchild").val();
										
									 jQuery.post('/main/Myneighborhood',dataString,
									 function(data){
										jQuery("#help_neb").html(data.star); 
										changebind();
										arrow();
										if(jQuery("#subjectheaderchild").val()=="ASC")
										{
											jQuery("#subjectheaderchild").val("DES");
											jQuery("#descriptionup").css("display","block");
										}
										else
										{
											jQuery("#subjectheaderchild").val("ASC");
											jQuery("#descriptiondown").css("display","block");
										}
										}, "json");
									
	
	
								}
var cratedon = function(){
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4 || jQuery("#mor").val()=="DES")
										dataString='page=10&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val()+'&sort=cratedon&sortby='+jQuery("#cratedonchild").val();
									else
										dataString='page=4&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val()+'&sort=cratedon&sortby='+jQuery("#cratedonchild").val();
									 jQuery.post('/main/Myneighborhood',dataString,
									 function(data){
										jQuery("#help_neb").html(data.star); 
										changebind();
										arrow();
										if(jQuery("#cratedonchild").val()=="ASC")
										{
											jQuery("#cratedonchild").val("DES");
											jQuery("#Categoryup").css("display","block");
																					
										}
										else
										{
											jQuery("#cratedonchild").val("ASC");
											jQuery("#Categorydown").css("display","block");
										}
									 }, "json");
	
	
								}

var username = function(){
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4 || jQuery("#mor").val()=="DES")
										dataString='page=10&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val()+'&sort=username&sortby='+jQuery("#usernamechild").val();
									else
										dataString='page=4&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val()+'&sort=username&sortby='+jQuery("#usernamechild").val();
									 jQuery.post('/main/Myneighborhood',dataString,
									 function(data){
										jQuery("#help_neb").html(data.star); 
										changebind();
										arrow();
										if(jQuery("#usernamechild").val()=="ASC")
										{
											jQuery("#usernamechild").val("DES");
											jQuery("#neighborup").css("display","block");
																															
										}
										else
										{
											jQuery("#usernamechild").val("ASC");
											jQuery("#neighbordown").css("display","block");
										}
									 }, "json");
																
	
	
								}

var selects = function()
								{
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4)
										dataString='page=10&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val();
									else
										dataString='page=4&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val();
									 jQuery.post('/main/Myneighborhood',dataString,
									 function(data){
										jQuery("#help_neb").html(data.star); 
										changebind();
										if(jQuery("#mor").val()=="DES")
											jQuery("#mor").val("no");
										updateMap(12);
										
									 }, "json");
									 }
var selectmy = function()
								{
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4)
										dataString='ourpage=10&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val();
									else
										dataString='ourpage=4&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val();
									 jQuery.post('/nebhelp/index',dataString,
									 function(data){
										jQuery("#helpour").html(data); 
										changebind();
										updateMap(12);
										if(jQuery("#morour").val()=="DES")
											jQuery("#morour").val("no");
									 });
									 }
/*var selecttable = function() {
		if(jQuery("input[name='selecttable']:checked").val()==2)
		{
			jQuery('#help_neb').attr('id','helpour');
			jQuery('#select').attr('id','selectMy');
			var Ident="";
			var dataString="";
			dataString='ourpage=4&ajaxcallour=y&categaury=1';
			jQuery.post('/nebhelp/index',dataString,
			function(data){
				jQuery("#helpour").html(data.our); 
				jQuery('.ourdelet').unbind('click',functio);
				jQuery('.ourdelet').bind('click',functio);
				jQuery('#morepage').unbind('click',functionmore);
				jQuery('#morepage').bind('click',functionmore);
				jQuery('#ourmoremessage').unbind('click',ourfunction);
				jQuery('#ourmoremessage').bind('click',ourfunction);
				jQuery('#select').unbind('click',selects);
				jQuery('#select').bind('click',selects);
				jQuery('#selectMy').unbind('click',selectmy);
				jQuery('#selectMy').bind('click',selectmy);
			}, "json");
			
		}
		else
		{
			jQuery('#helpour').attr('id','help_neb');	
			jQuery('#selectMy').attr('id','select');
			var Ident="";
			var dataString="";
			dataString='page=4&ajaxcall=y&categaury=1';
			jQuery.post('/main/Myneighborhood',dataString,
			function(data){
				jQuery("#help_neb").html(data.star); 
				jQuery('.delet').unbind('click',funct);
				jQuery('.delet').bind('click',funct);
				jQuery('#morepage').unbind('click',functionmore);
				jQuery('#morepage').bind('click',functionmore);
				jQuery('#ourmoremessage').unbind('click',ourfunction);
				jQuery('#ourmoremessage').bind('click',ourfunction);
				jQuery('#select').unbind('click',selects);
				jQuery('#select').bind('click',selects);
				jQuery('#selectMy').unbind('click',selectmy);
				jQuery('#selectMy').bind('click',selectmy);
				}, "json");
		}
		
		
	
	}*/
var ourfunction = function()
								{
									var Ident="";
									var dataString="";
									dataString='ourpage=10&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val();
									 jQuery.post('/nebhelp/index',dataString,
									 function(data){
										jQuery("#helpour").html(data); 
										changebind();
										updateMap(12);
										if(jQuery("#morour").val()=="no")
											jQuery("#morour").val("DES");
																					
									 });
									 }
var functionmore = function()
								{
									var Ident="";
									var dataString="";
									dataString='page=10&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val();
									 jQuery.post('/main/Myneighborhood',dataString,
									 function(data){
										jQuery("#help_neb").html(data.star); 
										changebind();
										updateMap(12);
										if(jQuery("#mor").val()=="no")
											jQuery("#mor").val("DES");
										
									 }, "json");
									 }
var functionclose = function() {
										var Ident=this.id;
										var dataString="";
										var result='';
										result = confirm("Do you want to send thank you message to your friends and delete this message?");
										dataString="ourdeleteid="+Ident+'&ajaxcallour=y&ourpage=10&responce=yes&categaury='+jQuery("input[name='category']:checked").val();
										if(result)
										{
											
											jQuery.post('/nebhelp/index',dataString,
											function(data){
												jQuery("#helpour").html(data);
												//jQuery("#total").html(data.total);
												changebind();
												updateMap(12);
											    			 });
										}
										
									}
var functio = function() {
										var Ident=this.id;
										var dataString="";
										var result='';
										result = confirm("Are you sure you want to delete this message ?");
										dataString="ourdeleteid="+Ident+'&ajaxcallour=y&ourpage=10&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val();
										if(result)
										{
											
											jQuery.post('/nebhelp/index',dataString,
											function(data){
												jQuery("#helpour").html(data); 
												//jQuery("#total").html(data.total);
												changebind();
												updateMap(12);
											    			 });
											
											jQuery.post('/nebhelp/gethelpmsgcount',
											 function(data){
													jQuery("#total").html(data); 		
													});
										}
										
									}
												
var funct=function()
									{
										var Ident=this.id;
										var name = this.name;
										var dataString="";
										var result='';
										result = confirm("Are you sure you want to delete this message ?");
										if(result)
										{
											Ident = Ident+'&ajaxcall=y&page=10&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val();
											dataString='deleteid='+Ident;
											jQuery.post('/main/Myneighborhood',dataString,
										 function(data){
											jQuery("#help_neb").html(data.star); 
											jQuery("#total").html(data.total);
											changebind();
											updateMap(12);
										 }, "json");
										}
									}


function binddelete_span(){	
	/*jQuery('.ignore_event_button').bind('mouseover',function(){
		jQuery(this).css('border','1px solid red');
	});	
	jQuery('.ignore_event_button').bind('mouseout',function(){
		jQuery(this).css('border','0px solid red');
	});*/
	jQuery('.ignore_event_button').bind('click',function(){
		jQuery.post('/sfEvents/ignoreEvent?id='+jQuery(this).next().attr('id'),'', ignore_event(jQuery(this).next().attr('id')));
	});
}
function ignore_event(obj_id){
	jQuery(".delete_event #"+obj_id).parent().remove();
}
function zoomin(){
if(parent.parent.document.body.style.zoom!=0) 
parent.parent.document.body.style.zoom*=1.2; 
else 
parent.parent.document.body.style.zoom=1.2;
}
function zoomout(){
if(parent.parent.document.body.style.zoom!=0) 
parent.parent.document.body.style.zoom*=0.833; 
else 
parent.parent.document.body.style.zoom=0.833;
}
function zoomrest(){
if(parent.parent.document.body.style.zoom!=0) 
parent.parent.document.body.style.zoom*=0; 
else 
parent.parent.document.body.style.zoom=0;
}

function submitAddEvent(){
		jQuery.post(jQuery('#createeventForm').attr('action'), jQuery('#createeventForm').serialize(), function(data){
			jQuery('#popover_td').html(data);
			jQuery('#popover_td').show();
		});
		return false;
	}
function eventform_date(obj, key){
	if(key == 8)
		return false;
	switch(jQuery(obj).val().length){
		case 2: jQuery(obj).val(jQuery(obj).val()+"/");break;
		case 5: jQuery(obj).val(jQuery(obj).val()+"/");break;
	}
}



function check_key_code(key){
	if(key > 47 && key < 58)
		return true;
	if(key > 95 && key < 106)
		return true;
	if(key == 9 || key == 13 || key == 8 || key == 37 || key == 39 || key == 46)
		return true;
	return false;
}

function changeImg(obj){    
	if(jQuery(obj).next().css('display')=='none'){
	    jQuery(obj).next().slideDown();
	    jQuery(obj).children('span').children('img').attr('src','images/minus.png');
   }
	else{
	    jQuery(obj).next().slideUp();
		jQuery(obj).children('span').children('img').attr('src', 'images/plus.png');
  }
}
function changebind()
{
	jQuery('.delet').unbind('click',funct);
    jQuery('.delet').bind('click',funct);
	jQuery('.delet').unbind('click',funct);
	jQuery('.delet').bind('click',funct);
	jQuery('#morepage').unbind('click',functionmore);
	jQuery('#morepage').bind('click',functionmore);
	jQuery('#ourmoremessage').unbind('click',ourfunction);
	jQuery('#ourmoremessage').bind('click',ourfunction);
	jQuery('#select').unbind('click',selects);
	jQuery('#select').bind('click',selects);
	jQuery('#selectMy').unbind('click',selectmy);
	jQuery('#selectMy').bind('click',selectmy);
	jQuery('.ourdelet').unbind('click',functio);
	jQuery('.ourdelet').bind('click',functio);
	jQuery('.ourclose').unbind('click',functionclose);
	jQuery('.ourclose').bind('click',functionclose);
	jQuery('#searchby_wrapper_our').unbind('click',searchby_wrapper_our);
	jQuery('#searchby_wrapper_our').bind('click',searchby_wrapper_our);
	jQuery('#searchby_wrapper').unbind('click',searchby_wrapper);
	jQuery('#searchby_wrapper').bind('click',searchby_wrapper);
}
var searchby_wrapper = function(){
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4)
										dataString='page=10&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val();
									else
										dataString='page=4&ajaxcall=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1']:checked").val();
									 jQuery.post('/main/Myneighborhood',dataString,
									 function(data){
										jQuery("#help_neb").html(data.star); 
										changebind();
										updateMap(12);
										 }, "json");
								 }
var searchby_wrapper_our = function()
								{
									var Ident="";
									var dataString="";
									if(jQuery("input[name='category']:checked").val()==4)
										dataString='ourpage=10&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val();
									else
										dataString='ourpage=4&ajaxcallour=y&categaury='+jQuery("input[name='category']:checked").val()+'&area='+jQuery("input[name='search_txt1_our']:checked").val();
							
									 jQuery.post('/nebhelp/index',dataString,
									 function(data){
																	jQuery("#helpour").html(data); 
										
										changebind();
										updateMap(12);
									 });
									 }
									 
function search_tab_function(obj){
	jQuery('.search_tabs').hide();
	jQuery('#'+ obj.id +'_tab').show();
	jQuery('.selected_tab').removeClass('selected_tab');
	jQuery(obj).addClass('selected_tab');
	if(jQuery('#simp_search_text').val())
	{
		jQuery.post('/main/getMapPegs', "search_text=" + jQuery('#simp_search_text').val() + "&search=" + obj.id, function(data){            
                updateGoogleMap({urlPostfix: 'simplesearch_' + obj.id});
		});	
	}
	else
	{
		jQuery.post('/main/getMapPegs', "search_text=" + jQuery('#search_text').val() + "&search=" + obj.id, function(data){
            updateGoogleMap({urlPostfix: 'simplesearch_' + obj.id});
		});
	}
    
}
function wall_reply_button(obj, url){
	jQuery.post(url, '', function(data){
		jQuery(obj).parent().parent().find('#reply_box').html(data);
		jQuery(obj).parent().parent().find('#reply_box').slideDown('slow');
		jQuery('.prosubfield .mid .button').click(reply_box_submit);
	});
}

var reply_box_submit = function(){		   
		if(jQuery(this).val()=='Cancel')
			return false;
		if(jQuery(this).parent().find('#wall_photo').val())
			return true;
		if(jQuery(this).parent().find("#msg_text").val().replace(' ',"").length < 1 && jQuery(this).val()=='Send'){
			jQuery(this).parent().parent().find('.msg_error').show();
			return false;
		}
		jQuery(this).parent().parent().find('.msg_error').hide();
		var temp = jQuery(this).parent().parent();
		jQuery(temp).attr('id', 'reply_box_success');
		jQuery.post('/main/postMsg',jQuery(this).parent().parent().find('#msg_post_form').serialize(),function(data){																				
				setTimeout(jQuery('#reply_box_success').fadeOut(), 7000);
				jQuery(temp).html(data);			
		});
		return false;	
}
function mega_wall_reply_button(obj, url){
	jQuery.post(url, '', function(data){
		jQuery(obj).parent().parent().find('#reply_box').html(data);
		jQuery(obj).parent().parent().find('#reply_box').slideDown('slow');
		jQuery('.prosubfield .mid .button').click(mega_reply_box_submit);
	});
}

var mega_reply_box_submit = function(){		   
		if(jQuery(this).val()=='Cancel')
			return false;
		if(jQuery(this).parent().find('#wall_photo').val())
			return true;
		if(jQuery(this).parent().find("#msg_text").val().replace(' ',"").length < 1 && jQuery(this).val()=='Send'){
			jQuery(this).parent().parent().find('.msg_error').show();
			return false;
		}
		jQuery(this).parent().parent().find('.msg_error').hide();
		var temp = jQuery(this).parent().parent();
		jQuery(temp).attr('id', 'reply_box_success');
		var tempid = jQuery(this).next().val();
		jQuery.post('/nebhelp/postReplyWall',jQuery(this).parent().parent().find('#msg_post_form').serialize(),function(data){	
				
				setTimeout(jQuery('#reply_box_success').fadeOut(), 7000);
				jQuery('#reply_box_success').remove();		
				jQuery('#mega_reply'+tempid).html(data);			
		});
		return false;	
}

function arrow()
{
	jQuery("#neighborup").css("display","none");
	jQuery("#neighbordown").css("display","none");
	jQuery("#descriptionup").css("display","none");
	jQuery("#descriptiondown").css("display","none");
	jQuery("#Categoryup").css("display","none");
	jQuery("#Categorydown").css("display","none");
	
}
function onlineUser()
{
	 jQuery.post('/nebhelp/onlineUser','recentMsg=1',
			function(data){
														 
			  }, "json");
		 
	setTimeout('onlineUser()',63000);
}

function searchAjax(img){
	var uri = window.location.toString();    
	var flag=1;
    var friendsStr ='';
    if(jQuery('#friendsCategorySelect').length)
        friendsStr = 'category=' + jQuery('#friendsCategorySelect').val() + jQuery('#street_friends').text() +"&";
	var custom_url=(uri.indexOf('friends') > -1? '/friends/ajaxList?' + friendsStr + jQuery(".assending .sort_column").attr('href') :
		(uri.indexOf('groups') > -1 ? '/groups/ajaxList?' : (uri.indexOf('bDirectory') > -1 ? '/bDirectory/ajaxList?' : '/sfClassifieds/ajaxList?'))
    );	
	if(uri.indexOf('newNeighbors') > -1)
		custom_url = '/main/myNeighborsAjaxList?';
		
	if(uri.indexOf('newGroups') > -1)
		custom_url = '/main/myNewgroupsAjaxList?';
  
    obj = jQuery('#ajax_search_text');
    objval = jQuery(obj).val(); 
    if(jQuery(obj).val()=='Friends Keyword Search' || jQuery(obj).val()=='Groups Keyword Search' || jQuery(obj).val()=='Classifieds Keyword Search' || jQuery(obj).val()=='Businesses Keyword Search')
        jQuery(obj).val('');
        
    var temp_zoom = 0;
    var t_chk_val = jQuery('#page_quick_search').val();
    jQuery('#area_zoom').val(t_chk_val);
    var mapoptions ={};
    t_chk_val == 'world' ? jQuery.extend(mapoptions , {'zoom':1}) : jQuery.extend(mapoptions , {'address':t_chk_val}); 
	
	/* Decide 'custom_url depending on hidden field value of 'mysearchtype'*/
	if(jQuery('#mysearchtype').val()=='nebhelp')
		custom_url = '/nebhelp/index?';
	else if(jQuery('#mysearchtype').val()=='newGroups')
		custom_url = '/groups/myNewgroupsAjaxList?';
	if(flag)
		jQuery.post(
			custom_url + jQuery('#search_nbr').serialize(),
			function(data){
			    /*for classified and b. directory*/
                if(data=='no-subdivision' || data=='no-county'){
                    jQuery('.category_header').attr('onclick','').css({'textDecoration':'none'}).find('span').children().remove();
                    jQuery('#keyword_search_error').html('No results because, you have not listed your '+ data.replace('no-', '') +'.');
                }else{                
				    jQuery('#nbr_data').html(data);
                    jQuery('#keyword_search_error').html('');                    
                }
                if(uri.indexOf('newNeighbors') == -1)
                    updateGoogleMap(mapoptions);
                    //uri.indexOf('groups') > -1?updateGoogleMap(jQuery.extend({'mapFor':1}, mapoptions)):updateGoogleMap(mapoptions);
				/*For 'nebhelp' page*/
					if(jQuery('#mysearchtype').val()=='nebhelp')
						jQuery('#nebhelp_data').html(data);				
				/*For 'newGroups' page*/		
					if(jQuery('#mysearchtype').val()=='newGroups')
						jQuery('#new_nbr_data').html(data);
				
				if( img!=1 ){
					jQuery(".assending .sort_column").parent().next().html(img);
				}
            jQuery(obj).val(objval);
		   });
}
function searchAjaxGroup(img){
	var flag=1;
	var custom_url='/groups/membersSort?';		
	if(flag)
		jQuery.post(
			custom_url + jQuery('#group_member').serialize(),
			function(data){
				jQuery('#member_data').html(data);
				//updateMap('q');
                updateGoogleMap({'mapFor':1});
				if( img!=1 ){
					jQuery(".assending .sort_column_group_member").parent().next().html(img);
				}
		});
}
function searchAjaxAdvance(img){
	var flag=1;
	var custom_url='/searches/advancedSearchResultsAjax?';		
	if(flag)
		jQuery.post(
			custom_url + jQuery('#search_people').serialize(),
			function(data){
				jQuery('#nbr_data').html(data);
				//updateGoogleMap();
				if( img!=1 ){
					jQuery(".assending .sort_column_name").parent().next().html(img);
				}
		});
}
function searchAjaxAdvanceGroup(img){
	var flag=1;
	var custom_url='/searches/advancedSearchResultsAjax?';		
	if(flag)
		jQuery.post(
			custom_url + jQuery('#advanced_search_group').serialize(),
			function(data){
				jQuery('#group_nbr_data').html(data);
				//updateGoogleMap({'mapFor':1});
				if( img!=1 ){
					jQuery(".assending .sort_column_group").parent().next().html(img);
				}
		});
}
function addFriends(id){
	jQuery.post('/sfFriends/addFriend', jQuery('#addFriendsSubmit').serialize(), function(data){
		jQuery(id).html(data);
	});
	}
	
function searchAjaxAdvanceClass(img){
	var flag=1;
	var custom_url='/searches/advancedSearchResultsAjax?';		
	if(flag)
		jQuery.post(
			custom_url + jQuery('#advanced_search_class').serialize(),
			function(data){
				jQuery('#class_nbr_data').html(data);
				//updateGoogleMap();
				if( img!=1 ){
					jQuery(".assending .sort_column_class").parent().next().html(img);
				}
		});
}
function invitecall(){
	jQuery('#invite_friends_content').html('<img align="middle" src="../images/addeventicon_header.gif" />');
	jQuery.post('/inviter/invite', '', function(data){jQuery('#invite_friends_content').html(data);});
}


function submitPopupform(obj){
	jQuery.post(jQuery(obj).attr('action'), jQuery(obj).serialize(), function(data){load_default_popup('Success');jQuery('.addhelp_contentpopup').html(data);});
}
function submitPopupform2(obj){
	jQuery.post(jQuery(obj).attr('action'), jQuery(obj).serialize(), function(data){popout();jQuery('#mask').remove();
																			 window.open('/alerts/petPrint')
																			});
}

function submitPopupform3(obj,url){
	if(url==1){
	jQuery.post(jQuery(obj).attr('action'), jQuery(obj).serialize(), function(data){popout();window.location.href='/usr/userprofileEdit';});
	}else{
	jQuery.post(jQuery(obj).attr('action'), jQuery(obj).serialize(), function(data){popout();window.location.href='/usr/settings';});
	}
}

function deleteFriends(obj, type){

	var cParent = jQuery(obj).parent().parent();
	jQuery.post(jQuery(obj).attr('href'), '', 
		function(data){
			if(type==1){
				jQuery(cParent).prev().remove();
				jQuery(cParent).remove();
			}
		}	
	);
	
}

function deletePhoto(obj){
	if(jQuery(obj).hasClass('done_button')){
		var url = String(window.location);
		url = url.indexOf('userprofileEdit')>-1?'':'&from=ajax';
		jQuery.post('/usr/viewPhotoSubmit?street=set'+url, '&selected='+jQuery('#selected').val(),function(data){
			if(data=='refresh')
				window.location.reload(true);
			popout();
		});
		return false;
	}
	
	jQuery.post(jQuery(obj).attr('action'), jQuery(obj).serialize(),function(data){
		if(data.indexOf('removephoto') >-1 )
			jQuery('#profile_default_photo').attr('src', '/media/icons/users/no-icon-'+ data.replace('removephoto-','') +'.gif');
		jQuery('.checks').each(function(index){			
			if(jQuery(this).attr('checked'))
				jQuery(this).parent().parent().remove();
		});
	});
	return false;
}

function selectProfilePhoto(){
	var url = String(window.location);
	url = url.indexOf('userprofileEdit')<0?'_small':'';
    
	jQuery.post('/usr/viewPhotoSubmit?street=set', '',function(data){        	   
		jQuery('#profile_default_photo').attr('src', '/uploads/icons/users/' + data + url +  ".jpg");
       // popout();			
	});
    
	return false;
}

function selectFamilyPhoto(){    
	jQuery.post('/usr/viewFamilyPhotoSubmit?street=set', '',function(data){        	   
		jQuery('#family_default_photo').attr('src', '/uploads/icons/users/' + data +  ".jpg");
        jQuery('#family_photoLink').html("Change Photo");
	});    
	return false;
}

function setProfilePhoto(){		
	jQuery.post('/usr/viewmorephotos','',function(data){
		jQuery('#popover_td').html(data);
	});
	return false;	
}
function inline_select(id){
	jQuery.post('/main/getInlineSelect?street='+ id, '', function(data){
		jQuery('#'+id).before(data);
		jQuery('#'+id).remove();
	});
}

function saveInlineSelect(id){
	jQuery.post('/main/saveInlineSelect?val='+ jQuery('#'+id).val() +'&street='+ id, '', function(data){
		jQuery('#'+id).before(data);
		jQuery('#'+id).remove();
	});
}
function formatTelephone(obj, e){
		if(window.event)
			e = window.event.keyCode;
		if(e ==8 || e ==9 || e ==16 || e ==17 || e ==18 || e ==27 || e ==37 || e ==38 || e ==39 || e ==40 || e==0)
			return true;
		var keychar = String.fromCharCode(e);
		if((("0123456789").indexOf(keychar) > -1)){			
			if(jQuery(obj).val().length==3 || jQuery(obj).val().length==7)
				jQuery(obj).val(jQuery(obj).val() + '-');
			return true;
		}
		else
			return false;
	}
function validatestate()
	{
		if(jQuery('#group_state').val()=='other')
		{
			jQuery('#other').css('display','block');
			
		}
		else
		{
			jQuery('#other').val('');
			jQuery('#other').css('display','none');
		}
	}
	
function checksInvite(){
	var flag=0;
	jQuery('.checks_invite').each(function(){
		if(jQuery(this).attr('checked'))
			flag=1;
	});
	if(flag)
		jQuery('#inviteSubmit').show();
	else
		jQuery('#inviteSubmit').hide();
}

function deleteMessagesAjax(link){
    if(!confirm("Are you sure?"))
        return false;
    jQuery.post(link, function(data){
        jQuery(link).parent().parent().next().slideUp('slow');
        jQuery(link).parent().parent().slideUp('slow');
    });
    return false;
}

function setSelectionRangeX(input, selectionStart, selectionEnd) { 
    // IE 
    jQuery(input).focus();
    if (input.createTextRange) { 
        var range = input.createTextRange(); 
        range.collapse(true); 
        range.moveEnd('character', selectionEnd); 
        range.moveStart('character', selectionStart); 
        range.select(); 
        // real browsers :) 
    } else if (input.setSelectionRange) { 
            input.focus(); 
            input.setSelectionRange(selectionStart, selectionEnd); 
        } 
} 
function addDays(month, current_month, year){      
       var basicDays= '<option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option>';
       var days30   = '<option value="29">29</option><option value="30">30</option>';
       var day31    = '<option value="31">31</option>';
       var varDays  = '';
       
       if(month < current_month)
            year++;            
       switch(eval(month)){
            case 2:                    
                    varDays = basicDays + (!(year % 4)? day30.replace('<option value="30">30</option>', ''):'');          
                    break;
            case 1:   case 3:   case 5:   case 7:   case 8:   case 10:   case 12:
                    varDays = basicDays + days30 + day31;          
                    break;            
            case 4:   case 6:   case 9:   case 11:
                    varDays = basicDays + days30;     
                    break;
       }
       jQuery('#eve_day').html(varDays); 
       if(selectedDay){
          jQuery('#eve_day').val(selectedDay);
       }      
    }
    
function replace_input(){
    jQuery('#alert-editdiv-img').html('<input type="file" value="" id="alert_icon" name="alert[icon]"/>');
}

function addUploader(){
    $("#uploadify").uploadify({
		'uploader'       : '/uploads/uploadify.swf',
		'script'         : '/main/uploadify?street=<?php echo base64_encode($passId)?>,<?php echo $type?>',
		'cancelImg'      : '/images/cancel2.png',
		'folder'         : '/uploads/temp_uploads',
		'multi'          : false
	});
}    

function sendmail_error()
{
	var flag=0;
	if(jQuery('#subject').val().length < 4 )
	{
	   jQuery('#error_title').html('<img width="10" alt="Alert" src="/images/alert.png"/>&nbsp;&nbsp;Subject is too short. ( Minimum 4 character)');
		jQuery('#error_title').css('display','block');
		flag=1;
	}
	else if(jQuery('#subject').val().length > 50 )
	{
	    jQuery('#error_title').html('<img width="10" alt="Alert" src="/images/alert.png"/>&nbsp;&nbsp;Subject is too long. ( Maximum 50 character)');
		jQuery('#error_title').css('display','block');
        flag=1;	
	}else{
	   jQuery('#error_title').css('display','none');
	}
	
	if(jQuery('#alias').val()=='')
	{
		jQuery('#text').css('display','block');
		flag=1;
	}
	else
	{
		jQuery('#text').css('display','none');
	}
	
	if(jQuery('#messagebody').val().length < 1)
	{
		jQuery('#body_err').css('display','block');
		flag=1;
	}
	else
	{
		jQuery('#body_err').css('display','none');
	}
	if(flag)
		return false;
	else
        return true;
}

function add_phone_edit_group(php_id)
  {
    cname = 'group';
    in_id = Math.round(Math.random()*10000);
    new_phone_id = Math.round(Math.random()*10000);
     
    var input_name = '<input type="text" value="phone title" onfocus= "this.value=\'\';"  id= "input_name_"+new_phone_id style= "font-style:italic; color:#333; margin:1px;" />';
    var input_value = '<input type="text" value= \'phone number\' maxLength=12 onfocus= "this.value=\'\';" onkeyPress=\'return formatTelephone(this, event.which);\'  id= \'input_value_\'+new_phone_id style= \'font-style:italic; color:#333; margin:1px;\' />';
    var remove_entry = '<input type="button" style= \'cursor:pointer; margin-left: 2px;\' value="Cancel" onclick= "container = jQuery(\'#in_id\').parent().remove(); "/>';     
    var save_entry = '<input type="button" value="Save" onclick= "jQuery.post(\'/phones/add?group_id='+ php_id +'&phone_name=\' + jQuery(this).prev().prev().val() + \'&phone_value=\' + jQuery(this).prev().val(), \'\', function(data){jQuery(\'#all_group_phones1\').html(data);} );return false; "/>';
    var container = "<div id='in_id'>"+input_name + input_value+ save_entry + remove_entry+"</div>";
    jQuery('#'+cname+'_phones').append(container);
  }
  
  function groupNameInplace(obj){
    var nameForm = '<form method="post" onsubmit="jQuery.post(\''+ jQuery(obj).attr('href') +'\', jQuery(this).serialize(), function(data){jQuery(\'#group_name\').next().next().remove();jQuery(\'#group_name\').html(data);jQuery(\'#group_name\').next().show();jQuery(\'#group_name\').show();});return false;"><div style=\"//margin-top:17px;\"><input type="text" name="value" class="inputgraysmall" /><input type="submit" value="Save"/>&nbsp;&nbsp;<input type="button" value="Cancel" onclick="var p=jQuery(this).parent().parent();jQuery(p).prev().show();jQuery(p).prev().prev().show();jQuery(p).remove();" /></div></form>';
    jQuery(obj).prev().hide();
    jQuery(obj).parent().append(nameForm);
    jQuery(obj).hide();
    return false;
  }
  
  function validatealertform(){
            if(!jQuery('#alert_text_message').val().length){
                jQuery('#body_err').show();
                return false;
            }
            jQuery('#body_err').hide();
            return true;
          }
  function submitNewAlbum(form, link_param){
     jQuery.post(jQuery(form).attr('action'), jQuery(form).serialize(), function(data){        
        if(data != 1){
            jQuery('#edit_photo_album').html(data);            
        }else{
            jQuery('.albumcointainer').html('<div class="photoalbuminfo_post"><div style="margin-left: 20px; margin-bottom: 10px; float: left;"> <a class="black_button" href="/main/getPhotoUploader?type=userphoto" onclick="popover(this);return false;"> <span class="black_button_part1">Add Photo(s)</span> </a> </div><div id="uploadimages" class="photolistalbum_wrapper">Album SuccessFully Created.</div></div>');
            jQuery('#album_link').show();
            popover('/main/getPhotoUploader?type=userphoto' + link_param);
        }        
     });
  }
  
  function text_check(obj, default_value){
    if(!jQuery(obj).val().length){
       jQuery(obj).val(default_value);
    }
  }
  
   function text_check2(obj, default_value){
    if(jQuery(obj).val() == default_value){
        jQuery(obj).val('');
    }
  }
  
  function sendOnlineStatus(){
    jQuery.post('/main/onlineClient?street=' + jQuery('#ping').val() + '&number=' + jQuery('#pingtype').val());
    setTimeout('sendOnlineStatus()', 5000);
  }
  
  function setpingtype(pingnumber){
    jQuery('#pingtype').val(pingnumber);
  }
  
  var newwindow;

function poptastic(url,name) {
var url1 = url+'?id=';
	newwindow=window.open(url1,name,'height=500, width=240, left=20, top=20, toolbar=no, menubar=no, directories=no, location=no, scrollbars=yes, status=no, resizable=no, fullscreen=no');
	newwindow.focus();
}
function setReadStatus_Wall()
{
    jQuery.post('/groups/SetReadStatusWall?read_wall=' + 1);
}

function showgroupmegawall()
{
		//alert(1);
		//jQuery.post('/groups/list?megagroup=megawall');
		window.location.href= '/groups/list?megagroup=megawall';
}
function postGroupJoinRequest()
{
	var id =jQuery('.joingroup').attr('id');
	
	jQuery.post( '/groups/joinRequestSubmit/group_id/'+id, jQuery('#addhelp_contentpopup').serialize(), function(data){jQuery('#addhelp_contentpopup').html(data);} );
}

function execute_editgroup_desc()
{
	jQuery('#group_description').html();
	jQuery('.group_desc').hide();
	jQuery("#group_description").show();
}

function validategroup_desc()
{
	var str = jQuery('#my_group_description').val();
	if(!jQuery.trim(str))
	{
		jQuery('.group_err').show();
		return false;
	}
		jQuery('.group_err').hide();
return true;
}

function categorySelectFriends(category){
    var obj = jQuery('#ajax_search_text');    
    jQuery(obj).val('');
    var t_chk_val = jQuery('#page_quick_search').val();
    
    var mapoptions ={};
    t_chk_val == 'world' ? jQuery.extend(mapoptions , {'zoom':1}) : jQuery.extend(mapoptions , {'address':t_chk_val}); 
	jQuery.post(
		'/friends/ajaxList?' + jQuery(".assending .sort_column").attr('href') + jQuery('#search_nbr').serialize() + '&category=' + category,
		function(data){
			jQuery('#nbr_data').html(data);
			updateGoogleMap(mapoptions);    
            return false;
     });
}

function recommendedgroups(){
	//jQuery('#invite_friends_content').html('<img align="middle" src="../images/addeventicon_header.gif" />');
	rec_groups_addcls();
	jQuery(".loading_data").ajaxStart(function(){
	   jQuery(this).show();
	 });
	jQuery.post('/groups/newGroups', '', 
				function(data){
					 jQuery('#new_groups_data').html(data);
					 updateGoogleMap({mapFor:1});
			});
	//alert(1);
}

function recommendedgroupssort()
{
		var sort_var = jQuery(this).html().toLowerCase();
		var order =  jQuery('#sortBy').val()==sort_var?(jQuery(this).next().val()=='asc'?'desc':'asc'):'asc';
		
		if(sort_var =='distance')
		{
			if(order=='asc' && jQuery(this).next().val()=='' ) 
			{
				order ='desc';
			}
		}
		
		var img_tag1 ='<img src="/images/wharrow_down.gif" class="img_tag"  alt="arrow"/>';
		var img_tag2 ='<img src="/images/wharrow_up.gif" class="img_tag" alt="arrow"/>';
		var img_tag3 ='<img src="/images/addeventicon_header.gif" class="img_tag" alt="arrow"/>';
		
		/*view settings*/
		jQuery('.assending').removeClass('assending');
		jQuery(this).parent().parent().addClass('assending');
		jQuery('.img_tag').remove();
		
		jQuery('#orderBy').val(order);
		jQuery('#sortBy').val(sort_var);
		jQuery(this).next().val(jQuery('#orderBy').val());
		jQuery(this).parent().next().html(img_tag3);
		searchAjaxRecGroups(order=='asc'?img_tag2:img_tag1);
		//return false;
}

function searchAjaxRecGroups(img)
{
	
	custom_url = '/groups/myNewgroupsAjaxList?';
		jQuery.post(
			custom_url + jQuery('#search_nbr').serialize(),
			function(data){
				jQuery('#new_nbr_data').html(data);
				//updateMap('q');
				if( img!=1 ){
					jQuery(".assending .sort_column").parent().next().html(img);
				}
		});
}

function rec_groups_removecls()
{
	jQuery('#new_groups').removeClass('selected_tab');
	jQuery('#new_groups_data').hide();
}
function rec_groups_addcls()
{
	jQuery('#group_map_tab').show();
	jQuery('#mygroup_tab').hide();
	jQuery('#megawall_tab').hide();
	jQuery('#check_megawall').removeClass('selected_tab');
	jQuery('#new_groups_data').show();
	jQuery('#new_groups').addClass('selected_tab');
	jQuery('#check_mygroup').removeClass('selected_tab');
	

}
function sendMSG(obj){
    popover_V2(obj, 'send message');
}
var  profileViewclick = function(){
    if(jQuery('.profile_view_list').css('display')=='none'){
        jQuery('.profile_view_list').slideDown();
        jQuery(this).css({backgroundColor:'#DDEEF6'});
    }else{
        jQuery('.profile_view_list').slideUp('slow',function(){jQuery('.profile_view').css({backgroundColor:'transparent'});});        
    }
}