$(document).ready(function(){

	$(".maparea").mouseenter(function(e){
		$(".shop_tooltip").hide();
		var tooltip = $(this).next(".shop_tooltip");
		$(tooltip).css("left",e.pageX-20);
		$(tooltip).css("top",e.pageY-210);
		$(tooltip).show();
	});

	$(".maparea").mousemove(function(e){
		var tooltip = $(this).next(".shop_tooltip");
		$(tooltip).css("left",e.pageX-20);
		$(tooltip).css("top",e.pageY-210);
	});


	$(".maparea").mouseleave(function(){
		$(".shop_tooltip").hide();
	});

	var months = ['0','Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'];

	$('img').ifixpng();

	$('.thumbnail').lightbox();

	$('.false').click(function(){
		return false;
	});

	$(".movie_poster").children("a").mouseenter(function(){
		$(this).children("img").fadeTo(100, 0.5);
	});

	$(".movie_poster").children("a").mouseleave(function(){
		$(this).children("img").fadeTo(100, 1);
	});

	$('.movie:first').show();
//	$('#floor-Z').show();
//
//	$('#annoucement_summary').vTicker();
//
	$('.other_movie').click(function(){
		var index = $('#other_movies > .other_movie').index(this);
		$('.movie').hide();
		$('.movie:eq('+index+')').slideDown();
	});
//
	$('.other_news').click(function(){
		var index = $('#other_news > ul > .other_news').index(this);
		$('.news').hide();
		$('.news:eq('+index+')').slideDown();
	});

	$('.news:first').show();
//
	$('.contact_link').click(function(){
		var index = $('.contact_link').index(this);

		$('.contact_link').removeClass('selected');
		$(this).addClass('selected');

		$('.contact_method').hide();
		$('.contact_method:eq('+index+')').slideDown();
		return false;
	});

//	if(jQuery.url.segment(1) == null) $('.contact_link:first').click();
//	else if(jQuery.url.segment(0) == 'iletisim-ve-ulasim' && (jQuery.url.segment(1) == 'kroki')) $('.contact_link:eq(2)').click();
//	else if(jQuery.url.segment(0) == 'iletisim-ve-ulasim' && (jQuery.url.segment(1) == 'iletisim-formu')) $('.contact_link:eq(1)').click();
//	else if(jQuery.url.segment(0) == 'iletisim-ve-ulasim' && (jQuery.url.segment(1) == 'eposta-onayi')) alert('E-postanız gönderildi. İlginiz için teşekkür ederiz.');

	//$(".floor:first").show();
	//$(".shop_list:first").show();
	//$(".shop_info:first").show();

	$("#floor_links > li").click(function(){

		var index = $("#floor_links > li").index($(this));
		//alert(index);

		$(".floor").hide();
		$(".floor:eq("+index+")").show();

		$(".shop_list").hide();
		$(".shop_list:eq("+index+")").show();


		return false;
	});

	$("#floor_links > li:eq(1)").click();

	$(".shop-list-link").click(function(){

		var id = $(this).attr("id").slice(10);
		//alert(id);

		$(".shop_info").hide();
		$("#shop-info-"+id).show();

		return false;
	});

	$(".shop_list:eq(1) > a:first").click();
//	$('.shop_link > img').hide();
//	$('.shop_link').each(function(){
//		$(this).css('width',$(this).children('img').width()+'px');
//		$(this).css('height',$(this).children('img').height()+'px');
//	});
//
//	$('.shop_link').mouseenter(function(e){
//		$(this).children('img').show();
//		var temp_id = $(this).attr('id').slice(5);
//
//		$('#shop_'+temp_id+'_info').css("top",'100px');
//		$('#shop_'+temp_id+'_info').css("left",'100px');
//		$('#shop_'+temp_id+'_info').show();
//	});
//
//	$('.shop_link').mouseleave(function(){
//		$(this).children('img').hide();
//
//		var temp_id = $(this).attr('id').slice(5);
//		$('#shop_'+temp_id+'_info').hide();
//	});
//
//	$('.shop_link').mousemove(function(e){
//
//	});
//
	var date = new Date();
	$(".months").hide();
	if($.browser.msie)
		var element = "#month-"+(date.getYear())+""+(date.getMonth() + 1);
	else
		var element = "#month-"+(date.getYear()+1900)+""+(date.getMonth() + 1);

	$(element).show();
//
//	var temp = $(element).attr('id').slice(10,12);
//	$("#calendar > h2").text(months[temp]);
//
//	$(".prev").click(function(){
//		var visible_element = $(".months:visible");
//
//		var temp = $(visible_element).prev().attr('id').slice(10,12);
//		$("#calendar > h2").text(months[temp]);
//
//		$(".months").hide();
//		$(visible_element).prev().show();
//
//		return false;
//	});
//
//	$(".prev > a").click(function(){
//		$(this).parent().click();
//		return false;
//	});
//
//	$(".next").click(function(){
//		var visible_element = $(".months:visible");
//
//		var temp = $(visible_element).next().attr('id').slice(10,12);
//		$("#calendar > h2").text(months[temp]);
//
//		$(".months").hide();
//		$(visible_element).next().show();
//
//		return false;
//	});
//
//	$(".next > a").click(function(){
//		$(this).parent().click();
//		return false;
//	});



	$('.image_counter > li').addClass('with_bg');
	$('.image_counter > li:first').removeClass('with_bg');

	if(typeof($("#slider_images").attr("id")) != "undefined"){
		var rotator_list = $("#slider_images");
		var rotator_width = 970; //$("#slider_images > li:first").width();
		var rotator_count = $("#slider_images > li").size();
		var rotator = "";

		$(rotator_list).css("width",(rotator_count * rotator_width)+"px");
		if(typeof(start_count) == 'undefined') var start_count = 0;

		start_rotator();

	}

	$('#slider').mouseenter(function(){
		clearInterval(rotator);
	});

	$('#slider').mouseleave(function(){
		start_rotator();
	});

	function start_rotator(){
		rotator = setInterval(function(){
			if(start_count >= rotator_count) start_count = 0;
			if($(rotator_list).css("margin-left") == (rotator_count * rotator_width)) $(rotator_list).css("margin-left","0px");
			$("#slider_images").animate({"marginLeft":-(start_count*rotator_width)+'px'},500);

			$('.image_counter > li').addClass('with_bg');
			$('.image_counter > li:eq('+start_count+')').removeClass('with_bg');
			start_count++;
		},3500);
	}

	$('.image_counter_link').click(function(){
		var index = $('.image_counter_link').index(this);
		
		$("#slider_images").animate({"marginLeft":-(index*rotator_width)+'px'},500);
		start_count = index;

		$('.image_counter > li').addClass('with_bg');
		$('.image_counter > li:eq('+start_count+')').removeClass('with_bg');

		return false;
	});


});

function str_replace(search, replace, subject, count) {
	var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
		f = [].concat(search),
		r = [].concat(replace),
		s = subject,
		ra = r instanceof Array, sa = s instanceof Array;
	s = [].concat(s);
	if (count) {
	    this.window[count] = 0;
	}
	
	for (i=0, sl=s.length; i < sl; i++) {
		if (s[i] === '') {
		    continue;
		}
		for (j=0, fl=f.length; j < fl; j++) {
		    temp = s[i]+'';
		    repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
		    s[i] = (temp).split(f[j]).join(repl);
		    if (count && s[i] !== temp) {
		        this.window[count] += (temp.length-s[i].length)/f[j].length;}
		}
	}
	return sa ? s : s[0];
}


function replace_chars(chars_array, sstring){
	for(cchar in chars_array){
		alert(chars_array[cchar]);
		sstring = sstring.replace(chars_array[cchar],' ');
	}
	
	return sstring;
}

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-7391939-3");
pageTracker._trackPageview();
} catch(err) {}

/*
* Tadas Juozapaitis ( kasp3rito@gmail.com )
*/
(function($){
$.fn.vTicker = function(options) {
	var defaults = {
		speed: 700,
		pause: 4000,
		showItems: 3,
		animation: '',
		mousePause: true,
		isPaused: false
	};

	var options = $.extend(defaults, options);

	moveUp = function(obj2, height){
		if(options.isPaused)
			return;

		var obj = obj2.children('ul');

    	first = obj.children('li:first').clone(true);

    	obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
        	$(this).children('li:first').remove();
        	$(this).css('top', '0px');
        });

		if(options.animation == 'fade')
		{
			obj.children('li:first').fadeOut(options.speed);
			obj.children('li:last').hide().fadeIn(options.speed);
		}

    	first.appendTo(obj);
	};

	return this.each(function() {
		var obj = $(this);
		var maxHeight = 0;

		obj.css({overflow: 'hidden', position: 'relative'})
			.children('ul').css({position: 'absolute', margin: 0, padding: 0})
			.children('li').css({margin: 0, padding: 0});

		obj.children('ul').children('li').each(function(){
			if($(this).height() > maxHeight)
			{
				maxHeight = $(this).height();
			}
		});

		obj.children('ul').children('li').each(function(){
			$(this).height(maxHeight);
		});

		obj.height(maxHeight * options.showItems);

    	var interval = setInterval(function(){moveUp(obj, maxHeight);}, options.pause);

		if(options.mousePause)
		{
			obj.bind("mouseenter",function(){
				options.isPaused = true;
			}).bind("mouseleave",function(){
				options.isPaused = false;
			});
		}
	});
};
})(jQuery);

/**
 * edge.js 1.41 (21-Mar-2009)
 * (c) by Christian Effenberger
 * All Rights Reserved
 * Source: edge.netzgesta.de
 * Distributed under Netzgestade Software License Agreement
 * http://www.netzgesta.de/cvi/LICENSE.txt
 * License permits free of charge
 * use on non-commercial and
 * private web sites only
**/

// the mask images must be set before loading "edge.js" !

if(typeof mask2load=="undefined") {var ina = true;var mask2load = new Array("");}

var tmp = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
if(tmp) var isIE = document.namespaces ? 1 : 0;

if(isIE) {
	if(document.namespaces['v']==null) {
		var e=["shape","shapetype","group","background","path","formulas","handles","fill","stroke","shadow","textbox","textpath","imagedata","line","polyline","curve","roundrect","oval","rect","arc","image"],s=document.createStyleSheet();
		for(var i=0; i<e.length; i++) {s.addRule("v\\:"+e[i],"behavior: url(#default#VML);");}document.namespaces.add("v","urn:schemas-microsoft-com:vml");
	}
}

if(document.images) {
	var maskimg = new Array();
	var mimgCount = 0;var mi, mtimerID;
	var loadedmask = new Array();
}

function preloadImages() {
	for(mi=0; mi<mask2load.length; mi++) {
		maskimg[mi] = new Image();
		maskimg[mi].src = mask2load[mi];
	}
	for(mi=0; mi<maskimg.length; mi++) {
		loadedmask[mi] = false;
	}
	checkMaskImgLoad();
}

function checkMaskImgLoad() {
	if(ina==true || mimgCount==maskimg.length || maskimg[0].src=='') {
		if(isIE){
			addIEdges();
			return;
		}else {
			addEdges();
			return;
		}
	}
	for(mi=0; mi<=maskimg.length; mi++) {
		if(loadedmask[mi] == false && maskimg[mi].complete) {
			loadedmask[mi] = true;mimgCount++;
		}
	}
	mtimerID = setTimeout("checkMaskImgLoad()",10);
}

function getImages(className){
	var children = document.getElementsByTagName('img');
	var elements = new Array();var i = 0;
	var child;var classNames;var j = 0;
	for (i=0;i<children.length;i++) {
		child = children[i];
		classNames = child.className.split(' ');
		for (var j = 0; j < classNames.length; j++) {
			if (classNames[j] == className) {
				elements.push(child);
				break;
			}
		}
	}
	return elements;
}

function getClasses(classes,string){
	var temp = '';
	for (var j=0;j<classes.length;j++) {
		if (classes[j] != string) {
			if (temp) {
				temp += ' '
			}
			temp += classes[j];
		}
	}
	return temp;
}

function getClassValue(classes,string){
	var temp = 0;var pos = string.length;
	for (var j=0;j<classes.length;j++) {
		if (classes[j].indexOf(string) == 0) {
			temp = Math.min(classes[j].substring(pos),100);
			break;
		}
	}
	return Math.max(0,temp);
}

function getClassAttribute(classes,string){
	var temp = 0;var pos = string.length;
	for (var j=0;j<classes.length;j++) {
		if (classes[j].indexOf(string) == 0) {
			temp = 1;break;
		}
	}
	return temp;
}

function setRadialStyle(ctx,x1,y1,r1,x2,y2,r2,o,c,i) {
	var sg = (i==true?o:0), eg = (i==true?0:o);
	var tmp = ctx.createRadialGradient(x1,y1,r1,x2,y2,r2);
	tmp.addColorStop(0,'rgba('+c+','+c+','+c+','+sg+')');
	tmp.addColorStop(1,'rgba('+c+','+c+','+c+','+eg+')');
	return tmp;
}

function setLinearStyle(ctx,x,y,w,h,o,c,i) {
	var sg = (i==true?o:0), eg = (i==true?0:o);
	var tmp = ctx.createLinearGradient(x,y,w,h);
	tmp.addColorStop(0,'rgba('+c+','+c+','+c+','+sg+')');
	tmp.addColorStop(1,'rgba('+c+','+c+','+c+','+eg+')');
	return tmp;
}

function addMask(ctx,x,y,w,h,r,o,c,i){
	var style;var os = r, p = Math.round(r/8);
	ctx.fillStyle = 'rgba('+c+','+c+','+c+','+o+')';
	if(i) {ctx.beginPath();ctx.rect(x+r,y+r,w-(r*2),h-(r*2));ctx.closePath();ctx.fill();}
	if(window.opera && !i) {
		ctx.beginPath();ctx.moveTo(x,y);ctx.lineTo(x,y+r);ctx.quadraticCurveTo(x+p,y+p,x+r,y);ctx.closePath();ctx.fill();
		ctx.beginPath();ctx.moveTo(x+w,y);ctx.lineTo(x+w,y+r);ctx.quadraticCurveTo(x+w-p,y+p,x+w-r,y);ctx.closePath();ctx.fill();
		ctx.beginPath();ctx.moveTo(x+w,y+h);ctx.lineTo(x+w,y+h-r);ctx.quadraticCurveTo(x+w-p,y+h-p,x+w-r,y+h);ctx.closePath();ctx.fill();
		ctx.beginPath();ctx.moveTo(x,y+h);ctx.lineTo(x,y+h-r);ctx.quadraticCurveTo(x+p,y+h-p,x+r,y+h);ctx.closePath();ctx.fill();
	}
	ctx.beginPath();ctx.rect(x+r,y,w-(r*2),os);ctx.closePath();style = setLinearStyle(ctx,x+r,y+os,x+r,y,o,c,i);ctx.fillStyle = style;ctx.fill();
	ctx.beginPath();ctx.rect(x,y,r,r);ctx.closePath();style = setRadialStyle(ctx,x+r,y+r,r-os,x+r,y+r,r,o,c,i);ctx.fillStyle = style;ctx.fill();
	ctx.beginPath();ctx.rect(x,y+r,os,h-(r*2));ctx.closePath();style = setLinearStyle(ctx,x+os,y+r,x,y+r,o,c,i);ctx.fillStyle = style;ctx.fill();
	ctx.beginPath();ctx.rect(x,y+h-r,r,r);ctx.closePath();style = setRadialStyle(ctx,x+r,y+h-r,r-os,x+r,y+h-r,r,o,c,i);ctx.fillStyle = style;ctx.fill();
	ctx.beginPath();ctx.rect(x+r,y+h-os,w-(r*2),os);ctx.closePath();style = setLinearStyle(ctx,x+r,y+h-os,x+r,y+h,o,c,i);ctx.fillStyle = style;ctx.fill();
	ctx.beginPath();ctx.rect(x+w-r,y+h-r,r,r);ctx.closePath();style = setRadialStyle(ctx,x+w-r,y+h-r,r-os,x+w-r,y+h-r,r,o,c,i);ctx.fillStyle = style;ctx.fill();
	ctx.beginPath();ctx.rect(x+w-os,y+r,os,h-(r*2));ctx.closePath();style = setLinearStyle(ctx,x+w-os,y+r,x+w,y+r,o,c,i);ctx.fillStyle = style;ctx.fill();
	ctx.beginPath();ctx.rect(x+w-r,y,r,r);ctx.closePath();style = setRadialStyle(ctx,x+w-r,y+r,r-os,x+w-r,y+r,r,o,c,i);ctx.fillStyle = style;ctx.fill();
}

function checkGifVersion(num) {
	var tmp, str, i, t, n, p, s;
	t = maskimg[num].src.split("/");n = t[t.length-1].toLowerCase();
	p = n.split(".");s = p[p.length-1];p = n.slice(0, n.length-s.length-1);
	if(s!='gif') {
		for(i=0; i<maskimg.length; i++) {
			tmp = maskimg[i].src.toLowerCase();str = tmp.lastIndexOf(p+'.gif');if(str >= 0) {return i;}
		}return -1;
	}else {return num;}
}

function applyMask() {
	var ia = document.getElementById("img_a");var ib = document.getElementById("img_b");
	if(ia!=null && ib!=null){
		ia.filters[0].Apply();ia.innerHTML = ib.innerHTML;ia.filters[0].Play();
		ia.filters['DXImageTransform.Microsoft.Compositor'].Function=6;ia.id = "";ib.id = "";
		return;
	}else {setTimeout("applyMask()",10);}
}

function addIEdges() {
	var theimages = getImages('edges');
	var image, object, canvas, display, head, fill, foot, map, flt, i, pos, tpa, tpb, ia, ib, source;
	var inbuilt = 0;var imask = 0;var classes = '';var newClasses = '';
	for (i=0;i<theimages.length;i++) {
		image = theimages[i];object = image.parentNode;
		classes = image.className.split(' ');map = '';
		imask = getClassValue(classes,"imask");
		inbuilt = getClassAttribute(classes,"inbuilt");
		newClasses = getClasses(classes,"edges");
		display = (image.currentStyle.display.toLowerCase()=='block')?'block':'inline-block';
		canvas = document.createElement(['<var style="zoom:1;overflow:hidden;display:' + display + ';width:' + image.width + 'px;height:' + image.height + 'px;padding:0;">'].join(''));
		flt = image.currentStyle.styleFloat.toLowerCase();
		display = (flt=='left'||flt=='right')?'inline':display;
		head = '<v:group style="zoom:1; display:' + display + '; margin:-1px 0 0 -1px; padding:0; position:relative; width:' + image.width + 'px;height:' + image.height + 'px;" coordsize="' + image.width + ',' + image.height + '">';
		fill = '<v:rect strokeweight="0" filled="t" stroked="f" fillcolor="#ffffff" style="zoom:1;margin:-1px 0 0 -1px;padding: 0;display:block;position:absolute;top:0px;left:0px;width:' + image.width + 'px;height:' + image.height + 'px; filter:Alpha(opacity=100, finishopacity=0, style=3);"><v:fill src="' + image.src + '" type="frame" /></v:rect>';
		if(image.getAttribute("usemap")) map = '<img usemap="'+image.getAttribute('usemap')+'" src="'+image.src+'" border="0" style="filter:Alpha(opacity=0); position:absolute; margin:0; padding:0; top:0; left:0; width:'+image.width+'px; height:'+image.height+'px;" />';
		foot = '</v:group>';
		if(typeof(window['mask2load'])!="undefined" && !ina && imask>=0) {pos = checkGifVersion(imask);
			if(maskimg[pos].width>0 && maskimg[pos].height>0 && inbuilt!=1 && pos>=0) {
				source = maskimg[pos].src;
				head = '<v:group style="zoom:1; display:'+display+';margin:0;padding:0;position:relative;width:'+image.width+'px;height:'+image.height+'px;" coordsize="'+image.width+','+image.height+'">';
				tpb = '<div id="img_b" style="margin:0;padding:0;position:absolute;top:0;left:0;width:'+image.width+'px;height:'+image.height+'px;display:none;"><img src="'+source+'" width="'+image.width+'" height="'+image.height+'" /></div>';
				tpa = '<div id="img_a" style="margin:0;padding:0;position:absolute;top:0;left:0;width:'+image.width+'px;height:'+image.height+'px; filter:progid:DXImageTransform.Microsoft.Compositor(Function=4);"><img src="'+image.src+'" width="'+image.width+'" height="'+image.height+'" /></div>';
				canvas.innerHTML = head+tpb+tpa+map+foot;applyMask();
			} else {
				canvas.innerHTML = head+fill+fill+fill+fill+fill+fill+map+foot;
			}
		} else {
			canvas.innerHTML = head+fill+fill+fill+fill+fill+fill+map+foot;
		}
		canvas.className = newClasses;
		canvas.style.cssText = image.style.cssText;
		canvas.style.height = image.height+'px';
		canvas.style.width = image.width+'px';
		canvas.height = image.height;
		canvas.width = image.width;
		canvas.src = image.src;canvas.alt = image.alt;
		if(image.id!='') canvas.id = image.id;map = '';
		if(image.title!='') canvas.title = image.title;
		if(image.getAttribute('onclick')!='') canvas.setAttribute('onclick',image.getAttribute('onclick'));
		object.replaceChild(canvas,image);
	}
}

function addEdges() {
	var theimages = getImages('edges');
	var image;var object;var canvas;var context;
	var isize = 0;var inbuilt = 0;var imask = 0;
	var classes = '';var newClasses = '';var radius;
	var maxdim = 0;var mindim = 0;var i;
	for (i=0;i<theimages.length;i++) {
		image = theimages[i];object = image.parentNode;
		radius = Math.round((image.width+image.height)/20);
		canvas = document.createElement('canvas');
		if (canvas.getContext) {
			classes = image.className.split(' ');
			isize = getClassValue(classes,"isize");
			imask = getClassValue(classes,"imask");
			inbuilt = getClassAttribute(classes,"inbuilt");
			newClasses = getClasses(classes,"edges");
			canvas.className = newClasses;
			canvas.style.cssText = image.style.cssText;
			canvas.style.height = image.height+'px';
			canvas.style.width = image.width+'px';
			canvas.height = image.height;
			canvas.width = image.width;
			canvas.src = image.src;canvas.alt = image.alt;
			if(image.id!='') canvas.id = image.id;
			if(image.title!='') canvas.title = image.title;
			if(image.getAttribute('onclick')!='') canvas.setAttribute('onclick',image.getAttribute('onclick'));
			maxdim = Math.min(canvas.width,canvas.height)/2;
			mindim = (isize==0?radius:isize);
			isize = Math.min(maxdim,mindim);
			imask = Math.min(imask,maskimg.length-1);
			context = canvas.getContext("2d");
			if(image.getAttribute("usemap")) {
				object.style.position = 'relative';
				object.style.height = image.height+'px';
				object.style.width = image.width+'px';
				canvas.left = 0;canvas.top = 0;
				canvas.style.position = 'absolute';
				canvas.style.left = 0 + 'px';
				canvas.style.top = 0 + 'px';
				image.left = 0;image.top = 0;
				image.style.position = 'absolute';
				image.style.height = image.height+'px';
				image.style.width = image.width+'px';
				image.style.left = 0 + 'px';
				image.style.top = 0 + 'px';
				image.style.opacity = 0;
				object.insertBefore(canvas,image);
			}else {
				object.replaceChild(canvas,image);
			}
			context.clearRect(0,0,canvas.width,canvas.height);
			context.globalCompositeOperation = "source-over";
			context.drawImage(image,0,0,canvas.width,canvas.height);
			context.globalCompositeOperation = "destination-out";
			if(maskimg[imask].width>0 && maskimg[imask].height>0 && inbuilt!=1) {
				context.drawImage(maskimg[imask],0,0,canvas.width,canvas.height);
			} else {
				addMask(context,0,0,canvas.width,canvas.height,isize,1,0);
			}
			canvas.style.visibility = 'visible';
		}
	}
}

var edgesOnload = window.onload;
window.onload = function () {if(edgesOnload) edgesOnload();preloadImages();}
