_search=function(){
	return false;
};
_news=function(){
	var email=encodeURIComponent($('.emailx:last').val());
	var http = false;

	if(navigator.appName == "Microsoft Internet Explorer") {
	  http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	  http = new XMLHttpRequest();
	}

	http.open("GET", "ajax.php?action=addnews&email="+email);
	http.onreadystatechange=function() {
	  if(http.readyState == 4 && http.status == 200) {
		switch (http.responseText){
			case "0":
			alert('Lütfen geçerli bir e-posta adresi yazınız.');
			break;
			case "1":
			alert('E-Bülten kaydınız yapıldı.');
			break;
		}
	  }
	};
	http.send(null);
	return false;
};
_switch_language=function(e){
	if(e>0){
		var params='&language=english';
	} else {
		var params='';
	}
	if(navigator.appName == "Microsoft Internet Explorer") {
	  http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	  http = new XMLHttpRequest();
	}

	http.open("GET", "language.php?action=switch"+params);
	http.onreadystatechange=function() {
	  if(http.readyState == 4 && http.status == 200) {
			document.location=top.location;
	  }
	};
	http.send(null);
	return false;
};
ATSWF = function (){
	ScrollArrow('right','navigation','scroller','frame1-pane');
};
ATSWF2 = function (){
	ScrollArrow('right','navigation2','scroller2','sframe1-pane');
};
sineInOut =function (t, b, c, d)
{
	return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
};

getSize = function() {
	if (document.all) {
		myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	} else {
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	}
    if (window.innerHeight && window.scrollMaxY) {	
        myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	} else {
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
};
findElementPos = function (elemFind)
{
	var elemX = 0;
	var elemY = 0;
	do {
		elemX += elemFind.offsetLeft;
		elemY += elemFind.offsetTop;
	} while ( elemFind = elemFind.offsetParent );
	return Array(elemX, elemY);
};


var currentSection = "frame1-pane";
var h_s = "-tab";
var f_s = "-pane";

var currentSection2 = "sframe1-pane";
var h_s2 = "-tab";
var f_s2 = "-pane";

ScrollSection = function (link, scrollArea, offset){
	if (currentSection == link) {
		return;
	}
	lastSection = currentSection;
	currentSection = link;
    sectionTab = currentSection.split("-")[0] + h_s;
    document.getElementById(sectionTab).className = "selected";
    if (lastSection) {
	    lastTab = lastSection.split("-")[0] + h_s;
	    document.getElementById(lastTab).className = "normal";
	}
	theScroll = document.getElementById(scrollArea);
	position = findElementPos(document.getElementById(link));
	if (offset != "") {
		offsetPos = findElementPos(document.getElementById(offset));
		position[0] = position[0] - offsetPos[0];
	}
	scrollStart(theScroll, theScroll.scrollLeft, position[0], "horiz");
};
ScrollArrow = function (direction, toolbar, scrollArea, offset) {
	toolbarElem = document.getElementById(toolbar);
	toolbarNames = new Array();
	if (toolbarElem.hasChildNodes())
	{
		var children = toolbarElem.childNodes;
		for (var i = 0; i < children.length; i++) 
		{
			if (toolbarElem.childNodes[i].tagName == "A") {
				toolbarNames.push(toolbarElem.childNodes[i].id.split("-")[0]);
			}
		}
	}
	for (var i = 0; i < toolbarNames.length; i++) {
		if (toolbarNames[i] == currentSection.split("-")[0]) {
			if (direction == "left") {
				if (i - 1 < 0) {
					gotoTab = toolbarNames[toolbarNames.length - 1];
				} else {
					gotoTab = toolbarNames[i - 1];
				}
			} else {
				if ((i + 1) > (toolbarNames.length - 1)) {
					gotoTab = toolbarNames[0];
				} else {
					gotoTab = toolbarNames[i + 1];
				}
			}
		}
	}
	ScrollSection(gotoTab+f_s, scrollArea, offset);
};

var scrollanim = {time:0, begin:0, change:0.0, duration:0.0, element:null, timer:null};

scrollStart=function(elem, start, end)
{
	if (scrollanim.timer != null) {
		clearInterval(scrollanim.timer);
		scrollanim.timer = null;
	}
	scrollanim.time = 0;
	scrollanim.begin = start;
	scrollanim.change = end - start;
	scrollanim.duration = 25;
	scrollanim.element = elem;
	scrollanim.timer = setInterval("scrollHorizAnim();", 15);
};

scrollHorizAnim=function()
{
	if (scrollanim.time > scrollanim.duration) {
		clearInterval(scrollanim.timer);
		scrollanim.timer = null;
	}
	else {
		move = sineInOut(scrollanim.time, scrollanim.begin, scrollanim.change, scrollanim.duration);
		scrollanim.element.scrollLeft = move;
		scrollanim.time++;
	}
};
ScrollSection2 = function (link, scrollArea, offset){
	if (currentSection2 == link) {
		return;
	}
	lastSection = currentSection2;
	currentSection2 = link;
    sectionTab = currentSection2.split("-")[0] + h_s2;
    document.getElementById(sectionTab).className = "selected";
    if (lastSection) {
	    lastTab = lastSection.split("-")[0] + h_s2;
	    document.getElementById(lastTab).className = "normal";
	}
	theScroll = document.getElementById(scrollArea);
	position = findElementPos(document.getElementById(link));
	if (offset != "") {
		offsetPos = findElementPos(document.getElementById(offset));
		position[0] = position[0] - offsetPos[0];
	}
	scrollStart2(theScroll, theScroll.scrollLeft, position[0], "horiz");
};
ScrollArrow2 = function (direction, toolbar, scrollArea, offset) {
	toolbarElem = document.getElementById(toolbar);
	toolbarNames = new Array();
	if (toolbarElem.hasChildNodes())
	{
		var children = toolbarElem.childNodes;
		for (var i = 0; i < children.length; i++) 
		{
			if (toolbarElem.childNodes[i].tagName == "A") {
				toolbarNames.push(toolbarElem.childNodes[i].id.split("-")[0]);
			}
		}
	}
	for (var i = 0; i < toolbarNames.length; i++) {
		if (toolbarNames[i] == currentSection2.split("-")[0]) {
			if (direction == "left") {
				if (i - 1 < 0) {
					gotoTab = toolbarNames[toolbarNames.length - 1];
				} else {
					gotoTab = toolbarNames[i - 1];
				}
			} else {
				if ((i + 1) > (toolbarNames.length - 1)) {
					gotoTab = toolbarNames[0];
				} else {
					gotoTab = toolbarNames[i + 1];
				}
			}
		}
	}
	ScrollSection2(gotoTab+f_s2, scrollArea, offset);
};
var scrollanim2 = {time:0, begin:0, change:0.0, duration:0.0, element:null, timer:null};

scrollStart2=function(elem, start, end)
{
	if (scrollanim2.timer != null) {
		clearInterval(scrollanim2.timer);
		scrollanim2.timer = null;
	}
	scrollanim2.time = 0;
	scrollanim2.begin = start;
	scrollanim2.change = end - start;
	scrollanim2.duration = 25;
	scrollanim2.element = elem;
	scrollanim2.timer = setInterval("scrollHorizAnim2();", 15);
};

scrollHorizAnim2=function()
{
	if (scrollanim2.time > scrollanim2.duration) {
		clearInterval(scrollanim2.timer);
		scrollanim2.timer = null;
	}
	else {
		move2 = sineInOut(scrollanim2.time, scrollanim2.begin, scrollanim2.change, scrollanim2.duration);
		scrollanim2.element.scrollLeft = move2;
		scrollanim2.time++;
	}
};

$(document).ready(function(){
	$('.nav_trigger').mouseover(function(){
		var id=$(this).attr('id');
		$('.submenux[id!='+id+']').animate({'height':'0px'},200).attr('data-open','0');
		var newid=id.split('_link');
		var sd=$('#'+newid[0]+' .line').size()*31;
		$('#'+newid[0]).animate({'height':sd+'px'},200).attr('data-open','1');
	}).mouseout(function(){
		setTimeout("$('.submenux[data-open!=\"1\"]').animate({'height':'0px'},200);",200);
		$('.submenux').attr('data-open','0');
	});
	$('.submenux').mouseover(function(){
		var parent=$(this).attr('id')+'_link';
		$('#'+parent).css('background-image','url(_img/nav_0.gif)');
		$(this).attr('data-open','1');
	}).mouseout(function(){
		var parent=$(this).attr('id')+'_link';
		$('#'+parent).css('background-image','');
		$(this).attr('data-open','');
		setTimeout("$('.submenux[data-open!=\"1\"]').animate({'height':'0px'},200);",200);
	});
	$('.line').mouseover(function(){
		$(this).css('background-position','0 -31px');
	}).mouseout(function(){
		$(this).css('background-position','0 0');
	});
});