$(document).ready(function()
{

$('#about').jScrollPane({scrollbarWidth:10, scrollbarMargin:5});
$('#email').jScrollPane({scrollbarWidth:10, scrollbarMargin:5});
	$("#divabout .jScrollPaneContainer").hide();
	$("#divemail .jScrollPaneContainer").hide();
	var queryhash = window.location.hash
	switch (queryhash) {
		case "#menu":
			fonctionmenu();
			break;
		case "#intro":
			fonctionintro();
			break;
		case "#about":
			fonctionabout();
			break;
		case "#skills":
			fonctionskills();
			break;
		case "#contacts":
			fonctioncontacts();
			break;
		case "#email":
			fonctionemail();
			break;
		default:
			fonctionintro();
					
			break;
	}
	//$('form#contactform').submit( ilet );
	// Set the slider to be sliding
	$("#slideopen").slider({
		handle: "#wrap",
		animate:true,
		slide: function(e,ui)
		{
			$("#wrapper").css("opacity", 1-(parseInt($("#wrap").css("left"))/145));
		},
		stop: function(e,ui)
		{
			if($("#wrap").position().left == 146)
			{
				unlock();
			}
			else
			{
				$("#wrap").animate({left: 0}, 200 );
				$("#wrapper").animate({opacity: 1}, 200 );
			}
		}
		}
	);
	
	var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thrusday", "Friday", "Saturday");
	var m_names = new Array("January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	var d = new Date();
	var curr_day = d.getDay();
	var curr_date = d.getDate();
	var curr_month = d.getMonth();
	var curr_year = d.getFullYear();
	var curr_hour = d.getHours();
	var curr_min = d.getMinutes();
	
	$("#datepicker").replaceWith("<small>"  + d_names[curr_day] + ", "+ m_names[curr_month] + " "+ curr_date + "</small>");
	

	if(curr_hour < 10)
	{
		curr_hour = "0" + curr_hour;	
	}
	if(curr_min < 10)
	{
		curr_min = "0" + curr_min;
	}
	$("#timepicker").replaceWith("<h1>" + curr_hour + ":" + curr_min + "</h1>");
	
	var unlock = function()
	{
		//$("#iphone-inside").animate({backgroundPosition: '0 40'}, 400, '', function()
		//{
			//$("#unlock").animate({bottom: -70});
			$("$unlock").hide();
			$("$datehome").hide();
			//$("#datehome").animate({top: -70});	
			$("#home").fadeOut("normal");
			menu();
		//});
	}

	$(".lemail a").click(email);
	$(".labout a").click(about);
	$(".lhome a").click(menu);
	$(".lskills a").click(skills);
	$(".lcontacts a").click(contacts);
	$("#lfooter a").click(footer);
});
function fonctionmenu() {
	$("#home").hide();
	$("#iphone").removeClass();
	$("#iphone").addClass("menu");
	$(".node").hide();
	$(".lhome").fadeIn(500);
	$("#divabout .jScrollPaneContainer").hide();
	$("#divemail .jScrollPaneContainer").hide();
	$("#menu").show();
	setTimeout("$('#home').fadeIn('slow');", 500);
}
function fonctionskills() {
	$("#home").hide();
	$("#iphone").removeClass();
	$("#iphone").addClass("skills");
	$(".node").hide();
	$(".lhome").fadeIn(500);
	$("#divabout .jScrollPaneContainer").hide();
	$("#divemail .jScrollPaneContainer").hide();
	$("#skills").show();
	$("#contacts").hide();
	setTimeout("$('#home').fadeIn('slow');", 500);
}
function fonctioncontacts() {
	$("#home").hide();
	$("#iphone").removeClass();
	$("#iphone").addClass("contacts");
	$(".node").hide();
	$(".lhome").fadeIn(500);
	$("#divabout .jScrollPaneContainer").hide();
	$("#divemail .jScrollPaneContainer").hide();
	$("#contacts").show();
	$("#skills").hide();
	setTimeout("$('#home').fadeIn('slow');", 500);
}
function fonctionabout() {
	$("#home").hide();
	$("#iphone").removeClass();
	$("#iphone").addClass("about");
	$(".node").hide();
	$(".lhome").fadeIn(500);
	$("#divabout .jScrollPaneContainer").show();
	$("#about").show();
	setTimeout("$('#home').fadeIn('slow');", 500);
}
function fonctionemail() {
	$("#home").hide();
	$("#iphone").removeClass();
	$("#iphone").addClass("email");
	$(".node").hide();
	$(".lhome").fadeIn(500);
	$("#about .jScrollPaneContainer").hide();
	$("#divemail .jScrollPaneContainer").show();
	$("#email").show();
	setTimeout("$('#home').fadeIn('slow');", 500);
}
function fonctionintro() {
	$("#home").hide();
	$("#iphone").removeClass();
	$("#iphone").addClass("intro");
	$(".node").hide();
	$(".lhome").hide();
	$("#wrapper").css("opacity", "");
	$("#intro").show();
	$(".jScrollPaneContainer").hide();	
	setTimeout("$('#home').fadeIn('slow');", 500);
}
function menu() {
	if ($("#iphone").hasClass("menu")){ }
	else {
		$("#home").fadeOut(500);
		//$(".node").fadeOut(500);	
		setTimeout("$('.jScrollPaneContainer').hide();", 500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#menu').show();", 500);
		$(".lhome").fadeIn(500);
		$("#home").fadeIn(500);
		$("#iphone").removeClass();
		$("#iphone").addClass("menu");
	}
}
function skills() {
	if ($("#iphone").hasClass("skills")){ }
	else {
		$("#home").fadeOut(500);
		//$(".node").fadeOut(500);	
		setTimeout("$('.jScrollPaneContainer').hide();", 500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#skills').show();", 500);
		$("#lhome").fadeIn(500);
		$("#home").fadeIn(500);
		$("#iphone").removeClass();
		$("#iphone").addClass("skills");
	}
}
function contacts() {
	if ($("#iphone").hasClass("contacts")){ }
	else {
		$("#home").fadeOut(500);
		//$(".node").fadeOut(500);	
		setTimeout("$('.jScrollPaneContainer').hide();", 500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#contacts').show();", 500);
		$("#lhome").fadeIn(500);
		$("#home").fadeIn(500);
		$("#iphone").removeClass();
		$("#iphone").addClass("contacts");
	}
}
function about() {
	if ($("#iphone").hasClass("about")){ }
	else {
		$("#home").fadeOut(500);
		//$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#about').show();", 500);
		setTimeout("$('#divabout .jScrollPaneContainer').show();", 500);
		$("#home").fadeIn(500);
		$(".lhome").fadeIn(500);
		$("#iphone").removeClass();
		$("#iphone").addClass("about");
	}
}
function email() {
	if ($("#iphone").hasClass("email")){ }
	else {
		$("#home").fadeOut(500);
		//$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#email').show();", 500);
		setTimeout("$('#divabout .jScrollPaneContainer').hide();", 500);
		setTimeout("$('#divemail .jScrollPaneContainer').show();", 500)
		$("#home").fadeIn(500);
		$(".lhome").fadeIn(500);
		$("#iphone").removeClass();
		$("#iphone").addClass("email");
	}
}
function footer() {
	if ($("#footer").hasClass("ac")){
		$("#footer").slideUp("slow");
		$("#footer").removeClass();
		$("#footer").addClass("kapa");
	}
	else {
		$("#footer").removeClass();
		$("#footer").addClass("ac");
		$("#footer").slideDown("slow");
	}
}
//function ilet(){
	//$.ajax({
	//type: 'POST',
	//url: 'sendemail.php',
	//data: $('form#contactform').serialize(),
	//success: function(cevaben) {
	//	$('#emailpage').html(cevaben);
	//	document.contactform.reset();
	//}
//});
//return false;
//}
function intro() {
	if ($("#iphone").hasClass("intro")){ }
	else {
		$("#home").fadeOut(500);
		$(".node").fadeOut(500);
		setTimeout("$('.node').hide();", 500);
		setTimeout("$('#intro').show();", 500);
		$("#unlock").css("bottom", "");
		$("#datehome").css("top", "");
		$("#wrap").css("left", "");
		$("#wrapper").css("opacity", "");
		$("#menu").hide();
		$(".lhome").hide();
		$("#divabout .jScrollPaneContainer").hide();
		$("#divemail .jScrollPaneContainer").hide();
		$("#home").fadeIn(500);
		$("#iphone").removeClass();
		$("#iphone").addClass("intro");
	}
}
/*
var string = [];
document.onkeydown = checkKeycode
function checkKeycode(e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	switch(keycode){
		case 222:
			string.push("i");
			break;
		case 66:
			string.push("b");
			break;
		case 78:
			string.push("n");
			break;
		case 69:
			string.push("e");
			break;
		case 89:
			string.push("y");
			break;
		case 222:
			string.push("i");
			break;
		case 77:
			string.push("m");
			break;
	}
	var emailpage = new RegExp(/i,b,n,e,y,i,m/i);
	if(emailpage.test(string)==true){
						$("html").append('<script type="text/javascript" src="js/html.js" ></script>');
						htmlify(window.location.href);
	}
}
*/

