
var overColor = "#6DACE4";
var outColor = "#134471";

function setDropDown(dd,val) {
	// check all dd values for equality to val - if equal set selected
	for (i=0;i < dd.length;i++) {
		if (dd.options[i].value == val) {
			dd.options[i].selected = true;
		}
	}
}


function submitThisPage()
{
	document.thisForm.submit();
}


function displayTermsOfUse(pageToDisplay)
{
	var cur_win = window.open(pageToDisplay, "presentationpictures", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=460,height=460,left=80,top=10");
	cur_win.focus();
}

function nextYear(pageTitle,selectedYear)
{
	if (selectedYear == '')
	{
		alert('No year selected');
		return false;
	}
	else
	{
		document.thisForm.method='Get';
		document.thisForm.action= pageTitle + selectedYear+'.php';
		document.thisForm.submit();
	}
}

function IsEmailValid(checkThisEmail)
{
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;


// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID

if (myAtSymbolAt < 1 )
 {myEMailIsValid = false}


// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID

if (myLastDotAt < myAtSymbolAt)
 {myEMailIsValid = false}

// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID

if (myLength - myLastDotAt <= 2)
 {myEMailIsValid = false}


// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid

if (mySpaceAt != -1)
 {myEMailIsValid = false}

return myEMailIsValid
}

function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);

    if(v_length < 1)
    {
		return"";
	}

    var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;

	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space)
    {
	}
	else
    {
		strTemp = VALUE.substring(iTemp,v_length);
		break;
	}
	iTemp = iTemp + 1;
	} //End While
return strTemp;
} //End Function