$.fn.weather = function(sehir) { 
		$.ajax({
                 type: "GET",
                 url: "/aktuel/modules/xml/weather/"+sehir+".xml",
                 dataType: "xml",
                 success: function(xml) {
					 var counter = 0;
					 $("#weatherError").addClass('hideElement');
					 $("#weatherIcon").removeClass('hideElement');
                     $(xml).find('forecast_conditions').each(function(){
                         
						 if(counter ===0)
						 {
							 var lowDegreeC ="";
							 var highDegreeC  ="";
							 
							 var lowD = $(this).find("low").attr("data");
							 var highD = $(this).find("high").attr("data");
							 
							 
							 if(lowD !=="")
							 {
								 //var lowDegreeC = parseInt(($(this).find("low").attr("data")-32)*0.55);
								  lowDegreeC = parseInt((lowD-32)*0.55);
							}
							else
							{
								lowDegreeC = "";
							}
							
							if(highD !=="")
							{
								//var highDegreeC = parseInt(($(this).find("high").attr("data")-32)*0.55);
								highDegreeC = parseInt((highD-32)*0.55);
							}
							else
							{
								lowDegreeC = "";
							}
							 
							
							if(lowDegreeC !=="")
							{
								$(".weatherLow").html(lowDegreeC + "C");
							}
							
							if(highDegreeC !=="")
							{
								$(".weatherHigh").html(highDegreeC + "C");
							}
							
							
							//eğer düşük ve yüksek sıcaklık değeleri varsa / ekle
							if(lowDegreeC !=="")
							{
								if(highDegreeC!=="")
								{
									$(".weatherSep").html("/");
								}
							}
												 
							 $("#weatherIcon").attr('src', 'http://turk.net/Assets/images/icons/weather/' + $(this).find("icon").attr("data").substring(19,$(this).find("icon").attr("data").length).replace('.gif','.png'));
							$("#weatherIcon").attr('alt', $(this).find("condition").attr("data"));
							$("#weatherIcon").removeClass("weatherIconLoading").addClass("weatherIcon");
							
							 
						 }
						 counter = counter + 1;

                     }); 
                 },
				 error:function (xhr, ajaxOptions, thrownError){ 
						$(".weatherLow").html('');
						$(".weatherHigh").html('');
						$("#weatherIcon").addClass('hideElement');
						$("#weatherError").removeClass('hideElement');
						//alert(xhr.responseText);
				 }     
				 
             });
	}

	
	
	

	
	$(document).ready(function() {
							   
		$.fn.weather("istanbul"); 
			
		$("#weatherCities").change(function(){
			$.fn.weather($(this).val());
		}); 
		
		
	});
	
