Event.observe(window,'load',homeInit);
//=================================== START: INIT FUNCTIONS =========================================//
	
	function homeInit(){
		setHomeNavListener();
		setBlankListeners();
		//insertGmap();
	};	
		
	  // Call this function when the page has been loaded
	  function initialize() {
	    var map = new google.maps.Map2(document.getElementById("gMap"));
	    //map.setCenter(new google.maps.LatLng(49.279397,-123.119102), 15);
	    map.setCenter(new google.maps.LatLng(49.275669,-123.11923), 16);
		map.setUIToDefault();
		map.addOverlay(new GMarker(map.getCenter()))
		map.openInfoWindowHtml(map.getCenter(),'<h4 id="mapMarkerTitle" class="gMapFont">Vancouver Bujinkan Ninjutsu @ <a href="http://www.exhalestudio.com" target="_blank" title="click to visit Exhale Studio">Exhale Studio</a></h4><p id="mapMarkerDescription" class="gMapFont">1083 Cambie St., Vancouver, BC</p>');		
	  };

	function insertGmap(e){
		Element.insert('gMap','<iframe width="495" height="495" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.ca/maps?client=safari&amp;oe=UTF-8&amp;ie=UTF8&amp;q=exhale+studio&amp;fb=1&amp;gl=ca&amp;hq=exhale+studio&amp;cid=0,0,13256203602359150053&amp;ei=KePqS6jGKIXiswP0wYXhBw&amp;ved=0CBYQnwIwAA&amp;hnear=&amp;ll=49.275669,-123.11923&amp;spn=0.006295,0.006295&amp;iwloc=A&amp;output=embed"></iframe><br /><small><a href="http://maps.google.ca/maps?client=safari&amp;oe=UTF-8&amp;ie=UTF8&amp;q=exhale+studio&amp;fb=1&amp;gl=ca&amp;hq=exhale+studio&amp;cid=0,0,13256203602359150053&amp;ei=KePqS6jGKIXiswP0wYXhBw&amp;ved=0CBYQnwIwAA&amp;hnear=&amp;ll=49.275669,-123.11923&amp;spn=0.006295,0.006295&amp;iwloc=A&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>');			
		}; 
	function setBlankListeners(){
		$$('.externalLink').each(function(item,index){
			$(item).writeAttribute('target', '_blank');
		});			
	};
//=================================== END: INIT FUNCTIONS =========================================//
//=================================== START: GENERAL FUNCTIONS =========================================//


//=================================== END: GENERAL FUNCTIONS =========================================//
//================================= START: INDEX FUNCTIONS ====================================================================
	
//================================= START: HELPER FUNCTIONS ====================================================================

//================================= END: HELPER FUNCTIONS ====================================================================
//================================= START: HOME FUNCTIONS ===================================================================

	function setHomeNavListener(){
		var navObjList = $$('.navObj');		
		navObjList.each(function(item,index){	
			Event.observe(item,'click',movePageObj,true);	
		});		
		var navObjList = $$('.question');		
		navObjList.each(function(item,index){	
			Event.observe(item,'click',faqShow,true);	
		});		
	};	
	
	function movePageObj(e){
		Event.stop(e);
		var srcObj = Event.element(e)
		
		if(srcObj.hasClassName('activeLink')==true){
			return;
		}
		else{
			setMovePageObj(e);
		};		
	};		
	
	function setMovePageObj(e){
		var srcObj = Event.element(e).id;
		var activeBtnList = $$('.activeLink');
		activeBtnList.each(function(item,index){			
			Element.removeClassName(item,'activeLink');		
		});		

		var srcObjMultiplier = Element.readAttribute(srcObj,"tabindex");
			targetTxtInt = ((srcObjMultiplier-1)*791);
		
		if(targetTxtInt<0){			
			targetTxtInt = -1*targetTxtInt;
		}
		else{
			targetTxtInt = targetTxtInt/-1;
		};	
	
		new Effect.Morph('centerBodyInnerContainer', {
		  style: {
			top:targetTxtInt + 'px'
		  }, // CSS Properties
		  duration: 0.5 // Core Effect properties
		});
			
		Element.addClassName(srcObj,'activeLink');			
	};	

	function faqShow(e){
		Event.stop(e);
		var srcObj = Event.element(e).id;
		var activeFAQs = $$('.activeFaq');
		activeFAQs.each(function(item,index){			
			Element.removeClassName(item,'activeFaq');
			var targetLastObj=Element.next(item).id;		
			Element.hide(targetLastObj);				
		});	
	
		var targetObj=Element.next(srcObj).id;		
		Element.show(targetObj);
		
		Element.addClassName(srcObj,'activeFaq');	
	};
//================================= END: HOME FUNCTIONS =====================================================================




