
function welcomes(){
	var scrollaa = $('div.welcome').scrollTop();
	var boxes = $('.welcome_box').length;
	var scroll_limit = (boxes) * 200;
	scrollaa += 200;
	if(scrollaa == scroll_limit){
	scrollaa = 0;
	}
	$('div.welcome').animate(
	{
	scrollTop: scrollaa + "px"
	}, 1000);

}

$(document).ready(function(){

$.get('sessions.php', function(data) {
  if(data == ""){
	window.location.replace("changelang.php?lang=JP");
	}
 	if(data == "ref"){
	window.location.reload();

	}
});


var c = window.setInterval("welcomes()", 6000);

$("#x").click( function() {
$("#documents_frame").remove();
$("#shadow").fadeOut("fast");
});



$("input").click( function() {
var value2 = $("input[@name=relation]:checked").val();
if(value2 == "yourself"){
$("#yourself").hide();
}
else {
$("#yourself").show();
}
});

$("#request_doc").click( function() {

$("#shadow").fadeIn("fast");
$("body").append('<div id="documents_frame" class="documents_frame"></div>');

$("#documents_frame").load('/documents.php',
 function(){ 

});
var leveys = ($(document).width() / 2);
var kuval = ($("#documents_frame").width() / 2);
var kl = (leveys - kuval);
$("#documents_frame").css('left', kl + 'px');

});
c = window.setTimeout("welcomes", 3000);

$("img.galimg").click( function() {
var sorsa = $(this).attr('src');
$("body").append('<img src="' + sorsa + '" id="big_image" />');
var leveys = ($(document).width() / 2);
var kuval = ($("#big_image").width() / 2);
var kl = (leveys - kuval);
$("#big_image").css('left', kl + 'px');

$("body").append('<div id="pictext"></div>');
$("#pictext").css('left', kl + 'px').html($(this).attr("alt"));
$("#pictext").css('top', ($(document).scrollTop() + 'px')).css('width', ($("#big_image").width() + 'px'));;
$("#big_image").css('top', (($(document).scrollTop()+ 25) + 'px'));
$("#shadow").fadeIn("slow");
});

$("#galdown").click( function() {

var gleft = $("#picframe").scrollLeft();

$("#picframe").animate( {
scrollLeft: gleft + 200
}, 1000);

});

$("#galup").click( function() {

var gleft = $("#picframe").scrollLeft();

$("#picframe").animate( {
scrollLeft: gleft - 200
}, 1000);

});


$("#shadow").click( function() {
$("#big_image").remove();
$("#shadow").fadeOut("fast");
$("#pictext").remove();
});

$("#shadow").click( function() {
$("#documents_frame").remove();
$("#shadow").fadeOut("fast");
});



$('a.flaga').mouseover(function() {

	var sijainti = $(this).offset();
	var vasen = sijainti.left+6;
	var yla = sijainti.top + 30;
	var idkortti = $(this).attr("id");
	idkortti += "l";
	var tausta = "";
	switch(idkortti) {
	case "enfl":
	tausta = "english.gif";
	break;

	case "jpfl":
	tausta = "japanese.gif";
	break;

	case "chfl":
	tausta = "chinese.gif";
	break;

	case "kofl":
	tausta = "korean.gif";
	break;

	}

	$('.flag').css( {left: vasen, top: yla, display: "block", position: "absolute"});
	$('.flag').css('background-image', 'url(' + tausta + ')');


});

$('a.flaga').mouseout(function(){

$('div.flag').css( {display: "none"});


});



$('#hover_map')
	.mouseover(function(){
		$(this).css({backgroundPosition: "60px 110px"});
		})
	.mouseout(function(){
		$(this).css({backgroundPosition: "0px -160px"});
});

$('div.cframe')
	.css( {opacity: .4} )
	.mouseover(function(){
		$(this).stop().animate(
			{opacity: 1}, 
			{duration:500})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{opacity: .4}, 
			{duration:500})
});


$("#hover_map").click( function() {

var leveys = $(document).width();
leveys = ($(document).width() / 2) - 300;
var close_p = leveys + 630;
$("#map").css({left: leveys});
$("#shadow").fadeIn("slow");
$("#map").slideDown("slow");
$("#map").css("top", "20px");
$("#close").slideDown("slow");
$("#close").css({left: close_p});

});

$("#close").click( function() {

var leveys = $(document).width();
leveys = ($(document).width() / 2) - 300;
var close_p = leveys + 430;
$("#map").css({left: leveys});
$("#shadow").fadeOut("slow");
$("#map").slideUp("slow");
$("#close").slideUp("slow");
$("#close").css({right: close_p});

});

$("#shadow").click( function() {

var leveys = $(document).width();
leveys = ($(document).width() / 2) - 300;
var close_p = leveys + 430;
$("#map").css({left: leveys});
$("#shadow").fadeOut("slow");
$("#map").slideUp("slow");
$("#close").slideUp("slow");
$("#close").css({right: close_p});

});

$('a.main_button')
	.css( {backgroundPosition: "0 0px"} )
	.mouseover(function(){
	var thisID = $(this).attr("id");
	thisID = "#button_hover_"+ thisID;
	$(thisID).css( {display: "block"});
	var button_left = $(this).position().left;
	var button_top = $(this).position().top - 99;
	$(thisID).css( {display: "block", left: button_left, top: button_top});
		$(thisID).animate(
			{backgroundPosition:"(0px -100px)"}, 
			{duration:500})
		})
	  	.mouseout(function(){
		var thisID2 = $(this).attr("id");
		thisID2 = "#button_hover_"+ thisID2;
		$(thisID2).stop().animate(
			{backgroundPosition:"(0px 0px)"}, 
			{duration:300, complete: function() {
			$(thisID2).css( {display: "none"});
			}
			});
});



$('div.welcome').click(function(){
	var scrollaa = $(this).scrollTop();
	var boxes = $('.welcome_box').length;
	var scroll_limit = (boxes) * 200;
	scrollaa += 200;
	if(scrollaa == scroll_limit){
	scrollaa = 0;
	}
	$(this).animate(
	{
	scrollTop: scrollaa + "px"
	}, 1000);

});


var linkLenght = 0;
	$('a.sub_button').mouseover( function() {
	linkLenght = $(this).css('width');
	$(this).animate(
	{
	width: "180px"
	
	}, {duration: 300})
	.mouseout( function() {
	$(this).stop().animate( {
	width: "170px"
	}, {duration: 300})
	})
});




});


function selectDataLang(ll) 
{

var title = $('#'+ll+'d1').html();
var content = $('#'+ll+'d2').html();
var lang = $('#'+ll+'d3').html();

$('#tit').val(title);
$('#cont').html(content);
$('#lang').val(lang);

$("#cl").show("fast");
$("#loading").hide("fast");

$("#cjp").css({ backgroundColor: "#009ec3"});
$("#cen").css({ backgroundColor: "#009ec3"});
$("#cch").css({ backgroundColor: "#009ec3"});
$("#ckr").css({ backgroundColor: "#009ec3"});

if(ll == "d1"){
$("#cch").css({ backgroundColor: "#eeeeee"});
}
else if (ll == "d2"){
$("#cen").css({ backgroundColor: "#eeeeee"});
}
else if(ll == "d3"){
$("#cjp").css({ backgroundColor: "#eeeeee"});
}
else if(ll == "d4"){
$("#ckr").css({ backgroundColor: "#eeeeee"});
}
}




function getEditData(idd)
{
$.post("sespage.php", {pid: idd}, function(data){
$("#datastorage").html(data);
});

$("#cl").hide("fast");
$("#loading").show("fast");

var t = window.setTimeout("selectDataLang('d3')", 1500);
}




