var sActiveElement = 'initial-content-panel';
var sRawId = null;
var sActiveTitle = '';
var iTotalOnPage = 0;
var iNextClip = new Array();
var bCommentSet = new Array();
var bTweetMode = new Array();
var sTweetMode = new Array();
var bTweetVerifying = new Array();
var iCurrentClip = 0;
var bShowEmailSubscribe = false;


// mini browser detection
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);

var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
	is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
	is_major = parseInt(is_minor);
}

var is_opera = (agt.indexOf("opera") != -1);
var is_gecko = ((navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
var is_firefox = (agt.indexOf("firefox") != -1);
var is_safari = (agt.indexOf("safari") != -1);
var is_ie = ((iePos!=-1) && (!is_opera));
var is_mac = (agt.indexOf("mac")!=-1);

var is_chrome = (agt.indexOf("chrome") != -1);
// end


function ShowBlockLinksPerma() {
	if ($('dvBlockLinksPerma').style.display == 'none') {
		Effect.Appear('dvBlockLinksPerma', { duration: 0.8, from: 0, to: 1 } );
	} else {
		Effect.Fade('dvBlockLinksPerma', { duration: 0.8, from: 1, to: 0 } );
	}
	return false;
}


function ShowContent(element, bIsComment){
	
	var cc;
	var ttl;
	
	if(element != 'most-voted' && element != 'latest-comments' && element != 'archives'){
		cc = 'post-' + element + '-content';
		ttl = 'title-' + element;
	} else {
		cc = element;
		ttl = '';
	}
	
	var oDiv = document.getElementById('dvCliplist' + element);

	
	if(sActiveElement != cc){
		
		Effect.Fade(sActiveElement, {duration:.25});
		sActiveElement = cc;
		Effect.Appear(cc, {duration:.25,queue:'end'});
		//scroll(0,0);
		if(window.pageYOffset > 200){
			Effect.ScrollTo('clipList',{offset:-50});
		}
		
		if (!!oDiv) { 
			oDiv.className = 'Act';
		}
		
	}
	
	if (sRawId && sRawId != element) {
		document.getElementById('dvCliplist' + sRawId).className = 'Norm';
	}
	
	sRawId = element;		
	sActiveTitle = ttl;
	
	
	if (bIsComment) {
		LoadClipComments(element);
	}
	if (!!$('comment_twitter_password-' + element)) {
		Event.observe('comment_twitter_password-' + element, 'blur', function(event) { TweetVerify(element); });
	}
	
	
	for(var x=0;x<10;x++){
		if(element==iNextClip[x]) {iCurrentClip = x;}
	}
	
	pageTracker._trackPageview(sFullURL + '/' + cc);
}

function ShowEmailSubscribe() {
	var obj = document.getElementById('dvEmailSubscribe');
	obj.style.display = (!bShowEmailSubscribe ? 'block' : 'none');
	if (is_ie) { document.getElementById('dvClogAbout').style.visibility = (!bShowEmailSubscribe ? 'hidden' : 'visible'); }
	if (!bShowEmailSubscribe) { document.getElementById('txtSub2Email').focus(); }
	bShowEmailSubscribe = (!bShowEmailSubscribe);
}

function NextClip(i) {
    if(isNaN(i)) i = iCurrentClip;
	var iNext = i + 1;
	if (iNext >= iTotalOnPage) {
		window.location.href = sNextLink.replace(/^.*\"(.+)\".*$/, '$1');
	} else {
		ShowContent(iNextClip[iNext]);
	}
}

function PrevClip() {
    j = iCurrentClip;
	var iPrev = j - 1;
	if (iPrev < 0) {
		window.location.href = sPrevLink.replace(/^.*\"(.+)\".*$/, '$1');
	} else {
		ShowContent(iNextClip[iPrev]);
	}
}


function OpenCMSave(sGuid) {
	var u = window.location.href; 
	if (u.indexOf('#') == -1) {
		var oCMSave = window.open('http://clipmarks.com/edit_clip.aspx?clipping=true&source=clog&clip_guid=' + sGuid, 'CMSave', 'width=759,height=555,resizable=yes');
		oCMSave.focus();
	}
}



function OpenFFJsLb(sType, bAuthed) {
	
	if (sType == 'google' && !bAuthed) {
		window.location.href = '/clog-ff.php?t=' + sType;
		return;
	}
	
	var sType_pr = sType.charAt(0).toUpperCase();
	sType_pr = sType_pr + sType.substr(1);
	
	myLightWindow = new lightwindow();
	myLightWindow.activateWindow({
		href: '/clog-ff.php?t=' + sType + (bAuthed ? '&fetched=true' : ''),
		title: 'Find your ' + sType_pr + ' friends on Amplify',
		width: '610',
		height: '340'
	});
	return false;
}

function FocusComment(obj) {
	if (obj.value == 'Write a comment...') {
		obj.value = '';
	}
	obj.className='Focussed';
}

function BlurComment(obj) {
}

function ScaleComment(obj) {
}


function getStyle(obj,styleProp) {
	var x = obj;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}



function SndLnk(sAcc, sDomain) {
	if (!sDomain) { sDomain = 'amplify.com'; }
	var s = '<a href="';
	s += 'mai';
	s += 'lt';
	s += 'o:' + sAcc + '&#64' + sDomain + '">' + sAcc + '&#64' + sDomain + '</a>';
	document.write(s);
}


function LoadClipComments(sId) {
	
	if (!!!sId) {
		return;
	}
	
	
	if (!!$('dvClipComments' + sId)) {
		$('dvClipComments' + sId).update('<div class="LoadingComments"><img src="/wp-content/themes/default/images/loader.gif" alt="O" width="16" height="16" />Loading Comments...</div>');
	}
	
		
	new Ajax.Request('/clog-ajax.php',
	  {
	    method:'get',
	    parameters: {ajaxaction: 'ajax-comments-json', id: sId }, 
	    onSuccess: function(transport){
		    ParseClogComments(sId, transport.responseText.evalJSON());
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });
}



function ShowViewCount(sId){
	new Ajax.Request('/clog-ajax-viewcount-test.html',
	  {
	    method:'get',
	    onSuccess: function(transport){
		    $('viewcount-'+sId).update(transport.responseText);
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });
	
}

function LikeClip(sId){
	if (!!!sId) {
		return;
	}
	
	
	// loader message
	if (!!$('dvClipComments' + sId)) {
		$('dvClipComments' + sId).update('<div class="LoadingComments"><img src="/wp-content/themes/default/images/loader.gif" alt="O" width="16" height="16" />Loading Comments...</div>');
	}

	$('like-clip-' + sId).addClassName('share_like_pressed');
	$('like-clip-' + sId).removeClassName('share_like_active');
	$('like-clip-' + sId).writeAttribute("onclick", "return(false);" );
	$('like-clip-img-' + sId).src = '/wp-content/themes/default/images/goodfind-inactive.png';


	new Ajax.Request('/clog-ajax.php',
	  {
	    method:'get',
	    parameters: {ajaxaction: 'ajax-like-post', id: sId }, 
	    onSuccess: function(transport){
		    ParseClogComments(sId, transport.responseText.evalJSON());
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });
}

function RecommendTweetEnable(bEnable, sId){
	new Ajax.Request('/clog-ajax.php',
	  {
	    method:'get',
	    parameters: {ajaxaction: 'ajax-recommend-tweet-enable', id: sId, enableit: bEnable}, 
	    onSuccess: function(transport){
	    	if(bEnable){
		   		$(sId).innerHTML = 'Your recommends will now be automatically posted to Twitter.';
		    }else{
		    	$(sId).innerHTML = 'Your recommends will no longer be posted to Twitter';
		    }
	    },
	    onFailure: function(){ alert('Something went wrong recommending...') }
	  });
	  
	  return false;

}


function RecommendClip(sId, bNoShowComments, bIsTS){
	if (!!!sId) {
		return false;
	}
	
	var bTweetIt = false;	
	
	if (!!$('dvClipComments' + sId) && !bNoShowComments) {
		$('dvClipComments' + sId).update('<div class="LoadingComments"><img src="/wp-content/themes/default/images/loader.gif" alt="O" width="16" height="16" />Loading Comments...</div>');
	}

	$('recommend-clip-' + sId).innerHTML = 'Recommended';
	$('recommend-clip-' + sId).addClassName('share_recommend_pressed');
	$('recommend-clip-' + sId).removeClassName('share_recommend_active');
	$('recommend-clip-' + sId).writeAttribute("onclick", "return(false);" );
	var oDiv = document.createElement('div');
	var sHTML = '<div class="recommendmsg" id="recommendmsg-' + sId + '" style="display: none;">This ' + (bIsTS ? 'thought' : 'post') + ' will appear in the Newsfeed of your Amplify followers.</div> ';
	oDiv.innerHTML = sHTML;
	$('post-clip-options-' + sId).appendChild(oDiv);
	Effect.Appear('recommendmsg-' + sId);

	new Ajax.Request('/clog-ajax.php',
	  {
	    method:'get',
	    parameters: {ajaxaction: 'ajax-recommend-post', id: sId, tweetit: bTweetIt }, 
	    onSuccess: function(transport){
		    //alert(transport.responseText);
		    if (!bNoShowComments) {
			    ParseClogComments(sId, transport.responseText.evalJSON());
		    }
		    
	    },
	    onFailure: function(){ alert('Something went wrong recommending...') }
	  });
	  
	  return false;
}


function ShowTweetCount(sId, sPerma){
	$('RetweetCount-' + sId).update('...');
	new Ajax.Request('http://api.tweetmeme.com/url_info.json',
	  {
	    method:'get',
	    parameters: {url:sPerma}, 
	    onSuccess: function(transport){
		    alert(transport.responseText);
		    var obj = transport.responseText.evalJSON();
		    $('RetweetCount-' + sId).update(obj.story.url_count);
	    },
	    onFailure: function(){ alert('Something went wrong with ...') }
	  });
}



function DefaultTweetMode(sId) {
	bTweetMode[sId] = true;
	Event.observe(window, 'load', function() {
		CharCounter(sId);
		Event.observe('txtComment-' + sId, 'keyup', function(event) { CharCounter(sId); });
		Event.observe('txtComment-' + sId, 'keydown', function(event) { CharCounter(sId); });
	});
}


function TweetCom(sId, sTwitterName, sType, sOther, sTweet, sReply, sLongPerma, bLoggedOut) {

	if (sOther && sTweetMode[sId] == sOther) {
		$('tweet-' + sOther + '-' + sId).removeClassName('Pressed');
		bTweetMode[sId] = !(bTweetMode[sId]);
	}
	
	bTweetMode[sId] = !(bTweetMode[sId]);
	
	if(bLoggedOut && $('comment_twitter_type-' + sId).getValue().length == 0){
		bTweetMode[sId] = true;
	}

	var bShowSaved = false;
	var sUpdate;
	
	if (!!sTwitterName) {
		if (sTwitterName.length > 0) {
			bShowSaved = true;
		}
	}

	if (bShowSaved) {
		$('dvTwitterAccSaved-' + sId).update('Comment will be posted to Twitter account: <b><a href="http://twitter.com/' + escape(sTwitterName) + '" target="_blank">' + sTwitterName + '</a></b><br/><br/>');
		$('hTwitterAcc-' + sId).update('');
		$('dvTwitterAccSaved-' + sId).style.display='block';
		$('dvTwitterAccNew-' + sId).style.display='none';
		$('comment_twitter_use_saved-' + sId).value='true';

	} else {
		if (!bLoggedOut) {
			$('hTwitterAcc-' + sId).update('<img src="/wp-content/themes/default/images/tweet-small-bird.png" width="20" height="17" />Enter your Twitter info below to post your comment on Twitter');
		}
		$('dvTwitterAccSaved-' + sId).style.display='none';
		$('dvTwitterAccNew-' + sId).style.display='block';
	}


	if (bTweetMode[sId]) {
		if (bLoggedOut) {
			if ($('comment-type-' + sId).value != 'Twitter') {
				CmntTabSwitch(sId, 0, 'Twitter');
			}
		}
		
		$('comment_twitter_type-' + sId).value = sType;
		$('comment_is_tweet-' + sId).value = 'true';
		$('comment-type-' + sId).value = 'Twitter';
		$('chkTwitterCb-' + sId).checked = true;

		if (sType == 'tweet' || sType == 'retweet') {
			$('dvShareTwitter-' + sId).addClassName('Pressed');
		} else {
			$('tweet-' + sType + '-' + sId).addClassName('Pressed');
		}
		
		$('submit-' + sId).value = 'Post Comment & Tweet' ;
		sTweetMode[sId] = sType;
		
		if (sType == 'retweet') {
			sUpdate = 'RT @' + sReply + ' ' + sTweet;
		} else if (sType == 'reply') {
			sUpdate = '@' + sReply + ' ';
		} else {
			//tweet it
			// short perma ajax here...
			var sShort;
			new Ajax.Request('/clog-ajax.php',
			  {
			    method:'GET',
			    parameters: {ajaxaction: 'ajax-short-perma', origperma: sLongPerma }, 
			    onSuccess: function(transport){
				    sShort = transport.responseText;
				    sUpdate = sTweet + ' ' + sShort;
				    var existingComment = $('txtComment-' + sId).getValue();
					if (existingComment.length == 0 || existingComment == 'Write a comment...') {
						existingComment = '';
					}
					$('txtComment-' + sId).value = sUpdate + ' ' + existingComment;
				    CharCounter(sId);
			    }
			  });

			sUpdate = sTweet;
		}
		
		var existingComment = $('txtComment-' + sId).getValue();
		if(sType == 'retweet'){
			//retweet
			if (existingComment.length == 0 || existingComment == 'Write a comment...' || existingComment == '@' + sReply) {
				existingComment = '';
			}
			existingComment = existingComment.replace("@" + sReply + ' ', '');
			$('txtComment-' + sId).value = sUpdate + ' ' + existingComment;
		}else if(sType == 'tweet'){
			if (existingComment.length == 0 || existingComment == 'Write a comment...') {
				existingComment = '';
			}
			
			$('txtComment-' + sId).value = existingComment;
		}
		
		
		FocCom($('txtComment-' + sId));
		$('txtComment-' + sId).focus();
		
		
		CharCounter(sId);
		if (bLoggedOut) {
			$('dvLoggedOutChars-' + sId).style.display = 'block';
		}
		
		Event.observe('txtComment-' + sId, 'keyup', function(event) { CharCounter(sId); });
		Event.observe('txtComment-' + sId, 'keydown', function(event) { CharCounter(sId); });

		if (!bLoggedOut) {
			Effect.SlideDown('dvTwitterCreds-' + sId, { duration: 0.6 } );
		}
		
		
	} else {

		$('comment_twitter_type-' + sId).value = '';
		$('comment_is_tweet-' + sId).value = '';
		$('chkTwitterCb-' + sId).checked = false;
		if (sType == 'tweet' || sType == 'retweet') {
			$('dvShareTwitter-' + sId).removeClassName('Pressed');
		} else {
			$('tweet-' + sType + '-' + sId).removeClassName('Pressed');
		}
		
		$('submit-' + sId).value = 'Post Comment' ;
		sTweetMode[sId] = '';
		
		CharCounter(sId, true);
		if (bLoggedOut) {
			$('dvLoggedOutChars-' + sId).style.display = 'none';
		} else {
			$('comment-type-' + sId).value = '';
		}
				
		if (!bLoggedOut) {
			Effect.SlideUp('dvTwitterCreds-' + sId, { duration: 0.4 } );
		}
		
		
	}

	return false;
}


function TweetModeOff(sId) {
	
	bTweetMode[sId] = false;
	sTweetMode[sId] = '';
	$('comment_twitter_type-' + sId).value = '';
	$('comment_is_tweet-' + sId).value = '';

	if (!!$('tweet-tweet-' + sId)) {
		$('tweet-tweet-' + sId).removeClassName('Pressed');
	}
	if (!!$('tweet-retweet-' + sId)) {
		$('tweet-retweet-' + sId).removeClassName('Pressed');
	}
	if (!!$('tweet-reply-' + sId)) {
		$('tweet-reply-' + sId).removeClassName('Pressed');
	}
	
	
	if (!bLoggedOut) {
		Effect.SlideUp('dvTwitterCreds-' + sId, { duration: 0.4 } );
	}
	
	if(!!$('LoggedOutFields-' + sId)){
		Effect.Appear('LoggedOutFields-' + sId, {duration:0.6});
	}
}


function TweetChangeUser(sId) {
	
	$('hTwitterAcc-' + sId).update('<img src="/wp-content/themes/default/images/tweet-small-bird.png" width="20" height="17" />Enter your Twitter info below to post your comment on Twitter');
	$('dvTwitterAccSaved-' + sId).style.display='none';
	$('dvTwitterAccNew-' + sId).style.display='block';
	$('comment_twitter_use_saved-' + sId).value='false';
	
	return false;
}

function TweetVerify(sId) {
	
	if ($('comment-type-' + sId).value != 'Twitter') {
		return;
	}
	
	bTweetVerifying[sId] = true;

	new Ajax.Request('/clog-ajax.php',
		  {
		    method:'GET',
		    parameters: {ajaxaction: 'ajax-check-twitter', twitter_login: $('comment_twitter_username-' + sId).getValue(), twitter_pass: $('comment_twitter_password-' + sId).getValue()}, 
		    onSuccess: function(transport){
			   verifyResponse = transport.responseText.evalJSON();
			   if(verifyResponse.result == 'success'){
				$('comment_twitter_auth_passed-' + sId).value = 'true';
			   }
			   bTweetVerifying[sId] = false;
		    }
		  });

	return false;
}


function VerifyCommentSubmit(sId) {
	if ($('comment-type-' + sId).value == 'Twitter') {
		if (bTweetVerifying[sId]) {
			alert('Please wait while your Twitter account is verified.');
		}
		
		if ($('comment_twitter_use_saved-' + sId).value != 'true') {		
			if ($('comment_twitter_username-' + sId).getValue() == '' || $('comment_twitter_password-' + sId).getValue() == '') {
				alert('Please enter your Twitter username and password.');
				return false;
			}
		}
		
		if (($('comment_twitter_auth_passed-' + sId).value != 'true') && ($('comment_twitter_use_saved-' + sId).value != 'true')) {
			alert('Sorry, it looks like the Twitter username and password you provided are not valid.');
			return false;
		}
	} else if ($('comment-type-' + sId).value == 'Facebook') {
		if (!!$('hdnFacebookComment-' + sId)) {
			if ($('hdnFacebookComment-' + sId).value != 'true') { 
				alert('Please connect to Facebook before you submit your comment.');
				return false;
			}
		} else {
			alert('Please connect to Facebook before you submit your comment.');
			return false;			
		}
	}
	
	return true;
}



function CmntTabSwitch(sId, iTab, sType) {
	
	Effect.Fade('formcontainer-' + sId, { duration: 0.2, from: 0, to: 1 } );

	for (i=0; i<3; i++) {
		$('aCmntTab' + i + '-' + sId).className = 'Rest';
		$('dvCmntPanel' + i + '-' + sId).className = 'PanelRest';
	}
	

	// reset form here...
	$('comment_twitter_type-' + sId).value = '';
	$('comment_is_tweet-' + sId).value = '';
	if (!!$('tweet-' + sTweetMode[sId] + '-' + sId)) {
		$('tweet-' + sTweetMode[sId] + '-' + sId).removeClassName('Pressed');
	}
	$('submit-' + sId).value = 'Post Comment' ;
	bTweetMode[sId] = false;
	sTweetMode[sId] = '';
	$('comment_twitter_use_saved-' + sId).value='false';
	$('dvLoggedOutChars-' + sId).style.display = 'none';
	
	$('chkTwitterCb-' + sId).checked = false;
	$('dvTwitterCb-' + sId).style.display = (sType == 'Twitter' ? 'block' : 'none');
	
	BlrCom(sId);
	// end reset


	$('aCmntTab' + iTab + '-' + sId).className = 'Active';
	$('dvCmntPanel' + iTab + '-' + sId).className = 'PanelActive';

	$('dvCmntFields-' + sId).style.display = (sType == 'Amplify' ? 'none' : 'block');
	
	$('comment-type-' + sId).value = sType;

	return false;
}

function CmntLoginSubmit(sId) {

	if ($('txtUserLogin-' + sId).value == '') {
		alert('Please enter your Amplify username.');
		return false;
	}
	
	if ($('txtUserPassword-' + sId).value == '') {
		alert('Please enter your Amplify password.');
		return false;
	}
	
	$('txtUserLogin').value = $('txtUserLogin-' + sId).value;
	$('txtUserPassword').value = $('txtUserPassword-' + sId).value;
	$('chkRememberMe').value = ($('chkRememberMe-' + sId).checked ? 'forever' : '');
	$('txtRedirectTo').value = $('txtRedirectTo-' + sId).value + '#post-comment';
	
	$('frmLoginform').submit();
	
}

function ScrollToCmntForm(sId) {
	Effect.ScrollTo('aPostComment-' + sId);
	$('txtComment-' + sId).focus();
	return false;
}

function TweetCountUpdate(results){
	temp = Math.floor(Math.random() * (10000 - 1 + 1)) + 1;
	document.write('<div id="a'+temp+'"></div>');
	parent = $('a'+temp).ancestors()[0];
	tcount = 0;
	if(results.total){
		tcount = results.total;
	}else{
		tcount = 0;
	}
	theLink = parent.identify();
	theCurrentCount = $(theLink).innerHTML;
	theCurrentCount = theCurrentCount.substring(0,theCurrentCount.indexOf('<'));
	if(parseInt(tcount) > 0){
		if(isNaN(parseInt(theCurrentCount))){
			$(theLink).update(parseInt(tcount));
		}else{
			$(theLink).update(parseInt(theCurrentCount) + parseInt(tcount));
		}
	}
	new Ajax.Request('/clog-ajax.php',
	{
		method:'get',
		parameters: {ajaxaction: 'ajax-update-tweetcount', pid: parent.identify(), total: tcount, since_id:results.max_id}, 
		onSuccess: function(transport){
		},
		onFailure: function(){ alert('Something went wrong updating tweet count cache...') }
	});

	return false;
}



function ViewCountUpdate(iResults){

	var temp = Math.floor(Math.random() * (10000 - 1 + 1)) + 1;
	var iCount = 0;
	
	if (iResults){
		iCount = iResults;
	}else{
		iCount = 0;
	}
	
	
	var oDiv = document.createElement('div');
	var sHTML = '<div class="viewcount"><div class="viewcount-inner"></div></div> ';
	oDiv.innerHTML = sHTML;
	
	
	var oNode = $('clipWrapper');
	var els = oNode.getElementsByTagName("div");

	for (i=0; i < els.length; i++) {
		if (els[i].className == 'Clog_Bottom_Wrap') {
			//alert('we got a match!');
			els[i].appendChild(oDiv);
		}
	}
	
	return false;	
}	



function ExpandCommentary(sId) {

	$('pShortClogCommentary-' + sId).parentNode.style.minHeight = parseInt($('pShortClogCommentary-' + sId).getHeight() + 22) + 'px';
	$('pShortClogCommentary-' + sId).style.display = 'none';
	
	Effect.Appear($('pFullClogCommentary-' + sId), { duration: 0.7, afterFinish: function() {
		//$('pShortClogCommentary-' + sId).style.display = 'none';
	} });
	
	
	return false;
}



Event.observe(document.onresize ? document : window, "resize", function() {
		
	if (!!$('dvNextFeedClip')) {
		var iWinHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
		var iTabLeft = parseInt(document.body.clientWidth - 27);
		var iTabTop = parseInt((iWinHeight - 173) / 2);
		$('dvNextFeedClip').style.top = iTabTop + 'px';
		$('dvNextFeedClip').style.left = iTabLeft + 'px';
	}
	
});



Event.observe(window, 'load', function() {
	if (!!$('dvInstallMask')) {
		setTimeout(function() {Effect.Fade('dvInstallMask');}, 1000);
	}
	
	if (!!$('comment_twitter_password-' + sRawId)) {
		Event.observe('comment_twitter_password-' + sRawId, 'blur', function(event) { TweetVerify(sRawId); });
	}

	
	$$('a[href!=""]').each(function(link){
		if(link.readAttribute('href').startsWith('http://') &&
		  (link.readAttribute('href').indexOf(sitematch) == -1) && (!link.readAttribute('href').match('http://.*amplify.com')) && (!link.readAttribute('href').match('http://.*dinnerswitch.com'))){
			link.writeAttribute('target','_blank');
			//conflicted with nofollow change, 06-16-09(W)
			//link.writeAttribute('rel','external');
		}
	});


	if (!!$('txtTSForm')) {
		Event.observe('txtTSForm', 'keyup', function(event) 	{ TSKeyPress($('txtTSForm')); });
		Event.observe('txtTSForm', 'keydown', function(event) 	{ TSKeyPress($('txtTSForm')); });
	}


	$$('a[data-uid]').each(function(link) {
		Event.observe(link, 'mouseover', function(event) { UCard_Init(link); });
		Event.observe(link, 'mouseout',  function(event) { UCard_Close(); });
		Event.observe(link, 'click',  function(event) { UCard_Unload(); });
	});

	
	if(!!$('TweetInitVerifyPerma')) {
		TweetInitVerifyPerma();
	}
	
	if(!!$('TryFbFeedPost')) {
		TryFbFeedPost();
	}
	
	
	if(!!$('dvOpenFFJsLb')) {
		OpenFFJsLbOnload();
	}
	
	if (!!sCmGuid) {
		OpenCMSave(sCmGuid);
	}
	
});


