//   ON LOAD
function sayfalar(){
	var mansetMargin  = $(window).height() - 370;
	$("#mansetArea").animate({marginTop:mansetMargin},1500);
	$("#mansetlist li a").click(function(){
		var id = $(this).attr("id");
		$("#manset .manset_content").animate({marginTop: 200},500);
		$("#manset").animate({height:0,paddingBottom:0},800,function(){
			$("#manset .manset_content").each(function(){
				if($(this).css("display")=="block" && $(this).attr("id")!=id){
					var id2 = $(this).attr("id");
					$("#manset #"+id2).slideUp(0,function(){
						$(this).hide();
						$("#manset #"+id).slideDown(0,function(){
							$("#manset").animate({height:170,paddingBottom:30},800);
							$("#manset .manset_content").animate({marginTop: 0},1200);
						});
						$("#mansetlist li a#"+id2).parents("li").removeClass("current");
						$("#mansetlist li a#"+id).parents("li").addClass("current");
					});
				}
			});
		});
		return false;
	});
	$(".pGaleri").mouseover(function(){
		$(this).animate({width:120},200);
	}).mouseout(function(){
		if($(this).hasClass("current")==false)
			$(this).animate({width:40},200);
	});
	$(".pVideo").mouseover(function(){
		$(this).animate({width:90},200);
	}).mouseout(function(){
		if($(this).hasClass("current")==false)
			$(this).animate({width:40},200);
	});
	$(".pPlan").mouseover(function(){
		$(this).animate({width:135},200);
	}).mouseout(function(){
		if($(this).hasClass("current")==false)
			$(this).animate({width:40},200);
	});
	$(".icerikAlani .icerik .projelist li").mouseover(function(){
		$(this).addClass("hover");
	}).mouseout(function(){
		$(this).removeClass("hover");
	});
}

//   ANA SAYFA


//   HAKKIMIZDA
function hakkimizda(id){
	contentDegistir("hakkimizda",id,"","");
}

//   İLETİŞİM
function iletisim(id){
	contentDegistir("iletisim",id,"","");
}

// PROJELER
function projeler(id,proje,sayfa){
	if(id == "satilik-daireler"){
		contentDegistir("projeler",id,"","");
		leftContentDegistir("satilik-daireler",proje);
	}
	else if(sayfa == "ornek-daire"){
		contentDegistir("projeler",id,proje,"");
		leftContentDegistir("ornek-daire",proje);
	}
	else if(sayfa == "santiye"){
		contentDegistir("projeler",id,proje,"");
		leftContentDegistir("santiye",proje);
	}
	else if(sayfa == "santiye-a1"){
		contentDegistir("projeler",id,proje,"");
		leftContentDegistir("santiye-a1",proje);
	}
	else if(sayfa != "daire-planlari"){
		contentDegistir("projeler",id,proje,sayfa);
		leftContentDegistir("","");
	}
	else {
		contentDegistir("projeler",id,proje,"");
		leftContentDegistir("daire-planlari",proje);
	}
	if(id != "satilik-daireler" && proje != ""){
		if($("div#projeler .bgs img.bgs_"+proje).attr("class")){
			$("div#projeler .bgs img").each(function(){
			if($(this).css("display")!="none" && $(this).attr("class")!="bgs_"+proje){
				$(this).fadeOut(400,function(){
					$('div#projeler .bgs img.bgs_'+proje).fadeIn(400);
				});
			}
		});
		}else {
			var img = new Image();
			$(img).load(function () {
				//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
				$(this).hide();
				var elem = $(this);
				$("div#projeler .bgs img").fadeOut(400,function(){
					$('div#projeler .bgs').append(elem);
					setTimeout(function(){resizeBGS($(window))},500);
					elem.fadeIn(400);
				});
			}).error(function () {
				// notify the user that the image could not be loaded
			}).attr('src', 'images/bg/'+proje+'.jpg').addClass("bgs_"+proje);
		}
		
		if(sayfa == "foto-galeri"){
			$("#projeler #page_"+proje+"-foto-galeri ul.galeri_nav li").each(function(){
				var elem  = $(this);
				var linka = elem.children("a");
				var image = linka.children("img");
				if($("div#projeler .bgs img.bgs_"+linka.attr("id")).attr("class")){
					//asdad
				}else {
					elem.html('<a href="#"><img src="images/spinner.gif" /></a>');
					// $("#loading").show();
					var img = new Image();
					$(img).load(function () {
						elem.html(linka);
						$('div#projeler .bgs').append($(this));
						$(this).hide();
						galeriLinkleri();
					}).error(function () {
						// notify the user that the image could not be loaded
					}).attr('src', linka.attr("href")).addClass("bgs_"+linka.attr("id"));
				}
			});
		}
	}
	else {
		if($("div#projeler .bgs img.bgs_projeler").css("display")=="none"){
			$("div#projeler .bgs img").each(function(){
				if($(this).css("display")!="none"){
					$(this).fadeOut(400,function(){
						$('div#projeler .bgs img.bgs_projeler').fadeIn(400);
					});
				}
			});
		}
	}
}
