$(document).ready(function(){
			
	sIFR.replace(f0810, {
	  selector: ".giris h2",
	  wmode: "transparent",
	  tuneHeight: "-5",
	  css:".sIFR-root {color:#383838; font-size:22px;}"
	});
	
	$(".form div span").addClass("s_span");
	
	$(document).click(function(e){
	
		var target = e.target;
	/*
		if(!$(target).hasClass("select") && !$(target).hasClass("open") ){
		
			$(".select").slideUp();
		}
	*/
	})
	
	// açılışta kutuları kapat
	
	// Ülke ve şehir kutularını açıp kapatalım

	$(".form .select").slideUp();

	
	$(".form div span").click(function(){
		
		//$(".form div span.open").removeClass("open").parent("div").children(".select").slideUp();			
		
		//$(".form div span").removeClass("open");
		
		if($(this).hasClass("open")){
			$(this).removeClass("open").parent("div").children(".select").slideUp();
			
		}else{
			$(this).addClass("open").parent("div").children(".select").slideDown(function(){
			
			});
		}
		//$(this).parent("div").children(".select").slideDown();
	})	

	$(".city span").click(function(){
		$(".country span.open").removeClass("open");
		$(".country .select").slideUp();
	})
	
	$(".country span").click(function(){
		$(".city span.open").removeClass("open");
		$(".city .select").slideUp();
	})
	
	// $(".form div span").click(function(event){
		
		// if($(this).hasClass("open")){
			// $(this).removeClass("open").parent("div").children(".select").slideUp();
		// }else{
			// $(this).addClass("open").parent("div").children(".select").slideDown();
		// }
		
		// $("body").click(function(){
			// alert("asd");
			// $("body").unbind();
			// $(".form div span").parent("div").children(".select").slideUp();
		// }).unbind();
		
		// return false;		
	// })

	// $("body").click(function(){
	//  	$(".form div span.open").parent("div").children(".select").slideUp();
	// })

	/*
	$(".form div.country span").click(function(){
	
		$(".form div.city .select").slideUp();
	})*/
	
	
	
	
	
	//var pane = $('.flexscroll');
	//pane.jScrollPane({ showArrows:true, animateTo:true });
	//var t = $('.schrool li.active').position().top;
	
	$(".schrool").jScrollPane({scrollbarWidth:8,showArrows:true});
	
	if($(".city .t4 ol").height()<145){
		$(".city .select").addClass("noscrool");
	}
	
	if($(".country .t4 ol").height()<145){
		$(".country .select").addClass("noscrool");
	}
	
	var x = $("#google_x").val();
	var y = $("#google_y").val();
	var z = $("#google_z").val();
	
	load(x,y,5);	
	
})

function select_ulke(perma, name){
	
	$.post("/content/servis_ajax/"+perma, function(html){
	
		$("#servis_city").html(html);
		//$(".city span").addClass("open");
		
		// name = name.split("",10);
		
		$(".country span b").html(name);
		
		
		$(".form div span").unbind().click(function(){
			
			//$(".form div span.open").removeClass("open").parent("div").children(".select").slideUp();			
			
			//$(".form div span").removeClass("open");
			
			if($(this).hasClass("open")){
				$(this).removeClass("open").parent("div").children(".select").slideUp();
			}else{
				$(this).addClass("open").parent("div").children(".select").slideDown();
			}
			
			
			//$(this).parent("div").children(".select").slideDown();
		})
		
		$(".city span").addClass("open");
		
		if($(".city .t4 ol").height()<145){
			$(".city .select").addClass("noscrool");
		}
			
		if($(".city .t4 ol").height()>145){
			$(".city .select").removeClass("noscrool");
		}		
		
		$(".form .country .select").slideUp();
		
		$(".city span").click(function(){
			$(".country span.open").removeClass("open");
			$(".country .select").slideUp();
		})
		
		$(".country span").click(function(){
			$(".city span.open").removeClass("open");
			$(".city .select").slideUp();
			$(".country .select").slideDown();
		})
		
		//$(".form .city .select").slideUp();
	})
	
	return false;
}



/*
 *
 */
function load_detay(ulke, sehir, city){

	$.post("/content/servis_ajax/"+ulke+"/"+sehir, function(html){
		
		$("#detail").html(html);
		$(".form .country .select").slideUp();
		$(".form .city .select").slideUp();
		$(".city span b").html(city);
		
		var x = $("#google_x").val();
		var y = $("#google_y").val();
		var z = $("#google_z").val();
		
		load(x,y,5);
		
		//$(".form .select").slideUp();
	});
	
	return false;
}

var map 	= null;
var marker	= "";
						
function load(x,y,z) {

  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("gmap"));
	var mapControl = new GMapTypeControl();

	map.setCenter(new GLatLng(y,x),z);

	marker=new GMarker(new GLatLng(y,x),z);
	map.addOverlay(marker);
  }
}
