/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Setting up the scene
 */

function reposition(){
	var screenW = $(window).width();

	var pageWidth = 1020;

	var diff = parseInt(screenW/2 - pageWidth /2);

	var logoX = diff + 30
	var logoY = 0;

	var charX = diff + 800;
	var charY = 600;

	$("#logo").css("left", logoX + "px");
	$("#logo").css("top", logoY + "px");

	$("#character").css("left", charX + "px");
	$("#character").css("top", charY + "px");

}

$(window).load(function(){

	reposition();

});

$(document).ready(function(){
	var locale = "en";
	reposition();

	$(window).resize(function(){
		reposition();
	});
	
	/* GET TO KNOW WHAT LANG IS BEING USED! */
	$.ajax ({
		type: "POST",
		url: "utils/getlocale.php",
		success: function(msg){
			locale = msg;
		}
	});

	$(".nav-item").mouseover(function(){
		$(this).css("padding-top", "1px");
		$(this).css("color" , "#e54607");
		$(this).css("border-bottom", "2px solid #ffcc00");
	});
	$(".nav-item").mouseout(function(){
		$(this).css("padding-top", "0px");
		$(this).css("color", "#ffcc00");
		$(this).css("border-bottom", "none");
	});

	$(".nav-item").click(function(){
		var page = $(this).attr("id");
		$(this).css("color", "#e54607");
		$(".nav").slideUp("slow", function(){
			window.location = page;
		});
	});
	
	$(".content").fadeIn("slow", function(){
		$(".nav").slideDown("slow");
	});


	/* EFFECTS FOR THE START BUTTONS */

	$(".gfx-button").mouseover(function(){
		var btn = $(this).attr("id");
		btn = btn.split("-");
		var buttonId = btn[0];
		$(this).attr("src", "images/buttons/" + buttonId + "_1_" + locale + ".png");
	});

	$(".gfx-button").mouseout(function(){
		var btn = $(this).attr("id");
		btn = btn.split("-");
		var buttonId = btn[0];
		$(this).attr("src", "images/buttons/" + buttonId + "_0_" + locale + ".png");
	});

	$(".helpTrigger").click(function(){
		if($(".helpBox").css("display") == "none"){
			$("#hideable").hide();
			$(".helpBox").slideDown();
		}
		else {
			$(".helpBox").slideUp();
			$("#hideable").fadeIn();
		}
	});

	/* LANGUAGE SELECTOR MOUSE OVER */

	$(".flag").mouseover(function(){
		$(this).css("filter:", "alpha(opacity=100)");
		$(this).css("opacity:", "1");
		$(this).css("-khtml-opacity", "1");
		$(this).css("-moz-opacity", "1");
		
	});

	$(".flag").mouseout(function(){
		$(this).css("filter:", "alpha(opacity=50)");
		$(this).css("opacity:", "0.5");
		$(this).css("-khtml-opacity", "0.5");
		$(this).css("-moz-opacity", "0.5");
	});


		$(".buttons").mouseover(function() {
		var fileName = $(this).attr("src");
		var tmpName = fileName.split(".");
		var name = tmpName[0];
		name = name.slice(0, name.length-2);
		name += "02";
		var newFileName = name + "." + tmpName[1];
		$(this).attr("src", newFileName);
	});

	$(".buttons").mouseout(function() {
		var fileName = $(this).attr("src");
		var tmpName = fileName.split(".");
		var name = tmpName[0];
		name = name.slice(0, name.length-2);
		name += "01";
		var newFileName = name + "." + tmpName[1];
		$(this).attr("src", newFileName);
	});



});
