function rollin(obj){
	obj.style.backgroundColor = "#DEDBD6"
	obj.style.cursor = 'pointer'
}
function rollout(obj, col){
	obj.style.backgroundColor = col
}

function getCopy(){
	return '&copy; Low GI Dieting ' + GetYear()
}
function GetYear()
{
	var d = new Date()
	return d.getFullYear()
}
function dest(loc){
	document.location = loc
}

function gotoarea(sel){
	var idx = sel.selectedIndex
	var loc = sel.options[idx].value + ".asp"
	document.location = loc
}

function GetADate(){
	var d = new Date()
	var months = new Array()
	months[0] = "January"
	months[1] = "February"
	months[2] = "March"
	months[3] = "April"
	months[4] = "May"
	months[5] = "June"
	months[6] = "July"
	months[7] = "August"
	months[8] = "September"
	months[9] = "October"
	months[10] = "November"
	months[11] = "December"
	return d.getDate() + ' ' + months[d.getMonth()] + ' ' + d.getFullYear()
}


var stories = new Array()
stories[0] = 'Do the GI Diet the Sweeter Way'

var ptr = 1
var story = -1
var widget = '_'
	

function doTicker(){

	if(document.all){
	
		if(ptr == 1){
		   nextStory();
		}

		if(ptr != stories[story].length) {
			drawStory();
		}
		else{
			stopStory();
		}
          
    }
    else{
		tckr = document.getElementById("tckr")
		story =Math.round(Math.random() * (stories.length - 1))		
		tckr.innerHTML = stories[story]
    }
          		
}

function nextStory(){
	story = story + 1
	if(story > stories.length - 1) story = 0
}

function drawStory(){

	if(!document.all) tckr = document.getElementById("tckr")
	
	tckr.innerHTML = stories[story].substring(0,ptr) + widget
	ptr ++
	
	setTimeout('doTicker()',100)
	
}

function stopStory(){

	if(!document.all) tckr = document.getElementById("tckr")
	tckr.innerHTML = stories[story]
	ptr = 1
	setTimeout("doTicker()", 5000);
	
}

// Checks for email in send to a friend
function validate(frm){

    if (frm.name.value == ""){ 
        alert("Please enter a name")
        frm.name.focus()
        return false
    }

    if (frm.email.value.indexOf ('@') == -1 || frm.email.value.indexOf ('.') == -1){
        alert("Please enter a valid email address")
        frm.email.focus()
        return false
    }

    if (frm.comments.value == ""){ 
        alert("Please enter a comment")
        frm.comments.focus()
        return false
    }
    
    return true
 
}

// Functions for menu handling
function showDiv(n,hdr,expandDirection,horAdj,verAdj){

	if(!currentDiv || currentDiv == null) return

	// Hide current div
	hideCurrentDiv(currentDiv)
	
	var xpos = 0
	var ypos = 0

	switch (expandDirection) { 
		case 'below': 
			xpos = getX(hdr); 
			ypos = getY(hdr) + hdr.offsetHeight; 
			break; 
		case 'right': 
			xpos = getX(hdr) + hdr.offsetWidth - 1; 
			ypos = getY(hdr) - 1; 
			break; 
		default: 
			xpos = getX(hdr) + hdr.offsetWidth; 
			ypos = getY(hdr); 
			break; 
	} 

	xpos += horAdj; 
	ypos += verAdj; 

	menutoshow = document.getElementById("menu" + n + "Div")
	if(!menutoshow || menutoshow == null) return
	
	menutoshow.style.left = xpos
	menutoshow.style.top = ypos

	currentDiv = n
    
}

function hideDiv(n){
    if(!keepMenu){
		menu = document.getElementById("menu" + n + "Div")
		if(!menu || menu == null) return
        menu.style.top = -500
	}
}

function hideCurrentDiv(n){
	menu = document.getElementById("menu" + n + "Div")
	if(!menu || menu == null) return
    menu.style.top = -500
}



// Calculates the absolute page x coordinate of any element 
function getX(element) { 

	var x = 0; 

	do { 

		if (element.style.position == 'absolute') { 

			return x + element.offsetLeft; 

		} 

		else { 

			x += element.offsetLeft; 

			if (element.offsetParent) 

				if (element.offsetParent.tagName == 'TABLE') 

					if (parseInt(element.offsetParent.border) > 0) { 

						x += 1; 

					} 
		} 

	} while ((element = element.offsetParent)); 

	return x; 

} 

// Calculates the absolute page y coordinate of any element 
function getY(element) { 

	var y = 0; 

	do { 

		if (element.style.position == 'absolute') { 

			return y + element.offsetTop; 

		} 

		else { 

			y += element.offsetTop; 

			if (element.offsetParent) 

				if (element.offsetParent.tagName == 'TABLE') 

					if (parseInt(element.offsetParent.border) > 0) { 

						y += 1; 

					} 

		} 

	} while ((element = element.offsetParent)); 

	return y; 

} 

