﻿/*
This Script is COPYRIGHTED by DIAPHONI A/S Denmark.
Contact us at webmaster@diaphoni.dk
*/
var mi = false
var n6 = false
var op = false
var mac = false
if (navigator.appName.charAt(0)=="M"){
	if (window.innerWidth > 0) {
		op = true
	} else {
		mi = true
	}
}
else if (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko") || navigator.appName=="Opera") {
	n6 = true
}
if (navigator.appVersion.indexOf('Macintosh') >= 1) {
	mac = true
}
var items = new Array()
var topelemwidth = new Array()
var subelempos = new Array()
var xoff=0
var xoffsubs=0
var yoff=0
var hereto=0
var width=100
var height=20
var heightn1=20
var n2off=6
var adress=""
var last=""
var previous=""
var t
var y
var h
var ob="'"
var str=""
var scroll=true
var winwidth1 = ""
var cu = false
var menualign = "left"
var space = 0 //space in backfill if menualign = right
var borderSepWidth = 1.5	// 一级子菜单的靠左边框
var firstSubXoffset = 0		// 一级子菜单的靠左像素
var CurrentN1Active

function remlast() {
	hide(last)
	hide(previous)
}

function remprevious() {
	hide(previous)
}

function timer(what){
	if ( what == "set"){
		t = setTimeout("remlast()",50)
	}
}

function timerpre(what){
	if ( what == "set"){
		y = setTimeout("remprevious()",50)
	}
}

function cleartimer(){
		clearTimeout(t)
}

function cleartimerpre(){
		clearTimeout(y)
}

function show(layname) {
	if ( layname.length == 7 ){
		hide(previous)
	}
	else {
		hide(last)
		hide(previous)
	}
	document.getElementById(layname).style.visibility = "visible"
}

function hide(layername) {
	document.getElementById(layername).style.visibility = "hidden"
}

function mouseover(name,showthis){
	if ( name.length > 2 || showthis != "" )
		cleartimer()
	if ( name.length == 7 && showthis.length == 7 )
		cleartimerpre()
	if ( name.length >= 9 )
		cleartimerpre()
	if ( showthis!="" ){
		show(showthis)
		if ( showthis.length == 7 ){
			previous=showthis
		}
		else {
			last=showthis
		}
	}
	if ( showthis.length == 7 )
		previous=showthis
}

function mouseout(name){
	timer("set")
	if (name.length < 9){
		timerpre("set")
	}
}

function presure(gowhere){
	if(gowhere.indexOf("opentipafriend") >= 0) {
		tipenven()
	}
	else if(gowhere.indexOf("openprinter") >= 0) {
		openprinter()
	}
	else if(gowhere.indexOf("opensitemap") >= 0) {
		opensitemap()
	}
	else if(gowhere.indexOf("openpopup") >= 0) {
		gowhere = gowhere.replace("openpopup","")
		var newwin = window.open(gowhere, 'popup', 'menubar,toolbar,location,scrollbars,status,resizable')
	}
	else if(gowhere!="") {
		if (cu == "ja"){
			afslutgem(gowhere)
		} else {
			location.href = gowhere;
		}
	}
}

function changeClassName(num,status) {
	if (document.getElementById("Mn1_center_" + num)) { document.getElementById("Mn1_center_" + num).className = status + "n1" }
}

function callbackfill(name,fillwidth){
	items[hereto]=name
	space = fillwidth
	var content=""
	str += ('<div id="'+name+'" style="position: absolute; visibility: hidden; left:'+xoff+'; z-index: 10;"><table border="0" width="'+fillwidth+'" cellpadding="0" cellspacing="0"><tr><td class="back" align="right" width="'+fillwidth+'" height="'+heightn1+'">&nbsp;</td></tr></table></div>')
	hereto++
}

//一. 主菜单选项
function startmenuitem(name){
	topelemwidth[0] = xoffsubs
	items[hereto]=name
	str += ('<div id="'+name+'" style="position: absolute; visibility: hidden; left:'+xoffsubs+'; z-index: 20; width: 597px;"><table border="0" cellpadding="0" cellspacing="0"><tr>')
	hereto++;
	h = 1
	
	if (CurrentN1Active == 0) {
		CurrentN1Active = 1
	}
}

function makemenuitem(name,subname,caption,href,thiswidth){
	if (parseInt(thiswidth,10) > 1) {
		topelemwidth[h] = parseInt(thiswidth,10)
		thisalign = "left"
	} else {
		topelemwidth[h] = width
		thisalign = "left"
	}
	if (h == CurrentN1Active) {
		str += ('<td id="Mn1_center_' + h + '" class="overn1" width="'+topelemwidth[h]+'" align="'+thisalign+'" height="'+heightn1+'" onMouseOver="mouseover('+ob+name+ob+','+ob+subname+ob+')" onMouseOut="mouseout('+ob+name+ob+')" onClick="presure('+ob+href+ob+')"><img src="../../images/share/blank1x1.gif" width="16" height="10" alt="">'+caption+'</td><td><img src="../../images/share/blank1x1.gif" width="3" height="10" alt=""></td>')
	} else {
		str += ('<td id="Mn1_center_' + h + '" class="outn1" width="'+topelemwidth[h]+'" align="'+thisalign+'" height="'+heightn1+'" onMouseOver="changeClassName(' + h + ','+ob+'over'+ob+') ; mouseover('+ob+name+ob+','+ob+subname+ob+')" onMouseOut="changeClassName(' + h + ','+ob+'out'+ob+') ; mouseout('+ob+name+ob+')" onClick="presure('+ob+href+ob+')"><img src="../../images/share/blank1x1.gif" width="16" height="10" alt="">'+caption+'</td><td><img src="../../images/share/blank1x1.gif" width="3" height="10" alt=""></td>')
	}
	topelemwidth[h] += borderSepWidth
	h++
}
function endmenuitem(){
	str += ('</tr></table></div>')
	h = 0
}
// 主菜单结束

//二. 一级子菜单选项
function startsubitem(name){
	items[hereto]=name
	last = name
	h = parseInt("0"+name.charAt(3)+name.charAt(4),10)
	h -= 1
	var xdist = firstSubXoffset //0
	for ( i=0 ; i <= h ; i++) {
		xdist += topelemwidth[i]
	}
	xdist += h * borderSepWidth
	subelempos[h] = xdist
	str += ('<div id="'+name+'" style="visibility: hidden; cursor: pointer; position: absolute; left: '+xdist+'; z-index: 20;"><table border="0" width="'+width+'" cellpadding="0" cellspacing="0">')
	hereto++
	h++
}
function makesubitem(name,subname,caption,href){
	var sub1num = name.charAt(3) + name.charAt(4)
	if (subname==""){
		str += ('<tr><td class="out" height="'+height+'" onMouseOver="className='+ob+'over'+ob+' ; mouseover('+ob+name+ob+','+ob+ob+')" onMouseOut="className='+ob+'out'+ob+' ; mouseout('+ob+name+ob+')" onClick="presure('+ob+href+ob+')" style="padding-left:3px;">'+caption+'</td></tr>')
	} else {
		str += ('<tr><td class="out" height="'+height+'" onMouseOver="className='+ob+'over'+ob+' ; mouseover('+ob+name+ob+','+ob+subname+ob+')" onMouseOut="className='+ob+'out'+ob+' ; mouseout('+ob+name+ob+')" onClick="presure('+ob+href+ob+')" style="padding-left:3px;">'+caption+'<img src="'+adress+'" width="3" height="5" border="0" style="position: absolute; left: ')
		str += ((width-6)+'; top: ')
		temp = ((parseInt("0"+subname.charAt(5)+subname.charAt(6),10)-1)*height)+(height/2-2)
		str += (temp+';"></td></tr>')
	}
}
function endsubitem(){
	str += ('</table></div>')
}
//一级子菜单结束

//二级子菜单
function startsubsubitem(name){
	items[hereto]=name
	previous = name
	h = parseInt("0"+name.charAt(3)+name.charAt(4),10)
	h -= 1
	var xdist = subelempos[h]
	xdist += width //+ 1
	if (mi) {
		if ( xdist+width > document.body.clientWidth )
			xdist -= (2*width+2)
	}
	else {
		if ( xdist+width > window.innerWidth )
			xdist -= (2*width+2)
	}
	str += ('<DIV ID="'+name+'" style="visibility: hidden; cursor: hand; position: absolute; left: '+xdist+'; z-index: 20;"><table border="0" width="'+width+'" cellpadding="0" cellspacing="0">')
	hereto++;
}
function makesubsubitem(name,caption,href){
	var sub1num = name.charAt(3) + name.charAt(4)
	str += ('<tr><td class="out" height="'+height+'" width="'+width+'" onMouseOver="className='+ob+'over'+ob+' ; mouseover('+ob+name+ob+','+ob+ob+')" onMouseOut="className='+ob+'out'+ob+' ; mouseout('+ob+name+ob+')" onClick="presure('+ob+href+ob+')" style="padding-left:3px;">'+caption+'</td></tr>')
}
function endsubsubitem(){
	str += ('</table></div>')
}
//二级子菜单结束

function setmenu(){
	if ( last=="" ) {
		//startmenuitem("sub01")
		startsubitem("sub01")
		endsubitem()
	}
	if ( previous=="" ) {
		startsubsubitem("sub01")
		endsubsubitem()
	}
	//alert(str)
	document.write(str)
}
function makestatic(){
	var byoff = 0
	if ( scroll && n6 )
		byoff = window.pageYOffset
	else if (scroll && (mi || op))
		byoff = document.body.scrollTop
	var temp = ""
	for ( var i = 0; i < hereto; i++ ) {
		temp = items[i]
		elm = document.getElementById(temp).style
		if ( temp.charAt(6) ){
			elm.top = byoff + yoff + ((parseInt("0"+temp.charAt(5)+temp.charAt(6),10)-1)*height) + heightn1 + n2off
		} else if ( temp.charAt(4) ){
			elm.top = (byoff + yoff + heightn1)
		} else {
			elm.visibility = "visible"
			elm.top = (byoff + yoff)
		}
	}
	if (menualign != "left") {
		alignmenu()
	}
	if ( scroll ){
		setTimeout("makestatic()",50)
	}
}

function refresh(){
	location.reload()
}

function alignmenu() {
	mostleft = parseInt(topelemwidth[0],10)
	mostright = mostleft + parseInt(space,10)
	itemswidth = borderSepWidth

	for (i=1;i<=topelemwidth.length-1;i++) {
		itemswidth += (topelemwidth[i] + borderSepWidth)
	}

	level1count = 0
	var level1dists = new Array()
	if (menualign == "right") {
		level1off = mostright - itemswidth
	}
	else if (menualign == "center") {
		level1off = (( mostright - itemswidth - mostleft ) / 2 ) + mostleft
	}
	for (i=1;i<=items.length-1;i++) {
		if (items[i].length == 1) {
			document.getElementById(items[i]).style.left = level1off
		}
		else if (items[i].length == 5) {
			document.getElementById(items[i]).style.left = level1off
			level1dists[level1count] = level1off + width //save position
			level1off += parseInt(topelemwidth[i-1],10) + borderSepWidth //add width and borderwidth
			level1count++
		}
		else if (items[i].length == 7) {
			temp1 = (parseInt("0"+items[i].charAt(3)+items[i].charAt(4),10)-1)
			xdist = level1dists[temp1] + 1
			if (mi) {
				if ( xdist+width > document.body.clientWidth )
					xdist -= (2*width+2)
			}
			else {
				if ( xdist+width > window.innerWidth )
					xdist -= (2*width+2)
			}
			document.getElementById(items[i]).style.left = xdist
		}
	}
	menualign = "left" //this prevents alignmenu to be run again if scroll=true
	putpostit()
}

window.onresize=refresh
