	function showRequest(formData, jqForm, options) {
        $('span.error').hide();
        error=0;
        if($('#name_req').val()=='' || $('#name_req').val()==$('#name_req').attr('title')){$('#name_error').show();error++;}
        if(isEmail($('#email_req').val())==false){$('#email_error').show();error++;}
        if($('#phone_req').val()==''|| $('#phone_req').val()==$('#phone_req').attr('title') || $('#phone_req').val()==dialing_for_contact){$('#phone_error').show();error++;}
        if($('#message_req').val()==''|| $('#message_req').val()==$('#message_req').attr('title')){$('#message_error').show();error++;}
        if(error==0)
            return true;
        else
            return false;
    }
    function showResponse(responseText, statusText)  {
        if(responseText=='done'){
            $('#request_result_message').html(request_after_message);
			$('#request_dr_result').show();
			$('#request_form_inner_holder').hide();
		}
    }
	function wimd(){}
	wimd.prototype.create_flashmap=function(){
		map_reloaded=0;
		var flashvars = {};
		flashvars.key = "ABQIAAAA3Vpp6cPm_NDvdnc_ONJ2ORRMBQUhEt_1rNNsRDT7B5VfSLhzlRRqaVZKsXYuqTeBaGPQSuitIqm7Ig";
		var params = {};
		params.menu = "false";
		params.allowFullScreen = "true";
		params.wmode = "transparent";
		var attributes = {};
		attributes.id = "flashmap";
		flashvars.mappath = "/gmaps.swf";
		flashvars.settingspath = "/mapsearch/settings/";
		flashvars.reload_url = '/mapsearch/index/?'+url_string;
		attributes.name = "flashmap";
		swfobject.embedSWF("/flash/preloader.swf", "flash", "100%", "300", "9.0.0", "/flash/expressInstall.swf", flashvars, params, attributes);
	}
    wimd.prototype.update_flashmap=function(){
        if(active_ltd!='' && active_lng!=''){
            flashmap.API_setLocation(active_ltd+','+active_lng);
            flashmap.API_setZoom(active_zoom_level);
            flashmap.API_reload('/mapsearch/index/?'+url_string);

        }else{
            setTimeout("flashmap.API_reload('/mapsearch/index/?'+url_string);",500);
        }

    }
	wimd.prototype.getUrlString=function(){
		filter.generate_url(1);
		return '/mapsearch/index/?'+url_string;
	}
	wimd.prototype.set_list_type=function(id){
		if(id==1 && active_list_type!=id){
			$('#swap_to_mapview').show();
			$('#swap_to_textview').hide();
			active_list_type=1;
			start=0;
			filter.generate_url();
			if (navigator.appName=="Microsoft Internet Explorer"){
				 }
			else
				flash_map_ready=0;
			if(current_profile>0 && current_profile!='')
				{$('div.map').hide();$("div.country_line").css('marginRight',0);}
			$('#listing').show();
			$('#flash_map_listing').hide();
			flash_map_status='';
			filter.showLoading();
			filter.get_text_listing(active_branch_id,active_treatment_id,'0');
			//$("span:contains('Map data')").hide();
		}if(id==2 && active_list_type!=id){
			$('#swap_to_mapview').hide();
			$('#swap_to_textview').show();

			$('#flash_map_listing').show();
			$('#listing').hide();
			filter.create_flashmap();
			active_list_type=2;
			map_reloaded=0;
			flash_map_status='active';
			if (navigator.appName=="Microsoft Internet Explorer" && flash_map_ready_once==1){
				flash_map_ready=1;
				map_reloaded=1;
				flashmap.API_setLocation(active_ltd+','+active_lng);
            	flashmap.API_setZoom(active_zoom_level);
           	    flashmap.API_reload('/mapsearch/index/?'+url_string);
			}
			else
				flash_map_ready=0;
			filter.generate_url();

			$(window).resize();
		}

	}
	function flashmapready(){
		flashmap = document.getElementById("flashmap");
		flash_map_ready=1;
		flash_map_ready_once=1;
		map_reloaded=0;
		if(active_lng=='' && active_ltd=='')
			init_loc();
		flashmap.API_showClose(0);
		filter.generate_url();

		if(initial_map_center!=''){
			flashmap.API_setLocation(initial_map_center);
			flashmap.API_setZoom(active_zoom_level);
		}else{
			filter.update_flashmap();
		}
		flashmap.API_reload('/mapsearch/index/?'+url_string);
        filter.update_flashmap();
	}
	function blocklisting(){
		filter.remove_location(0);
		$('#message_flash_map').show();
		//$('#flash_map_loading').show();

       		//filter.black_out('listing', message_updating_clinics);

	}
	function unblocklisting(){
        active_llnw=flashmap.API_getLLNW();
        active_llse=flashmap.API_getLLSE();
        active_zoom_level=flashmap.API_getZoom();
		if(map_reloaded==0 && flash_map_ready==1 )
		{
			//alert('/mapsearch/index/?'+url_string);
			filter.generate_url();
			flashmap.API_reload('/mapsearch/index/?'+url_string);
			map_reloaded=1;
		}else if(map_reloaded==0){
			filter.generate_url();
			flashmap.API_reload('/mapsearch/index/?'+url_string);
		}
		//alert(map_reloaded+'-'+flash_map_ready);
	}
	wimd.prototype.update_status_bar=function(update_flash){
		if(active_llnw!="" && active_llse!='' && active_zoom_level>2)in_location=sb5;
		else if(active_city!="")in_location=active_city+', the '+active_country;
		else if(active_county!="")in_location=active_county+', the '+active_country;
		else if(active_state!="")in_location=active_state+', '+active_country;
		else if(active_country!="")in_location=active_country;
		else in_location='';
/*		if(in_location!=''){
			if(result_count>0)
				filter.status_bar=tokentovariable(sb2)+(active_treatment_id!=''?tokentovariable(sb3):'')+tokentovariable(sb4);
			else
				filter.status_bar=tokentovariable(sb1)+(active_treatment!=''?tokentovariable(sb3):'')+tokentovariable(sb4);
		}else if(active_treatment_id!=''){
			if(result_count>0)
				filter.status_bar=tokentovariable(sb2)+tokentovariable(sb3);
			else
				filter.status_bar=tokentovariable(sb1)+tokentovariable(sb3);
		}else{
			if(result_count>0)
				filter.status_bar=tokentovariable(sb2);
			else
				filter.status_bar=tokentovariable(sb1);
		}
*/	initialize_filter();
		if(active_treatment_id!='')
			$("#dt2.dropdown dt a span").html(active_treatment);
		else
			$("#dt2.dropdown dt a span").html(message_select_a_treatment);
		if(in_location!="")in_location=" in "+in_location; else in_location=" Worldwide";
		$('#status_bar').html('');
		$('#status_bar').html(filter.status_bar);
		$('#status_bar_new').html('Showing '+result_count+' '+active_provider_name+(active_treatment_id!=''?' that provide '+active_treatment:'')+in_location);
		document.title='Showing '+result_count+' '+active_provider_name+(active_treatment_id!=''?' that provide '+active_treatment:'')+in_location;
       // $('#status_bar').unblock();
	   if(active_zoom_level<4 && result_count==0 && allse!=flashmap.API_getLLSE() && allnw!=flashmap.API_getLLNW())
	  { flashmap.API_setLocation("39.876019,-15.512695"); allse=flashmap.API_getLLSE();allnw!=flashmap.API_getLLNW()}
	}
    wimd.prototype.change_loc=function(type){
		if(active_loc_text!=$('#location').val() && type!=1 ){
		start=0;
		var loc=$('#location').val().split(',');
		$.ajax({
			url: "/query/get_country",
			type: "POST",
			cache: true,
			data:'limit=1&q='+loc[0]+(loc[1]?'&q2='+loc[1]:'')+'&branch_id='+active_branch_id,
			success: function(html){
						var x=html.slice(0,html.indexOf("\n"));
						var data=x.split('|');
						if(data[2]==''){
							data[0]='';
						}
						if(data[1]==''){
							active_country=data[0];
							active_state=data[1];
						}else{
							active_country=data[1];
							active_state=data[0];
						}
						active_loc_text=data[0];
						active_country_id=data[2];
						active_state_id=data[3];
						active_county_id=data[4];
						active_city_id=data[5];
						active_ltd=data[6];
						active_lng=data[7];
						active_zoom_level=data[8];

						if(data[9])
						{
							active_zoom_level=16;
							if(active_list_type==1){
								normal_map_status='active';
								flash_map_status=='';
							}else if(active_list_type==2){
								featured(data[9]);
							}
										}

						if(active_list_type==1 && active_ltd!='' && active_lng!='' ){
							free_count=0;
							paid_count=0;
							filter.generate_url();
							filter.get_text_listing();
							filter.updateHotPage();

						}else if(active_list_type==2){
							if(active_ltd!='' && active_lng!='' && active_zoom_level!=''){
								filter.generate_url();
								flashmap.API_setLocation(active_lng+','+active_ltd);
								flashmap.API_setZoom(active_zoom_level);
								flashmap.API_reload('/mapsearch/index/?'+url_string);
							}
						}else if(active_ltd=='' && active_lng==''){
							alert('There is no available '+active_provider_name+' in the location that you write. Please write another location');
							$('#location').select();
							}
					}
		 });
				/*$.ajax({
					url: "/query/get_country",
					type: "POST",
					cache: true,
					data:'limit=1&q='+ $('#location').val()+'&branch_id='+active_branch_id,
					success: function(html){
						var x=html.slice(0,html.indexOf("\n"));
						var data=x.split('|');
						if(data[2]==''){
							data[0]='';
						}
						if(data[1]==''){
							active_country=data[0];
							active_state=data[1];
						}else{
							active_country=data[1];
							active_state=data[0];
						}
						active_loc_text=data[0];
						active_country_id=data[2];
						active_state_id=data[3];
						active_county_id=data[4];
						active_city_id=data[5];
						active_ltd=data[6];
						active_lng=data[7];
						active_zoom_level=data[8];

						if(data[9])
						{
							active_zoom_level=16;
							if(active_list_type==1){
								normal_map_status='active';
								flash_map_status=='';
							}else if(active_list_type==2){
								featured(data[9]);
							}
										}

						if(active_list_type==1 && active_ltd!='' && active_lng!='' ){
							filter.generate_url();
							filter.get_text_listing();
						}else if(active_list_type==2){
							if(active_ltd!='' && active_lng!='' && active_zoom_level!=''){
								filter.generate_url();
								flashmap.API_setLocation(active_lng+','+active_ltd);
								flashmap.API_setZoom(active_zoom_level);
								flashmap.API_reload('/mapsearch/index/?'+url_string);
							}
						}else if(active_ltd=='' && active_lng==''){
							alert('There is no available '+active_provider_name+' in the location that you write. Please write another location');
							$('#location').select();
							}
					}
				 });*/
				//filter.change_loc();
			}else{
				if(active_list_type==1){
					free_count=0;
					paid_count=0;
					this.generate_url();
					this.get_text_listing();
					this.updateHotPage();
				}else if(active_list_type==2){
					if(active_ltd!='' && active_lng!='' && active_zoom_level!=''){
						this.generate_url();
						flashmap.API_setLocation(active_lng+','+active_ltd);
						flashmap.API_setZoom(active_zoom_level);
						flashmap.API_reload('/mapsearch/index/?'+url_string);
					}
				}
			}

    }
	wimd.prototype.black_out= function(target,message){
	}
	wimd.prototype.generate_url= function(for_map){
		if(for_map==1)
			url_string='test=true&a_ltd='+active_ltd+'&a_lng='+active_lng+'&start='+start+'&featured='+url_string_featured_status+'&branch_id='+active_branch_id+(active_treatment_id!=''?'&cat_id='+active_treatment_id:'');
		else
			url_string='test=true&a_ltd='+active_ltd+'&a_lng='+active_lng+'&start='+start+'&featured='+url_string_featured_status+'&branch_id='+active_branch_id+(active_treatment_id!=''?'&cat_id='+active_treatment_id:'')+(active_country_id!=''?'&country_id='+active_country_id:'')+(active_state_id!=''?'&regionCode='+active_state_id:'')+(active_county_id!=''?'&county_id='+active_county_id:'')+(active_city_id!=''?'&city_id='+active_city_id:'');
		//appendHash(url_string);
		}
	wimd.prototype.get_text_listing=function(branch_id,cat_id,type){

		if(active_list_type==1){
		if(type==1 && active_llse!='' && active_llnw!=''){
			type='1&llse='+active_llse+'&llnw='+active_llnw;
		}
		else if(active_llse!='' && active_llnw!=''){
			type='0&llse='+active_llse+'&llnw='+active_llnw;
			}
		this.generate_url();
		if(active_list_type==1 && (active_state!="" || active_country!="")){
			this.black_out('listing', message_updating_clinics);
			type="";llse=''; llnw="";
		}
	
		filter.showLoading();
		scroll(0,0);
		$.ajax({
		   type: "POST",
		   dataType: 'json',
		   url: "/query/get_text_listing",
		   data: url_string+'&type='+type+'&data_type=json&zoom='+active_zoom_level,
		   success: function(data){
			   $('#listings div#holder').remove();
			   $('#normal_map_listing').html('');
			   if(data.details.target_number_of_clinics>0){
				   
					free_count=0;
					filter.showBanner(data.details);
			  		$.each(data.items, function(i,item){
					if(i==0)
					{
						active_ltd=item.ltd;
						active_lng=item.lng;
						active_zoom=15;
						initial_map_center="";
					}
					if(item.other==0)
						filter.populateList(item,data.details);
					else {
						filter.populateCountryListing(data);
						return false;	
					}

				});
					
					if(paid_count<5 && free_count==0) filter.insertAd();					
						

					filter.pagination(data.details, data);
					if(current_profile>0 && current_profile!=''){
					$('div.map').hide();
					$("div.country_line").css('marginRight',0);
				}
		   		}else{
					filter.populateRequestForm(data.details);
					filter.insertAd();
					if(data.details.total_number_of_clinics>0){
						//filter.populateOtherList(data.details);
						if(data.state_id){
							$.each(data.items, function(i,item){
								if(i==0)
								{
									active_ltd=item.ltd;
									active_lng=item.lng;
									active_zoom=15;
									initial_map_center="";
								}
								filter.populateList(item,data.details);

							});
						}else{
							filter.populateCountryListing(data);
						}
					}
				}
				$('.has_tipsy').tipsy({gravity: $.fn.tipsy.autoWE,html:true});
		   }
		 });
		}else{
			active_ltd='';active_lng='';
			this.generate_url();
			}

	}
	wimd.prototype.showBanner = function(details){
		var output='<div class="left_info">'+
				'<div class="left_info_left"></div>'+
				'<div class="left_info_center">'+
					'<div class="info_icon"></div>'+
					'<div class="info_text">Below are <font style="color:#C00; font-size:14px; font-weight:bold">'+details.target_number_of_clinics+' '+details.provider_name+'</font> ';
		if(details.treatment>0){
			output+='providing <font style="color:#C00; font-size:14px; font-weight:bold">'+details.treatment_name+'</font>';
		}

		output+= ' in <font style="color:#C00; font-size:14px; font-weight:bold">'+details.location+'.</font> <b>Contact them now for Free!</b></div>'+
				'</div>'+
				'<div class="left_info_right"></div>'+
			'</div>';

		$('#normal_map_listing').prepend(output);

	}
	wimd.prototype.other_levels=function(id1,id2,id3,id4){
		filter.remove_location(0);
		active_country_id=id1;
		active_state_id=id2;
		active_county_id=id3;
		active_city_id=id4;
		this.get_text_listing();
	}
	wimd.prototype.open_showcase=function(provider_id,is_featured){
		appendHash(provider_id);
		show_profile(provider_id,is_featured,filter.branch_id);
		$('#body').css({'overflow':'auto'});
	}
	wimd.prototype.remove_treatment=function(status){
		active_treatment='';
		active_treatment_id='';
		//$("#dt2.dropdown dt a span").html(message_select_a_treatment);
		this.generate_url();
		if(active_list_type==2)
			flashmap.API_reload('/mapsearch/index/?'+url_string);
		if(status!=1)
			this.get_text_listing(active_branch_id,active_treatment_id);
		else{
			$("#dt2.dropdown dt a span").html('Loading...');
			$("#dt2.dropdown dd ul").html('Loading...');}
	}
	wimd.prototype.remove_location=function(update){

		active_llse="";
		active_llnw="";
		active_country="";
		active_state="";
		active_county="";
		active_city="";
		active_country_id="";
		active_state_id="";
		active_county_id="";
		active_city_id="";
		$('#searchfield').val('');
		if(active_list_type==2 && update!=0 )
        	flashmap.API_setZoom(2);
		if(update!=0)
			this.get_text_listing(active_branch_id,active_treatment_id);
		}
	wimd.prototype.generate_search=function(branch_id,cat_id,cat_name,level){
		start=0;
		if(active_branch_id!=branch_id){
			this.remove_treatment(1);
			$.ajax({
			type: "POST",
			url: "/query/get_filter_details",
			data: "branch_id="+branch_id,
			success: function(msg){
				if(msg!='none'){
					$("#cat_id").html(msg);
				}else{
					cflr='';
				}
			}
			});
		}
		if(branch_id>0){
			active_branch_id=branch_id;
			//get_countries();
		}
		flashmap = document.getElementById("flashmap");
		if(!cat_id || cat_id=='' || cat_id=='undefined'){
			this.remove_treatment();
		}else{
			active_treatment_id=cat_id;
		}
		if(active_list_type==1){
			free_count=0;
			paid_count=0;
			this.get_text_listing(branch_id,cat_id);
			this.updateHotPage(branch_id,cat_id);
		}else{
			this.get_text_listing(branch_id,cat_id,1);
			filter.update_flashmap();
		}
	}
	wimd.prototype.populateList=function(item,details){
		var chat_icon = ((details.current_time - item.login_status) <=5)? '':'_offline';
		var rating = (item.rating==0)? '':'<div class="footer_text">Patient Reviews</div> <div class="rate_star"><img src="/images/rate_'+item.rating+'.png" width="93" height="17" /></div>';
		if(item.account_plan==3){
			$('#normal_map_listing').append('<div class="result"> <div class="result_top_left"></div> <div class="result_top_center"> <div class="result_top_header"><a href="/profiles/'+item.url_name+'">'+item.firm_name+'</a></div> </div> <div class="result_top_right"></div><br clear="all" /> <div class="result_center_left"></div> <div class="result_center_center"> <div class="result_map_area"> <div class="result_map_area_top"></div> <div class="result_map_area_center"> <div class="city">'+(item.country=='US'?item.City:item.City2)+'</div> <div class="maps_flag"> <div class="flag"> '+filter.convertLanguages(item.languages)+' </div> <div class="gmap"> <img src="http://maps.google.com/staticmap?center='+item.ltd+','+item.lng+'&amp;zoom=14&amp;size=108x70&amp;key=ABQIAAAAqH7a8yiR03uIgLt79wgyyhRMBQUhEt_1rNNsRDT7B5VfSLhzlRQrDLgQFce-zxUqSZbIcOeWvRpX6w&amp;markers='+item.ltd+','+item.lng+',midred&amp;sensor=false" width="108" height="70" /><br /> </div> <div class="map_button"> <a href="/profiles/'+item.url_name+'"><img style="margin-top:5px;" border="0" src="/images/profile_button.png" width="107" height="20" border="0" /></a><br /> <a href="javascript:void(0)"  title="Click to see the contact details of the clinic and contact them directly for free..."  class="has_tipsy"  onclick="alert_phone('+item.provider_id+');"><img style="margin-top:5px;" border="0" src="/images/contact_red.png" width="107" height="20" /></a></div><br /> </div> </div> <div class="result_map_area_footer"></div> </div> <div class="result_detail_area"> <div class="result_logo_area"> <div class="result_logo"><a href="/profiles/'+item.url_name+'"><img src="http://static.whereismydoctor.com/albums/'+(item.profile_image!='' && item.profile_image!=null?item.profile_image:'generic_logo.jpg')+'" width="130" /> </a></div> </div> <div class="result_detail">'+char_limiter(item.description,item)+'</div></div> '+(item.image_count>0?'<div class="images_for_holder" id="images_for_'+item.provider_id+'"></div> ':'')+' </div> <div class="result_center_right"></div><br clear="all" /> <div class="result_footer_left"></div> <div class="result_footer_center"> <div class="footer_area">'+(item.promotional_text!=''?' <div class="promotion_icon"></div>':'')+' <div class="footer_text">'+item.promotional_text+'</div> </div> <div class="footer_rate"> '+(Math.round(item.review_count)>0?'<div class="rate_star has_tipsy" title="Has '+item.review_count+' review(s)"><img src="/images/rate_'+Math.round(item.review_average)+'.png"  /></div>':'')+' </div> </div> <div class="result_footer_right"></div><br clear="all" /> </div>');
			if(item.image_count>0){
				this.populateImages(item);
			}
			paid_count++;
		}else if(item.account_plan==2){
			$('#normal_map_listing').append('<div class="value"> <div class="value_top_left"></div> <div class="value_top_center"> <div class="value_top_header"><a href="/profiles/'+item.url_name+'">'+item.firm_name+'</a></div> </div> <div class="value_top_right"></div><br clear="all" /> <div class="value_center_left"></div> <div class="value_center_center"> <div class="value_map_area"> <div class="value_map_area_top"></div> <div class="value_map_area_center"> <div class="city">'+(item.country=='US'?item.City:item.City2)+'</div> <div class="maps_flag"> <div class="flag"> '+filter.convertLanguages(item.languages)+' </div> <div class="gmap"> <img src="http://maps.google.com/staticmap?center='+item.ltd+','+item.lng+'&amp;zoom=14&amp;size=108x70&amp;key=ABQIAAAAqH7a8yiR03uIgLt79wgyyhRMBQUhEt_1rNNsRDT7B5VfSLhzlRQrDLgQFce-zxUqSZbIcOeWvRpX6w&amp;markers='+item.ltd+','+item.lng+',midred&amp;sensor=false" width="108" height="70" /><br /> </div> <div class="map_button"> <a href="/profiles/'+item.url_name+'"><img style="margin-top:2px;" border="0" src="/images/profile_button.png" width="107" height="20" border="0" /></a><br /> <a href="javascript:void(0)" onclick="alert_phone('+item.provider_id+');"><img style="margin-top:2px;" border="0" src="/images/contact_blue.png" width="107" height="20" /></a></div><br /> </div> </div> <div class="value_map_area_footer"></div> </div> <div class="value_detail_area"> <div class="value_logo_area"> <div class="value_logo"><a href="/profiles/'+item.url_name+'"><img src="http://static.whereismydoctor.com/albums/'+(item.profile_image!='' && item.profile_image!=null?item.profile_image:'generic_logo.jpg')+'" border="0" width="130" /></a></div> </div> <div class="value_detail">'+char_limiter(item.description,item)+'</div><br clear="all" /> </div> </div> <div class="value_center_right"></div><br clear="all" /> <div class="value_footer_left"></div> <div class="value_footer_center"> <div class="footer_rate"> '+rating+' </div> </div> <div class="value_footer_right"></div><br clear="all" /> </div> ');
			paid_count++;
		}else if(item.account_plan==1){
			$('#normal_map_listing').append('<div class="basic"> <div class="basic_top_left"></div> <div class="basic_top_center"> <div class="basic_top_header"><a href="/profiles/'+item.url_name+'">'+item.firm_name+'</a></div> </div> <div class="basic_top_right"></div><br clear="all" /> <div class="basic_center_left"></div> <div class="basic_center_center"> <div class="basic_detail_area"> <div class="basic_detail">'+char_limiter(item.description,item)+'</div><br clear="all" /> </div> <div class="basic_map_area"> <div class="basic_map_area_top"></div> <div class="basic_map_area_center"> <div class="city">'+(item.country=='US'?item.City:item.City2)+'</div> <div class="maps_flag"> <div class="flag"> '+filter.convertLanguages(item.languages)+' </div> <div class="map_button"> <a href="/profiles/'+item.url_name+'"><img style="margin-top:2px;" border="0" src="/images/profile_button.png" width="107" height="20" /></a><br /> <a href="javascript:void(0)" title="Click on thumbnail to see the contact details of the clinic and contact them directly for free..." onclick="alert_phone('+item.provider_id+');"><img style="margin-top:2px;" border="0" src="/images/contact_red.png" width="107" height="20" /></a></div><br /> </div> </div> <div class="basic_map_area_footer"></div> </div> </div> <div class="basic_center_right"></div><br clear="all" /> <div class="basic_footer_left"></div> <div class="basic_footer_center"></div> <div class="basic_footer_right"></div><br clear="all" /> </div>');
			paid_count++
		}else{
			if(paid_count<5 && free_count==0) this.insertAd();
			$('#normal_map_listing').append('<div class="free"> <div class="free_top_left"></div> <div class="free_top_center"> <div class="free_top_header"><a href="/profiles/'+item.url_name+'">'+item.firm_name+'</a></div> <div class="free_top_header_country">'+(item.country=='US'?item.City:item.City2)+'</div> </div> <div class="free_top_right"></div><br clear="all" /> <div class="free_center_left"></div> <div class="free_center_center"> <div class="contact_free_button"><a href="javascript:void(0)" onclick="alert_phone('+item.provider_id+');"><img border="0"  title="Click on thumbnail to see the contact details of the clinic"  src="/images/contact_red.png" width="107" height="20" /></a></div> <div style="font-size:11px; padding-top:10px;">Is this your clinic? <a href="/membership/'+item.provider_id+'" style="text-decoration:underline;">Claim your profile</a></div></div> <div class="free_center_right"></div><br clear="all" /> <div class="free_footer_left"></div> <div class="free_footer_center"></div> <div class="free_footer_right"></div><br clear="all" /> </div>');
			free_count++;
		}
	}
	wimd.prototype.populateOtherList=function(data){
		$('#normal_map_listing').append('<div class="alert_area"><div class="alert_area_left"><div class="alert_area_right"></div><div class="alert_area_center"><div class="alert_area_center_text">'+data.no_result_message+'</div></div></div></div><br><br>');
	}
	wimd.prototype.populateImages=function(item){
		images=item.images.split(',')
		image_names=item.image_names.split(',')
		maximages=(item.image_count<8?item.image_count:8);
		for(i=0;i<maximages;i++){
			$('#images_for_'+item.provider_id).append('<a rel="lightbox['+item.provider_id+']" href="'+images[i]+'" title="'+(jQuery.trim(image_names[i])!=''?image_names[i]+' <br /> Click on thumbnail to see the full size':'Click on thumbnail to see the full size')+'" class="premium_image_holder has_tipsy" style="background:url(/query/manipulate_images/'+item.provider_id+'/35)  0px -'+parseInt(i*35)+'px;"></a>');
		}
		$('#images_for_'+item.provider_id+' a').lightBox({fixedNavigation:true});
	}
	wimd.prototype.populateRequestForm=function(data){
		document.getElementById('normal_map_listing').innerHTML=document.getElementById('request_form_holder').innerHTML;
		$('#no_clinic_alert_holder').html('Oops, we don\'t have any '+data.provider_name+' here yet.');
		$('#notification_request_title').html(data.notification_request);
		request();
	}
	wimd.prototype.populateCountryListing=function(data){
		var output_links="";
		if(data.details.target_number_of_clinics==0){
			$('#normal_map_listing').append('<div class="other_locations_title">'+data.details.no_result_message+'</div>');
		}
		
		$.each(data.items_other, function(i,item){
			output_links=output_links+"<a href=\"javascript:void(0)\" onclick=\"filter.updateListing('"+item.country+"','"+(active_state_id!=''?item.state:'')+"','"+(active_county_id!=''?item.county:'')+"','"+(active_city_id!=''?item.city:'')+"')\">"+data.details.provider_name+" in "+(active_city_id!=''?item.city_name+', '+item.state:((active_county_id!=''?capWords(item.county_name)+" County":active_state_id!=''?item.state_name+', '+item.country_name:item.country_name)))+' ('+item.nr_of_clinics+')'+"</a><br/>";
		});

		$('#normal_map_listing').append('<div class="other_locations">'+output_links+'</div>');
	}
	wimd.prototype.updateListing=function(country, state, county, city){
		active_country_id=country;
		active_state_id=(state==0 || state==''?'':state);
		active_county_id=(county==0 || county==''?'':county);
		active_city_id=(city==0 || city==''?'':city);
		start=0;
		filter.generate_url();
		filter.showLoading();
		scroll(0,0);
		filter.updateHotPage();
		filter.get_text_listing();
	}
	wimd.prototype.pagination=function(data,full_data){
		total_pages=Math.ceil(data.target_number_of_clinics/listing_per_page);
		if(total_pages-1==(data.current_page_number/listing_per_page)){
				if(data.number_of_clinics[1]>0){
					$('#normal_map_listing').append('<div class="other_locations_title">'+data.finished_message+'</div>');
					filter.populateCountryListing(full_data);
				}
		}
		if(total_pages>1){
			$('#normal_map_listing').append('<div class="paginationing">'+data.target_number_of_clinics+' Results <ul id="pagination_holder"></ul></div>');
			current_page=data.current_page_number/listing_per_page;
			total_pages=Math.ceil(data.target_number_of_clinics/listing_per_page);
			first_page=(current_page>0?(current_page>3?current_page-3:0):0);
			last_page=(total_pages>current_page?(total_pages-current_page>3?((current_page<3 && 6<=total_pages)?6:current_page+3):total_pages):current_page);
			if(current_page==0)
				$('#pagination_holder').append('<li class="previous-off">&laquo; Previous</li>');
			else
				$('#pagination_holder').append('<li class="previous"><a href="javascript:void(0);">&laquo; Previous</a></li>');

			for(i=first_page;i<last_page;i++)
			{
				if(current_page==i)
					$('#pagination_holder').append('<li id="'+i+'" class="active_page">'+(i+1)+'</li>');
				else
					$('#pagination_holder').append('<li id="'+i+'" class="nonactive"><a href="javascript:void(0);">'+(i+1)+'</a></li>');

			}
			if(total_pages-1==current_page){
				$('#pagination_holder').append('<li class="next-off">Next &raquo;</li>');
			}else
				$('#pagination_holder').append('<li class="next"><a href="javascript:void(0);">Next &raquo;</a></li>');
			pages = $("#pagination_holder li.nonactive");
			//hide loading bar
			function hideLoading(){
				loading.fadeTo(1000, 0);
			};


			//Manage click events
			pages.click(function(){
				//show the loading bar
				

				//Highlight current page number
				//pages.css({'background-color' : ''});
				//$(this).css({'background-color' : 'yellow'});

				//Load content
				start = this.id*listing_per_page;
				filter.get_text_listing();
				//var targetUrl = "content.php?page=" + pageNum + "&" + $("#myForm").serialize() + " #content";
				//content.load(targetUrl, hideLoading);
			});
			$("#pagination_holder li.next").click(function(){
				//show the loading bar
				filter.showLoading();

				//Highlight current page number
				//pages.css({'background-color' : ''});
				//$(this).css({'background-color' : 'yellow'});

				//Load content
				start = (current_page+1)*listing_per_page;
				filter.get_text_listing();
				//var targetUrl = "content.php?page=" + pageNum + "&" + $("#myForm").serialize() + " #content";
				//content.load(targetUrl, hideLoading);
			});
			$("#pagination_holder li.previous").click(function(){
				//show the loading bar
				filter.showLoading();

				//Highlight current page number
				//pages.css({'background-color' : ''});
				//$(this).css({'background-color' : 'yellow'});

				//Load content
				start = (current_page-1)*listing_per_page;
				filter.get_text_listing();
				//var targetUrl = "content.php?page=" + pageNum + "&" + $("#myForm").serialize() + " #content";
				//content.load(targetUrl, hideLoading);
			});

		}
	}
	wimd.prototype.showLoading=function(){
		$('#normal_map_listing div').fadeOut('slow');
		$('#normal_map_listing').append('<div style="margin:70px auto; height:200px; display:block; text-align:center; "><img src="/images/loading.gif" /><br>Loading</div>');
	}
	wimd.prototype.convertLanguages=function(d){
		l=d.split('|');
		str='';
		for(i=0;i<l.length;i++){
			tmp=eval('languages["'+l[i]+'"]');
			if(tmp!=undefined){
				if(i>0)str+='<br>';
				str+='<img vspace="2" src="http://static.whereismydoctor.com/flags/'+tmp+'.gif" alt="'+tmp+'" />';
			}
		}
		return str;
	}
	wimd.prototype.swapMapView=function(ltd,lng){
		active_ltd=ltd;
		active_lng=lng;
		initial_map_center="";
		active_zoom_level=15;
		filter.set_list_type(2);
	}
	wimd.prototype.getLanguages=function(){
		$.ajax({
		   type: "POST",
		   dataType: 'json',
		   url: "/query/get_all_languages",
		   success: function(data){
			   $.each(data.items, function(i,item){
					eval('languages["'+item.language_id+'"]="'+item.country_id+'"');
				});
		   }
		 });
	}
	wimd.prototype.updateHotPage=function(bid,cid){
		$("#body_right_holder").html('<div style="margin:70px auto; width:100%; height:200px; display:block; text-align:center; "><img src="/images/loading.gif" /><br>Loading</div>');
		$.ajax({
			type: "POST",
			url: "/query/get_hot_page",
			data: url_string,
			success: function(msg){
					if(msg!='none'){
						//eval(msg);
						$("#body_right_holder").html(msg);
						$('.manset_detail_area').hide();
						$('.tab_manset').click(function(){ switch_tab($(this)); return false;});
						switch_tab($('.tab_manset:first'));
						$(".tab_content").hide();
						$("ul.tabs li:first").addClass("active").show(); //Activate first tab
						$(".tab_content:first").show(); //Show first tab content
						$("ul.tabs li").click(function() {
							$("ul.tabs li").removeClass("active"); //Remove any "active" class
							$(this).addClass("active"); //Add "active" class to selected tab
							$(".tab_content").hide(); //Hide all tab content
							var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
							$(activeTab).fadeIn(); //Fade in the active content
							return false;
						});

					}
				}
			});
	}
	wimd.prototype.insertAd=function(){
		$('#normal_map_listing').append('<div class="hot_new_area"><div class="hot_new_right"></div><div class="hot_new_left"></div><div class="hot_new_center"><div class="header_text_adv">Advertise your clinic.</div> <div class="hot_center_area"><div class="hot_right_area">      	<a href="/membership"><img src="images/adv/add_clinic.png" border="0" /></a><a href="/membership"><img src="images/adv/view_memberships.png" border="0" /></a>      <a href="javascript:void(0);" id="contact_us_doctors"> <img src="images/adv/contact_us.png" border="0" /></a>         </div><div class="hot_left_area"><div class="adv_text">Become a member<br /><div class="adv_small_text">for as low as <font style="font-family:Arial, Helvetica, sans-serif; font-weight:bold;">$1</font> day <strong>!</strong> </div></div></div><div style="clear:both"></div> </div></div></div><br clear="all" />');
		$('#contact_us_doctors').click(function(){
			$.fn.colorbox({href:"/membership/help_popup", open:true,overlayClose:false, width:1020,iframe:true, height:1000});			
	});
	}
	function featured(provider_id,is_featured,part) {

		alert_phone(provider_id, '','');
	}
	function old_featured(provider_id,is_featured,part) {

		url_string_featured_status=1;
		$('.hotpages').hide();
		//alert(provider_id);
		if(current_profile==provider_id){
			return false;
		}else{
			current_profile=provider_id;
		}
		show_profile_iframe(provider_id,is_featured,'side',part);
		showcase_status='1';
		appendHash(provider_id);
		if(flash_map_ready==1){
			flashmap.API_reload('/mapsearch/index/?'+url_string);
			flashmap.API_showClose(1);
			flashmap.API_centerLastActive();
		}
        $('#side').show();
		document.getElementById("fm").style.marginRight = "612px";
		document.getElementById("side").style.width = "610px";
		//$('#side').width($('#side').width()-5);$('#fm').width($('#fm').width()-10);
		//if(part==1)part='contact';

	}
	function zoomin(zoom) {
    	current_zoom=flashmap.API_getZoom();
        if(current_zoom<zoom && current_zoom+3<=zoom){
       		target_zoom=current_zoom+2;
        }else{
       		target_zoom=zoom;
        }
    	flashmap.API_centerLastActive();
		flashmap.API_setZoom(target_zoom);
        flashmap.API_centerLastActive();

	}
	function request(cat_id, cat_root, cat_name) {
/*		$('#request_form').submit(
			function() {
				$('#is_ajax').val(1);
				$(this).ajaxSubmit({ beforeSubmit:showRequest,success:showResponse});
				return false;
			}
		);

*/
$('span.error').hide();
$('#normal_map_listing form.request_form input,#normal_map_listing form.request_form textarea').each(
				function() {
					$(this).val(this.title);
					if(this.id=='phone_req'){
						$(this).focus(function() {
							if (this.value == this.title ){
								$(this).removeClass('input_temp');
								this.value = dialing_for_contact;
							}
							//$(this).dpDisplay();
						});
						$(this).blur(function() {
						if ($.trim(this.value) == '' || this.value==dialing_for_contact){
							$(this).addClass('input_temp');
							this.value = (this.title? this.title : '');
							$('#'+$(this).attr('name')+'_error').show();
						}else{
							$('#'+$(this).attr('name')+'_error').hide();
							}
						});
					}else{
						$(this).focus(function() {
							if (this.value == this.title){
								this.value = '';
								$(this).removeClass('input_temp');
							}
						});
						$(this).blur(function() {
						if ($.trim(this.value) == ''){
							$(this).addClass('input_temp');
							this.value = (this.title?this.title:'');
							$('#'+$(this).attr('name')+'_error').show();
						}else{
							$('#'+$(this).attr('name')+'_error').hide();
							}
						});
					}
				}
		);
	$('#normal_map_listing form.request_form').submit(
				function() {
					$('#is_ajax').val(1);

						$(this).ajaxSubmit({ beforeSubmit:showRequest,success:showResponse});
						return false;

				}
		);
		$("#request").click(function(){
			$("#emaillistform").toggle('slow');
		});
	}
	function show_profile_iframe(provider_id,is_featured,tg,part){
		show_hide(0);
		//alert('a');
		if(tg!='side')tg='left_content'; else tg='iframe_content';
		$('#'+tg).show();
		$('#flash_showcase_loading').show().html(message_loading_profile);
		$('#'+tg).hide();
		$('#'+tg).attr('src','/gp/'+provider_id+'/'+active_branch_id+'/'+is_featured);

	}
	function isEmail(str) {

	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   var address = str;
	   if(reg.test(address) == false) {
		  return false;
	   }

	}

	function appendHash(providerId){
		var myUrl=document.location.toString();
		var hashPosition=myUrl.indexOf('#');
		if(hashPosition>0){myUrl=myUrl.substr(0,hashPosition);}
		myUrl+='#'+providerId;document.location=myUrl;
	}
	function initialize_filter(){}
	function alert_phone(provider_id, address,clinic_name){
		if(active_provider_id!=provider_id){
			active_provider_id=provider_id;
			$.fn.colorbox({href:"/phone_info/"+provider_id+"/"+active_branch_id, open:true,overlayClose:false, width:850,iframe:true, height:500,onClosed:phone_closed});
			/*$.ajax({
			   type: "POST",
			   url: "/query/get_phone_number",
			   data: "provider_id="+provider_id,
			   success: function(data){

				$.fn.colorbox({href:"/phone_info/"+provider_id, open:true,overlayClose:false, width:850,iframe:true, height:500,onClosed:phone_closed});
				$('#phone_nr_holder').html(data);
				$('#address_holder').html(address);
				$('#clinic_name_holder').html(clinic_name);
				//$.fn.colorbox({html:$('#popup_number_content').html(), open:true,overlayClose:false, width:460, height:300}); $('#phone_nr_holder').html(data);$('#address_holder').html(address);$('#clinic_name_holder').html(clinic_name);
			   }
			 });*/
		}
	}
	function phone_closed(){
		active_provider_id='';
		}
	function flag_phone(){
		 $.ajax({
			   type: "POST",
			   url: "/query/flag_phone_number",
			   data: "provider_id="+active_provider_id,
			   success: function(data){
				   if(data=="done")
						$('#flag_holder').html("Thanks...");
			   }
			 });
	}
	function get_other_results(s){
		start=s;
		filter.get_text_listing(active_branch_id,active_treatment_id);
		}
	function getFlashVersion(){
		var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
		var output = "You have Flash player " + playerVersion.major + "." + playerVersion.minor + "." + playerVersion.release + " installed";
		//alert(output);
		return playerVersion.major;
	}
	function char_limiter(txt,item)
	{
		var limit=120;
		if(txt.length> limit){
			return txt.substring(0,limit)+'...<br><a href="/profiles/'+item.url_name+'">read more</a>';
		}else{
			return txt;
		}
	}
function capWords(str){ 
   var words = str.split(" "); 
   for (var i=0 ; i < words.length ; i++){ 
      var testwd = words[i]; 
      var firLet = testwd.substr(0,1); 
      var rest = testwd.substr(1, testwd.length -1) 
      words[i] = firLet.toUpperCase() + rest 
   } 
   return words.join(" "); 
} 

	var paid_count=0;
	var free_count=0;
	var filter=new wimd;
	var allse;
	var allnw;
