$(document).ready(function(){
	$("#footer").jFooter("#container");	
	$(".menu-bottom a").bind("click", function(){
		location.href = "/default.aspx";
	});
	directLink();
	activeLink();
	execJFTR();
	initJPrompt();
	CheckPlayer();
});

/* flash player kontrolu */
function CheckPlayer() {
	var _img = "<img src=/images/no_flplayer.jpg border=0 />";
	var _href = "http://get.adobe.com/flashplayer/?promoid=BUIGP";
	if (getFlashPlayer()) {
		$(".menu").empty();
		$(".pattern").empty();
		$("#content").empty();
		$("<a href="+_href+" target=_blank></a>").html(_img).appendTo(".menu, .pattern, #content");
	}
}

/* window open*/
function winOpen(url) {
	window.open(url, "_blank", "fullscreen=yes");;
}

/* aktif menu ayarlari*/
function activeLink() {
	var _location = unescape(location.href);
	_location = escapeURL(_location);

	$(".menu-content ul li a").not(".menu-content ul li ul li a").each(function(){
		var $this = $(this);
		if (_location.indexOf((escapeURL(unescape($this.attr("href")))).split("?")[0]) != -1) {
			$this.addClass("selected");
			$this.parent().find("ul").css("display", "block");
			$this.parent().find("ul li a").each(function(){
				var _ahref = $(this);
				if (_location.indexOf(escapeURL(unescape(_ahref.attr("href")))) != -1)
					_ahref.addClass("selected");
			});
		}
		else {
			$this.removeClass();
			$this.parent().find("ul").css("display", "none");
		}
	});

	$(".content-head .jftr").text(_location.split("|")[1]);
}

/* direct link ayarlari*/
function directLink() {
	$(".customer-service").bind("click", function(){
		location.href = "/bizeulasin/iletisim-bilgileri.aspx";
	});
	
	$(".logo").bind("click", function(){
		location.href = "/default.aspx";
	});	
}

/* jFTR ayarlari*/
function execJFTR() {
	$(".content-head h1.jftr").jFTR({
		css: [ '* { color: #da261e; font-size: 36px; text-align: left }',
               'a { color: #0099CC; text-decoration: none; }',
               'a:hover { text-decoration: underline; }'
             ],
		src: "/_flash/avantgarde.swf"
	});
	
	$(".content-accordion-list li h1.jftr").jFTR({
		css: [ '* { color: #ffffff; font-size: 20px; text-align: left }',
               'a { color: #0099CC; text-decoration: none; }',
               'a:hover { text-decoration: underline; }'
             ],
		src: "/_flash/avantgarde.swf"
	});	
}
/*footer ayarlari settings:referans element*/
	$.fn.jFooter = function(settings) {
		var element = this;
			SetResize();
			$(window).bind("resize", function() {
				SetResize();
			});
			$(window).bind("load", function() {
				SetResize();
			});
			var ival = setInterval(SetResize, 1000/2);

	function SetResize() {
		var _footerHeight = $(element).height();
		var _refHeight = $(settings).height();
		var _winHeight = $(window).height()-20;//margin-top: 20px
		if ((_footerHeight+_refHeight) < _winHeight) {
				$(element).css({"margin-top":parseFloat((_winHeight)-(_footerHeight+_refHeight))+"px"});
		}
		else {
			$(element).css({"margin-top":"35px"});
		}
	  };
	  
	function isIE() {
		return $.browser.msie;
	}
};

/* hali temizlik  liste*/
$.fn.openinglist = function() {
	var _array = ["#a0","#a1","#a2","#a3","#a4","#a5"];
	$(_array.join(",")).hide();
	var $this = $(this);
	var _id = "a"+($this.attr("id"));
	var $object = $(".content-accordion-list #"+_id);
	$object.removeAttr("style");
	$object.css("display", "block");
	var _height = $object.height()+5;
	$object.height(0);
	$object.animate({
		height: _height
	},1000);
}

/* url escaper*/
function escapeURL(v) {
	v = v.replace(/Ã/ , "Ü");
	v = v.replace(/Ä°/, "İ");
	v = v.replace(/Ã/, "Ç");
	v = v.replace(/Ä/, "Ğ");
	return v;
}

function getFlashPlayer() {
	var $version = $().flash.hasFlash.playerVersion();
	return parseInt($version.split(",")[0]) < 9;
}