function changeList(listType)
{

var xmlhttp;

if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
  
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("courseList").innerHTML=xmlhttp.responseText;
    }
  
  }


xmlhttp.open("GET",listType + "?t=" + Math.random(),true);
xmlhttp.send();

}



function gotocourse(courseid)
{

var xmlhttp;

if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
  {
  
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("courseList").innerHTML=xmlhttp.responseText;
    }
  
  }



xmlhttp.open("GET","coursepage.php?q=" + courseid +"&t=" + Math.random(),true);
xmlhttp.send();

}





function mouseover(buttonid, cname)
{
	butt = document.getElementById(buttonid);
	butt.setAttribute("class", cname);
	butt.setAttribute("className", cname);
}


function mouseout(buttonid, cname)
{
	butt = document.getElementById(buttonid);
	butt.setAttribute("class", cname);
	butt.setAttribute("className", cname);
}



function mouseover2(buttonid, image)
{
	butt = document.getElementById(buttonid);
	butt.src = "images/sitepics/" + image;
}


function mouseout2(buttonid, image)
{
	butt = document.getElementById(buttonid);
	butt.src = "images/sitepics/" + image;
}



function redirect(url)
{
window.location.href=url;
}


		
function setvisibility(elem,tf)
{
	elem = document.getElementById(elem);
        if (tf == "visible")
	{
		elem.style.visibility =	'visible';
	}
	else
	{
		elem.style.visibility = 'hidden';
	}


}


function positionPopup(elem,bgelem) 
{
	var winwidth = 630, winheight = 460;
	if (document.body && document.body.offsetWidth) 
	{
		winwidth = document.body.offsetWidth;
		winheight = document.body.offsetHeight;
	}
	if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) 
	{
 		winwidth = document.documentElement.offsetWidth;
 		winheight = document.documentElement.offsetHeight;
	}
	if (window.innerWidth && window.innerHeight) {
 		winwidth = window.innerWidth;
 		winheight = window.innerHeight;
	}
			
	if (document.getElementById) 
	{
				
		if (winheight > 0) 
		{
			var elem = document.getElementById(elem);
			var elemheight = elem.offsetHeight;
			var elemwidth = elem.offsetWidth;
			if (winheight - elemheight > 0) 
			{
				elem.style.position = 'fixed';
				elem.style.top = ((winheight / 2) - (elemheight / 2)) + 'px';
				elem.style.left = ((winwidth / 2) - (elemwidth / 2)) + 'px';
			}
			else 
			{
				elem.style.position = 'static';
			}

			var bgelem = document.getElementById(bgelem);
			bgelem.style.position = 'fixed';
			bgelem.style.width = winwidth  + 'px';
			bgelem.style.height = winheight  + 'px';
			bgelem.style.top = '0px';
			bgelem.style.left = '0px';
		}
	}
}



function validateGFForm()
{
//var firstname=document.forms["greenfeepurchaseform"]["firstname"].value;
//var lastname=document.forms["greenfeepurchaseform"]["lastname"].value;
//var city=document.forms["greenfeepurchaseform"]["city"].value;
//var province=document.forms["greenfeepurchaseform"]["province"].value;
var email1=document.forms["greenfeepurchaseform"]["email1"].value;
var email2=document.forms["greenfeepurchaseform"]["email2"].value;

/*
if (firstname==null || firstname=="" || lastname==null || lastname=="" || city==null || city=="" || province==null || province=="" || email1==null || email1=="" || email2==null || email2=="")
  {

  firstnameerr="";
  lasttnameerr="";
  cityerr="";
  emailerr="";

  if (firstname==null || firstname=="") {firstnameerr="Please enter your FIRST NAME in the appropriate field";}
  if (lastname==null || lastname=="") {lastnameerr="Please enter your LAST NAME in the appropriate field";}
  if (city==null || city=="") {cityerr="Please enter your CITY in the appropriate field";}
  if (email1==null || email1=="" || email2==null || email2=="") {emailerr="Please fill in both E-MAIL fields";}

  alert("Please complete all required fields:" + '\n' + '\n' + firstnameerr + '\n' + lastnameerr + '\n' + cityerr + '\n' + emailerr);
  return false;
  }

*/

if (email1==null || email1=="" || email2==null || email2=="")
  {
  alert("Please fill in both E-MAIL fields");
  return false;
  }

if (email1 != email2)
  {
  alert("ERROR - E-MAIL address fields do not match");
  return false;
  }

setCookie("email",email1,1000);

if (document.getElementById("optincheck").checked==true)
{
   setCookie("optin","YES",1000);
}
else
{
   setCookie("optin","NO",1000);
}

}



function validateCouponForm()
{
var email1=document.forms["coupondownloadform"]["email1"].value;
var email2=document.forms["coupondownloadform"]["email2"].value;

if (email1==null || email1=="" || email2==null || email2=="")
  {
  alert("Please fill in both E-MAIL fields");
  return false;
  }

if (email1 != email2)
  {
  alert("ERROR - E-MAIL address fields do not match");
  return false;
  }

setCookie("email",email1,1000);

if (document.getElementById("optincheck").checked==true)
{
   setCookie("optin","YES",1000);
}
else
{
   setCookie("optin","NO",1000);
}

}



function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}


function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function prepop()
{
  var email=getCookie("email");
  var optin=getCookie("optin");
  if (email!=null && email!="")
  {
   document.getElementById("emailinput1").value = email;
   document.getElementById("emailinput2").value = email;
  }
  
if (optin == "YES")
{
   document.getElementById("optincheck").checked=true;
}
else
{
   document.getElementById("optincheck").checked=false;
}
  
}

