var IE = true;
// menu functions 

var selected;

var arrow = new Image()
arrow.src = "images/arrow.png"
var empty = new Image()
empty.src = "images/empty.png"

function select() { 
	selected=document.getElementById("selectMe")
	if (selected) {
		selected.style.border= "solid 1px #ADC0D8"
		selected.firstChild.firstChild.src= "images/bluearrow.png"
		selected.style.color="#065A8A"
	}
}
function over(t) {
	if (t == selected)
		return
	t.style.textDecoration= "underline" 
	t.firstChild.firstChild.src= arrow.src //"images/arrow.png"
	t.style.backgroundColor= '#FFE8BF' // #FFFFFF
}
function out(t) {	
	if (t == selected)
		return
	t.style.textDecoration= "none" 
	t.firstChild.firstChild.src= empty.src //"images/empty.png"
	t.style.backgroundColor= "#EEEEEE"
}
function nav(ref) {	
	document.location = ref 
}

function newWin(ref,name,w,h) {
	window.open(ref,name,"toolbar=no,screenX=0,screenY=0,width=" + w + ",height=" + h)
}


// dropdown menu functions
function mOver(e) {
	e.style.backgroundColor= '#FFE8BF' // #FFFFFF
	e.firstChild.style.color= "#FF8D1A" //"#009900"
}

function mOut(e) {
	e.style.backgroundColor= '#FFFFFF'
	e.firstChild.style.color= "#000000"
}

// Navigation javascript
function hideit(e) {
	var d = document.getElementById("dropdown")
	if (d.style.visibility == "visible") {
		if (IE) { // grab the x-y pos.s if browser is IE
			tempX = event.clientX + document.body.scrollLeft
			tempY = event.clientY + document.body.scrollTop
		}	else {  // grab the x-y pos.s if browser is NS
			tempX = e.pageX
			tempY = e.pageY
		}  
		if (tempX < 0)
			tempX = 0
		if (tempY < 0)
			tempY = 0 
		dPad = 10
		dLeft = getx(d)
		dBottom = gety(d) - 8
		if (tempX < dLeft - dPad) {
			d.style.visibility="hidden"
			return
		}
		if (tempX > dLeft + d.offsetWidth + dPad) {
			d.style.visibility="hidden"
			return
		}
		if (tempY < dBottom - d.offsetHeight - 30 - dPad) {
			d.style.visibility="hidden"
			return
		}
		if (tempY > dBottom + dPad)
			d.style.visibility="hidden"
	}
}

function showit(d,r) {
	// remove all children
	var m = document.getElementById("dropdown")
	var c = m.childNodes
	while (m.hasChildNodes())
		m.removeChild(m.firstChild)
//	for (var i=0; i<c.length; i++)
//		m.removeChild(c[i])
	switch(d.id) {
		case "products":
			makeMenuLink(m,"Grouputer","web-conferencing.html")
			makeMenuLink(m,"SigmaSense","sigmasenseoverview.html")
//			makeMenuLink(m,"Overview","overview.html")
//			makeMenuLink(m,"Solutions","solutions.html")
//			makeMenuLink(m,"Training","training.html")
//			makeMenuLink(m,"Support","support.html")
//			makeMenuLink(m,"Pricing","pricing.html")
			break
		case "demos":
			makeMenuLink(m,"Screen Tours","usinggrouputer.html")
			makeMenuLink(m,"LIVE Demonstrations","livedemos.html")
//			makeMenuLink(m,"LIVE: Survey Demo","livesurveydemo.html")
//			makeMenuLink(m,"LIVE: Process Demo","liveprocessdemo.html")
			break
		case "resources":
			makeMenuLink(m,"White Papers","whitepapers.html")
			makeMenuLink(m,"Testimonials","testimonials.html")
			break
		case "events":
			makeMenuLink(m,"Seminars","seminars.html")
//			makeMenuLink(m,"Webinars","webinars.html")
			break
		case "us":
			makeMenuLink(m,"Who Are We?","whoarewe.html")
			makeMenuLink(m,"Resellers","resellers.html")
			makeMenuLink(m,"Alliance Partners","partners.html")
			break
		case "contact":
			makeMenuLink(m,"Office Location","location.html")
			makeMenuLink(m,"Make an Enquiry","inquiry.html")
			break
	}
	m.style.visibility="visible"
//	m.style.left= Math.round((getx(d) + (d.offsetWidth/2)) - 75) + "px"
	if (r)
		m.style.left= (getx(d) - 20) + "px"
	else
		m.style.left= (getx(d) - 80) + "px"
  m.style.top= gety(d) + "px"
	
}

function makeMenuLink(m,title,link) {
	linkstr = "<div class=\"dropdown\" onMouseOver=\"mOver(this)\" onMouseOut=\"mOut(this)\">" +
						 "<li style=\"list-style-type:square;font-size:8pt\"><a href=\"" + link + "\" class=\"link\" onClick=\"hideit()\">" + title + "</a></li></div>"
	m.innerHTML = m.innerHTML + linkstr
}

function gety(e){
  var y = e.offsetTop + e.offsetHeight
  var p = e.offsetParent
  while (p != null) { 
  	y += p.offsetTop
    p = p.offsetParent
  }
  return y + 3
}

function getx(e){
  var x = e.offsetLeft
  var p = e.offsetParent
  while (p != null) { 
  	x += p.offsetLeft
    p = p.offsetParent
  }
  return x
}


