//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|.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'){
			ab_open(this.href,'img',t);
		}else if(urlType == 'custom'){
			ab_open(this.href,'custom',t);
		}else{
			ab_open(this.href,'url',t);
		}
	  
	  this.blur();
	  return false;
	});
	$("a.ajax_box_dblclick").click(function(){
	  this.blur();
	  return false;
	});
	$("a.ajax_box_dblclick").dblclick(function(){
	  var t = this.title || this.innerHTML || this.href;
	  var urlString = /.jpg|.JPG|.jpeg|.JPEG|.png|.PNG|.gif|.GIF|.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'){
			ab_open(this.href,'img',t);
		}else if(urlType == 'custom'){
			ab_open(this.href,'custom',t);
		}else{
			ab_open(this.href,'url',t);
		}
	  
	  this.blur();
	  return false;
	});
}

function ab_close(){
	$("#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){
	$("body").append('<div id="ab_overlay" class="ab_overlay_'+contentType+'"></div><div id="ab_window" class="ab_window_'+contentType+'"></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="cbhz">&nbsp;</div>');
			$("#ab_window").append('<a href="javascript:void(0);" id="ab_close_button" class="ab_close_button"><span>KAPAT</span></a>');
			ab_position();
			$("#ab_window").slideDown("normal");
			$("#ab_close_button").click(ab_close); 
			}
	  	
			imgPreloader.src = url;
	}else if(contentType == 'url'){
		$("#ab_window").append('<div class="ab_box" style="background-color:#fff;"><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");
	}
	ab_position();
	$(window).resize(ab_position());
	$("#ab_overlay").click(ab_close);
}