
/* 
  * adds a bookmark for IE and firefox.
  *
  * url -- window.location
  * title -- string for the bookmark.
  * fcParam -- a parameter that is appended to the url for fire click.
  */
 function bookmarkSite(url, title, fcParam)
 {
    if (document.all)
    {
        window.external.AddFavorite(appendFireClickParam(url, fcParam), title);
    }
    else if (window.sidebar)
    {
        window.sidebar.addPanel(title, appendFireClickParam(url, fcParam), "");
    }
    else 
    { 
        alert("Your browser doesn't support this function."); 
    }
}

/*
 * appends the fireclick parameter if it exists.
 */
function appendFireClickParam(url, fcParam)
{
    var finalUrl = null;
    var addFc = fcParam != null && fcParam != 'undefined' && fcParam != '';
		
    if(url.search == null || url.search == 'undefined' || url.search == '')
    {
        finalUrl = url.protocol + '//' + url.host + url.pathname + (addFc ? '?fc='+ fcParam : '');
    }
    else
    {
        finalUrl = url.protocol + '//' + url.host + url.pathname + url.search + (addFc ? '&fc='+ fcParam : '');
    }
	
    return finalUrl;
}

/*
 * Clears Email Collection input box
 */
function ClearEmail(textbox)
{
	if(textbox.value == textbox.defaultValue)
	{
		textbox.value = '';
	}
}

/* 
 * special onChange function for TrackingDropDown 
 */
function trackingSelectionChanged(select)
{
	var idx = select.selectedIndex;
	var url = select.options[idx].value;
	var trackValue = select.options[idx].getAttribute('track');
	var eventValue = select.options[idx].getAttribute('event');

	if(typeof(ExternalTracker) != 'undefined')
	{
		var tracker = new ExternalTracker();
		
		if(trackValue)
		{
			tracker.DoTracking(select, trackValue);
		}
		if(eventValue)
		{
			tracker.DoEvent(select, eventValue);
		}
	}
	
	top.location = url;
}


/* 
 * Checks for the enter key on key press. FB case 10068.
 */
function isEnterKey(e) {
     var charCode;
    
    if(e && e.which){
        charCode = e.which;
    }else if(window.event){
        e = window.event;
        charCode = e.keyCode;
    }

    if(charCode == 13) {
        return true;
    }
    else
    {
        return false;
    }
}