var flgError = new Array();
var intNumFormElement = 0;

function ajax_favorite( divID, dataSource) {
  	$.get(dataSource,
    		  function(respText) {
    		  		$('#'+divID).html(respText);
    		  });    
}

function ajax_add_good( divID, dataSource) {
  	$('#'+divID).html('<img src="/images/ajax-loader.gif" />'); 
	$.get(dataSource,
    		  function(respText) {
    		  		$('#'+divID).html(respText);
    		  });    
}

function ajax_post_save(dataSource, body, reply_to) {
	$.ajax({
		  type: "POST", 
		  url: dataSource,
		  data: "body="+encodeURIComponent(body)+"&reply_to="+encodeURIComponent(reply_to),
		  cache: false,
		  success: function(html){
				load_massage_discuss();
				ajax_send_replymail('/ajax/sendreplymail');
		  }
	});    	
}

function ajax_discuss_reply(dataSource, body, reply_to) {
	$.ajax({
		  type: "POST", 
		  url: dataSource,
		  data: "body="+encodeURIComponent(body)+"&reply_to="+encodeURIComponent(reply_to),
		  cache: false,
		  success: function(html){
				$("#replies_"+reply_to).html($("#replies_"+reply_to).html()+html);
				ajax_send_replymail('/ajax/sendreplymail');
		  }
	});    	
}

function ajax_post_delete( dataSource ) {
	$.ajax({
		  type: "GET", 
		  url: dataSource,
		  cache: false,
		  success: function(html){
				//load_massage();
		  }
		});    	
}

function ajax_post_slug_save(dataSource, body, reply_to ,parent_post_id) {
	$.ajax({
		  type: "POST", 
		  url: dataSource,
		  data: "body="+encodeURIComponent(body)+"&reply_to="+encodeURIComponent(reply_to),
		  cache: false,
		  success: function(html){
				load_slug_massage(parent_post_id);
				ajax_send_replymail('/ajax/sendreplymail');
		  }
	});    	
}

function ajax_post_slug_delete( dataSource,parent_slug ) {
	$.ajax({
		  type: "GET", 
		  url: dataSource,
		  cache: false,
		  success: function(html){
				load_slug_massage(parent_slug);
		  }
		});    	
}

function ajax_send_replymail( dataSource ) {
	$.ajax({
		  type: "GET", 
		  url: dataSource,
		  cache: false,
		  success: function(html){
				
		  }
		});    	
}

function ajax_message_delete( dataSource ) {
	$.ajax({
		  type: "GET", 
		  url: dataSource,
		  cache: false,
		  success: function(html){
				load_massage();
		  }
		});    	
}

function ajax_load_massage( divID, dataSource ) {  
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_massage_discuss( divID, dataSource ) {  
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_massage_app( divID, dataSource ) {  
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_user_massage( divID, dataSource ) {   
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_rewozaibyothers( divID, dataSource ) {  
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_rewozaibyyou( divID, dataSource ) {  
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_rewozaiofyou( divID, dataSource ) {  
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_lbs_checkin_message( divID, dataSource ) {  
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_lbs_spot_checkin_message( divID, dataSource ) {  
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_lbs_spot_tips_message( divID, dataSource ) {  
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_lbs_tips_message( divID, dataSource ) {  
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_lbs_spot_mayor_message( divID, dataSource ) {  
	//$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_slug_massage( divID, dataSource ) {   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_widget_user_massage( divID, count, dataSource ) {   
	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  		if(count==0){
  		  			$("#"+divID+" table").hide();
  		  		}
  		  });
}

function ajax_load_widget_search( divID, count, dataSource ) {   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  		if(count==0){
  		  			$("#"+divID+" table").hide();
  		  		}
  		  });
}

function showlist( divID, dataSource) {
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');
	$.get(dataSource,
    		  function(respText) {
    		  		$('#'+divID).html(respText);
    		  });    
}

function chkform( divID, dataSource) {
	$('#'+divID).html('<img src="/images/ajax-loader.gif" />');
	$.get(dataSource,
    		  function(respText) {
    		  		$('#'+divID).html(respText);
    		  });    
}

function ajax_getschoollist( divID, dataSource ){
	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_location_a( divID, dataSource ) {     
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_location_b( divID, dataSource ) {     
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_search(divID, dataSource) {    
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>'); 
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_get_job_users(divID, dataSource) {     
  	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');
	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_last_post( divID, dataSource ) {     
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_getrewozai(divID, dataSource) {     
  	var status_len;
	var total_len = 140;
	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).val(respText);
				status_len = $("#"+divID).val().length;
				if ( total_len - status_len >= 0 ) $('#charlimitinfo').html(total_len-status_len);
				else $('#charlimitinfo').html('<span style="color: red;">'+(total_len-status_len)+'</span>');
				
				setCursor(document.getElementById("status"),status_len ,status_len);
				function setCursor(el,st,end) { 
					if(el.setSelectionRange) { 
						el.focus(); 
						el.setSelectionRange(st,end); 
					} 
					else { 
						if(el.createTextRange) { 
							range=el.createTextRange(); 
							range.collapse(true); 
							range.moveEnd('character',end); 
							range.moveStart('character',st); 
							range.select(); 
						} 
					} 
				} 
  		  });
}

function ajax_fbgoconnect( divID, dataSource ) {     
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_twitgoconnect( divID, dataSource ) {     
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_check_events( divID, dataSource ) {
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
				setTimeout(function(){
			        check_events(divID);
			    }, 10000);
  		  });
}

function ajax_show_events( divID, dataSource ) {
	$('#'+divID).html('<div align="center"><img src="/images/ajax-loader.gif" /></div>');
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_search_loc( divID, dataSource ) {  
	$('#'+divID).html('<div><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_save_search( divID, dataSource ) {  
	$('#'+divID).html('<div><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
				show_saved_searches('saved_searches');
  		  });
}

function ajax_show_saved_searches( divID, dataSource ) {  
	//$('#'+divID).html('<div><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function go_search(query){
	var query;
	$('#query').val(query);
    search();
}

function ajax_follow_list( divID, dataSource ) {  
	$('#'+divID).html('<img src="/images/ajax-loader.gif" />');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_add_list_user( dataSource ) {
	$.ajax({
		  type: "GET", 
		  url: dataSource,
		  cache: false,
		  success: function(html){
		  }
		});    	
}

function ajax_load_list_massage( divID, dataSource ) {  
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_list_members( divID, dataSource ) {  
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_list_subscribers( divID, dataSource ) {  
	$('#'+divID).html('<div align="center" style="padding:10px;width:460px;"><img src="/images/ajax-loader.gif" /></div>');   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_friends_auto_complete( showID, dataSource ) {  
	$.get(dataSource,
  		  function(respText) {
  		  		if( $('#'+showID).css("display")=="none" ){
	  		  		parent.$("#upload_iframe").attr("height",550);
	  		  		$('#'+showID).css("display","block");
  		  		}
  		  		$('#'+showID).html(respText);
  		  });
}

function ajax_get_user_photos( showID, dataSource ) {  
	$.get(dataSource,
  		  function(respText) {
			$('#'+showID).html(respText);
	  		$('#'+showID).css("display","block");
  		  });
}

function ajax_get_user_videos( showID, dataSource ) {  
	$.get(dataSource,
  		  function(respText) {
			$('#'+showID).html(respText);
	  		$('#'+showID).css("display","block");
  		  });
}

function ajax_get_user_loc( divID, dataSource ) {
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  		/*
				setTimeout(function(){
					get_user_loc(divID);
			    }, 10000);
			    */
  		  });
}

function ajax_go_refresh_loc( divID, dataSource ) {
  	$.get(dataSource,
  		  function(respText) {
  				//$('#'+divID).html(respText);
				//get_user_loc(divID);
				window.location = "/place/index";
				//$("#address_bar").hide("hide");
  		  });
}

function ajax_geo_enabled( divID, dataSource ) {
  	$.get(dataSource,
  		  function(respText) {
				get_user_loc(divID);
  		  });
}

function ajax_go_checkin( guid, dataSource ) {
	$('#msg'+guid).css("display","block");
	$('#msg'+guid).html("<img src='/images/ajax-loader_1.gif' border='0' />");
	$.get(dataSource,
  		  function(respText) {
				$('#msg'+guid).html(respText);
				$("#checkin_btn_"+guid).attr("disabled","");
  		  });
}

function ajax_go_addtips( guid, dataSource ) {
	$('#msg'+guid).css("display","block");
	$('#msg'+guid).html("<img src='/images/ajax-loader_1.gif' border='0' />");
	$.get(dataSource,
  		  function(respText) {
				$('#msg'+guid).html(respText);
				$("#addtips_btn_"+guid).attr("disabled","");
  		  });
}