﻿
var my_base_url='http://freshpips.com';
var my_pligg_base='';


dochref = document.location.href.substr(document.location.href.search('/')+2, 1000);
if(dochref.search('/') == -1){
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref;
} else {
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref.substr(0, dochref.search('/'));
}
$thisurl = $thisurl + '';

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
  try {
	xmlhttp = new XMLHttpRequest ();
  }
  catch (e) {
  xmlhttp = false}
}

function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

// Fix for issue #282 (https://pips.sifterapp.com)
function getUserId(callback) {
	// In case UserLogin object is not available, proceed with login	
	if(typeof FreshPips.UserLogin != 'object') {
		window.location="http://freshpips.com/login.php?return="+location.href;
	}	
	
	FreshPips.UserLogin.showLogin(null, function(success, ret_obj) {
		if(success && (typeof ret_obj == 'object') ) {
			if(typeof callback == 'function') {
				callback(ret_obj.user.user_id);
			}
			location.reload(true);
		}
	}, false);
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;

function vote (user, id, htmlid, md5, value, callback)
{ 
  	if (xmlhttp) {
		url = $thisurl + "/vote.php";
		var mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value ;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            getUserId(function(user) {vote (user, id, htmlid, md5, value, function() { location.reload(true); }) });
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			if(typeof callback == 'function') {
    				callback();
    				return;
    			}
    			
    			errormatch = new RegExp ("^ERROR:");
   				target1 = document.getElementById ('xvotes-' + htmlid); 
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {    					    
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues (htmlid, value, true);    					} else {
														if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {changemnmvalues2 (htmlid, value, false, 'voteup');}     					}
    				}
    			}
    		}
    	}
	}
}
function cfvote (user, id, htmlid, md5, value, callback)
{ 
	var news = $$('div.news-summary');
	var statusExec = false;
	var votetype = (value >= 0 ) ? 'voteup' : 'votedown';
	var voteStat = (value >= 0 ) ? '' : 'votedown=true&';
	
	for(x=0; x < news.length; x++){
		temp_news_id = news[x].id; 
		temp_link_id = temp_news_id.match(/[\d\.]+/g);
		news_id = temp_link_id[0];
		if(id == news_id){
			statusExec = true;
		}
	}
  	if (xmlhttp) {
		url = $thisurl + "/vote.php";
		var mycontent = voteStat + "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value ;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            getUserId(function(user) {cfvote (user, id, htmlid, md5, value, function() { location.reload(true); }) });
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			if(typeof callback == 'function') {
    				callback();
    			}    
    			
    			errormatch = new RegExp ("^ERROR:");
   				target1 = document.getElementById ('xvotes-' + htmlid); 
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues2 (htmlid, value, false, votetype);    					} else {
														changemnmcfvalues ( htmlid, value, false, votetype);if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {if(statusExec){changemnmvalues2 (htmlid, value, false, votetype);}}    					}
    				}
    			}
    		}
    	}
	}
}
function changemnmcfvalues ( id, value, error, type)
{
/*	target = $('vote-up-btn_'+ id);
	target.removeClassName('cf-vote-up');
	target.addClassName('cf-voted');
	target.onclick = '';
	if(value > 0){
		target.innerHTML='<img src=\"/templates/freshpips/ui/media/images/forms/voted-fresh.png\" alt=\"voted as fresh\" />';
	}else if (value < 0){
		target.innerHTML='<img src=\"/templates/freshpips/ui/media/images/forms/voted-stale.png\" alt=\"voted as stale\" />';
	}
*/
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	target1 = (type == 'votedown') ? document.getElementById ('cfxvotesdown-' + id) : document.getElementById ('cfxvotes-' + id);
	target2a = document.getElementById ('cfxvote-' + id);
	target2b = document.getElementById ('cfxvotedown-' + id);
	target3 = document.getElementById ('cfxreport-' + id);
	target5a = document.getElementById ('cfvote-up-btn-' + id);
	target5b = document.getElementById ('cfvote-down-btn-' + id);
	buttonup  = document.getElementById ('cfvote-up-link_' + id);
	buttondown  = document.getElementById ('cfvote-down-link_' + id);
	descVoted = (type == 'votedown') ? "<img src=\"/templates/freshpips/ui/media/images/forms/voted-stale.png\" alt=\"voted as stale\" />" : "<img src=\"/templates/freshpips/ui/media/images/forms/voted-fresh.png\" alt=\"voted as fresh\" />";
	if (error) {
		if (value > 0) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> "; 
			target2b.innerHTML = "<span>"+descVoted+"</span> ";
		}
		else if (value < 0) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> "; 
			target2b.innerHTML = "<span>"+descVoted+"</span> "; 
		}
		return false;
	}
	buttonup.onclick = '';
	buttondown.onclick = '';
	if (b.length <= 3) {
		countVote = (b[0] == 1) ? 'vote' : 'votes';
		descVote = (type == 'votedown') ? document.getElementById ('downdescVote-' + id).innerHTML = countVote : document.getElementById ('updescVote-' + id).innerHTML = countVote;
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		//new Effect.Fade(target3);
		if (value > 0) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> "; 
			target2b.innerHTML = "<span>"+descVoted+"</span> ";
			removeClass(buttonup,'new-vote-up-link');
			addClass(buttonup,'new-voted-up-link');
			FreshPips.VoteEffects.onmouseoverSlideVotedUp(buttonup);
		}
		else if (value < 0 ) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> ";
			target2b.innerHTML = "<span>"+descVoted+"</span> ";
			removeClass(buttondown,'new-vote-down-link');
			addClass(buttondown,'new-voted-down-link');
			FreshPips.VoteEffects.onmouseoverSlideVotedDown(buttondown);
		}
	}
	return false;
}
function changecfvotebtn(id,value){
/*	target = $('vote-up-btn_'+ id);
	target.removeClassName('cf-vote-up');
	target.addClassName('cf-voted');
	target.onclick = '';
	if(value > 0){
		target.innerHTML='<img src=\"/templates/freshpips/ui/media/images/forms/voted-fresh.png\" alt=\"voted as fresh\" />';
	}else if (value < 0){
		target.innerHTML='<img src=\"/templates/freshpips/ui/media/images/forms/voted-stale.png\" alt=\"voted as stale\" />';
	}
*/
}
function votedown (user, id, htmlid, md5, value)
{ 
  	if (xmlhttp) {
		url = $thisurl + "/vote.php";
		var mycontent = "votedown=true&id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value ;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            getUserId(function(user) { votedown(user, id, htmlid, md5, value) });
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");
   				target1 = document.getElementById ('xvotesdown-' + htmlid); 
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues2 (htmlid, value, false, 'votedown');    					} else {
														if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {changemnmvalues2 (htmlid, value, false, 'votedown');}     					}						
    				}
    			}
    		}
    	}
	}
}

function unvote (user, id, htmlid, md5, value)
{
  	if (xmlhttp) {
		url = $thisurl + "/vote.php";
		var mycontent = "unvote=true&id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            getUserId(function(user) { unvote(user, id, htmlid, md5, value) });
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");    
				target1 = document.getElementById ('xvotes-' + htmlid);
  				target2 = document.getElementById ('xvote-' + htmlid);    
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					if (xvotesString[htmlid].match (errormatch)) {
    						 xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues (htmlid, value, true);target2.innerHTML = "<span>Vote</span>";						} else {
							if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {target2.innerHTML = "<span>Vote</span>";changemnmvalues (htmlid, value, false); }							
    					}
    				}
    			}
    		}
    	}
	}
}


function cvote (user, id, htmlid, md5, value)
{
	if (xmlhttp) {
		url = $thisurl + "/cvote.php";
		mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;

        if (anonymous_vote == false && user == '0') {
            getUserId(function(user) { cvote (user, id, htmlid, md5, value) });
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");
    			target1 = document.getElementById ('cvote-' + htmlid);        
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			target1.style.backgroundColor = '#FFFFFF';
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
    						changecvotevalues (htmlid, true);	
    						FaceboxP.show( '<div class="error" align="center">'+xvotesString[htmlid]+'</div>', { title: "Error", height: 300 } );						
    					} else {
							target1 = document.getElementById ('ratebuttons-' + id);
							target1.style.display = "none";
							target2 = document.getElementById ('ratetext-' + id);
							target2.innerHTML = "Thank you for rating this comment.";
							changecvotevalues (htmlid, false);
							FaceboxP.show( '<div align="center"><p>Thank you for rating this comment.</p></div>', { title: "Rating Successful", height: 300 } );
    					}
    				}
    			}
    		}
    	}
	}
}

function changemnmvalues (id, value, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	//alert(id);
	target1 = document.getElementById ('xvotes-' + id);
	target2 = document.getElementById ('xvote-' + id);
	target3 = document.getElementById ('xreport-' + id);
	target4 = document.getElementById ('xnews-' + id);
	buttonup  = document.getElementById ('vote-up-link_' + id);
	buttondown  = document.getElementById ('vote-down-link_' + id);
	if (error) {
		if (value > 0) { 
			target2.innerHTML = "<span>Voted</span> ";
			buttonup.onclick = '';
			buttondown.onclick = ''; 
		}
		else if (value < 0) { target2.innerHTML = "<span>Buried</span> "; }
		return false;
	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		new Effect.Fade(target3);
		if (value > 0) { target2.innerHTML = "<span>Voted</span> ";
			buttonup.onclick = '';
			buttondown.onclick = ''; 
		}
		else if (value < 0 ) { target2.innerHTML = "<span>Buried</span> ";
													new Effect.Opacity(target4, {duration:0.8, from:1.0, to:0.3}); }
	}
	return false;
}
/**	Version 2 of changemnmvalues, parameter type is just added
  * This cater both votedown or voteup modification of mnm values
  *	
  *	@params string type is added to know if it is for votedown or voteup
  */
function changemnmvalues2 ( id, value, error, type)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	target1 = (type == 'votedown') ? document.getElementById ('xvotesdown-' + id) : document.getElementById ('xvotes-' + id);
	target2a = document.getElementById ('xvote-' + id);
	target2b = document.getElementById ('xvotedown-' + id);
	target3 = document.getElementById ('xreport-' + id);
	//target4 = document.getElementById ('xnews-' + id);
	target4 = document.getElementById ('story_' + b[1]);
	target5a = document.getElementById ('vote-up-btn-' + id);
	target5b = document.getElementById ('vote-down-btn-' + id);
	buttonup  = document.getElementById ('vote-up-link_' + id);
	buttondown  = document.getElementById ('vote-down-link_' + id);
	descVoted = (type == 'votedown') ? "<img src=\"/templates/freshpips/ui/media/images/forms/voted-stale.png\" alt=\"voted as stale\" />" : "<img src=\"/templates/freshpips/ui/media/images/forms/voted-fresh.png\" alt=\"voted as fresh\" />";
	if (error) {
		if (value > 0) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> "; 
			target2b.innerHTML = "<span>"+descVoted+"</span> ";
		}
		else if (value < 0) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> "; 
			target2b.innerHTML = "<span>"+descVoted+"</span> "; 
		}
		return false;
	}
	buttonup.onclick = '';
	buttondown.onclick = '';
	if (b.length <= 3) {
		countVote = (b[0] == 1) ? 'vote' : 'votes';
		descVote = (type == 'votedown') ? document.getElementById ('downdescVote-' + id).innerHTML = countVote : document.getElementById ('updescVote-' + id).innerHTML = countVote;
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		//new Effect.Fade(target3);
		if (value > 0) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> "; 
			target2b.innerHTML = "<span>"+descVoted+"</span> ";
			removeClass(buttonup,'new-vote-up-link');
			addClass(buttonup,'new-voted-up-link');
			FreshPips.VoteEffects.onmouseoverSlideVotedUp(buttonup);
		}
		else if (value < 0 ) { 
			target2a.innerHTML = "<span>"+descVoted+"</span> ";
			new Effect.Opacity(target4, {duration:0.8, from:1.0, to:0.3}); 
			target2b.innerHTML = "<span>"+descVoted+"</span> ";
			new Effect.Opacity(target4, {duration:0.8, from:1.0, to:0.3});
			target4.getElementsByClassName('save')[0].hide();
			removeClass(buttondown,'new-vote-down-link');
			addClass(buttondown,'new-voted-down-link');
			FreshPips.VoteEffects.onmouseoverSlideVotedDown(buttondown);
		}
	}
	return false;
}

function changecvotevalues (id, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	target1 = document.getElementById ('cvote-' + id);
	if (error) {
		return false;
	}
	if (b.length <= 3) {
		var str = ( b[0] > 1 ) ? 'votes' : 'vote' ;
		target1.innerHTML = b[0] + ' ' + str;
		target1.style.backgroundColor = mnmPrevColor[id];
	}
	return false;
}


function enablebutton (button, button2, target)
{
	var string = target.value;
	button2.disabled = false;
	if (string.length > 0) {
		button.disabled = false;
	} else {
		button.disabled = true;
	}
}

function checkfield (type, form, field)
{
	url = $thisurl + '/checkfield.php?type='+type+'&name=' + field.value;
	checkitxmlhttp = new myXMLHttpRequest ();
	checkitxmlhttp.open ("GET", url, true);
	checkitxmlhttp.onreadystatechange = function () {
		if (checkitxmlhttp.readyState == 4) {
		responsestring = checkitxmlhttp.responseText;
			if (responsestring == 'OK') {
				//document.getElementById (field.name+'checkitvalue').innerHTML = '<span style="color:black">"' + field.value + '": ' + responsestring + '</span>';
				form.submit.disabled = '';
                document.getElementById(field.name+'checkitvalue').setAttribute('title', 'OK');
                document.getElementById(field.name+'checkitvalue').removeClassName('field_bad');
                document.getElementById(field.name+'checkitvalue').addClassName('field_ok');
			} else {
				//document.getElementById (field.name+'checkitvalue').innerHTML = '<span style="color:red">"' + field.value + '": ' + responsestring + '</span>';
				form.submit.disabled = '';
                document.getElementById(field.name+'checkitvalue').setAttribute('title', responsestring);
                document.getElementById(field.name+'checkitvalue').removeClassName('field_ok');
                document.getElementById(field.name+'checkitvalue').addClassName('field_bad');
			}
		}
	}
  checkitxmlhttp.send (null);
  return false;
}

function emailto (original_id, htmlid, instpath, address_count)
{
	email_message = document.getElementById('email_message' + htmlid).value;
	email_address = document.getElementById('email_address_1_' + htmlid).value;
	if (address_count > 1){ 
		for ($i = 2; $i <= address_count; $i++) {
			if(document.getElementById('email_address_' + $i + '_' + htmlid).value != "") {
				email_address = email_address + ', ' + document.getElementById('email_address_' + $i + '_' + htmlid).value;
			}
		}
	}
	
	if (xmlhttp) {
		url = $thisurl + "/recommend.php";
		mycontent = "email_address=" + escape(email_address) + "&email_to_submit=submit&email_message=" + escape(email_message) + "&original_id=" + original_id + "&backup=0" + "&htmlid=" + htmlid + "&linkid=" + original_id;
		//target2 = document.getElementById ('emailto-' + htmlid);
		//target2.innerHTML = "<br>Sending, please wait....";
		
		FreshPips.UserLogin.showLoading();
		var modal_params = {
			title: "Tell a friend",
			width: 400
		}
		
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
			
					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						//target2 = document.getElementById ('emailto-' + htmlid);
						//target2.innerHTML = xvotesString[htmlid];	
						FaceboxP.show( xvotesString[htmlid], modal_params );						
					} else {
						//target2 = document.getElementById ('emailto-' + htmlid);
						//target2.innerHTML = xvotesString[htmlid];						
						FaceboxP.show( xvotesString[htmlid], modal_params );
					}
				}
			}
		}
	}
}

function show_recommend(htmlid, linkid, instpath)
{
	//var emailtodisplay=document.getElementById('emailto-' + htmlid).style.display ? '' : 'none';
	//document.getElementById('emailto-' + htmlid).style.display = emailtodisplay;

	if (xmlhttp) {
		url = $thisurl + "/recommend.php";
		mycontent = "draw=small&htmlid=" + htmlid + "&linkid=" + linkid;		
		//target2 = document.getElementById ('emailto-' + htmlid);
		//target2.innerHTML = "<br>Loading, please wait....";	
		
		FreshPips.UserLogin.showLoading();
		var modal_params = {
			title: "Tell a friend",
			width: 400
		}
		
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;			
					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						//target2 = document.getElementById ('emailto-' + htmlid);
						//target2.innerHTML = xvotesString[htmlid];		
						FaceboxP.show( xvotesString[htmlid], modal_params );				
					} else {
						//target2 = document.getElementById ('emailto-' + htmlid);
						//target2.innerHTML = xvotesString[htmlid];
						FaceboxP.show( xvotesString[htmlid], modal_params );	
					}
				}
			}
		}
	}
}
function hasClass(ele,cls) 
{
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
	if (!hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
	if (hasClass(ele,cls)) {
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}
