$(document).ready(function(){

// !Hover Tick
	var audioTick = document.createElement('audio');
	audioTick.setAttribute('src', 'sound/tick.wav');
	audioTick.load()

// !Click Tack
	var audioTick = document.createElement('audio');
	audioTick.setAttribute('src', 'sound/tick.wav');
	audioTick.load()

  
// !Loop
	var loopitem = $('#cascom li');
	var fadein = 600;
	var fadeout = 1000;
	
	function loopit(i) {
     	if(i===7) {
			$(loopitem[i]).find('a').animate({ opacity: 0.75 }, fadein).animate({ opacity: 0.1 }, fadeout).animate({ opacity: 0 }, 2000);
			setTimeout(function() {
				loopit(0);
			}, 3500);
				
     	} else if(i<3) {
			$(loopitem[i]).find('a').delay(400).animate({ opacity: 0.75 }, fadein).animate({ opacity: 0.1 }, fadeout).animate({ opacity: 0 }, 2000);
			setTimeout(function() {
				loopit(i+1);
			}, 150);
     	} else {
			$(loopitem[i]).find('a').animate({ opacity: 0.75 }, fadein).animate({ opacity: 0.1 }, fadeout).animate({ opacity: 0 }, 2000);
			setTimeout(function() {
				loopit(i+1);
			}, 150);
			
		}
	}
	
	//loopit(0);

// !Init
	var loopimg = $('#cascom li');

	function dissolve(i) {
		if(i<8) {
			$(loopimg[i]).find('img').animate({ opacity: 0 }, fadeout);
			setTimeout(function() {
				dissolve(i+1);
			}, 150);				
		}
	}

	setTimeout(function() {
		//dissolve(0);
	}, 1500);				

	


// !Sound effects
	$('#cascom li a').hover(function () {
		audioTick.play();
		//$(this).parent().find('img').animate({ opacity: 1 },'fast');
		//$(this).parent().find('img').css('opacity', '1');
	},
	function() {
		//$(this).parent().find('img').animate({ opacity: 0.1 },'fast').animate({ opacity: 0 },'slow');
		//$(this).parent().find('img').css('opacity', '0');
	});

	$('#cascom a').click(function () {
		audioTack.play();
	});

// !Show Title
	$('#cascom').hover(function () {
		$(this).find('h1').animate({ opacity: 1 },'fast');
	},
	function() {
		$(this).find('h1').animate({ opacity: 0 },'fast');
	});

// !Translations
	$('#cascom #box-1 a').hover(function() {
		$('#cascom').addClass('pos-1')
	},
	function() {
		setTimeout(function() {
			$('#cascom').removeClass('pos-1')
		}, 100);				
	});

	$('#cascom #box-2 a').hover(function() {
		$('#cascom').addClass('pos-2')
	},
	function() {
		setTimeout(function() {
			$('#cascom').removeClass('pos-2')
		}, 100);				
	});

	$('#cascom #box-3 a').hover(function() {
		$('#cascom').addClass('pos-3')
	},
	function() {
		setTimeout(function() {
			$('#cascom').removeClass('pos-3')
		}, 100);				
	});

	$('#cascom #box-4 a').hover(function() {
		$('#cascom').addClass('pos-4')
	},
	function() {
		setTimeout(function() {
			$('#cascom').removeClass('pos-4')
		}, 100);				
	});

	$('#cascom #box-5 a').hover(function() {
		$('#cascom').addClass('pos-5')
	},
	function() {
		setTimeout(function() {
			$('#cascom').removeClass('pos-5')
		}, 100);				
	});

	$('#cascom #box-6 a').hover(function() {
		$('#cascom').addClass('pos-6')
	},
	function() {
		setTimeout(function() {
			$('#cascom').removeClass('pos-6')
		}, 100);				
	});

	$('#cascom #box-7').hover(function() {
		$('#cascom').addClass('pos-7')
	},
	function() {
		setTimeout(function() {
			$('#cascom').removeClass('pos-7')
		}, 100);				
	});

// !Menu
	$('#cascom .cascom').hover(function() {
		$('#cascom h1').text('Cas com0');
	},
	function() {
	});
	
	$('#cascom .archive').hover(function() {
		$('#cascom h1').text('Arc hive');
	},
	function() {
	});
	
	$('#cascom .blog').hover(function() {
		$('#cascom h1').text('Net Blog');
	},
	function() {
	});

	$('#cascom .c100').hover(function() {
		$('#cascom h1').text('kl. C100');
	},
	function() {
	});
	
	$('#cascom .mail').hover(function() {
		$('#cascom h1').text('Nat ive');
	},
	function() {
	});
	
	$('#cascom.firstpage').hover(function() {
	},
	function() {
		$('#cascom h1').text('Cas com0');
	});

// !Approach
//	$('#cascom h1').css('opacity', 0);
//	$('h1').approach({
//  		opacity: 1
//	}, 512);
//
//	$('#cascom a').css('opacity', 0);
//	$('a').approach({
//		opacity: 1
//	}, 512);


});
