// CSS SWICH
var CurrentFontSize = 0;
function Zoom() {
if (CurrentFontSize == 0) {
document.styleSheets[1].disabled=true;
document.styleSheets[2].disabled=false;
document.styleSheets[3].disabled=true;
CookieSet('zoom',  '0', '', '/', '', '' );
CurrentFontSize = 1;
} else if (CurrentFontSize == 1) {
document.styleSheets[1].disabled=false;
document.styleSheets[2].disabled=true;
document.styleSheets[3].disabled=true;	
CookieSet('zoom',  '1', '', '/', '', '' );
CurrentFontSize = 2;
} else {
document.styleSheets[1].disabled=true;
document.styleSheets[2].disabled=true;
document.styleSheets[3].disabled=false;
CookieSet('zoom',  '2', '', '/', '', '' );
CurrentFontSize = 0;
}
}
// CSS SWICH

var visionCss = true;
function Vision() {
if (visionCss) {
CookieSet('vision',  '1', '', '/', '', '' );		
document.styleSheets[4].disabled=true;
visionCss = false;
} else {
CookieSet('vision',  '0', '', '/', '', '' );	
document.styleSheets[4].disabled=false;
visionCss =  true;
}
}

function CheckCookies() {
if (CookieGet('zoom')) {	
CurrentFontSize = parseInt(CookieGet('zoom'));
} else {
CurrentFontSize = 2;	
}
if (CookieGet('vision') == '1') {
visionCss = true;
} else if (CookieGet('vision') == '0') {
visionCss = false;
}
Zoom();
Vision();
}


var SoundPlaying = false;
function Sound() {
if (SoundFile && !SoundPlaying) {
var so = new SWFObject("audioplayer.swf?AudioFile="+SoundFile, "audioPlayer", "10", "10", "7", "");
so.write("audioObject");
SoundPlaying = true;
} else {
document.getElementById('audioObject').innerHTML = '';	
SoundPlaying = false;	
}
}

////////////////////////////////////////////////////////// DETECT KEY

// VERIABLES
window.document.onkeydown = BodyGetKeyEvents;
window.document.onkeyup = BodyGetKeyEvents;

// KEY EVENTS
function BodyGetKeyEvents (evt) {
var evt = (evt) ? evt : ((window.event) ? event : null);
	if (evt.type == 'keydown') {
	var charCode = (evt.charCode) ? evt.charCode : evt.keyCode;
	// W INTRODUCTION
	if (charCode == 87 || charCode == 119) {
	location.href = 'introduction.php';	
	}
	
	// N NEWS AND EVENTS
	if (charCode == 78 || charCode == 110) {
	location.href = 'news.php';	
	}
	
	// K CONTACT
	if (charCode == 75 || charCode == 107) {
	location.href = 'contact.php';	
	}
	
	// 0 MEMBERS DIRECTORY
	if (charCode == 79 || charCode == 111) {
	location.href = 'directory.php';	
	}
	
	// X HOME 
	if (charCode == 88 || charCode == 120) {
	location.href = 'index.php';	
	}
	
	// SPACE H HELP
	if (charCode == 72 || charCode == 32 || charCode == 104 || charCode == 32) {
	location.href = 'help.php';	
	}
	
	// V VISION
	if (charCode == 86 || charCode == 118) {
	Vision();	
	}
	
	// Z ZOOM
	if (charCode == 90 || charCode == 122) {
	Zoom();
	}
	
	// S SOUND
	if (charCode == 83 || charCode == 115) {
	Sound();
	}
	
	
	} 
}
////////////////////////////////////////////////////////// DETECT KEY

////////////////////////////////////////////////////////// COOKIES

// COOKIES GET
function CookieGet(name) {	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
// COOKIES GET

// COOKIES SET
function CookieSet(name, value, expires, path, domain, secure) {
	var NowDate = new Date();
	NowDate.setTime(NowDate.getTime());
	if (expires) {
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(NowDate.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}
// COOKIES SET

////////////////////////////////////////////////////////// COOKIES
CheckCookies();