var bLibraryWindowOpen = true;
var lPopCount = 0;
var KEY_ENTER = 13;

function ShowTagCloud(sUsername) {
	window.open('/tag_cloud.aspx?u=' + sUsername, sUsername + 'TagCloud', 'height=550,width=550');
}

//*** DOM NODE FUNCTIONS ***//
function CloneNode(oNode, bDeep) {
	var oNewNode = null;
	var oNewChildNode = null;
	var i = 0;
	
	if (oNode.nodeType == 3) {
		return document.createTextNode(oNode.nodeValue);
	} else if (oNode.nodeType != 1) {
		return null;
	}
	
	oNewNode = document.createElement(oNode.tagName);
	
	for (i = 0; i < oNode.attributes.length; i++) {

		if (oNode.attributes[i].name.indexOf('on') == 0 && is_ie) {
			// this is for ie but works in all browsers
			eval('oNewNode.' + oNode.attributes[i].name + ' = function() {' + oNode.attributes[i].value + '}');
		} else if (is_ie && oNode.attributes[i].name == 'style') {
			oNewNode.style.cssText = oNode.attributes[i].value;
		} else if (is_ie && oNode.attributes[i].name == 'class') {
			oNewNode.setAttribute('className', oNode.attributes[i].value);
		} else {
			oNewNode.setAttribute(oNode.attributes[i].name, oNode.attributes[i].value);
		}
	}
	
	if (!bDeep) {
		return oNewNode;
	}
	
	for (i = 0; i < oNode.childNodes.length; i++) {
		oNewChildNode = CloneNode(oNode.childNodes[i], true);
		if (!!oNewChildNode) {
			oNewNode.appendChild(oNewChildNode);
		}
	}
	
	return oNewNode;
}


//***  STRING FUNCTIONS   ***//

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}


//***  HTML NODE FUNCTIONS   ***//

function GetAttribute(oElement, sAttribute, sDefault) {
	var sReturn = sDefault
	if (oElement.getAttribute(sAttribute)) {
		sReturn = oElement.getAttribute(sAttribute);
	}
	return sReturn;
}

//***  EVENT FUNCTIONS   ***//

function StopPropagation(e, bPreventDefault) {
	if (!e) e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	if (bPreventDefault) {
		if (e.preventDefault) e.preventDefault();
	}
	return false;
}

//***  XML FUNCTIONS   ***//

function CreateXMLHTTP() {
	var oXMLHTTP = false;
    if(window.XMLHttpRequest) {
    	try {
			oXMLHTTP = new XMLHttpRequest();
        } catch(e) {
			oXMLHTTP = false;
        }
    } else if(window.ActiveXObject) {
       	try {
        	oXMLHTTP = new ActiveXObject('Msxml2.XMLHTTP');
      	} catch(e) {
        	try {
          		oXMLHTTP = new ActiveXObject('Microsoft.XMLHTTP');
        	} catch(e) {
          		oXMLHTTP = false;
        	}
		}
    }
    return oXMLHTTP;
}


function stripQuotes(sText) {
	sText = sText.replace(/\'/mig, "\\'");		
	return(sText);
}

function stripAllQuotes(sText) {
	sText = sText.replace(/\"/mig, "");		
	sText = sText.replace(/\'/mig, "\\'");		
	return(sText);
}

function safeAttribute(sText) {
	sText = sText.replace(/\"/mig, "&quot;");		
	sText = sText.replace(/\'/mig, "&rsquo;");		
	return(sText);
}

function stripUnsafe(sText, iMode) {
	if (iMode == 2) { 
		sText = sText.replace(/\'/mig, "\\'");
	} else {
		sText = sText.replace(/\'/mig, "\'");			
	}	
	sText = sText.replace(/(%0D|%0A|%0d|%0a|\n|\r)/mig, "\+");		
	return(sText);
}

function stripBBCode(sText) {
	// remove bbcode
	sText = sText.replace(/\[([^\]]+)\]/ig,"");
	return(sText);
}

// Login
function OpenProfile(sAnchor) {
	var sAppend = '';
	if (sAnchor) { sAppend = '#' + sAnchor; }
	var lBoxWidth = 610;
	var lBoxHeight = 590;
	var lPosX = parseInt((document.body.clientWidth - lBoxWidth)/2); 
	var lPosY = parseInt((document.body.clientHeight - lBoxHeight)/2); 
	var oProfileWindow = window.open('/profile.aspx' + sAppend, 'Clipmarks_Profile', 'width=' + lBoxWidth + ',height=' + lBoxHeight + ',top=' + lPosY + ',left=' + lPosX + ',scrollbars=yes,resizable=yes');
	oProfileWindow.focus();
}


function OpenDemo() {
	var lBoxWidth = 648;
	var lBoxHeight = 542;
	var lPosX = parseInt((document.body.clientWidth - lBoxWidth)/2); 
	var lPosY = parseInt((document.body.clientHeight - lBoxHeight)/2); 
	var oDemoWindow = window.open('/demo_window.htm', 'Clipmarks_Demo', 'width=' + lBoxWidth + ',height=' + lBoxHeight + ',left=' + lPosX + ',top=' + lPosY + ',scrollbars=yes');
	oDemoWindow.focus();
}


// show dialog box ....
function ShowDialog(sMessage, xOffset, yOffset, bHideButton, sButtonLabel, lWidth, lHeight, bHardPosition, bDragBar, sCallbackFunction, bCancelButton) {
	var lBoxWidth = 280;
	var lBoxHeight = 144;
	var lPosX = 0;
	var lPosY = 0;
	
	if (lWidth) { lBoxWidth = lWidth; }
	if (lHeight) { lBoxHeight = lHeight; }
	
	if (is_ie) { lBoxHeight = lBoxHeight + 38; }
	
	document.getElementById("dvDialogBox").style.width = lBoxWidth  + 'px';
	document.getElementById("dvDialogBox").style.height = lBoxHeight + 'px';

	if (bHardPosition) { 
		lPosX = xOffset; 
		lPosY = yOffset; 
	} else {
		lPosX = parseInt((document.body.clientWidth - lBoxWidth)/2); 
		lPosY = parseInt((document.body.clientHeight - lBoxHeight)/2); 
	}
	
	var lOffsetX = 0;
	var lOffsetY = 0;
	if (xOffset) { lPosX += xOffset; }
	if (yOffset) { lPosY += yOffset; }
	
	lPosX += document.body.scrollLeft;
	lPosY += document.body.scrollTop; 
		
	if (lPosX < 0) { lPosX = 0; }
	if (lPosY < 0) { lPosY = 0; }	
	
	document.getElementById("dvDialogBox").style.top = lPosY + 'px';
	document.getElementById("dvDialogBox").style.left = lPosX + 'px';
	document.getElementById("spnDialogMessage").innerHTML = sMessage;
	
	if (bHideButton) { 
		document.getElementById("spnDialogButton").style.display = 'none';  
	} else {
		document.getElementById("spnDialogButton").style.display = 'block';
	}
	
	if (!sButtonLabel) { sButtonLabel = 'OK'; }
	
	document.getElementById("spnDialogButton").innerHTML='<table style="margin-top:8px;"><tr>' + '<td>&nbsp;&nbsp;</td><td><span class="DialogButton" ><a href="javascript:HideDialogBox();"' + (!!sCallbackFunction ? ' onclick="' + sCallbackFunction + '"' : '') + '>' + sButtonLabel + '</a></span></td>' + (!!bCancelButton ? '<td><span class="DialogButton" ><a href="javascript:HideDialogBox();">Cancel</a></span></td>' : '') + '</tr></table>';
	
	document.getElementById("dvDialogBox").style.display='block';
	
	if (bDragBar) { 
		document.getElementById("dvDragBar").style.display='block';
	} else {
		document.getElementById("dvDragBar").style.display='none';
	}
	
	HideScrollbars();	
}

function HideDialogBox() {

	document.getElementById("dvDialogBox").style.display='none';
	
	if (bLibraryWindowOpen) { bLibraryWindowOpen = false; }
	if (bBlockWindowOpen)   { bBlockWindowOpen = false;   }

	ShowScrollbars();
}


// clipmark functions ....
function EditClipmark(sGUID) {
	var popW = 440;
	var popH = 590;
	var popX = parseInt((document.body.clientWidth - popW) / 2);
	var popY = parseInt((document.body.clientHeight - popH) / 2);
	var oEditWindow = window.open('/edit_clip.aspx?new=false&nav=true&clip_guid=' + sGUID, 'Clipmarks_EditClipmark', 'width=' + popW + ',height=' + popH + ',top=' + popY + ',left=' + popX + ',resizable=no,scrollbars=no');
	oEditWindow.focus();
}

function EmailClipmark(sGUID) {
	var popW = 440;
	var popH = 590;
	var popX = parseInt((document.body.clientWidth - popW) / 2);
	var popY = parseInt((document.body.clientHeight - popH) / 2);
	var oEmailWindow = window.open('/email_clipmark.aspx?clipmark=' + sGUID, 'EmailClipmark', 'width=' + popW + ',height=' + popH + ',top=' + popY + ',left=' + popX + ',resizable=no,scrollbars=no');
	oEmailWindow.focus();
}

function BlogClipmark(sGUID) {
	var popW = 440;
	var popH = 590;
	var popX = parseInt((document.body.clientWidth - popW) / 2);
	var popY = parseInt((document.body.clientHeight - popH) / 2);
	var oBlogWindow = window.open('/blog_this.aspx?c=' + sGUID, 'BlogClipmark', 'width=' + popW + ',height=' + popH + ',top=' + popY + ',left=' + popX + ',resizable=yes,scrollbars=no');
	oBlogWindow.focus();
}

function DeleteClipmark(sGUID) {
	if (confirm('Are you sure you want to permanently delete this clipmark?  Please be aware that doing so will also delete it from the public clip exchange and from any other clipper\'s page.  You can select the "Remove from My Clips" option in the File menu to solely remove it from your clips.')) {
		PostDeleteClipmark();
	}
}

function RemoveClipmark(sGUID) {
	if (confirm('Are you sure you want to remove this clipmark from your clips?  Doing so will not remove it from the public clip exchange or from any other clipper\'s page.')) {
		PostRemoveClipmark();
	}
}

function PrintClipmark(sGUID) {
	var popW = 740;
	var popH = 590;
	var popX = parseInt((document.body.clientWidth - popW) / 2);
	var popY = parseInt((document.body.clientHeight - popH) / 2);
	var oPrintWindow = window.open('/print_clips.aspx?mode=clip&print=true&c=' + sGUID, 'PrintClips', 'width=' + popW + ',height=' + popH + ',top=' + popY + ',left=' + popX);
	oPrintWindow.focus();
}

function SaveClipmark(sGUID) {
	var popW = 740;
	var popH = 590;
	var popX = parseInt((document.body.clientWidth - popW) / 2);
	var popY = parseInt((document.body.clientHeight - popH) / 2);
	var oSaveWindow = window.open('/save_clips.aspx?mode=clip&save=true&c=' + sGUID, 'SaveClips',  'width=' + popW + ',height=' + popH + ',top=' + popY + ',left=' + popX);
	oSaveWindow.focus();
}

function PopupClipmark(sGUID) {
	var popW = 640;
	var popH = 480;
	var popX = parseInt((document.body.clientWidth - popW) / 2);
	var popY = parseInt((document.body.clientHeight - popH) / 2);
	var oContentWindow = window.open('/view_clip.aspx?guid=' + sGUID, 'Popup_Content', 'width=' + popW + ',height=' + popH + ',top=' + popY + ',left=' + popX + ',resizable=yes,scrollbars=yes');
	oContentWindow.focus();
}


function OpenReference(iType) { 
	var lBoxWidth = 540;
	var lBoxHeight = 444;
	var lPosX = parseInt((document.body.clientWidth - lBoxWidth)/2); 
	var lPosY = parseInt((document.body.clientHeight - lBoxHeight)/2); 
	var oRefWindow = window.open('/reference.aspx?type=' + iType, 'Clipmarks_Ref', 'width=' + lBoxWidth + ',height=' + lBoxHeight + ',top=' + lPosY + ',left=' + lPosX + ',scrollbars=yes,resizable=yes');
	oRefWindow.focus();
}


function OpenBookmarkOptions(u,d,t,n, bPermalink) {
	
	if (document.getElementById('fraClipmark')) { document.getElementById('fraClipmark').style.overflow='hidden'; }
	
	bLibraryWindowOpen = true;
	bKeepDialogOpen = true;

	var t_unescape = unescape(t);
	var sTagStringDel = t_unescape.replace(/\,/g, '\+');
    var sHrefDelicious = 'javascript:BookmarkDelicious(\'' + encodeURI(stripUnsafe(u, 2)) + '\',\'' + encodeURI(stripUnsafe(d, 2)) + '\',\'' + encodeURI(stripUnsafe(sTagStringDel, 2)) + '\',\'' + encodeURI(stripUnsafe(n, 2)) + '\')';
    
    /*var sHrefDigg = 'http://digg.com/submit?url=' + escape(u) + '&title=' + escape(d) + '&phase=2';
    var sHrefBlinklist = 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=' + escape(u) + '&Title=' + escape(d) + '&Tag=' + escape(t) + '&Description=' + escape(n);
    var sHrefMagnolia = 'http://ma.gnolia.com/bookmarklet/add?url=' + escape(u) + '&title=' + escape(d) + '&description=' + escape(n) + '&tags=' + escape(t);

	var sHrefNetvouz = 'http://www.netvouz.com/action/submitBookmark?url=' + escape(u) + '&title=' + escape(d) + '&description=' + escape(n) + '&tags=' + escape(t) + '&popup=no';
	var sHrefFurl = 'http://www.furl.net/storeIt.jsp?t=' + escape(d) + '&u=' + escape(u);
	var sHrefSimpy = 'http://www.simpy.com/simpy/LinkAdd.do?href=' + escape(u) + '&title=' + escape(d) + '&note=' + escape(n) + '&tags=' + escape(t);
	var sHrefSlashdot = 'http://slashdot.org/submit.pl';
	var sHrefSpurl = 'http://spurl.net/spurl.php?title=' + escape(d) + '&url=' + escape(u) + '&tags=' + escape(t);
	
	var sHrefStumble = 'http://www.stumbleupon.com/submit?url=' + escape(u) + '&title=' + escape(d);
	var sHrefNewsvine = 'http://www.newsvine.com/_tools/seed&save?u=' + escape(u) + '&h=' + escape(d) + '&tags=' + escape(t);
	var sHrefFark = 'http://cgi.fark.com/cgi/fark/edit.pl?new_url=' + escape(u) + '&new_comment=' + escape(d) + '&linktype=';
	
	var sHrefFacebook = 'window.open(\'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(d) + '\',\'sharer\',\'toolbar=0,status=0,width=626,height=436\');return false;';
	var sHrefYahoo = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + escape(u) + '&t=' + escape(d);

	var sHrefDiigo = 'http://www.diigo.com/post?url=' + escape(u) + '&title=' + escape(d) + '&comments=' + escape(n);
	var sHrefReddit = 'http://www.reddit.com/submit?url=' + escape(u) + '&title=' + escape(d);*/

	var sParams = '\'' + stripUnsafe(u, 2) + '\',\'' + stripUnsafe(d, 2) + '\',\'' + stripUnsafe(t, 2) + '\',\'' + stripUnsafe(n, 2) + '\''; 

	var sHTML = '<div id="dvCollectionMenu" style="padding-bottom: 4px;" onmouseover="bLibraryWindow=true"; onmouseout="bLibraryWindow=false";>';

	sHTML += '<div><b>Post <a href="' + u + '" target="_blank" class="CL">this ' + (bPermalink ? 'clipmark' : 'url') + '</a> to:</b></div>';	

	sHTML += '<table cellspacing="0" style="margin: 10px 0px -12px 0px;"><tr><td width="50%">';
	sHTML += '<div align="left" class="BK" style="width: 110px; border: none;">\
			   <a href="javascript:void(0)" onclick="BkmkIt(\'facebook\',' + sParams + ')" ><img src="/images/icons/facebook.gif" width="14" height="14" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> facebook.com</a>\
			   <a href="' + sHrefDelicious + '"><img src="/images/icons/delicious.jpg" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> del.icio.us</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'digg\',' + sParams + ')"><img src="/images/icons/digg.gif" width="14" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> digg.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'blinklist\',' + sParams + ')"><img src="/images/icons/blinklist.gif" width="14" height="14" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> blinklist.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'magnolia\',' + sParams + ')"><img src="/images/icons/magnolia.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> ma.gnolia.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'netvouz\',' + sParams + ')"><img src="/images/icons/netvouz.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> netvouz.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'furl\',' + sParams + ')"><img src="/images/icons/furl.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> furl.net</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'diigo\',' + sParams + ')"><img src="/images/icons/diigo.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> diigo.com</a>\
	</div></td><td width="50%">';
	sHTML += '<div align="left" class="BK" style="width: 110px; border: none;">\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'reddit\',' + sParams + ')"><img src="/images/icons/reddit.png" width="16" height="14" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> reddit.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'stumble\',' + sParams + ')"><img src="/images/icons/stumbleit.gif" width="14" height="14" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> stumbleupon</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'slashdot\',' + sParams + ')"><img src="/images/icons/slashdot.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> slashdot.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'spurl\',' + sParams + ')"><img src="/images/icons/spurl.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> spurl.net</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'newsvine\',' + sParams + ')"><img src="/images/icons/newsvine.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> newsvine.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'fark\',' + sParams + ')"><img src="/images/icons/fark.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> fark.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'simpy\',' + sParams + ')"><img src="/images/icons/simpy.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> simpy.com</a>\
			   <a href="javascript:void(0);" onclick="BkmkIt(\'yahoo\',' + sParams + ')"><img src="/images/icons/yahoo.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> yahoo.com</a>\
		    </div>';
	sHTML += '</td></tr></table>';

	sHTML += '</div>';	
	
	ShowDialog(sHTML, 0, -70, false, "Close", 280, 246, false, true);
}


function BookmarkDelicious(u,d,t,n) {
	var thisURL = 'http://del.icio.us/post?v=3&noui=yes&jump=close&url=' + escape(u) + '&title=' + escape(d) + '&notes=' + escape(n);
	window.open(thisURL, 'delicious','toolbar=no,width=700,height=260,resizable=yes');
	outbound('delicious', thisURL);
}


function BkmkIt(sType,u,d,t,n) {

	var sBkmkUrl = '';

	if (sType == 'digg') {
		sBkmkUrl = 'http://digg.com/submit?url=' + escape(u) + '&title=' + escape(d) + '&phase=2';
    } else if (sType == 'blinklist') {
		sBkmkUrl = 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=' + escape(u) + '&Title=' + escape(d) + '&Tag=' + escape(t) + '&Description=' + escape(n);
    } else if (sType == 'magnolia') {
		sBkmkUrl = 'http://ma.gnolia.com/bookmarklet/add?url=' + escape(u) + '&title=' + escape(d) + '&description=' + escape(n) + '&tags=' + escape(t);
	} else if (sType == 'netvouz') {
		sBkmkUrl ='http://www.netvouz.com/action/submitBookmark?url=' + escape(u) + '&title=' + escape(d) + '&description=' + escape(n) + '&tags=' + escape(t) + '&popup=no';
	} else if (sType == 'furl') {
		sBkmkUrl = 'http://www.furl.net/storeIt.jsp?t=' + escape(d) + '&u=' + escape(u);
	} else if (sType == 'simpy') {
		sBkmkUrl  = 'http://www.simpy.com/simpy/LinkAdd.do?href=' + escape(u) + '&title=' + escape(d) + '&note=' + escape(n) + '&tags=' + escape(t);
	} else if (sType == 'slashdot') {
		sBkmkUrl = 'http://slashdot.org/submit.pl';
	} else if (sType == 'spurl') {
		sBkmkUrl = 'http://spurl.net/spurl.php?title=' + escape(d) + '&url=' + escape(u) + '&tags=' + escape(t);
	} else if (sType == 'stumble') {
		sBkmkUrl = 'http://www.stumbleupon.com/submit?url=' + escape(u) + '&title=' + escape(d);
	} else if (sType == 'newsvine') {
		sBkmkUrl  = 'http://www.newsvine.com/_tools/seed&save?u=' + escape(u) + '&h=' + escape(d) + '&tags=' + escape(t);
	} else if (sType == 'fark') {
		sBkmkUrl  = 'http://cgi.fark.com/cgi/fark/edit.pl?new_url=' + escape(u) + '&new_comment=' + escape(d) + '&linktype=';
	} else if (sType == 'facebook') {
		sBkmkUrl  = 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(d);
	} else if (sType == 'yahoo') {
		sBkmkUrl = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + escape(u) + '&t=' + escape(d);
	} else if (sType == 'diigo') {
		sBkmkUrl = 'http://www.diigo.com/post?url=' + escape(u) + '&title=' + escape(d) + '&comments=' + escape(n);
	} else if (sType == 'reddit') {
		sBkmkUrl = 'http://www.reddit.com/submit?url=' + escape(u) + '&title=' + escape(d);
	} else {
		return false;
	}

	if (sType == 'facebook') {
		window.open(sBkmkUrl,'sharer','toolbar=0,status=0,width=626,height=436');
	} else {
		window.open(sBkmkUrl);
	}
	
	outbound(sType, sBkmkUrl);

	return false;
}


function outbound(sType, sURL) {
	var xmlOutbound = CreateXMLHTTP();
	if (!xmlOutbound) {
		return;
	}
	
	xmlOutbound.open('GET', '/xml_action.aspx?action=outbound&type=' + sType + '&url=' + sURL, true);
	xmlOutbound.send(null);
}


function LoginPrompt(sType, sUrl) {

	HideScrollbars();

	var objPrompt = document.getElementById('dvLoginPrompt');
	var objMessage = document.getElementById('dvLoginPromptMessage');
	var sMessage = '';
	
	if (sType == 'add') {
		sMessage = 'add this to your clips';
	} else if (sType == 'email') {
		sMessage = 'email this clip';
	} else if (sType == 'comment') {
		sMessage = 'comment on this clip';
	} else if (sType == 'fav') {
		sMessage = 'add this tag to your Favorite Tags';
	} else if (sType == 'topic') {
		sMessage = 'customize this menu';
	} else if (sType == 'tag') {
		sMessage = 'add this topic to your &quot;My Topics&quot; list';
	} 
	
	if (sUrl && sUrl != '') { sUrl = '?url=' + encodeURI(sUrl); } else { sUrl = ''; }
	
	var sHTML;
	
	if (sType == 'pop') {
		sHTML = '<div style="text-align:left; margin: 4px 4px 12px 4px; font-size: 16px;"><img src="/images/right/bottom-pop.jpg" style="margin: 0px 4px -10px 0px;"><b>Pop It!</b></div>';
		sHTML += '<div style="text-align:left; margin: 16px 8px 16px 8px; font-size: 13px;">Popping a clip sends it back to the top for everyone to see. This is how the community decides which clips get the most prominence.</div>';
		sHTML += '<div style="margin: 10px 10px 16px 10px; font-size: 14px;">Please <b><a href="/login.aspx' + sUrl + '" class="CL">login</a></b> &nbsp;or&nbsp; <b><a href="/register/" class="CL">sign up</a></b> to pop clips.</div>';
	} else if(sType == 'follow') {
		sHTML = '<div style="text-align:left; margin: 4px 4px 12px 4px; font-size: 16px;"><img src="/images/icons/followers-add.gif" style="margin: 0px 4px 0px 0px;"><b>Add to My Clippers</b></div>';
		sHTML += '<div style="text-align:left; margin: 16px 8px 16px 8px; font-size: 13px;">Your personal clipper list is the easiest way to keep up with clips from your favorite users.</div>';
		sHTML += '<div style="margin: 10px 10px 16px 10px; font-size: 14px; line-height: 20px;">Please <b><a href="/login.aspx' + sUrl + '" class="CL">login</a></b> &nbsp;or&nbsp; <b><a href="/register/" class="CL">sign up</a></b> to add this user.</div>';
	} else {
		sHTML = '<b>You must be logged in to ' + sMessage + '</b>';
		sHTML += '<div style="margin: 10px; font-size: 16px;"><b><a href="/login.aspx' + sUrl + '" class="CL">Login</a></b> &nbsp;or&nbsp; <b><a href="/register/" class="CL">Sign Up</a></b></div>';
	}

	sHTML += '<a href="javascript:HideLoginPrompt()" class="CL">close</a>';

	objPrompt.style.height = document.body.scrollHeight + 'px';
	objPrompt.style.display='block';
		
	objMessage.style.top = parseInt((document.body.clientHeight - 36)/2 - 80 + document.body.scrollTop) + 'px';
	objMessage.style.left = parseInt((document.body.clientWidth - 300)/2) + 'px';
	objMessage.innerHTML = sHTML;
	objMessage.style.display='block';
	
	/*if (!bIsNav) {
		document.body.style.overflow='hidden';
	}*/
}


function HideLoginPrompt() {
	ShowScrollbars();
	document.getElementById('dvLoginPrompt').style.display='none';	
	document.getElementById('dvLoginPromptMessage').style.display='none';	
	if (!bIsNav) {
		document.body.style.overflow='scroll';
	}
}


function HideScrollbars() {
	// note safari doesn't always hide scrollbars, but layers and scrollbars are not a problem with safari
	if (is_mac || is_safari) { 
		if (document.getElementById('dvClipList')) { document.getElementById('dvClipList').style.overflow='hidden'; }
		if (document.getElementById('fraClip')) { document.getElementById('fraClip').style.overflow='hidden'; }
		if (document.getElementById('dvCollections')) { document.getElementById('dvCollections').style.overflow='hidden'; }
		if (document.getElementById('dvClippers')) { document.getElementById('dvClippers').style.overflow='hidden'; }
		if (document.getElementById('dvTags')) { document.getElementById('dvTags').style.overflow='hidden'; }
	}
}


function ShowScrollbars() {
	if (is_mac || is_safari) { 
		if (document.getElementById('dvClipList')) { document.getElementById('dvClipList').style.overflow='auto'; }
		if (document.getElementById('fraClip')) { document.getElementById('fraClip').style.overflow='auto'; }
		if (document.getElementById('dvCollections')) { document.getElementById('dvCollections').style.overflow='auto'; }
		if (document.getElementById('dvClippers')) { document.getElementById('dvClippers').style.overflow='auto'; }
		if (document.getElementById('dvTags')) { document.getElementById('dvTags').style.overflow='auto'; }
	}
}


function ViewDemo() {
	var lBoxWidth = 500;
	var lBoxHeight = 460;
	var lPosX = parseInt((document.body.clientWidth - lBoxWidth)/2); 
	var lPosY = parseInt((document.body.clientHeight - lBoxHeight)/2); 
	var oDemoWindow = window.open('/demo/play.html', 'Clipmarks_Demo', 'width=' + lBoxWidth + ',height=' + lBoxHeight + ',top=' + lPosY + ',left=' + lPosX + ',scrollbars=no,resizable=yes');
	oDemoWindow.focus();
}
