//Adobe Flash Scripts
function createSWF(swf_id,swf_src,swf_w,swf_h){
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', swf_w,
			'height', swf_h,
			'src', swf_src,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', swf_id,
			//'bgcolor', '#ffffff',
			'name', swf_id,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', swf_src,
			'salign', ''
			); //end AC code
	}
}
function openHeaderBig(){
	$("#header_big").height(510);
}
function closeHeaderBig(){
	$("#header_big").height(167);
}

//Ajax Box Scripts
$(document).ready(ab_launch); 
function ab_launch() {
$("a.ajax_box").click(function(){
  var t = this.title || this.innerHTML || this.href;
  var urlString = /.jpg|.JPG|.jpeg|.JPEG|.png|.PNG|.gif|.GIF|.bmp|.BMP|.swf|.SWF|.flv|.FLV|.mp3|.MP3/g;
	var urlType = this.href.match(urlString);
	
	if($(this).hasClass("ab_type_custom")){
		urlType ='custom';
	}
	
	if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif'
		|| urlType == '.JPG' || urlType == '.JPEG' || urlType == '.PNG' || urlType == '.GIF'
		|| urlType == '.bmp' || urlType == '.BMP'){
		ab_open(this.href,'img',t,1);
	}else if(urlType == 'custom'){
		ab_open(this.href,'custom',t);
	}else{
		ab_open(this.href,'url',t);
	}
  
  this.blur();
  return false;
});
}

function ab_close(sp){
	if(sp==1){
		$("#ab_window").hide();
		$('#ab_window,#ab_overlay').remove();
	}else{
		$("#ab_window").fadeOut("fast",function(){
			$('#ab_window,#ab_overlay').remove();
		}); 
	}
	return false;
}
function ab_position() {
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
  
  	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}
  	
  	if (window.innerWidth && window.scrollMaxX) {	
		xScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
  	}
	ab_win_W = $("#ab_window").width();
	ab_win_H = $("#ab_window").height();
	tx = (w - ab_win_W)/2 + document.documentElement.scrollLeft;
	ty = (h - ab_win_H)/2 + document.documentElement.scrollTop;
	if(tx<0){
		tx = 0;
	}
	if(ty<0){
		ty = 0;
	}
	$("#ab_window").css({left: tx+"px", top: ty+"px" });
	$("#ab_overlay").css("height",yScroll +"px");
}
function ab_open(url,contentType,contentTitle,closeButton){
	$(".banner_container").hide();
	$("body").append('<div id="ab_overlay" class="ab_overlay_'+contentType+'"></div><div id="ab_window"></div>');
	if(contentType == 'img'){
		var imgPreloader = new Image();
			imgPreloader.onload = function(){
				$("#ab_window").append('<img id="ab_image" onclick="ab_position();" src="'+url+'" width="'+imgPreloader.width+'" height="'+imgPreloader.height+'" alt="'+contentTitle+'"/>');
				$("#ab_window").append('<div class="fbhz">&nbsp;</div>');
				$("#ab_window").append('<a href="javascript:void(0);" onclick="ab_close();" class="ab_box_close_button_big"><span>kapat</span></a>');
				ab_position();
				$("#ab_window").slideDown("normal"); 
			}
	  
			imgPreloader.src = url;
	}else if(contentType == 'url'){
		$("#ab_window").append('<div class="ab_box"><div class="ab_box_top"></div><div class="ab_box_middle"><div class="ab_box_content" id="ab_box_content"></div></div><div class="ab_box_bottom"></div></div>');
		$("#ab_box_content").load(url, function(){
			ab_position();
			$("#ab_window").fadeIn("normal");
			});
	}else if(contentType == 'txt'){
		$("#ab_window").append(url);
		ab_position();
		$("#ab_window").fadeIn("normal");
	}else if(contentType == 'not'){
		$("#ab_window").append('<div class="ab_box"><div class="ab_box_top"></div><div class="ab_box_middle"><div class="ab_box_content" id="ab_box_content"></div></div><div class="ab_box_bottom"></div></div>');
		$("#ab_box_content").append(url);
		ab_position();
		$("#ab_window").fadeIn("normal");
	}else if(contentType == 'custom'){
		$("#ab_window").append('<div class="ab_box_content_custom" id="ab_box_content"></div>');
		$("#ab_box_content").load(url, function(){
			ab_position();
			$("#ab_window").fadeIn("normal");
			});
		ab_position();
		$("#ab_window").slideDown("normal");
	}else if(contentType == 'html'){
		$("#ab_window").append(url);
		ab_position();
		$("#ab_window").fadeIn("normal");
	}else if(contentType == 'html_wbg'){
		$("#ab_window").append(url);
		ab_position();
		$("#ab_window").fadeIn("normal");
	}
	
	if(closeButton==1){
		$("#ab_window").append('<a class="ab_box_close_button" href="javascript:void(0);" onclick="ab_close();"><span>kapat</span></a>');
	}
	ab_position();
	$(window).resize(ab_position());
	if(contentType != 'html' && contentType != 'html_wbg'){
		$("#ab_overlay").click(ab_close);
	}
}

/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 


this.tooltip = function(){
	/* CONFIG */		
		xOffset = -42;
		yOffset = 0;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$(".tooltip").hover(function(e){											  
		this.t = this.title || this.alt;
		$("#tooltip_container .ttc_body").html(this.t);
		yOffset = $("#tooltip_container").height()+28;
		$("#tooltip_container")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.show();		
    },
	function(){
		$("#tooltip_container").hide();
    });	
	$(".tooltip").mousemove(function(e){
		$("#tooltip_container")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});