//alert("Welcome to the CECP virtual Conference");
//Custom API for cross-platform object positioning
//Adapted from "Dynamic HTML: The Definitive Guide" by Danny Goodman

//--------------------------------------------------------------
//Global variables

var isNav
var isIE
var coll=""
var styleObj = ""
var z=0
if (parseInt(navigator.appVersion) >=4) {
	if (navigator.appName=="Netscape") {
		isNav=true
		isIE=false
	} else {
		isNav = false
		isIE  = true
		coll = "all."
		styleObj = ".style"
	}
}
//--------------------------------------------------------------



//--------------------------------------------------------------
// Convert object name string or object reference
// into a valid object reference
function getObject(obj) {
	var theObj 
	if (typeof obj == "string") {
		theObj = eval("document." + coll + obj + styleObj)
	} else {
		theObj = obj
	}
	return theObj
}
//--------------------------------------------------------------


//--------------------------------------------------------------
//Positioning an object at a specific pixel coordinate
function shiftTo(obj, x ,y) {
	var theObj = getObject(obj)
	if (isNav) {
		theObj.moveTo(x,y)
	} else {
		theObj.pixelLeft = x
		theObj.pixelTop = y
	}
}
//--------------------------------------------------------------


//--------------------------------------------------------------
//Moving an object by x and/or y pixels
function shiftBy(obj, deltaX ,deltaY) {
	var theObj = getObject(obj)
	if (isNav) {
		theObj.moveBy(deltaX,deltaY)
	} else {
		theObj.pixelLeft += deltaX
		theObj.pixelTop += deltaY
	}
}
//--------------------------------------------------------------


//--------------------------------------------------------------
//Setting the z-order of an object
function setZIndex(obj, zOrder) {
	var theObj = getObject(obj)
	theObj.zIndex = zOrder
}
//--------------------------------------------------------------



//--------------------------------------------------------------
//Setting the background color of an object
function setBGColor(obj, color) {
	var theObj = getObject(obj)
		if (isNav) {
		theObj.bgColor = color
	} else {
		theObj.backgroundColor = color
	}
}
//--------------------------------------------------------------

//--------------------------------------------------------------
//Setting the font color of an object
function setColor(obj, color) {
	var theObj = getObject(obj)
		theObj.Color = color
}
//--------------------------------------------------------------



//--------------------------------------------------------------	
//Set element background color (dynamic in IE only)
function setBorderColor(obj, color) {
	var theObj = getObject(obj)
	theObj.borderColor = color
}
//--------------------------------------------------------------


	
//--------------------------------------------------------------		
//Show an object		
function show(obj) {
	var theObj = getObject(obj)
	theObj.visibility="visible"
	if (isIE) {
	theObj.display="block"
	}  else {
	theObj.height=""
	}
}
//--------------------------------------------------------------



//--------------------------------------------------------------
//Hide an object
function hide(obj) {
//alert(obj);
	var theObj = getObject(obj)
	theObj.visibility = "hidden"
	if (isIE) {
	theObj.display="none"
	} else {
	theObj.height=0
	}
}
//--------------------------------------------------------------


//--------------------------------------------------------------
//Retrieve the x coordinate of a positionable object
function getObjectLeft(obj) {
	var theObj = getObject(obj)
		if (isNav) {
		return theObj.left
	} else {
		return theObj.pixelLeft
	}
}
//--------------------------------------------------------------



//--------------------------------------------------------------
//Retrieve the y coordinate of a positionable object
function getObjectTop(obj) {
	var theObj = getObject(obj)
		if (isNav) {
		return theObj.top
	} else {
		return theObj.pixelTop
	}
}
//--------------------------------------------------------------



//--------------------------------------------------------------
//Determine whether to hide or show an object
function HideOrSeek(obj){
	//alert('in HideOrSeek! for obj=\n' + obj);
	var theObj = getObject(obj)
	if (theObj.visibility=="visible" || theObj.visibility=="show") {
		hide(obj)
	} else {
		show(obj)
	}
	//alert(theObj.visibility);
}
//--------------------------------------------------------------




//--------------------------------------------------------------
//Set a given image to "on"
function imageOn(name,i) {
	if (document.images) {
		document.images[name].src = onImgArray[i].src
		}
}
//--------------------------------------------------------------



//--------------------------------------------------------------
//Set a given image to "off"
function imageOff(name,i) {
	if (document.images) {
		document.images[name].src = offImgArray[i].src
		}
}
//--------------------------------------------------------------



//--------------------------------------------------------------
//Set a given image to "clicked"
function imageClick(name,i) {
	if (document.images) {
		document.images[name].src = clickImgArray[i].src
		}
}
//--------------------------------------------------------------



//--------------------------------------------------------------
//determine which image to show
function imageSwitch(name,i) {
	if (document.images) {
		if (document.images[name].src == offImgArray[i].src) {
		imageOn(name, i)
		} else {
		imageOff(name, i)
		}
	}
}

//--------------------------------------------------------------
function action(actionvalue) {
	document.LoginFrm.theaction.value=actionvalue
	document.LoginFrm.submit()
}

function submitbadlogin(modevalue) {
	document.badpass.action.value=modevalue
	document.badpass.submit()
}

// whitespace characters
var whitespace = " \t\n\r";

// Check whether string s is empty.
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s) {
	 var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

//--------------------------------------------------------------
//emails user password
function sendpass() {
   //alert(document.LoginFrm.id.value);
	if (isWhitespace(document.LoginFrm.id.value)) {
		alert('Please enter your participant ID');
	} else {
		document.LoginFrm.theaction.value='sendpassword';
		document.LoginFrm.submit();
	}
}

function sendpass_2() {
   //alert(document.BadLoginFrm.id.value);
	if (isWhitespace(document.BadLoginFrm.id.value)) {
		
		alert('Please enter your participant ID');
	} else {
		document.BadLoginFrm.theaction.value='sendpassword';
		document.BadLoginFrm.submit();
	}
}

	
