var g_sPrivateColor = '#40c100';
var g_sPublicColor = '#157EBA';
var bShowClipCastLinks = true;
var bFavoritesLoad = false;
var bFacebookApp = false;
var bLibraryWindowOpen = true;
var KEY_ENTER = 13;
var bInClipcast = false;

function ShowTagCloud(sUsername) {
	window.open('/tag_cloud.aspx?u=' + sUsername, sUsername + 'TagCloud', 'height=550,width=550,resizable=yes');
}

//*** DOM NODE FUNCTIONS ***//

function CreateIfNone(sElementID, sTagName) {
	var oElement = document.getElementById(sElementID);
	if (!oElement) {
		oElement = document.createElement(sTagName);
		oElement.id = sElementID;
		oElement.style.display = 'none';
		document.body.appendChild(oElement);
	}
	return oElement;
}

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 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) {
	sText = sText.replace(/\[([^\]]+)\]/ig,"");
	return(sText);
}

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 - 80); // + document.body.scrollTop);

		//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) { 
		if (!!document.getElementById("dvDragBar")) {
			document.getElementById("dvDragBar").style.display='block';
		}
	} else {
		if (!!document.getElementById("dvDragBar")) {
			document.getElementById("dvDragBar").style.display='none';
		}
	}
	
	HideScrollbars();	
}

function HideDialogBox() {

	document.getElementById("dvDialogBox").style.display='none';
	
	if (bLibraryWindowOpen) { bLibraryWindowOpen = false; }
	if (!!bBlockWindowOpen)   { bBlockWindowOpen = false;   }

	ShowScrollbars();
}

function OpenFunctionWindow(sFunction, sKey, bSizable, bScrollbars, bTargetSelf) {
	var lWidth, lHeight, lX, lY, sGUIDParam, sURL;
	switch (sFunction) {
		case 'EDIT':
		case 'SAVEFROMWIN':
		case 'EMAIL':
		case 'BLOG':
		case 'PRINT':
			lWidth = 740;
			lHeight = 590;
			break;
		case 'SAVE':
			lWidth = 740;
			lHeight = 590;
			break;
		case 'CONTENT':
			lWidth = 640;
			lHeight = 480;
			break;
		case 'REFERENCE':
			lWidth = 540;
			lHeight = 444;
			break;
		case 'DEMO':
			lWidth = 670;
			lHeight = 570;
	}
	var lX = parseInt((document.body.clientWidth - lWidth) / 2);
	var lY = parseInt((document.body.clientHeight - lHeight) / 2);
	switch (sFunction) {
		case 'EDIT':
			sURL = '/edit_clip.aspx?new=false&nav=true&clip_guid=';
			break;
		case 'SAVEFROMWIN':
			sURL = '/edit_clip.aspx?clipping=true&clip_guid=';
			break;
		case 'EMAIL':
			sURL = '/email_clipmark.aspx?clipmark=';
			break;
		case 'BLOG':
			sURL = '/blog_this.aspx?c=';
			break;
		case 'PRINT':
			sURL = '/print_clips.aspx?mode=clip&print=true&c=';
			break;
		case 'SAVE':
			sURL = '/save_clips.aspx?mode=clip&save=true&c=';
			break;
		case 'CONTENT':
			sURL = '/view_clip.aspx?guid=';
			break;
		case 'REFERENCE':
			sURL = '/reference.aspx?type=';
			break;
		case 'DEMO':
			sURL = '/demo_window.aspx?r=3';
	}
	if (!!sKey) {
		sURL += sKey;
	}

	if (bTargetSelf) {
		window.location.href = sURL;
	} else {
		var oFunctionWindow = window.open(sURL, 'Clipmarks_' + sFunction, 'width=' + lWidth + ',height=' + lHeight + ',top=' + lY + ',left=' + lX + ',resizable=' + (bSizable ? 'yes' : 'no') + ',scrollbars=' + (bScrollbars ? 'yes' : 'no'));
		oFunctionWindow.focus();
	}
}

function DeleteClipmark(sGUID, bPermanent, bBypassPrompt, bPrivate) {
	if ((!!bBypassPrompt && bPermanent) || (bPermanent && confirm('Are you sure you want to delete this clip?'))) {
		PostDeleteClipmark(true);
	} else if ((!!bBypassPrompt && !bPermanent) || (!bPermanent && confirm('Are you sure you want to remove this clipmark from your clips?' + (!bPrivate ? '  Doing so will not remove it from the public clip exchange or from any other clipper\'s page.' : '')))) {
		PostDeleteClipmark(false);
	}
}

function OpenBookmarkOptions(u,d,t,n, bPermalink) {
	if (document.getElementById('fraClipmark')) { document.getElementById('fraClipmark').style.overflow='hidden'; }
	
	if (bLibraryWindowOpen) { HideDialogBox(); } else {
	
	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 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="CLB">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(\'mixx\',' + sParams + ')"><img src="/images/icons/mixx.gif" width="12" height="12" alt="" border="0" style="margin: 0px 6px -2px 0px;" /> mixx.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(\'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,bFromPopup) {

	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 if (sType == 'mixx') {
		sBkmkUrl = 'http://www.mixx.com/submit?page_url=' + escape(u);
	} else if (sType == 'ffeed') {
		sBkmkUrl = 'http://friendfeed.com/share?url=' + escape(u) + '&title=' + escape(d);
	} else if (sType == 'twit') {
		sBkmkUrl = 'http://twitthis.com/twit?url=' + escape(u);
	} else if (sType == 'del') {
	    BookmarkDelicious(u,d,t,n);
	    return false;
	} else {
		return false;
	}

	if (sType == 'facebook') {
		window.open(sBkmkUrl,'sharer','toolbar=0,status=0,width=626,height=436');
	} else {
		if (bFromPopup) {
			oNewWindow = window.open(sBkmkUrl, 'Clipmarks_New', 'width=1010,top=0,left=0,scrollbars=yes,toolbar=yes,location=yes,menubar=yes,directories=yes,statusbar=yes,resizable=yes');
		} else {
			window.open(sBkmkUrl);
		}
	}
	
	outbound(sType, sBkmkUrl);

	return false;
}


function EmbedClip(sClipGuid) {
	
	// static guid must be dynamic
	bLibraryWindowOpen = true;
	bKeepDialogOpen = true;

	var sCode;
	sCode = '<object height="425" width="395" VIEWASTEXT>';
    sCode += '<param name="movie" value="http://content0.clipmarks.com/swfs/clipcast.swf">';
    sCode += '<param name="wmode" value="transparent">';
    sCode += '<param name="FlashVars" value="CastGUID=4811BD20-20A7-4D18-95C3-832E325D62F9&#038;clipGuid=' + sClipGuid + '&#038;clipWindowBackground=0x000000&#038;ffauto=0">';
    sCode += '<embed src="http://content0.clipmarks.com/swfs/clipcast.swf" flashvars="CastGUID=4811BD20-20A7-4D18-95C3-832E325D62F9&#038;clipGuid=' + sClipGuid + '&#038;clipWindowBackground=0x000000&#038;ffauto=0" wmode="transparent" width="425" height="395">';
    sCode += '</object>';

	sCode = sCode.replace(/\</mig, '&lt;');
	sCode = sCode.replace(/\>/mig, '&gt;');
	
	var sHTML = '<h4>Paste this code in your blog, myspace profile, or other page to embed this clip.</h4>';
	sHTML += '<textarea name="txtEmbedIt" id="txtEmbedIt" style="width: 280px; height: 120px;" onfocus="this.select();">';
	sHTML += sCode;
	sHTML += '</textarea>';

	ShowDialog(sHTML, 0, -70, false, "Close", 280, 246, false, true);

}

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) {

	var sMessage = '';
	
	switch (sType) {
		case 'add':
			sMessage = 'add this to your clips';
			break;
		case 'comment':
			sMessage = 'comment on this clip';
			break;
		case 'email':
			sMessage = 'email this clip';
			break;
		case 'fav':
			sMessage = 'add this tag to your Favorite Tags';
			break;
		case 'ignore':
			sMessage = 'moderate your interaction with this user';
			break;
		case 'pop':
			sMessage = 'pop this clip';
			break;
		case 'tag':
			sMessage = 'add this topic to your &quot;My Topics&quot; list';
			break;
		case 'topic':
			sMessage = 'customize this menu';
			break;
	} 
	
	if (sUrl && sUrl != '') { sUrl = '&url=' + encodeURI(sUrl); } else { sUrl = ''; }
	
	var sHTML = '<div style="padding: 20px;">';
	
	if (sType == 'pop') {
		sHTML += '<div style="text-align:left; margin: 4px 4px 12px 8px; font-size: 16px;"><b>Pop this clip!</b></div>';
		sHTML += '<div style="text-align:left; margin: 16px 8px 16px 8px; font-size: 13px;">A pop is a way of thanking someone for posting a clip and telling others they should see it.</div>';
		sHTML += '<div style="margin: 10px 10px 6px 10px; font-size: 14px; line-height: 20px;">Please <b><a href="/login.aspx?type=pop' + sUrl + '" class="CLB" target="_top">login</a></b> &nbsp;or&nbsp; <b><a href="/login.aspx?signup=true&type=pop' + sUrl + '" class="CLB" target="_top">sign up</a></b> to pop this clip.</div>';
	} else if (sType == 'follow') {
		sHTML += '<div style="text-align:left; margin: 4px 4px 12px 8px; font-size: 16px;"><b>Follow this user!</b></div>';
		sHTML += '<div style="text-align:left; margin: 16px 8px 16px 8px; font-size: 13px;">Following a user lets you easily follow their latest clips.</div>';
		sHTML += '<div style="margin: 10px 10px 16px 10px; font-size: 14px; line-height: 20px;">Please <b><a href="/login.aspx?type=follow' + sUrl + '" class="CLB" target="_top">login</a></b> &nbsp;or&nbsp; <b><a href="/login.aspx?signup=true&type=follow' + sUrl + '" class="CLB" target="_top">sign up</a></b> to follow this user.</div>';
	} else {
		sHTML += '<br/><b>Please login to ' + sMessage + '</b>';
		sHTML += '<div style="margin: 10px; font-size: 16px;"><b><a href="/login.aspx?type=' + sType + sUrl + '" target="_top" class="CLB">Login</a></b> &nbsp;or&nbsp; <b><a href="/login.aspx?signup=true&type=' + sType + '" class="CLB" target="_top">Sign Up</a></b></div><br/>';
	}
	
	sHTML += '</div>';

	sHTML += '<div style="margin: 4px 0px 4px 0px; padding-top: 0px; font-size: 14px;" align="center"><b><a href="javascript:CloseLayeredDialog();" class="CLB">close</a></b></div>';
	
	ShowLayeredDialog(sHTML, 430, 190, false, true);

}

function HideLoginPrompt() {
	ShowScrollbars();
	document.getElementById('dvDialogBlackout').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 setClientSize(W, H) {
	window.resizeTo(W + 4, H + 24);

	var cp = document.createElement("div");
	cp.style.position = "absolute";
	cp.style.width = "0px";
	cp.style.height = "0px";
	cp.style.right = "0px";
	cp.style.bottom = "0px";

	document.body.appendChild(cp);

	var current_width = cp.offsetLeft;
	var current_height = cp.offsetTop;

	var dw = W - current_width;
	var dh = H - current_height;

	window.resizeBy(dw, dh);

	document.body.removeChild(cp);
}

function GetUserDomain(sUser) {
	var sDomain = sUser.toLowerCase();
	var sHost = window.location.host;
	sDomain = 'http://' + ((sUser != '') ? sDomain.replace(/[_\s]/g, '') : 'clipcast') + '.' + ((sHost.indexOf('dev.') > 0) ? 'dev.clipmarks.com' : 'clipmarks.com');
	return(sDomain);
}

function IEHd() {
	// prevents header from dissapearing in ie
	if (is_ie) {
		document.getElementById('dvHeaderSearch').style.display='none';
		document.getElementById('dvHeaderSearch').style.display='block';
	}
}
