/*
	helper_functions.js

	Quint King
	415-902-6509
	quintking@gmail.com
*/

// SPECIFIC TO POST RANCH INN
function openReservationForm()
{
	var url="https://gc.synxis.com/rez.aspx?Hotel=27123&Chain=10237&template=MYRPR2&shell=MRYPR3&adult=2";

  // Append #data to transfer tracking data to secondary sites
  try {
    if (_gat) url = _gat._getTrackerByName()._getLinkerUrl(url, false);
    _gat._getTrackerByName()._trackEvent('Outbound Link', 'reservation');
    setTimeout('window.location = "' + url + '"', 100);
  } catch (err) {
    window.location = url;
  }
}


// GENERAL HELPER FUNCTIONS

// dump an array object to a string ( useful for debugging )
function dump(arr,level)
{
	var dumped_text = "";
	if(!level) level = 0;

	// The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";

	if(typeof(arr) == 'object') //Array/Hashes/Objects
	{
	 	for(var item in arr)
	 	{
	  		var value = arr[item];

	  		if(typeof(value) == 'object')
	  		{ //If it is an array,
	   			dumped_text += level_padding + "'" + item + "' ...\n";
	   			dumped_text += dump(value,level+1);
	  		}
	  		else
	  		{
	   			dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
	  		}
	 	}
	}
	else
	{
		//Stings/Chars/Numbers etc.
	 	dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}

// JS helper function to add the custom scrollbars
function updateScrollPaneScrollbars($domElementIn)
{
	$domElementIn.jScrollPane(
	{
		scrollbarWidth: 11,
		dragMinHeight: 20,
		dragMaxHeight: 140,
		showArrows: true,
		arrowSize: 13,
		topCapHeight: 5,
		bottomCapHeight: 5
	}
    );
}

// return the current page URL with NO trailing slash
function getCurrentPageURL()
{
  	var currentURL = unescape(String(window.location).toLowerCase());
  	if(currentURL.charAt(currentURL.length-1) == '/')		// without a trailing slash to match the items in our accordian
  		currentURL = currentURL.substring(0,currentURL.length-1);
	return currentURL;
}

function removePageAnchorTagFromURL(urlString)
{
	var tagItemStartIndex = urlString.lastIndexOf('/#');
	if(tagItemStartIndex != -1)
		urlString = urlString.substring(0, tagItemStartIndex);
	return urlString;
}

