function getElementAbsoluteCoords(aElement){
      aLeft = 0;
      aTop  = 0;
      if (aElement.offsetParent)
      {
            aLeft = aElement.offsetLeft;
            aTop  = aElement.offsetTop;
            while (aElement = aElement.offsetParent)
            {
                  aLeft += aElement.offsetLeft;
                  aTop  += aElement.offsetTop;
            }
      }
      point=Array(2);
      point[0]=aLeft;
      point[1]=aTop;
      return point;
}

// asaf 26-7-2011



function change_cities_list_by_area_and_shovar_type()
{
	  
	// alert($('#city_hidden_value').val());
	$('#city_selector_div').html('<select name="city" style="background-color:#f0f0f0; float:right; width:135px; margin-left:10px; border:0px;"> <option value="0">בחר עיר</option></select>			');
	// get all cities for the area id as option list and return it to #city_selector_div
	$.ajax({
			   type: "POST",
			   url: "site/js/ajax/cities_option_list.php",
			   data: "area_id="+$("#area").val()+'&shovar_type_id='+$("#shovar_type_id").val()+"&city_id="+$('#city_hidden_value').val(),
			   success: function(msg)
			   {
					$('#city_selector_div').empty().append(msg);
				 // alert( "Data Saved: " + msg );
			   }
			 });
}

// asaf 26-7-2011
/* function change_area_list_by_area_and_shovar_type()
{
	  alert('x');
	// alert($("#area").val());
	alert($('#city_hidden_value').val());
	$('#area_selector_div').html('<select name="area" style="background-color:#f0f0f0; float:right; width:135px; margin-left:10px; border:0px;"> <option value="0">בחר אזור</option></select>			');
	// get all cities for the area id as option list and return it to #city_selector_div
	$.ajax({
			   type: "POST",
			   url: "site/js/ajax/areas_option_list.php",
			   data: "area_id="+$("#area").val()+'&shovar_type_id='+$("#shovar_type_id").val(),
			   success: function(msg)
			   {
					$('#area_selector_div').html(msg);
					change_cities_list_by_area_and_shovar_type();
				 // alert( "Data Saved: " + msg );
			   }
			 });
}
 */

 function filter_shovar_category(category_id)
 {
	if (category_id>0)
	{
		 // alert('#category_'+$('#shovar_category').val())
		 $('div[id^="category_"]').hide();
		$('#category_'+category_id).show('slow');
	}
	else
	{
	 $('div[class^="category_"]').show('slow');
	}
 }

$(document).ready
(
	function () 
	{
		$('#area').change(
		function() 
		{
			// alert($('#city_hidden_value').val());
			change_cities_list_by_area_and_shovar_type();
		});

		$('#shovar_type_id').change(
		function() 
		{
			// change_area_list_by_area_and_shovar_type();
			change_cities_list_by_area_and_shovar_type();
		});
		
		// load cities list when page loads any way		
		change_cities_list_by_area_and_shovar_type();
		// change_area_list_by_area_and_shovar_type();
		
		$('#shovar_category').change
		(
			function()
			{
				filter_shovar_category($('#shovar_category').val())
				
			}
		)
	}
	

);
