// JavaScript Document

var Site = {

	currentPage: "intro",

	showPage: function(page){
		if(page == this.currentPage) return false;
		if(this.currentPage){
			$$('#nav_'+this.currentPage+' a').first().removeClassName('selected');
			$(this.currentPage+'_box').hide();
		}
		this.currentPage = page;
		$$('#nav_'+this.currentPage+' a').first().addClassName('selected');
		$(this.currentPage+'_box').show();
		return false;
	},

	currentGender: null,
	
	showGenderAdvoiceNav: function(gender){
		if(gender == this.currentGender) return false;
		if(this.currentGender){
			$$(".gender_"+this.currentGender).invoke("hide");
		}
		this.currentGender = gender;
		//$('voice_'+this.currentVoice).addClassName('nav_active');
		$$(".gender_"+this.currentGender).invoke("show");
		return false;
	}
	

}

Event.addBehavior({
  '#nav-main a:click' : function(e) {
	 var page = this.href.split("#")[1];
	 Site.showPage(page);
	 e.cancel = true;
  },

  
  '.main_gender a:click' : function(e) {
	 var gender = this.href.split("#")[1];
	 Site.showGenderAdvoiceNav(gender);
	 e.cancel = true;
  },
  'a.popup' : function(e) {
	 this.onClick= function(){return false};
  },
  'a.popup:click' : function(e) {
	  ///alert(this.href);
	 this.target = '_self';
	 var w=window.open(this.href,'terms','width=570,height=650,status=no,scrollbars=yes');
	 e.cancel = true;
	 return false;
  }
});

Event.onReady(function() {
	$$('.content_box').each(function(item){
		if(item.id != "intro_box")	{						 
			item.hide();
		}
  	});
	if(location.href.indexOf('#') != -1){
		var page = location.href.split("#")[1];
		if(page) Site.showPage(page);
	}
	document.body.style.display = 'block';
	
	if(navigator.appName.indexOf("Microsoft") != -1) {
		Player.flash = window.flashObject;
	}else {
		Player.flash = window.document.flashObject
	}

});


var Player = {
	
	flash:null,
	
	playVoice: function(path, name, id){
		if(this.currentId) {
			this.flash.stopVoice();
			this.playerToggle(this.currentId);
		}
		this.currentId = id;
		this.flash.playVoice(path, name);
		this.playerToggle(this.currentId);	
	},
	
	stopVoice: function(){
		this.flash.stopVoice();
		this.playerToggle(this.currentId);
		this.currentId = null;
	},
	
	endVoice: function(){
		this.playerToggle(this.currentId);
		this.currentId = null;
	},
	
	playerToggle: function(id){
		$$("#"+id+" .playBtn").first().toggle();
		$$("#"+id+" .stopBtn").first().toggle();
	}
}

function endVoice(){
	Player.endVoice();
}