﻿(function(jQuery){
	
	jQuery(function(){
		
		//jQuery("head title").html(jQuery("head title").html().replace(/Sayfalar - /gi,''));
		document.title = document.title.replace(/Sayfalar - /gi,'');
		
		jQuery("#jsFront").hide();
	
		jQuery("#alp_leftMenu li").click(function(){
			//alert("a");
			var a = jQuery(this).children("a").attr("href");
			if(a && a.length && a.length > 0)
			{
				window.location = a;
			}
		});
		
		
		ShowGrass();
		
		window.setTimeout("CreateTurtle()", RandomInteger(1000,3000));
		window.setTimeout("CreateGiraffe()", RandomInteger(4000,6000));
		window.setTimeout("CreateHippopotamus()", RandomInteger(7000,9000));
 
 		
 		jQuery("#alp_globallinks")
 			.empty()
 			.append('<a href="/">İTK Anaokulları</a>');
 		
 		if(document.location.pathname.match(/^(\/(alsancak|bornova|cigli|mithatpasa|cesme|narlidere)\/).*$/gi)){
 			//jQuery("#dBanner").flashembed(document.location.pathname.replace(/(\/.*?\/).*/gi,'$1Resources/swfs/banner.swf')); 
 			
 			if(document.location.pathname.match(/^(\/(alsancak)\/).*$/gi)){
 				jQuery("#alp_globallinks").append(' &gt; <a href="/alsancak/"> Alsancak Anaokulu </a>');
	 			jQuery("#dBanner").flashembed(document.location.pathname.replace(/(\/.*?\/).*/gi,'$1Resources/swfs/banner.swf')); 
 			}
			else if(document.location.pathname.match(/^(\/(bornova)\/).*$/gi)){
 				jQuery("#alp_globallinks").append(' &gt; <a href="/bornova/"> Bornova Anaokulu </a>');
	 			jQuery("#dBanner").flashembed(document.location.pathname.replace(/(\/.*?\/).*/gi,'$1Resources/swfs/banner.swf')); 
 			}
			else if(document.location.pathname.match(/^(\/(cigli)\/).*$/gi)){
 				jQuery("#alp_globallinks").append(' &gt; <a href="/cigli/"> Çiğli Anaokulu </a>');
	 			jQuery("#dBanner").flashembed(document.location.pathname.replace(/(\/.*?\/).*/gi,'$1Resources/swfs/banner.swf')); 
 			}
			else if(document.location.pathname.match(/^(\/(mithatpasa)\/).*$/gi)){
 				jQuery("#alp_globallinks").append(' &gt; <a href="/mithatpasa/"> Mithatpaşa Anaokulu </a>');
	 			jQuery("#dBanner").flashembed(document.location.pathname.replace(/(\/.*?\/).*/gi,'$1Resources/swfs/banner.swf')); 
 			}
			else if(document.location.pathname.match(/^(\/(cesme)\/).*$/gi)){
 				jQuery("#alp_globallinks").append(' &gt; <a href="/cesme/"> Çeşme Yaz Kulübü </a>');
 				jQuery("#dBanner").css({cursor: 'pointer', background: 'transparent url(/cesme/resources/images/banner.jpg)'}).click(function(){ window.location = 'http://anaokulu.ozelturkkoleji.com/cesme/default.aspx'; });
 			}
			else if(document.location.pathname.match(/^(\/(narlidere)\/).*$/gi)){
 				jQuery("#alp_globallinks").append(' &gt; <a href="/narlidere/"> Narlıdere Anaokulu </a>');
	 			//jQuery("#dBanner").flashembed(document.location.pathname.replace(/(\/.*?\/).*/gi,'$1Resources/swfs/banner.swf')); 
 				jQuery("#dBanner").css({cursor: 'pointer', background: 'transparent url(/narlidere/resources/images/banner.jpg)'}).click(function(){ window.location = 'http://anaokulu.ozelturkkoleji.com/narlidere/default.aspx'; });
 			}
	    }
	    else{
 			jQuery("#dBanner").flashembed("/Resources/swfs/banner.swf"); 
	    }
	    
	    ResizeWindow();
	    jQuery(window).resize(function(){ResizeWindow();});
		
		
		window.setTimeout('if(jQuery(".ms-searchform").prev().length > 0) jQuery(".ms-searchform").prev().hide();',100);

		ShowImagesInOverlay();
	});	
})(jQuery);


function ResizeWindow(){
	var $ = jQuery;
	var of = jQuery('#alp_leftMenu_Head').offset();
	var left = of.left + jQuery('#alp_leftMenu_Head').outerWidth();
	if(jQuery("#dBodyInnerArea").length == 0){
	    jQuery('<div id="dBodyInnerArea"/>').css({
			background:'transparent url(/resources/images/opacity60.png) no-repeat left top',
		 	width: 731,
		 	height: 390,
		 	'float': 'left',
		 	left: left,
		 	top: of.top,
		 	position: 'absolute',
		 	zIndex: 100
		}).appendTo(document.body);
		
		jQuery("<a id=dBackLink href='javascript:history.go(-1)'>Geri</a>").css({
			position:'absolute',
			width: 50,
			height: 20,
			left: of.left + 661 + jQuery('#alp_leftMenu_Head').outerWidth(),
			top: of.top,
			zIndex: 2500,
			textAlign: "right",
			fontSize: "9pt",
			opacity: 0.7
		})
		.hover(function(){jQuery(this).css("opacity",1);}, function(){jQuery(this).css("opacity",0.7);})
		.appendTo(document.body);
	}
	else {
		jQuery('#dBodyInnerArea').css({
			background:'transparent url(/resources/images/opacity60.png) no-repeat left top',
		 	width: 731,
		 	height: 390,
		 	'float': 'left',
		 	left: left,
		 	top: of.top,
		 	position: 'absolute',
		 	zIndex: 100
		});
		jQuery("#dBackLink").css({
			position:'absolute',
			width: 50,
			height: 20,
			left: of.left + 661 + jQuery('#alp_leftMenu_Head').outerWidth(),
			top: of.top,
			zIndex: 2500,
			textAlign: "right",
			opacity:0.7
		});

	}
	jQuery('#dBodyArea').css({
		background:'transparent',
		left: left,
	 	top: of.top,
	 	position: 'absolute',
	 	zIndex: 101
	});
	
	jQuery("#dGrass").stop().css({left: jQuery("#dBody").offset().left+10, top: jQuery("#dBody").offset().top + jQuery("#dBody").outerHeight() - 70, zIndex: 9995});
	GrassScroll();

	jQuery('#dTurtle').stop().hide(1000, function(){ jQuery('#dTurtle').remove(); window.setTimeout("CreateTurtle()", RandomInteger(1000,5000));});
	jQuery('#dGiraffe').stop().hide(1000, function(){ jQuery('#dGiraffe').remove(); window.setTimeout("CreateGiraffe()", RandomInteger(10000,15000));});
	jQuery('#dHippopotamus').stop().hide(1000, function(){ jQuery('#dHippopotamus').remove(); window.setTimeout("CreateHippopotamus()", RandomInteger(20000,25000));});

	

	if(jQuery(".ms-ToolPaneOuter").length>0){
		var of = jQuery("#dBody").offset();
		if(jQuery(".ms-ToolPaneOuter").parent() != jQuery("#aspnetForm")){
			jQuery(".ms-ToolPaneOuter").appendTo(jQuery("#aspnetForm"));
		}
		jQuery(".ms-ToolPaneOuter").css({
			position : 'absolute',
			left: of.left + jQuery("#dBody").outerWidth(),
			top: of.top,
			zIndex: 1000
		});
	}
}

function ShowGrass(){
	var off = jQuery("#dBody").offset();
	var grass=jQuery("<div id=dGrass/>").css({left: off.left+10, top: off.top + jQuery("#dBody").outerHeight() - 70, zIndex: 9995});
	
	jQuery(document.body).append(grass);
	grass.show();
	GrassScroll();
}

function GrassScroll(){
	if(jQuery("body form").css("display") != "none")
	jQuery("#dGrass").animate({backgroundPosition: 100}, 6000, function(){ jQuery("#dGrass").animate({backgroundPosition: 0}, 6000, function(){ GrassScroll(); }); });
}


function RandomInteger(min, max){
	return Math.round(Math.random()*(max-min)+min);
}

function CreateTurtle(){
	if(jQuery("body form").css("display") != "none"){

		var off = jQuery("#dBody").offset();
		if(off){
			jQuery(document.body).append(
				jQuery('<div id=dTurtle/>').css({left: off.left + 10, top: off.top + jQuery('#dBody').outerHeight() - 70})
			); 
			AnimalScroll('dTurtle');
		}
	}
}

function CreateGiraffe(){
	if(jQuery("body form").css("display") != "none"){
		var off = jQuery("#dBody").offset();
		if(off){
			var giraffe = jQuery('<div id=dGiraffe/>').css({left: off.left+10, top: off.top + jQuery('#dBody').outerHeight() - 70}); 
			jQuery(document.body).append(giraffe); 
			AnimalScroll('dGiraffe');
		}
	}
}

function CreateHippopotamus(){
	if(jQuery("body form").css("display") != "none"){
		var off = jQuery("#dBody").offset();
		if(off){
			var hippopotamus = jQuery('<div id=dHippopotamus/>').css({left: off.left+10, top: off.top + jQuery('#dBody').outerHeight() - 70}); 
			jQuery(document.body).append(hippopotamus); 
			AnimalScroll('dHippopotamus');
		}
	}
}

function AnimalScroll(div){
	if(jQuery("body form").css("display") != "none"){

		var off = jQuery("#dBody").offset();
		jQuery("#"+div).css({
			backgroundPosition: '-'+jQuery("#"+div).width()+'px 0', 
			zIndex: RandomInteger(2000,8000), 
			left: off.left + 10	
		})
		.animate({left: off.left + jQuery("#dBody").outerWidth() - 82 }, 45000, // RandomInteger(25000,50000),
		function(){
			jQuery("#"+div).css({
				backgroundPosition: '0 0', 
				zIndex: RandomInteger(2000,8000), 
				left: off.left + jQuery("#dBody").outerWidth() - 82	
			})
			.animate({left: off.left + 10 }, 45000,//RandomInteger(25000,50000),
			function(){
				eval("AnimalScroll('"+div+"');");
			});
		});
	}
}


function ShowGallery(){
	jQuery('<div class="simple_overlay" id="gallery"><a class="prev">geri</a> <a class="next">ileri</a><div class="info"></div><img class="progress" src="http://static.flowplayer.org/tools/img/overlay/loading.gif" /></div>').appendTo(document.body);
	var res = jQuery("<div/>").css({width:200 * 3, margin: "0 auto", textAlign:"Center"}).append("<h2>Fotoğraflarla Okulumuz</h2>");
	var res2 = jQuery("<div/>").css({width: 1, height: 1, position: 'absolute', overflow:'hidden', left:-1, top:-1}).appendTo(document.body);
	window.GalleryImages = new Array();
	jQuery("#dImageGallery .cImageGalleryItem").each(function(i, item){
		var o = {
			ID: jQuery('.cImageGalleryItemID',item).html(),
			Title: jQuery('.cImageGalleryItemTitle',item).html(),
			FileDirRef: jQuery('.cImageGalleryItemFileDirRef',item).html(),
			FileRef: jQuery('.cImageGalleryItemFileRef',item).html(),
			Description: jQuery('.cImageGalleryItemDescription',item).html(),
			FileSize: jQuery('.cImageGalleryFileSize',item).html(),
			ImageWidth: jQuery('.cImageGalleryItemImageWidth',item).html(),
			ImageHeight: jQuery('.cImageGalleryItemImageHeight',item).html(),
			FileLeafRef: jQuery('.cImageGalleryItemFileLeafRef',item).html(),
			ThumbnailUrl: ''
		};
		o.ThumbnailUrl = '/'+ o.FileDirRef+'/_t/'+o.FileLeafRef.replace(/^(.*)\.(.*)$/gi,'$1_$2')+".jpg";
		//window.GalleryImages[window.GalleryImages.length] = o;
		//alert(o.ThumbnailUrl);
		window.GalleryImages.splice(0,0,o);
		
		jQuery('<a class="gall" href="' + o.FileRef + '" title="' + o.Title + '" />')
			.css({display: 'inline-block', margin:'10px', opacity: 0.8})
			.append('<img src="' + o.ThumbnailUrl + '" border="0" title="' + o.Title + '" />')
			.hover(function(){jQuery(this).css("opacity", 1);},function(){jQuery(this).css("opacity", 0.8);})
			.prependTo(res);
		jQuery("<a href=\""+o.FileRef+"\" />").appendTo(res2);
	});
	jQuery("#dBodyArea").children().css({display: "none"});
	//jQuery("#dBodyArea").append(res);
	var of = jQuery("#dBodyInnerArea").offset();
	jQuery("<div id=pg/>").css({
		position: 'absolute', 
		left: of.left, 
		top: of.top, 
		width: jQuery("#dBodyInnerArea").width()-10,	
		height: jQuery("#dBodyInnerArea").height()-12,
		padding: '5px',	
		zIndex: 200,
		overflow: 'auto'
	}).append(res).appendTo(document.body);
	
	jQuery("form#aspnetForm").children("table:last").hide();
	window.setTimeout("fn_Overlay();", 1000);
}


function fn_Overlay(){
	jQuery('a.gall')
		.overlay({ 
			target: '#gallery', 
			expose: { color: '#f1f1f1', loadSpeed: 200, opacity: 0.9 }, 
			onStart : function(){ jQuery('#dBanner, #dGrass, #dTurtle, #dGiraffe, #dHippopotamus').hide(); }, 
			onClose : function(){ jQuery('#dBanner, #dGrass, #dTurtle, #dGiraffe, #dHippopotamus').show(); } 	
		}).gallery({ 
			speed: 500, 
			template: '<strong>${title}</strong> <span> ${total} resim içinde ${index}. </span>' 
		});
}
function fn_BANO(){
	var $ = jQuery;
	window.Bano4 = new Array();
	window.Bano5 = new Array();
	window.Bano6 = new Array();
	/*
	$(".bano4").each(function(i,item){ 
		var tds = $("td", item);
		var o = {
			ID: tds.eq(0).text(),
			ContentType: tds.eq(1).text(),
			CreatedDate: tds.eq(2).text(),
			Creator: tds.eq(3).text(),
			ModifiedDate: tds.eq(4).text(),
			UrlPath: tds.eq(5).text(),
			Title: tds.eq(6).text()
		};
		window.Bano4[window.Bano4.length] = o;
	});	

	$(".bano5").each(function(i,item){ 
		var tds = $("td", item);
		var o = {
			ID: tds.eq(0).text(),
			ContentType: tds.eq(1).text(),
			CreatedDate: tds.eq(2).text(),
			Creator: tds.eq(3).text(),
			ModifiedDate: tds.eq(4).text(),
			UrlPath: tds.eq(5).text(),
			Title: tds.eq(6).text()
		};
		window.Bano5[window.Bano5.length] = o;
	});	

	$(".bano6").each(function(i,item){ 
		var tds = $("td", item);
		var o = {
			ID: tds.eq(0).text(),
			ContentType: tds.eq(1).text(),
			CreatedDate: tds.eq(2).text(),
			Creator: tds.eq(3).text(),
			ModifiedDate: tds.eq(4).text(),
			UrlPath: tds.eq(5).text(),
			Title: tds.eq(6).text()
		};
		window.Bano6[window.Bano6.length] = o;
	});	
*/
	jQuery.get('http://anaokulu.ozelturkkoleji.com/Bu%20Ay%20Neler%20Oluyor/Forms/4Yas.aspx', null, function(data, status){
		if(status != 'success') return;
		var trs = jQuery("table.ms-listviewtable[summary='Bu Ay Neler Oluyor'] > tbody > tr", data).not('tr.ms-viewheadertr');
		if(trs.length == 0) return;
		
		trs.each(function(i,item){ 
			var tds = jQuery(item).children("td");
			var o = {
				ID: tds.eq(0).text(),
				ContentType: tds.eq(1).text(),
				CreatedDate: tds.eq(2).text(),
				Creator: tds.eq(3).text(),
				ModifiedDate: tds.eq(4).text(),
				UrlPath: tds.eq(5).children("a").attr("href"),
				Title: tds.eq(6).text()
			};
			window.Bano4[window.Bano4.length] = o;
		});
		
		if(window.Bano4.length>0){
			jQuery("#f1").wrap('<a id=f1 href="' + window.Bano4[0].UrlPath + '" style="padding: 77px 10px 10px 10px; vertical-align:top; display: inline-block; background: transparent url(/Resources/images/yesil.png); width:80px; height:55px;">' + window.Bano4[0].Title + '</a>');
		}
	}, 'html' );
	
	jQuery.get('http://anaokulu.ozelturkkoleji.com/Bu%20Ay%20Neler%20Oluyor/Forms/5Yas.aspx', null, function(data, status){
		if(status != 'success') return;
		var trs = jQuery("table.ms-listviewtable[summary='Bu Ay Neler Oluyor'] > tbody > tr", data).not('tr.ms-viewheadertr');
		if(trs.length == 0) return;
		
		trs.each(function(i,item){ 
			var tds = jQuery(item).children("td");
			var o = {
				ID: tds.eq(0).text(),
				ContentType: tds.eq(1).text(),
				CreatedDate: tds.eq(2).text(),
				Creator: tds.eq(3).text(),
				ModifiedDate: tds.eq(4).text(),
				UrlPath: tds.eq(5).children("a").attr("href"),
				Title: tds.eq(6).text()
			};
			window.Bano5[window.Bano5.length] = o;
		});
		
		if(window.Bano5.length>0){
			jQuery("#f2").wrap('<a id=f2 href="' + window.Bano5[0].UrlPath + '" style="padding: 77px 10px 10px 10px; vertical-align:top; display: inline-block; background: transparent url(/Resources/images/mavi.png); width:80px; height:55px;">' + window.Bano5[0].Title + '</a>');
		}
	}, 'html' );
	


	jQuery.get('http://anaokulu.ozelturkkoleji.com/Bu%20Ay%20Neler%20Oluyor/Forms/6Yas.aspx', null, function(data, status){
		if(status != 'success') return;
		var trs = jQuery("table.ms-listviewtable[summary='Bu Ay Neler Oluyor'] > tbody > tr", data).not('tr.ms-viewheadertr');
		if(trs.length == 0) return;
		
		trs.each(function(i,item){ 
			var tds = jQuery(item).children("td");
			var o = {
				ID: tds.eq(0).text(),
				ContentType: tds.eq(1).text(),
				CreatedDate: tds.eq(2).text(),
				Creator: tds.eq(3).text(),
				ModifiedDate: tds.eq(4).text(),
				UrlPath: tds.eq(5).children("a").attr("href"),
				Title: tds.eq(6).text()
			};
			window.Bano6[window.Bano6.length] = o;
		});
		
		if(window.Bano6.length>0){
			jQuery("#f3").wrap('<a id=f3 href="' + window.Bano6[0].UrlPath + '" style="padding: 77px 10px 10px 10px; vertical-align:top; display: inline-block; background: transparent url(/Resources/images/kirmizi.png); width:80px; height:55px;">' + window.Bano6[0].Title + '</a>');
		}
	}, 'html' );
	

	/*
	if(window.Bano5.length>0){
		jQuery("#f2").wrap('<a id=f2 href="' + window.Bano5[0].UrlPath + '" style="padding-top: 72px; vertical-align:top; display: inline-block; background: transparent url(/Resources/images/mavi.png); width:100px; height:70px;">5 yaş<br/>' + window.Bano5[0].Title + '</a>');
	}
	if(window.Bano6.length>0){
		jQuery("#f3").wrap('<a id=f3 href="' + window.Bano6[0].UrlPath + '" style="padding-top: 72px; vertical-align:top; display: inline-block; background: transparent url(/Resources/images/kirmizi.png); width:100px; height:70px;">6 yaş<br/>' + window.Bano6[0].Title + '</a>');
	}
	*/
	
	jQuery("form#aspnetForm").children("table:last").hide();
}

function ShowImagesInOverlay(){
	jQuery('<div class="simple_overlay" id="dPhoto"><div class="info"></div><img class="progress" src="http://static.flowplayer.org/tools/img/overlay/loading.gif" /></div>').appendTo(document.body);
	
	jQuery("a[rel][rel='#dPhoto']").each(function(i,item) {
		jQuery(item)
			.css({'opacity': 0.8, border: 'solid 5px #0080ce'})
			.hover(function(){ jQuery(this).css('opacity', 1); },function(){ jQuery(this).css('opacity', 0.8); })
			.overlay({
				target: '#dPhoto', 
				expose: { color: '#f1f1f1', loadSpeed: 200, opacity: 0.9 }, 
				onStart : function(){ jQuery('#dBanner, #dGrass, #dTurtle, #dGiraffe, #dHippopotamus').hide(); }, 
				onClose : function(){ jQuery('#dBanner, #dGrass, #dTurtle, #dGiraffe, #dHippopotamus').show(); } 	
			})
			.gallery({ 
				speed: 800, 
				template: '<strong>${title}</strong>' 
			});
		jQuery("img", item)
			.attr('border', 0);
			//.css('border', 0);	
	});	
}
