		
$(function(){			
		   
		   
		   
	$(".more-info").click(function() {
		$(this).siblings(".package-description pkg787").toggle('fast')
		return false;
	})
		   
	function setUpTabs(){
		if('#media-tabs'){
			$('#media-tabs a').click(function(){
				var activetab = $(this).attr('href');
				$(this).parent().siblings().children('a').removeClass('active');
				$(this).addClass('active');
				$('#media .content-container').hide();
				$('#'+activetab).show();
				return false;
			});
		}
		$('#content-tabs a').click(function(){
			
			var activetab = $(this).attr('href');
			$(this).parent().siblings().children('a').removeClass('active');
			$(this).addClass('active');
			$('#details-content .content-container').hide();
			$('#'+activetab).show();
			if(activetab == "directions"){
				loadmap(); // calls the map load function
			}
			return false;
		});
	}
	setUpTabs();
	
   $('a').each(function () {
	var mylink = $(this).attr("href");
     if(typeof(mylink) != "undefined" && mylink.indexOf('compasscove.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=CConMBH");
		}
		else {
			$(this).attr("href","http://www.compasscove.com/?cmpid=CConMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('bayviewresort.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=BVonMBH");
		}
		else {
			$(this).attr("href","http://www.bayviewresort.com/?cmpid=BVonMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('dunesvillage.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=DVonMBH");
		}
		else {
			$(this).attr("href","http://www.dunesvillage.com/?cmpid=DVonMBH");
		}
	 }
	  else if (typeof(mylink) != "undefined" && mylink.indexOf('caribbeanresort.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=CBonMBH");
		}
		else {
			$(this).attr("href","http://www.caribbeanresort.com/?cmpid=CBonMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('longbayresort.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=LBonMBH");
		}
		else {
			$(this).attr("href","http://www.longbayresort.com/?cmpid=LBonMBH");
		}
	 }
	  else if (typeof(mylink) != "undefined" && mylink.indexOf('oceanreefmyrtlebeach.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=ORonMBH");
		}
		else {
			$(this).attr("href","http://www.oceanreefmyrtlebeach.com/?cmpid=ORonMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('breakers.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=BRonMBH");
		}
		else {
			$(this).attr("href","http://www.breakers.com/?cmpid=BRonMBH");
		}
	 }
	  else if (typeof(mylink) != "undefined" && mylink.indexOf('litchfieldbeach.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=LRonMBH");
		}
		else {
			$(this).attr("href","http://www.litchfieldbeach.com/?cmpid=LRonMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('montereybaysuites.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=MBonMBH");
		}
		else {
			$(this).attr("href","http://www.montereybaysuites.com/?cmpid=MBonMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('driftwoodlodge.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=DLonMBH");
		}
		else {
			$(this).attr("href","http://www.driftwoodlodge.com/?cmpid=DLonMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('paradiseresortmb.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=PRonMBH");
		}
		else {
			$(this).attr("href","http://www.paradiseresortmb.com/?cmpid=PRonMBH");
		}
	 }
	 else if (typeof(mylink) != "undefined" && mylink.indexOf('northbeachrentals.com') > 0){
		if(mylink.indexOf('?') > 0){
			$(this).attr("href",$(this).attr("href")+"&cmpid=NBonMBH");
		}
		else {
			$(this).attr("href","http://www.northbeachrentals.com/?cmpid=NBonMBH");
		}
	 }
	});


   //Add the google stuff to the url
   $("a[href*='secure.guestdesk.com']").click(function() {
        pageTracker._link(this.href);
        return false;
    });
   
   //Do the ranking system here
   $(".Ratingwrapper").each(function(i) { 
            var explanationDiv = $(this).find(".explanation");
            var explanationText = $(this).find(".explanationText");
            var hdnField = $(this).find(".explanation >input:hidden");
            var ratingLabel = $(this).find(".ratingLabel");
            var ratingCap = $(this).find(".rating");

            //Hide the radio button labels since we don't need because javascript is enabled
            ratingLabel.hide();

            //Show the rating label we do need.
            ratingCap.show();

            //Hide the explanation section since javascipt is enabled
            explanationDiv.hide();

            //Turn the radio buttons into our stars
            $(this).find(".question").stars({
            	captionEl: $(this).find(".caption")
            });

            $(this).find(".question").click(function() {
                var instance = $(this).data("stars");
                $(this).find(".caption");
                hdnField.val(instance.options.value);

                if (instance.options.value == 1 || instance.options.value == 2 || instance.options.value == 3 || instance.options.value == 4) {
                    explanationDiv.show();
                    if (explanationText.val() == "NA") {
                        explanationText.val('').focus();
                    }
                    else {
                        explanationText.focus();
                    }
                }
                else {
                    explanationDiv.hide();
                    explanationText.val("NA");
                }
            });
            
        });		   
// JavaScript Document

// -------------------------------------------
// will add target to external links (jQuery)
// -------------------------------------------
function externalLinks(){
	$('a[@rel^="external"]').attr('target', '_blank').click(function(){
		hideAmbassador();
	});
}
// -------------------------------------------

// -------------------------------------------
// functions to launch Stay and Play
// -------------------------------------------
function stayandplay() {
	playerwin = window.open("https://secure.guestdesk.com/golf/?ID=365&siteID=golfinsidermb", "newwindow", "height=505,width=800", "toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no");
}




// -------------------------------------------
// 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')
}

function openNew(url){
	myhandle=window.open(url,'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');
}

// -------------------------------------------
// functions to launch golf packages app
// -------------------------------------------
function openGolfPackageSystem(){
	var urlVars = 'https://secure.guestdesk.com/golf/?ID=365&siteID=golfinsidermb';
	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')
}

	
	active_color = '#000'; 
	inactive_color = '#999';
    $(document).ready(function() {
        $(".Ratingwrapper").each(function(i) {
            var explanationDiv = $(this).find(".explanation");
            var explanationText = $(this).find(".explanationText");
            var hdnField = $(this).find(".explanation >input:hidden");
            var ratingLabel = $(this).find(".ratingLabel");
            var ratingCap = $(this).find(".rating");

            //Hide the radio button labels since we don't need because javascript is enabled
            ratingLabel.hide();

            //Show the rating label we do need.
            ratingCap.show();

            //Hide the explanation section since javascipt is enabled
            explanationDiv.hide();

            //Turn the radio buttons into our stars
            $(this).find(".question").stars({
                captionEl: $(this).find(".caption")
            });

            $(this).find(".question").click(function() {
                var instance = $(this).data("stars");
                $(this).find(".caption");
                hdnField.val(instance.options.value);

                if (instance.options.value == 1 || instance.options.value == 2 || instance.options.value == 3 || instance.options.value == 4) {
                    explanationDiv.show();
                    if (explanationText.val() == "NA") {
                        explanationText.val('').focus();
                    }
                    else {
                        explanationText.focus();
                    }
                }
                else {
                    explanationDiv.hide();
                    explanationText.val("NA");
                }
            });
        });
		
		$("input.default-value").css("color", inactive_color);
		  var default_values = new Array();
		  $("input.default-value").focus(function() {
			if (!default_values[this.id]) {
			  default_values[this.id] = this.value;
			}
			if (this.value == default_values[this.id]) {
			  this.value = '';
			  this.style.color = active_color;
			}
			$(this).blur(function() {
			  if (this.value == '') {
				this.style.color = inactive_color;
				this.value = default_values[this.id];
			  }
			});
		  });
		  
		$(".box").fancybox(); 
		
		$("table.forum tbody tr").hover(function(){
				$(this).addClass('hover');
			}, function() {
				$(this).removeClass('hover');
		});
    });
						   })