﻿var flasher;
var conpla;
var timer;
var bgtimer;
var height;
var isNewsHover = false;

$(function()
{
	IEChecker();
	var cookie = $.cookie('cookiename');

	if(cookie == 'complete')
	{
			$('#openingback').hide();
	}
	flashLoader();
	menuSet();
	height = document.documentElement.scrollHeight ;
	$('#openingback').height(height);
/*
	var i=0;
	bgtimer = setInterval(
		function()
		{
			$("body").css("backgroundPosition",i++);
		},80);
*/
	$(window).resize(function(e) {
		height = document.documentElement.scrollHeight
		$('#openingback').height(height);
	});

	 setNewsArea();
});

function IEChecker()
{
	if (typeof document.body.style.maxHeight != "undefined") {
	// IE 7, mozilla, safari, opera 9
	} else {
		document.location = "./oldblowser.html";
	}
}

function flashLoader()
{
	var opening = new SWFObject("opening.swf", "opening", "800", "600", "8", "#000000");
	var topview = new SWFObject("topfl.swf", "topview", "479", "350", "8", "#000000");
	var planets = new SWFObject("right.swf", "planets", "188", "150", "8", "#000000");

	opening.addParam("wmode", "transparent");
//	topview.addParam("allowScriptAccess", "always");
	opening.write("opening");



	topview.addParam("wmode", "transparent");
//	topview.addParam("allowScriptAccess", "always");
	topview.write("topwindow");

	planets.addParam("wmode", "transparent");
//	planets.addParam("allowScriptAccess", "always");
	planets.write("planet");

	flasher = document.all? window["topview"] : document["topview"];
	conpla = document.all? window["planets"] : document["planets"];
}
function openingEnd()
{
	$('#openingback').fadeOut(500);
	$.cookie('cookiename','complete');
	$('#opening').html(' ');
}
function menuSet()
{
	$('#menutips')
		.hover(function(e)
		{
			try {
				flasher.callTips();
				conpla.callTips();
			}catch(e){}
			$('#info').hide();
			$('#tipsdesc').show();
		},
		function(e)
		{
			$('#tipsdesc')
				.stop()
				.hide();
			$('#info').show();
		});
	$('#menudl')
		.hover(function(e)
		{
			try {
				flasher.callDl();
				conpla.callDl();
			}catch(e){}
			$('#info').hide();
			$('#dldesc').show();
		},
		function(e)
		{
			$('#dldesc')
				.stop()
				.hide();
			$('#info').show();
		});
	$('#menumail')
		.hover(function(e)
		{
			try {
				flasher.callMail();
				conpla.callMail();
			}catch(e){}
			$('#info').hide();
			$('#maildesc').show();
		},
		function(e)
		{
			$('#maildesc')
				.stop()
				.hide();
			$('#info').show();
		});
	$('#menuout')
		.hover(function(e)
		{
			try {
				flasher.callOut();
				conpla.callOut();
			}catch(e){}
			$('#info').hide();
			$('#outdesc').show();
		},
		function(e)
		{
			$('#outdesc')
				.stop()
				.hide();
			$('#info').show();
		});
	$('#menublog')
		.hover(function(e)
		{
			try {
				flasher.callBlog();
				conpla.callBlog();
			}catch(e){}
			$('#info').hide();
			$('#blogdesc').show();
		},
		function(e)
		{
			$('#blogdesc')
				.stop()
				.hide();
			$('#info').show();
		});

	$('#menucon')
		.hover(function(e)
		{
			try {
				flasher.callCon();
				conpla.callCon();
			}catch(e){}
			$('#info').hide();
			$('#condesc').show();
		},
		function(e)
		{
			$('#condesc')
				.stop()
				.hide();
			$('#info').show();
		});
	$('#menulink')
		.hover(function(e)
		{
			try {
				flasher.callLink();
				conpla.callLink();
			}catch(e){}
			$('#info').hide();
			$('#linkdesc').show();
		},
		function(e)
		{
			$('#linkdesc')
				.stop()
				.hide();
			$('#info').show();
		});
	$('#menuaisa')
		.hover(function(e)
		{
			try {
				flasher.callAisa();
				conpla.callAisa();
			}catch(e){}
			$('#info').hide();
			$('#aisadesc').show();
		},
		function(e)
		{
			$('#aisadesc')
				.stop()
				.hide();
			$('#info').show();
		});
}

function setNewsArea()
{
	var len = $("#newsbox li").length;
	$("#newsbox li").hover(
			function()
			{
				isNewsHover = true;
			},
			function()
			{
				isNewsHover = false;
			}
	)
	var i=0;
	$("#newsbox li:eq(" + i + ")").show();
	i++;
	setInterval(
		function()
		{
			if ( isNewsHover ) return;
			$("#newsbox li").hide();
			$("#newsbox li:eq(" + i + ")").show();

			i++;
			if( len <= i )		i=0;
		}
	,8000);
}