// 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(s_account);
			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(s_account);
				s.linkTrackVars = 'events';
				s.linkTrackEvents='event15';
				s.events = 'event15';
				s.tl(this, 'o', 'Event 15');
			});
	}
	
	if ($('.sort').length >0 ) {
		$('.sort').click(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'prop30';
				s.prop30 = $(this).attr('rel').toLowerCase();
				s.tl(this, 'o', 'Sort by Clicks');
			});
	}
	if ($('.returnForm').length >0 ) {
		$('.returnForm').click(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'prop25';
				s.prop25 = 'Return To Form';
				s.tl(this, 'o', 'Return To Form');
			});
	}
	
	if ($('.omni-tab').length >0 ) {
		$('.omni-tab').click(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'prop32';
				s.prop32 = $(this).html().toLowerCase();
				s.tl(this, 'o', 'Course Profile Tab Click');
			});
	}
	
	if ($('.omni-quotes').length >0 ) {
		$('.omni-quotes').click(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'events,eVar21';
				s.linkTrackEvents='event45';
				s.events = 'event45';
				s.eVar21 = $(this).html().toLowerCase();
				s.tl(this, 'o', 'Profile Page Widget Click');
			});
	}
	
	if ($('#bookform').length >0 ) {
		$('#bookform').submit(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'events';
				s.linkTrackEvents='event35';
				s.events = 'event35';
				s.tl(this, 'o', 'Initial TTO Search Submission');
			});
	}
	
	/*if ($('.continueTwo').length >0 ) {
		$('.continueTwo').click(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'events';
				s.linkTrackEvents='event24';
				s.events = 'event24';
				s.tl(this, 'o', 'Quick Quote Step 1');
			});
	}*/
	
	if ($('.ttrounds').length >0 ) {
		$('.ttrounds').click(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'prop33';
				s.prop33 = $(this).html().toLowerCase();
				s.tl(this, 'o', 'Tee Time Special Nav Clicks');
			});
	}
	
	if ($('#lpButDivID-1280157430').children().children().children().children().children().children().length > 0 ) {
		$('#lpButDivID-1280157430').children().children().children().children().children().children().click(function(){
				s=s_gi(s_account);
				s.linkTrackVars = 'events';
				s.linkTrackEvents='event41';
				s.events = 'event41';
				s.tl(this, 'o', 'Online Chat Click');
			});
	}
	
	if ($('#showCoursese').length > 0){
		jQuery('#showCoursese').click(function(){
				jQuery('#allCourses').toggle();
			
		});
	}
});
