﻿//***********************************paging***********************************
function Paging(f,path,page)
{
	obj = f;
	if(page != null)
	{
		obj.PageNo.value = page;
	}
	
	obj.action = path;
	obj.submit();
}
///////////////////////////////////end paging////////////////////////////////////

//***********************************png backgrounds***********************************
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	window.attachEvent("onload", fixPngs);
}

function alphaBackgrounds(){
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
	for (i=0; i<document.all.length; i++){
		var bg = document.all[i].currentStyle.backgroundImage;
		if (itsAllGood && bg){
			if (bg.match(/\.png/i) != null){
				var mypng = bg.substring(5,bg.length-2);
				document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"',sizingMethod='scale')";
				document.all[i].style.backgroundImage = "url('/assets/images/x.gif')";
			}
		}
	}
}

// Loops through all img tags

///////////////////////////////////end backgrounds////////////////////////////////////

//***********************************popup***********************************

function OpenGallery(type,id,index)
{
	window.open("../includes/ga_" + type + "_gallery.asp?" + type + "ID=" + id + "&imageIndex=" + index, '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=510,height=600');	
	/*
	if (type == "club")
	{
		window.open("club_gallery.asp?clubID=" + id + "&imageIndex=" + index, '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=510,height=600');	
	}	
	if (type == "hotel")
	{
		window.open("hotel_gallery.asp?hotelID=" + id + "&imageIndex=" + index, '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=510,height=600');	
	}
	*/
}

function CheckSearch()
{
	var bOK;
	var obj;
	obj = document.txtKeyWord
	bOK=true;

		if(obj.txtKeyWord.value == "") {
			alert("Form Help\n===================\nPlease enter the keyword\nyou wish to search for");
			obj.txtKeyWord.focus();
			bOK = false;
		}
    return bOK;
}

function legals() {
			window.open("../legals/legals.asp",'_blank',WinType);		
			}
			var WinType;
			WinType="width=400,height=470,left=380,top=50,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no";

function enquiryForm() {
			window.open("../contact/enquiry_form_popup.asp",'_blank',WinType2);		
			}
			var WinType2;
			WinType2="width=350,height=440,left=380,top=50,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no";

///////////////////////////////////end popup////////////////////////////////////


//***********************************print***********************************

var da = (document.all) ? 1 : 0; // browser is VB compatible
var pr = (window.print) ? 1 : 0; // must be NS4, IE5
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage() {

  if (pr)
  {
	if ((navigator.appName.substring(0,8) == "Netscape") && (parseInt(navigator.appVersion) <= 4))
	 {
		if ((parseInt(navigator.appVersion) == 4) && (parseInt(navigator.appMinorVersion) == 7)) {
			 alert("Page Help\n===================\nSorry, your browser doesn't\nsupport this feature.\nTo print this page on a\nMacintosh please use\nthe Command and P keys."); 
		}		
	}
	else {
		window.print();
	}
  }	
  else if (da && !mac)
    vbPrintPage()
  else
   
    alert("Page Help\n===================\nSorry, your browser doesn't\nsupport this feature.\nTo print this page on a\nMacintosh please use\nthe Command and P keys."); 
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}
///////////////////////////////////end print////////////////////////////////////

//***********************************select jumper***********************************

function quickFinder() {
	sWindow = document.forms[0].jumper.options[document.forms[0].jumper.selectedIndex].value;
			
	if (sWindow == 1) {
	window.open("../contact/","_self");							
	}

	if (sWindow == 2) {
	window.open("../contact/","_self");							
	}

	if (sWindow == 3) {
	window.open("../it_consultancy/","_self");							
	}

	if (sWindow == 4) {
	window.open("../login/","_self");							
	}


}	

///////////////////////////////////end select jumper////////////////////////////////////

//***********************************favourites***********************************

function favourites(){
		if (navigator.platform.indexOf('Mac') > -1){
		alert("Page Help\n===================\nSorry, your browser doesn't\nsupport this feature. To add\nthis page to your favourites\non a Macintosh please use\nthe Command and D keys.");
		}
		else {
		window.external.AddFavorite(location.href, document.title);
		}
		}
///////////////////////////////////end favourites////////////////////////////////////

function toggle(anchor, items)
{
	tbody = document.getElementById('tbody_' + items);
	if (!tbody)
	{
		alert('TBODY ' + items + ' not found!');
		return;
	}
	
	if (tbody.style.display == 'none')
	{
		tbody.style.display = '';
		anchor.innerText = 'Less ' + items + '...';
	}
	else
	{
		tbody.style.display = 'none';
		anchor.innerText = 'More ' + items + '...';
	}
	
}

function toggleSearchTabs(tabName) {
	var teeDiv = document.getElementById('divTeeSearch2');
	teeDiv.style.display = (tabName == "tee" || tabName == "")? 'block' : 'none';
	
	var courseDiv = document.getElementById('divCourseSearch2');
	courseDiv.style.display = (tabName == "course")? 'block' : 'none';
	
	var searchType = document.getElementById('searchType');
	searchType.value = (tabName == "course")? 'course' : 'tee';
	
	var ttime = document.getElementById('teeTimeTab');
	var gcourse = document.getElementById('courseSearchTab');
	ttime.src = (tabName == 'tee' || tabName == '')? '/images/blank.gif':'/images/blank.gif';
	gcourse.src = (tabName == 'tee' || tabName == '')? '/images/blank.gif':'/images/blank.gif';
	
	var tabForm = document.getElementById('frmClubSearch');
	
	if(tabName == "course") {
	
		document.frmClubSearch.action = "/course-directory/search-results.asp";
		document.getElementById('courseLink').blur();
		document.getElementById('courseLink').className = "courseLinkSelected";	
		document.getElementById('teeLink').className = "";		
		
	} else {
	
		document.frmClubSearch.action = "/course-directory/search-results-tee-time.asp";
		document.getElementById('teeLink').blur();	
		document.getElementById('teeLink').className = "teeLinkSelected";	
		document.getElementById('courseLink').className = "";		
	}
	
	
	

}

function submitCourseAndTeeForm() {


	if(document.getElementById('eventday').value == '' || document.getElementById('eventmonth').value == '' || document.getElementById('eventyear').value == '' ||document.getElementById('event2day').value == '' || document.getElementById('event2month').value == '' || document.getElementById('event2year').value == '') 
        { 
        	 window.alert('Please enter a start and end date.');
        } else { 
        
         	document.frmClubSearch.submit();
        }
}


function processTeeTimeCourseSearchForm() {


	var clubList = document.getElementById('clublistdisplay');
	
	var courseInputStr = "";
	
	var courseInputs = clubList.getElementsByTagName("input");
	
	for (var i = 0; i < courseInputs.length; i++) { 
	
    		courseInput = courseInputs[i];
    		
    		if(courseInput.checked) {
    		   courseInputStr =  courseInputStr + courseInput.value + ",";
    		}
    		
    	}
    	
    	
    	if(courseInputStr == "") {
   			 	
   	 	window.alert("Please select at least one course to search for tee times");
   	 	
    	} else {
    	
    		document.getElementById('hdCourses').value = courseInputStr;
    		document.frmTeeSearchCourses.submit();
    	}
    	
    	
    

}

function changeImage(displayImage, maxCount)
	{
		if( displayImage < 1)
		{
			displayImage = 1;
		}
		
		if(	displayImage > maxCount )
		{
			displayImage = maxCount;
		}
	
		if ((displayImage > 0) && (displayImage <= maxCount))
		{ 
			var shotName;
			document.getElementById('clubshot').style.backgroundImage = "url(../images/" + eval("gaimages[" + displayImage + "].imageType") + "/" + eval("gaimages[" + displayImage + "].countryName") + "/medium/" +  eval("gaimages[" + displayImage + "].imageName") +  "b.jpg)" ;
			document.getElementById('imageNo').value = displayImage;
			shotName = eval("gaimages[" + displayImage + "].imageName");
			shotName = shotName.substring(19,23)
			
			if (shotName == "--th" )
			{
				shotName = "";
			}
			else
			{
				if (shotName == "club" )
				{
					shotName = ", club house";
				}
				else
				{
					shotName = ", " + shotName + " hole";
					
					if ( shotName.substring(2,3) == "0")
					{
						shotName = ", " +  shotName.substring(3,11);
					}
				}
			}
			document.getElementById('imageLabel').innerHTML = shotName;
			
			//deal with disabling buttons
			if (displayImage >= maxCount)
			{
				document.getElementById('nextimg').disabled = true;




			}
			else
			{
				document.getElementById('nextimg').disabled = false;
			}
			if (displayImage <= 1)
			{
				document.getElementById('previmg').disabled = true;	
			}
			else
			{
				document.getElementById('previmg').disabled = false;
			}	
		}
	
	}
		
	function hide() 
	{ 
		document.getElementById("hideSearch").style.display = "none";
		document.getElementById("hideSearchlink").style.display = "none";  
		document.getElementById("searchBar").style.display = "none";
		document.getElementById("expandSearch").style.display = "inline";
		document.getElementById("expandSearchlink").style.display = "inline";
		return;
	}
	
	function show() 
	{ 
		document.getElementById("hideSearch").style.display = "inline";
		document.getElementById("hideSearchlink").style.display = "inline";
		document.getElementById("searchBar").style.display = "inline";
		document.getElementById("expandSearch").style.display = "none";
		document.getElementById("expandSearchlink").style.display = "none";
		return;
	}
	
	function hideGuide() 
		{ 
			document.getElementById("hideGuide").style.display = "none";
			document.getElementById("expandGuide").style.display = "inline";
			return;
		}
		
		function showGuide() 
		{ 
			document.getElementById("hideGuide").style.display = "inline";
			document.getElementById("expandGuide").style.display = "none";
			return;
		}
	

	
	function GaImage(courseImageID, imageName, countryName, imageType)
	{	
		this.courseImageID = courseImageID;
		this.imageName = imageName;
		this.countryName = countryName;
		this.imageType = imageType;
	}


