function ajax_link(){
	$(".ajax").each(function(i){
		if( $(this).attr("mdajax") !=='ok'){
			$(this).attr("mdajax","ok");
			$(this).click(function (){
				page_load(this.href , $(this).attr("ajaxid"));
				return false;
			})
		}
	});
}
function fromUtf8ToEntity (my_str) {
  my_str = my_str.replace(/([^\x00-\x7f])/g,
    function(s, c, ofs, all) {
      c = String(c);
      return "&#"+c.charCodeAt(0)+";";
    }
  );
  return my_str;
}
function page_load(ajax_url, ajaxid){
	ajax_url= ajax_url.replace(/fullmode/g,"ajaxmode");
	if ( ajaxid =='' || ajaxid == null){
		ajaxid="md_main";
	}
	do_ajax( "GET" , fromUtf8ToEntity(ajax_url) , "" , ajaxid , "body" , "ok" , "normal", "write" )
}
function use_gallery(){
	window.open(my_site_base_url+'/advertisement_gallery.php','gallery','status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no ,width=500px,height=400px') ;
}
function do_search(search){
	search =encodeURIComponent(document.getElementById('search').value) ;
	search_stateid =document.getElementById('search_stateid').value ;
	search_catid =document.getElementById('search_catid').value ;
	if( search !=='' ){
		my_go(my_site_base_url+'/fullmode/search/'+search_catid+'/'+search_stateid+'/'+search+'.html');
	}else{
		my_go(my_site_base_url+'/fullmode/all/'+search_catid+'/'+search_stateid+'/'+mohsen_davari_cats_title[search_catid]+'/'+mohsen_davari_state_title[search_stateid]+'.html');		
	}
}
$(document).ready(function() {
	ajax_link();
	change_list_class();
});
