// JavaScript Document

// -------------------------------------------
// will add target to external links (jQuery)
// -------------------------------------------
function externalLinks(){
	$('a[@rel^="external"]').attr('target', '_blank').click(function(){
		hideAmbassador();
	});
}
// -------------------------------------------

// -------------------------------------------
// coupons page popup
// -------------------------------------------
function setUpCouponPopup(){
	$('a.coupon').click(function(){
		var dimensions = new Array();
		dimensions = $(this).attr('rel').split('-');
		window.open(this.href,'viewer','width='+dimensions[0]+',height='+dimensions[0]);
		return false;
	});
}
// -------------------------------------------

function togglePkgDesc(pkg){
	//alert(pkg);
	$('.'+pkg).toggle('fast');
}

// -------------------------------------------
// will close the "talking head" online ambassador (jQuery)
// -------------------------------------------
function hideAmbassador(){
	$("#onlineAmbassador_wrap").slideUp("slow");
}
// -------------------------------------------

// -------------------------------------------
// functions to launch MULTICAST Player
// -------------------------------------------
function launchPlayer(hashCode) {
	playerwin = window.open("http://vidego.multicastmedia.com/player.php?v=" + hashCode, "newwindow", "height=504,width=869", "toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no");
}

// -------------------------------------------

// -------------------------------------------
// functions to launch tee times app
// -------------------------------------------
var myhandle=null;

function checkit(UID,SiteID,PID,RedLine) {
// This function is used to close any open tee time windows, then open a new window for the tee time app to prevent application var problems
	if(myhandle && !(myhandle.closed)) {
 		//alert('Window is open - closing');
 		myhandle.close();
 		openit(UID,SiteID,PID,RedLine);
	} else {
 		//alert('Window is closed - opening');
 		openit(UID,SiteID,PID,RedLine);
	}
}
// -------------------------------------------
function openit(UID,SiteID,PID,RedLine,urlCourseID){
	//var urlVars = 'https://secure.guestdesk.com/teetimes/?UID='+UID+'&SiteID='+SiteID+'&PID='+PID+'&ShowRedLine='+RedLine;
	//if(urlCourseID != undefined){ urlVars += '&urlCourseID='+urlCourseID; }
	//myhandle=window.open(urlVars,'windowName','toolbar=no,scrollbars=no,location=no,resizable=no,directories=no,status=yes,menubar=no,width=800,height=505,titlebar=TeeTimes,left=2,top=2')

	var urlVars = 'http://secure.guestdesk.com/reservations/?systemType=3&UID='+UID+'&SiteID='+SiteID+'&PID='+PID;
	if(urlCourseID != undefined){ urlVars += '&courseID='+urlCourseID; }
	myhandle=window.open(urlVars,'windowName','scrollbars=yes,toolbar=yes,location=no,directories=no,status=yes,width=1000,height=800,titlebar=TeeTimes,left=2,top=2')
}

// -------------------------------------------
// functions to launch golf packages app
// -------------------------------------------
function openGolfPackageSystem(ID,siteID,systemType,packageURLID){
	var urlVars = 'https://secure.guestdesk.com/golf/main.cfm?ID='+ID+'&siteID='+siteID+'&systemType='+systemType+'&packageURLID='+packageURLID;
	myhandle=window.open(urlVars,'windowName','toolbar=no,scrollbars=no,location=no,resizable=no,directories=no,status=yes,menubar=no,width=800,height=505,titlebar=GolfPackages,left=2,top=2')
}

// -------------------------------------------
// functions to track through omniture (jQuery)
// -------------------------------------------
$(document).ready(function(){
	if ($('.gilink').length > 0) {
		$('.gilink').click(function(){
			s=s_gi('bambncom');
			s.linkTrackVars = 'prop19';
			s.prop19 = $(this).parent().parent().children(':first').children(':first').html().toLowerCase();
			s.tl(this, 'o', s.prop19);
		});
	}
	if ($('.action').length >0 ) {
		$('.action').click(function(){
				s=s_gi('bagolfholidaydev');
				s.linkTrackVars = 'events';
				s.linkTrackEvents='event15';
				s.events = 'event15';
				s.tl(this, 'o', 'Event 15');
			});
	}
	
	if ($('#bookform').length >0 ) {
		$('#bookform').submit(function(){
				s=s_gi('bambncom');
				s.linkTrackVars = 'events';
				s.linkTrackEvents='event35';
				s.events = 'event35';
				s.tl(this, 'o', 'Initial TTO Search Submission');
			});
	}
	
	if ($('#showCoursese').length > 0){
		jQuery('#showCoursese').click(function(){
				jQuery('#allCourses').toggle();
			
		});
	}
});