/*
var api = M4.API.from(window);
var win = api.window();
function centerLayout() {
	var layoutLayer = win.getLayer('layout');
	if(!layoutLayer){
		return;
	}
	var x = (win.getWidth()-layoutLayer.getWidth())/2;
	if (x<0) {
		x = 0;
	}
	
	var y = (win.getHeight()-layoutLayer.getHeight())/3;
	if (y<0) {
		y = 0;
	}
	alert('x='+x+', y='+y);
	layoutLayer.moveTo(x,y);
	layoutLayer.setVisibility(true);
}
*/
// for menues
function MM_findObj(n, d){
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_showHideLayers(){
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore(){
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage(){
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// menues on start page
function show_menu_1(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar1','','show');
MM_showHideLayers('sub1','','show');
}

function show_menu_2(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar2','','show');
MM_showHideLayers('sub2','','show');
}

function show_menu_3(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar3','','show');
MM_showHideLayers('sub3','','show');
}

function show_menu_4(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar4','','show');
MM_showHideLayers('sub4','','show');
}

function show_menu_5(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar5','','show');
MM_showHideLayers('sub5','','show');
}

function show_menu_6(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar6','','show');
MM_showHideLayers('sub6','','show');
}

function show_menu_7(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar7','','show');
MM_showHideLayers('sub7','','show');
}
function show_menu_8(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar8','','show');
MM_showHideLayers('sub8','','show');
}
function show_menu_9(){
hide_all_menues()
MM_swapImgRestore()
MM_showHideLayers('obar9','','show');
MM_showHideLayers('sub9','','show');
}
function hide_all_menues(){
MM_swapImgRestore()
MM_showHideLayers('obar1','','hide');
MM_showHideLayers('obar2','','hide');
MM_showHideLayers('obar3','','hide');
MM_showHideLayers('obar4','','hide');
MM_showHideLayers('obar5','','hide');
MM_showHideLayers('obar6','','hide');
MM_showHideLayers('obar7','','hide');
MM_showHideLayers('obar8','','hide');
MM_showHideLayers('obar9','','hide');
MM_showHideLayers('sub1','','hide');
MM_showHideLayers('sub2','','hide');
MM_showHideLayers('sub3','','hide');
MM_showHideLayers('sub4','','hide');
MM_showHideLayers('sub5','','hide');
MM_showHideLayers('sub6','','hide');
MM_showHideLayers('sub7','','hide');
MM_showHideLayers('sub8','','hide');
MM_showHideLayers('sub9','','hide');
}
// end menu


// menues on level 2
function show_orange(){
hide_all_orange();
MM_swapImgRestore();
}

function hide_all_orange(){
MM_swapImgRestore()
MM_showHideLayers('obar1','','hide');
MM_showHideLayers('obar2','','hide');
MM_showHideLayers('obar3','','hide');
MM_showHideLayers('obar4','','hide');
MM_showHideLayers('obar5','','hide');
MM_showHideLayers('obar6','','hide');
MM_showHideLayers('obar7','','hide');
MM_showHideLayers('obar8','','hide');
MM_showHideLayers('obar9','','hide');
}

//---------------------------------------------------------------------

// for scroll
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

bw=new checkBrowser()

var speed=100
var loop, timer

function makeObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    var o = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    if(o==null){
    	this.valid=false;
	    return null;
	}    
	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.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp;this.down=goDown;
	this.moveIt=moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    this.valid = true;
    return this
}

function moveIt(x,y){
	this.x=x;this.y=y
	this.css.left=this.x
	this.css.top=this.y
}

function goDown(move){
	if(this.y>-this.scrollHeight+oCont.clipHeight){
		this.moveIt(0,this.y-move)
			if(loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}

function goUp(move){
	if(this.y<0){
		this.moveIt(0,this.y-move)
		if(loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}

function scroll(speed){
	if(loaded){
		loop=true;
		if(speed>0) oScroll.down(speed)
		else oScroll.up(speed)
	}
}

function noScroll(){
	loop=false
	if(timer) clearTimeout(timer)
}

var loaded;
function scrollInit(){
	//centerLayout();
	oCont=new makeObj('mainContent')
	if(!oCont.valid){return;}
	oScroll=new makeObj('mainText','mainContent')
	if(!oScroll.valid){return;}
	oScroll.moveIt(0,0)
	oCont.css.visibility='visible'
	loaded=true;
}
// end scroll
// pop up window
function cw(page,pagename,settings,w,h){
	var xMax = screen.width;
	var yMax = screen.height;
	var xOffset = (xMax - w)/2
	var yOffset = (yMax - h)/2;
	var oppna = window.open(page,pagename,settings + ',width=' + w +',height=' + h +',top='+yOffset+',left='+xOffset+'');
}

//---------------------------------------------------------------------
