// JavaScript Document
var isIE = /compatible; MSIE/g.test(navigator.userAgent);
function version() {
	var info = navigator.userAgent, ver;
	if (isIE) {
		ver = info.substr(info.indexOf('MSIE') + 5);
		ver = parseFloat(ver.substr(0, ver.indexOf(';')));
	}
	else if (isFF) ver = info.substr(info.lastIndexOf('/') + 1);
	else if (isOpera) ver = parseFloat(info.substr(0, info.indexOf(' ')).replace('Opera/', ''));
	else if (isChrome) {
		ver = info.substr(info.indexOf('Chrome') + 7);
		ver = ver.substr(0, ver.indexOf(' '));
	}
	return ver;
}

function menu() {
	var a = document.getElementById('menu').getElementsByTagName('a');
	var sub_menu = document.getElementById('sub_menu');
	if (isIE) {
		sub_menu.onmouseover = function () {this.style.display = 'block';}
		sub_menu.onmouseout = function () {this.style.display = 'none';}
		a[1].onmouseover = function () {document.getElementById('sub_menu').style.display = 'block';}
		a[1].onmouseout = function () {document.getElementById('sub_menu').style.display = 'none';}
	}
	else {
		sub_menu.addEventListener('mouseover', function () {this.style.display = 'block';}, false);
		sub_menu.addEventListener('mouseout', function () {this.style.display = 'none';}, false);
		a[1].addEventListener('mouseover', function () {document.getElementById('sub_menu').style.display = 'block';}, false);
		a[1].addEventListener('mouseout', function () {document.getElementById('sub_menu').style.display = 'none';}, false);
	}
}

function clear_focus() {
	var a = document.getElementsByTagName('a'), i;
	var area = document.getElementsByTagName('area');
	if (isIE) {
		for (i = 0; i < a.length; i++) a[i].onfocus = function () {this.blur();}
		for (i = 0; i < area.length; i++) area[i].onfocus = function () {this.blur();}
	}
	else {
		for (i = 0; i < a.length; i++) a[i].addEventListener('focus', function () {this.blur();}, false);
		for (i = 0; i < area.length; i++) area[i].addEventListener('focus', function () {this.blur();}, false);
	}
	area = a = null;
}

function pic(x) {
	if (x > 6) x = 1; if (x < 1) x = 1;
	with (document.getElementById('pic')) {
		if (isIE) {
			style.filter = 'progid:DXImageTransform.Microsoft.Wipe(duration=2, gradientsize=0.25,motion=forward)';
			filters[0].apply();
		}
		src = '/images/x' + (x++) + '.jpg';
		if (isIE) filters[0].play();
	}
	setTimeout('pic(' + x + ');', 3500);
}

window.onload = function () {clear_focus(); menu(); if (isIE && version() > 6) pic(2);}

