<!--

if(window.attachEvent) {

	window.attachEvent("onload",loadSidebar);
	
} // end if

if(window.addEventListener) {

	window.addEventListener("load",loadSidebar,false);
	
} // end if

function readCookie(name) {

	var nameEQ = name + "=";
	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {

		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

	} // end for

	return null;

} // end function


function loadSidebar() {
	
 	audioOff(true);

	document.getElementById('latest_hostesses').style.backgroundColor="#f9cdc0";
	document.getElementById('latest_hostesses').innerHTML = "<div style=\"padding:10px;\">Loading...</div>";

	document.getElementById('latest_references').style.backgroundColor="#f9cdc0";
	document.getElementById('latest_references').innerHTML = "<div style=\"padding:10px;\">Loading...</div>";

	document.getElementById('latest_news').style.backgroundColor="#f9cdc0";
	document.getElementById('latest_news').innerHTML = "<div style=\"padding:10px;\">Loading...</div>";

	getHostesses();

} // end function

function getHostesses() {
	
	ajaxPostRequest("insertHostesses","/hostess/latest","",true);

} // end function

function insertHostesses(data) {

	if(decodeURI(data).match("</tr>")) {

		document.getElementById('latest_hostesses').style.backgroundColor="#ffffff";
		document.getElementById('latest_hostesses').innerHTML = decodeURI(data);
		
	}else{

		document.getElementById('latest_hostesses_row').style.display='none';
		document.getElementById('latest_hostesses_row_spacer').style.display='none';
	
	} // end if

	getReferences();

} // end function

function getReferences() {
	
	ajaxPostRequest("insertReferences","/reference/latest","",true);

} // end function

function insertReferences(data) {

	if(decodeURI(data).match("</tr>")) {

		document.getElementById('latest_references').style.backgroundColor="#ffffff";
		document.getElementById('latest_references').innerHTML = decodeURI(data);
		
	}else{

		document.getElementById('latest_references_row').style.display='none';
		document.getElementById('latest_references_row_spacer').style.display='none';
	
	} // end if

	getNews();

} // end function

function getNews() {
	
	ajaxPostRequest("insertNews","/news/latest","",true);

} // end function

function insertNews(data) {

	if(decodeURI(data).match("</tr>")) {

		document.getElementById('latest_news').style.backgroundColor="#ffffff";
		document.getElementById('latest_news').innerHTML = decodeURI(data);
		
	}else{

		document.getElementById('latest_news_row').style.display='none';
		document.getElementById('latest_news_row_spacer').style.display='none';
	
	} // end if
	
	var sound_cookie = readCookie("sound");
	//console.log(sound_cookie);
	//console.log(start_sound);
	//console.log(sound_cookie);

	if(start_sound && sound_cookie!="off") {
		
		if(sound_cookie==1) {
	
			audioSound1(true);

		}else if(sound_cookie==2){
			
			audioSound2(true);

		}else if(sound_cookie==3){

			audioSound3(true);

		}else{

			audioSound1(true);		
		
		} // end if
	
	} // end if

} // end function

function audioOff(init) {

	if(document.getElementById('music_off')) {

  	audioButtonsOff();
  	document.getElementById('music_off').className="music_link_active";
  	swfobject.embedSWF('/files/swf/music/off.swf','swfMusic','5','5','9.0.0');

	if(typeof init == "undefined") {

		document.cookie = "sound=off";

	} // end if
  	
  } // end if

} // end function

function audioSound1(init) {

	if(document.getElementById('music_sound1')) {
		
		audioButtonsOff();
		document.getElementById('music_sound1').className="music_link_active";		
		swfobject.embedSWF('/files/swf/music/sound1.swf','swfMusic','5','5','9.0.0');
  	
	} // end if

	if(typeof init == "undefined") {

		document.cookie = "sound=1";

	} // end if

} // end function

function audioSound2() {

	if(document.getElementById('music_sound2')) {

		audioButtonsOff();
		document.getElementById('music_sound2').className="music_link_active";
		swfobject.embedSWF('/files/swf/music/sound2.swf','swfMusic','5','5','9.0.0');
  	
	} // end if

	document.cookie = "sound=2";

} // end function

function audioSound3() {

	if(document.getElementById('music_sound3')) {

		audioButtonsOff();
		document.getElementById('music_sound3').className="music_link_active";
		swfobject.embedSWF('/files/swf/music/sound3.swf','swfMusic','5','5','9.0.0');
  	
	} // end if

	document.cookie = "sound=3";

} // end function

function audioButtonsOff() {

	if(document.getElementById('music_off') && document.getElementById('music_sound1') && document.getElementById('music_sound2') && document.getElementById('music_sound3')) {

		document.getElementById('music_off').className="music_link";
		document.getElementById('music_sound1').className="music_link";
		document.getElementById('music_sound2').className="music_link";
		document.getElementById('music_sound3').className="music_link";
  	
  } // end if
  
}

function menuMouseOver(element){

	element.parentNode.style.listStyleImage = "url('../images/icon/9x9/arrow_down_active.gif')";
	element.parentNode.style.backgroundColor = "#ee6376";
	
}// end function

function menuMouseOut(element){

	element.parentNode.style.listStyleImage = "url('../images/icon/9x9/arrow_down_inactive.gif')";
	element.parentNode.style.backgroundColor = "#999999";

}// end function

//-->

