
function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()
//The speed of the timeout between each scroll.
timSpeed = 50

//The height of the container (change this when it scrolls to much or to little)
contHeight = 100

/*********************************************************************************
This is the object constructor function, which applies 
methods and properties to the Cross-browser layer object
*********************************************************************************/
function makeScrollObj(obj,nest){
	nest=(!nest) ? "":'document.'+nest+'.'		
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;		
	this.height=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.top=b_gettop										
	return this
}

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

//Getting the top for the top method
function b_gettop(){
	var gleft=(bw.ns4 || bw.ns6)?parseInt(this.css.top):eval(this.css.pixelTop);
	return gleft;
}
//Variables
var scrollTim = 1;
var active = 'yatsen1';
opened = false;
/*********************************************************************************
The scroll function. Checks what way to scroll and checks if the
layer is not already on top or bottom.
*********************************************************************************/
function scroll(speed){
	clearTimeout(scrollTim)
	way = speed>0?1:0
	if ((!way && oScroll[active].top()>-oScroll[active].height+contHeight) || (oScroll[active].top()<0 && way)){
		oScroll[active].css.top = (oScroll[active].top()+speed)+px
		scrollTim = setTimeout("scroll("+speed+")",timSpeed)
	}
}
//Clears the timeout so the scroll stops, this is called onmouseout.
function noScroll(){
	clearTimeout(scrollTim)
}
/*********************************************************************************
Changes the active layer. Hides the one that's visible and
shows the "new" one. Also set's the new layers top to
0 so it starts at top.
*********************************************************************************/
function changeActive(section,num){
	oScroll[active].css.visibility = "hidden"
	active = section + num
	oScroll[active].css.top = 0+px
	//show current page #
		switch (num)
		{
		case 1:
		MM_swapImage('numOn','','images/1.gif',1);
		break;
		case 2:
		MM_swapImage('numOn','','images/2.gif',1);
		break;
		case 3:
		MM_swapImage('numOn','','images/3.gif',1);
		break;
		case 4:
		MM_swapImage('numOn','','images/4.gif',1);
		break;
		}
	MM_swapImage('_1','', sites [section] ['image' + num ] ,1)
	if (opened == true){
	oScroll[active].css.visibility = "visible"
	}
}

function pgFor(){
	if(currentPg  < 3){
	    MM_showHideLayers('faq_ask'+currentPg,'','hide','faq_ask'+(currentPg+1),'','show');
		currentPg = currentPg + 1;
		MM_swapImage('numOn','','../../images/' + currentPg + 'blk.gif',1);
      //changeActive(section, currentPg);
   }
 if (currentPg < 3){  
MM_swapImage('forth','','../../images/forth_black.gif','back','','../../images/back_black.gif',1);
	}else{
	MM_swapImage('forth','','../../images/clearDot.gif','back','','../../images/back_black.gif',1);
	//changeActive(section, currentPg);
   }
}


function pgBk(){

if (currentPg > 1){
   MM_showHideLayers('faq_ask'+currentPg,'','hide','faq_ask'+(currentPg-1),'','show');
		currentPg = currentPg - 1;
		MM_swapImage('numOn','','../../images/' + currentPg + 'blk.gif',1);
	}
	
if(currentPg == 1)	{
	MM_swapImage('forth','','../../images/forth_black.gif','back','','../../images/clearDot.gif',1);
	}else{
	MM_swapImage('forth','','../../images/forth_black.gif','back','','../../images/back_black.gif',1);
	}
	
}

/*********************************************************************************
Initilizes the page, makes a oScroll Array and calls the object constructor.
Here you can add as many scrollObjects as you want
*********************************************************************************/
function startPage(){
	oScroll = new Array()
	
	// You can add and remove scrollObjects here.
	oScroll['yatsen1'] =  new makeScrollObj('yatsen1','divCont')
	
	oScroll['who1'] =   new makeScrollObj('who1','divCont')	
	
	oScroll['bedroom1'] =   new makeScrollObj('bedroom1','divCont')
	
	oScroll['warm1'] =   new makeScrollObj('warm1','divCont')
	
	oScroll['jade1'] =   new makeScrollObj('jade1','divCont')
	
	oScroll['language1'] =   new makeScrollObj('language1','divCont')
		
	oScroll['words1'] =   new makeScrollObj('words1','divCont')
	
	oScroll['taoismdaoism1'] =   new makeScrollObj('taoismdaoism1','divCont')
	
	oScroll['yinyang1'] =   new makeScrollObj('yinyang1','divCont')
	
	oScroll['confucius1'] =   new makeScrollObj('confucius1','divCont')
	
	oScroll['buddhism1'] =   new makeScrollObj('buddhism1','divCont')
	
	oScroll['calendar1'] =   new makeScrollObj('calendar1','divCont')
	
	oScroll['yatsen1'].css.left = 0+px
	oScroll['yatsen1'].css.top = 0+px
	oScroll['yatsen1'].css.visibility = "hidden"
	oControl = new makeScrollObj('divControl')
	oControl.css.visibility = "hidden"
	
	preLoad('images/background_'+lang+'.gif','images/read_title.gif','images/faq_01.jpg','images/faq_02.jpg','images/faq_04.jpg','images/faq_05.jpg','images/faq_06.jpg','images/yel_li.gif','../images/bgBottom.gif','images/clearDot.gif');
	var sections = new Array("yatsen", "who", "bedroom", "warm", "jade", "language", "words" , "taoismdaoism", "yinyang" , "confucius","buddhism","calendar" );
	preloadFirstImg(sections);
}

//************image preloading*****************

function preLoad(images)
{
   var allImages = new Array(images);
   preloadImages(allImages);
}

function preloadImages(the_images_array) {
   for(var loop = 0; loop < the_images_array.length; loop++)
   {
 	var an_image = new Image();
	an_image.src = the_images_array[loop];
   }
}
var lang = 'sites';
function preloadFirstImg(sections){
	for (var loop = 0; loop < sections.length; loop++)
	{
		var an_image = new Image();
		an_image.src = eval(lang) [sections[loop]] ['image1'];
		}
}
/*********************************************************************************
Executes the scrollInit function on pageload.
*********************************************************************************/
onload = startPage;

/***************
Multiple Scripts
If you have two or more scripts that use the onload event, probably only one will run (the last one).
Here is a solution for starting multiple scripts onload:
   1. Delete or comment out all the onload assignments, onload=initScroll and things like that.
   2. Put the onload assignments in the body tag like in this example, note that they must have braces ().
   Example: <body onload="initScroll(); initTooltips(); initMenu();">
**************/


