var flgError = new Array();
var intNumFormElement = 0;

function ajax_favorite( divID, dataSource) {
  	$.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();
				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_slug) {
	$.ajax({
		  type: "POST", 
		  url: dataSource,
		  data: "body="+encodeURIComponent(body)+"&reply_to="+encodeURIComponent(reply_to),
		  cache: false,
		  success: function(html){
				load_slug_massage(parent_slug);
				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 ) {     
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_user_massage( divID, dataSource ) {   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_load_slug_massage( divID, dataSource ) {   
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

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) {     
  	$.get(dataSource,
  		  function(respText) {
  		  		$('#'+divID).html(respText);
  		  });
}

function ajax_getrewozai(divID, dataSource) {     
  	var status_len;
	var total_len = 70;
	$.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(); 
						} 
					} 
				} 
  		  });
}
