$(document).ready(function(){
	
	var IS_IE_6 = $.browser.msie && $.browser.version < 7;
	
	$('.buttons a').hover(
		function(){
			$(this).find('span')
				.css({'display' : 'block', 'opacity':0, 'left': '-10px' })
				.animate({ 'left':0, 'opacity': 1 }, 250)
		},
		function(){
			$(this).find('span').fadeOut('fast');
		}
	);
	
	$('.buttons a').click(function(){
		var to = $(this).attr('href');
		$.scrollTo(to, 1200);
		return false;
	});
	
	/** Animation **/
	for( var i in items) {
		$(items[i]).hide();
	}
	//_animate(0, 700);
	
	$('.island').fadeIn( 'slow', function(){ 
		$('.ships').fadeIn( function(){
			$('.about-link, .portfolio-link, .contact-link, .tr-link, .en-link').fadeIn();
			
			if(IS_IE_6) {
				$('.balloon').show();
			}else {
				$('.balloon')
					.css({'display' : 'block', 'opacity':0, 'left': '800px' })
					.animate({ 'left':490, 'opacity': 1 }, 800, function(){
						$('.balloon').show();
					});	
			}
		});
	});

	$('.projects').jcarousel({ scroll: 1, wrap: 'both' });
	
	/** External **/
	$('a.external').click(function() {
		return !window.open(jQuery(this).attr('href'));
	});

	/** PrettyPhoto **/
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			opacity: 0.80, /* Value between 0 and 1 */
			showTitle: true, /* true/false */
			allowresize: true, /* true/false */
			default_width: 640,
			default_height: 500,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: true, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: true /* If set to true, only the close button will close the window */
		});

});

var items = ['.island', '.ships', '.balloon', '.about-link', '.portfolio-link', '.contact-link', '.tr-link', '.en-link'];

/** Form Validation **/
function invalidMail(email) {
var result = false
var theStr = new String(email)
var index = theStr.indexOf("@");
	if (index > 0) {
	var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
return result;
}

function validate(obj) {
	if (obj.name.value == '') {
		document.getElementById('reqName').innerHTML = "<strong>Name</strong>";
		document.getElementById('required').innerHTML = "What is your name?";
		obj.name.select();
		return false;
	}
	if (!obj.name.value == '') {
		document.getElementById('reqName').innerHTML = "Name";
	}
	if ( (obj.email.value == '') || (!invalidMail(obj.email.value)) ) {
		document.getElementById('reqMail').innerHTML = "<strong>Email</strong>";
		document.getElementById('required').innerHTML = "Please type your real address.";
		obj.email.select();
		return false;
		}
	if (!obj.email.value == '') {
		document.getElementById('reqMail').innerHTML = "Email";
	}
	if (obj.verification.value != 'white') {
		document.getElementById('reqVerification').innerHTML = "<strong>Color of snow</strong>";
		document.getElementById('required').innerHTML = "Please type the right answer in lowercase .";
		obj.verification.select();
		return false;
		}
	if (!obj.verification.value == '') {
		document.getElementById('reqVerification').innerHTML = "Color of snow";
		document.getElementById('required').innerHTML = "Allright!";
	}
	if (obj.message.value == '') {
		document.getElementById('message').value = "Hello m[e]s!";
	}
return true;
}

function spamNotice() {
		document.getElementById('required').innerHTML = "This is to confirm that you are not a robot.";
		}

function denetle(obj) {
	if (obj.name.value == '') {
		document.getElementById('reqName').innerHTML = "<strong>Ad</strong>";
		document.getElementById('required').innerHTML = "Adınız nedir?";
		obj.name.select();
		return false;
	}
	if (!obj.name.value == '') {
		document.getElementById('reqName').innerHTML = "Ad";
	}
	if ( (obj.email.value == '') || (!invalidMail(obj.email.value)) ) {
		document.getElementById('reqMail').innerHTML = "<strong>Eposta</strong>";
		document.getElementById('required').innerHTML = "Lütfen gerçek adresinizi girin.";
		obj.email.select();
		return false;
		}
	if (!obj.email.value == '') {
		document.getElementById('reqMail').innerHTML = "Eposta";
	}
	if (obj.verification.value != 'beyaz') {
		document.getElementById('reqVerification').innerHTML = "<strong>Kar ne renk</strong>";
		document.getElementById('required').innerHTML = "Lütfen doğru cevabı küçük harflerle girin.";
		obj.verification.select();
		return false;
		}
	if (!obj.verification.value == '') {
		document.getElementById('reqVerification').innerHTML = "Kar ne renk";
		document.getElementById('required').innerHTML = "Hepsi tamam!";
	}
	if (obj.message.value == '') {
		document.getElementById('message').value = "Merhaba m[e]s!";
	}
return true;
}

function spamNotu() {
		document.getElementById('required').innerHTML = "Bu soru robot olmadığınızı doğrulamak içindir.";
		}

/** StatCounter **/
var sc_project=5408945;
var sc_invisible=1;
var sc_partition=53;
var sc_click_stat=1;
var sc_security="f75ba4c3";