<?php



function csmap_form_alter(&$form, &$form_state, $form_id)  {


	$icon='<span class="beautytips-icon-wrapper"><img class="beautytips-icon" src="/sites/all/themes/diy/images/icons/hover-help.png" /></span>';

	if ($form['#id']=='views-exposed-form-inserate-suche-map-page' || $form['#id']=='views-exposed-form-heimwerker-suchen-page') {

		$form['address']=array(
			'#type'=>'textfield',
			'#name'=>'address',
			'#id'=>'address',
			'#title'=>'PLZ oder Ort',
			'#size'=>20,
			'#weight'=>88,
			'#prefix'=>'
<style>
  .ui-autocomplete {

    width: 300px;
    border: 1px solid #cfcfcf;
    list-style-type: none;
    padding-left: 0px;
    }
</style>',
			'#suffix'=>'
<div id="map_canvas" style="width:615px; height:300px; border: 1Px solid gray; display:none;"></div><br/>
<div id="hidden_container"></div>
',
/*
			'#description'=>'Nach Ihrer Adress-Eingabe erscheint unter dem Feld eine Liste mit Adress-Vorschlägen.<br /> Bitte wählen Sie aus dieser eingeblendeten Liste einen Adresse durch anklicken aus..
',
*/			'#weight'=>-200,
		);
		
#		dpm($form);
		$form['sort_by']['#weight']=99;
		
		
		
	} 
  
	if ($form['#id']=='views-exposed-form-inserate-suche-map-page-1') {
#  	
	#	dpm($form);
#		dpm($form_state);
		$form['field_proxsearchstring']['#type'] = 'textfield';
		$form['field_proxsearchstring']['#default_value'] = '';
		
#		dpm($form_state);
	}
 
 }

function csmap_menu() {


    $items = array();

    $items['csmap/autocompletemap'] = array(
        'title' => 'My Map',
        'page callback' => 'my_map',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
     );

    return $items;
}

function my_map() {

	#return "hallo";
	#return;


#dpm($_GET);

   //drupal_add_js('//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', 'external');
   //drupal_add_js('//ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js', 'external');
   drupal_add_js('//maps.google.com/maps/api/js?sensor=false', 'external');
   drupal_add_js(drupal_get_path('module', 'csmap'). '/js/csmap.js', $options=array());


    $output='


 <style>
  .ui-autocomplete {

    width: 300px;
    border: 1px solid #cfcfcf;
    list-style-type: none;
    padding-left: 0px;
}
  </style>
  

<!--
   <input name="address" id="address" type="text"/><br /><br />
-->     
  
     	<div id="map_canvas" style="width:615px; height:300px; border: 1Px solid gray; display: none;"></div><br/>
     	
 	   <div id="hidden_container"></div>
    ';

    return $output;
}
