$(document).ready(function(){
	Cufon.replace('.wrapper .navigation ul li a.h',{textShadow: '#000 1px 1px',hover: true });
	Cufon.replace('.footer ul li a.h',{textShadow: '#000 1px 1px',hover: true });
	Cufon.replace('.g h2',{textShadow: '#000 1px 1px'});
	$('.navigation ul li.subbed').mouseover(function(){
		var wi=$(this).width();
		$(this).addClass('nav_hover');
		$(this).find('a:first').css('color','#147d4b');
		$(this).find('.sub').css('display','block');
		$(this).find('.topi').css('width',(wi-2)+'px');
	}).mouseout(function(){
		$(this).removeClass('nav_hover');
		$(this).find('.sub').css('display','none');
		$(this).find('a:first').css('color','#FFFFFF');
	});
	_get_schedule(0);
	$('.photo_trig').click(function(){
		$('#video_holder').css('display','none');
		$('#gallery_holder').css('display','block');
		$('.photo_trig').removeClass('free').addClass('indicator');
		$('.video_trig').removeClass('indicator').addClass('free');
	});
	$('.video_trig').click(function(){
		$('#video_holder').css('display','block');
		$('#gallery_holder').css('display','none');
		$('.photo_trig').addClass('free').removeClass('indicator');
		$('.video_trig').addClass('indicator').removeClass('free');

	});
});
_get_schedule=function(id){
	$('#sc-loading').css('display','block');
	$.ajax({
		type: 'POST',
		url: 'index.php',
		data: 'engine=auto&action=schedule&id='+id,
		success: function(r) {
			$('#schedule').html(r);
				$('#sc-loading').css('display','none');
		}
	});
}
function ADDC(){
	var error=0;
	var params=$('#newcomment').serializeArray();
	jQuery.each( params, function(i, field){
	  if(!field.value){
		  error++;
	  }
	});
	if(!error){
		var params=$('#newcomment').serialize();
		jQuery.post( 'yorumekle', params,
			function(r){
				if(r!="1"){
					$("#error").html(r).show("slow");
				} else {
					$("#error").css('width','auto').html('Yorumunuz onaylandıktan sonra yayınlanacaktır.<br />Teşekkür ederiz.').show("slow");
					$('#newcomment_div').slideToggle();
				}
			}
		);
	} else {
		$("#error").html('Lütfen tüm alanları doldurunuz!').show("slow");
	}
	return false;

}
route = function ( url ){
	if(url!="0"){
	window.location.href=url;
	}
}
ATSWF = function (){
	ScrollArrow('right','navigation','scroller','frame1-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";

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++;
	}
}
