//Javascript document
//Author: Jeff Easton
//Modified: 10.16.2005
	
	
//This function is used client-side to validate the newsletter signup field
//Note: there is also server side validation within the php page as well
	function check(newsLetter){
	
				if(!validemail(newsLetter.email.value) || newsLetter.email.value == "Enter Email Address"){
				alert("Please enter a valid email address")
				newsLetter.email.focus()
				newsLetter.email.select()
				return false
			}
			
			
	}
	
//This function is used client-side to validate the contact form
//Note: there is also server side validation within the php page as well
	function checkIt(form){
			
			if (form.name.value == ""){
				alert("Please enter your first name")
				form.name.focus();
				return false;
			}
			
			if(!validemail(form.email.value)){
				alert("Please enter a valid email address")
				form.email.focus()
				form.email.select()
				return false
			}
		
			if (form.subject.value == ""){
				alert("Please enter a subject")
				form.subject.focus();
				return false;
			}
			if (form.comments.value == ""){
				alert("Please enter some comments")
				form.comments.focus();
				return false;
			}		
	}
			
			
	//validates the email address format
	function validemail(Email){
			
			invalidChars = "/:,;"

			if(Email == ""){
				return false
			}

			for(i=0;i<invalidChars.length;i++){
			badChar = invalidChars.charAt(i)
			
				if(Email.indexOf(badChar,0)>-1){
					return false
			}

	}

		atPos = Email.indexOf("@",1)
		if(atPos == -1){
		return false

	}
	
		if(Email.indexOf("@",atPos+1)>-1){
		return false
	
	}

		periodPos = Email.indexOf(".",atPos)
		if(periodPos == -1){
		return false
	
	}

		if(periodPos+3 > Email.length) {
		return false

	}

return true

}


//This function is used to set focus to the first field on the contact form using an onload event
	function sf(){
			document.contactForm.name.focus();
}


//These variables are used with the random image display on the homepage
var imagenumber = 3 ; //sets number of images for use
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;

//images array stores the images
//if imagenumber is increased, add new array variable
images = new Array;
images[1] = "/images/splash.jpg";
images[2] = "/images/splash2.jpg";
images[3] = "/images/splash3.jpg";



var img_src = images[rand1];


//Featured Course Rotator
var coursenumber = 36 ;
var randomnumber = Math.random() ;
var rand = Math.round( (coursenumber-1) * randomnumber) + 1 ;

courseimages = new Array;
courseimages[01] = "/images/cougar_creek_small.jpg";
courseimages[02] = "/images/athabasca_small.jpg";
courseimages[03] = "/images/black_bull_small.jpg";
courseimages[04] = "/images/black_hawk_small.jpg";
courseimages[05] = "/images/devon_small.jpg";
courseimages[06] = "/images/eagle_rock_small.jpg";
courseimages[07] = "/images/fort_in_view_small.jpg";
courseimages[08] = "/images/golden_west_small.jpg";
courseimages[09] = "/images/goose_hummock_small.jpg";
courseimages[10] = "/images/huntersgreen_small.jpg";
courseimages[11] = "/images/hinton_small.jpg";
courseimages[12] = "/images/indian_lakes_small.jpg";
courseimages[13] = "/images/iron_head_small.jpg";
courseimages[14] = "/images/jagare_ridge_small.jpg";
courseimages[15] = "/images/leduc_small.jpg";
courseimages[16] = "/images/pine_ridge_small.jpg";
courseimages[17] = "/images/pioneer_meadows_small.jpg";
courseimages[18] = "/images/raven_crest_small.jpg";
courseimages[19] = "/images/redtail_landing_small.jpg";
courseimages[20] = "/images/river_ridge_small.jpg";
courseimages[21] = "/images/sand_piper_small.jpg";
courseimages[22] = "/images/stony_plain_small.jpg";
courseimages[23] = "/images/sturgeon_valley_small.jpg";
courseimages[24] = "/images/twin_willows_small.jpg";
courseimages[25] = "/images/the_links_of_spruce_grove_small.jpg";
courseimages[26] = "/images/thenursery_small.jpg";
courseimages[27] = "/images/theranch_small.jpg";
courseimages[28] = "/images/whitemud_creek_small.jpg";
courseimages[29] = "/images/wolf_creek_small.jpg";
courseimages[30] = "/images/whitecourt_small.jpg";
courseimages[31] = "/images/albertabeach_small.jpg";
courseimages[32] = "/images/broadmoor_small.jpg";
courseimages[33] = "/images/lewis_estates_small.jpg";
courseimages[34] = "/images/riverside_small.jpg";
courseimages[35] = "/images/rundle_small.jpg";
courseimages[36] = "/images/victoria_small.jpg";


var crimg_src = courseimages[rand];

coursename = new Array;
coursename[01] = "Cougar Creek Golf Resort";
coursename[02] = "Athabasca Golf and Country Club";
coursename[03] = "Black Bull Golf Resort";
coursename[04] = "Blackhawk Golf Club";
coursename[05] = "Devon Golf Course";
coursename[06] = "Eagle Rock";
coursename[07] = "Fort-In-View";
coursename[08] = "Golden West Golf Course";
coursename[09] = "Goose Hummock Golf Resort";
coursename[10] = "Hunters Green Golf Course";
coursename[11] = "Hinton Golf Club";
coursename[12] = "Indian Lakes Golf Club";
coursename[13] = "Ironhead Golf and Country Club";
coursename[14] = "Jagare Ridge Golf Club";
coursename[15] = "Leduc Golf and Country Club";
coursename[16] = "Pineridge Golf Course";
coursename[17] = "Pioneer Meadows";
coursename[18] = "Raven Crest";
coursename[19] = "Redtail Landing Golf Club";
coursename[20] = "River Ridge";
coursename[21] = "Sandpiper";
coursename[22] = "Stony Plain Golf Course";
coursename[23] = "Sturgeon Valley Golf and Country Club";
coursename[24] = "Twin Willows";
coursename[25] = "The Links at Spruce Grove";
coursename[26] = "The Nursery Golf and Country Club";
coursename[27] = "The Ranch Golf and Country Club";
coursename[28] = "Whitemud Creek Golf Club";
coursename[29] = "Wolf Creek Golf Resort";
coursename[30] = "White Court Golf and Country Club";
coursename[31] = "Alberta Beach Golf and Country Club";
coursename[32] = "Broadmoor Golf Course";
coursename[33] = "Lewis Estates Golf Course";
coursename[34] = "Riverside Golf Course";
coursename[35] = "Rundle Golf Course";
coursename[36] = "Victoria Golf Course";

var crname_src = coursename[rand];

courselinks = new Array;
courselinks[01] = "www.cougarcreekgolf.com";
courselinks[02] = "www.athagolf.com";
courselinks[03] = "www.blackbullgolf.com";
courselinks[04] = "www.playblackhawk.com";
courselinks[05] = "www.devongolf.ca";
courselinks[06] = "www.eaglerockgolf.com";
courselinks[07] = "www.fortinview.com";
courselinks[08] = "www.goldenwestgolf.com";
courselinks[09] = "www.golfthegoose.com";
courselinks[10] = "www.huntersgreen.ca";
courselinks[11] = "www.hintongolfclub.com";
courselinks[12] = "www.indianlakes.ca";
courselinks[13] = "www.ironheadgolfcourse.ca";
courselinks[14] = "www.jagaregolf.com/home.htm";
courselinks[15] = "www.leducgolf.com";
courselinks[16] = "www.golfpineridge.com";
courselinks[17] = "www.pioneermeadows.com";
courselinks[18] = "www.countryclubtour.com";
courselinks[19] = "www.redtaillanding.com";
courselinks[20] = "www.countryclubtour.com";
courselinks[21] = "www.countryclubtour.com";
courselinks[22] = "";
courselinks[23] = "www.sturgeonvalleygolfclub.com";
courselinks[24] = "www.twinwillowsgolf.com";
courselinks[25] = "www.linksgolfcourse.com";
courselinks[26] = "www.nurserygolf.com";
courselinks[27] = "www.theranchgolf.com";
courselinks[28] = "www.whitemudcreek.com";
courselinks[29] = "www.wolfcreekgolf.com";
courselinks[30] = "www.whitecourtgolf.com";
courselinks[31] = "";
courselinks[32] = "www.broadmoorpublicgolfcourse.com";
courselinks[33] = "";
courselinks[34] = "";
courselinks[35] = "";
courselinks[36] = "";


var crlink_src = courselinks[rand];

courseyards = new Array;
courseyards[01] = "6,900";
courseyards[02] = "6,500";
courseyards[03] = "7,342";
courseyards[04] = "";
courseyards[05] = "5,818";
courseyards[06] = "6,630";
courseyards[07] = "";
courseyards[08] = "6,018";
courseyards[09] = "6,700";
courseyards[10] = "";
courseyards[11] = "6,729";
courseyards[12] = "6,425";
courseyards[13] = "6,835";
courseyards[14] = "6,835";
courseyards[15] = "6,635";
courseyards[16] = "6,244";
courseyards[17] = "4,711";
courseyards[18] = "6,722";
courseyards[19] = "6,736";
courseyards[20] = "6,472";
courseyards[21] = "6,461";
courseyards[22] = "6,473";
courseyards[23] = "6,700";
courseyards[24] = "6,255";
courseyards[25] = "6,767";
courseyards[26] = "6,690";
courseyards[27] = "6,506";
courseyards[28] = "";
courseyards[29] = "6,500";
courseyards[30] = "6,800";
courseyards[31] = "6,836";
courseyards[32] = "6,652";
courseyards[33] = "6,737";
courseyards[34] = "";
courseyards[35] = "";
courseyards[36] = "";

var cryard_src = courseyards[rand];

coursephone = new Array;
coursephone[01] = "780-892-4545";
coursephone[02] = "780-675-4599";
coursephone[03] = "780-586-2254";
coursephone[04] = "780-470-4790";
coursephone[05] = "780-987-3477";
coursephone[06] = "780-464-4653";
coursephone[07] = "780-998-1234";
coursephone[08] = "780-447-1099";
coursephone[09] = "780-921-2444";
coursephone[10] = "780-973-6687";
coursephone[11] = "780-865-2904";
coursephone[12] = "780-470-4653";
coursephone[13] = "780-892-4653";
coursephone[14] = "780-432-4030";
coursephone[15] = "780-986-4652";
coursephone[16] = "780-797-2488";
coursephone[17] = "780-988-8375";
coursephone[18] = "780-408-TOUR";
coursephone[19] = "780-890-7888";
coursephone[20] = "780-408-TOUR";
coursephone[21] = "780-408-TOUR";
coursephone[22] = "780-963-2133";
coursephone[23] = "780-973-6700";
coursephone[24] = "780-447-2934";
coursephone[25] = "780-962-4653";
coursephone[26] = "403-782-5400";
coursephone[27] = "780-470-4700";
coursephone[28] = "780-988-6800";
coursephone[29] = "1-800-783-6050";
coursephone[30] = "780-778-3531";
coursephone[31] = "780-675-4599";
coursephone[32] = "780-467-7373";
coursephone[33] = "780-489-4653";
coursephone[34] = "780-944-4427";
coursephone[35] = "780-496-4426";
coursephone[36] = "780-496-4710";

var crphone_src = coursephone[rand];
