



String.prototype.Trim = function() 
{ 
return this.replace(/(^\s*)|(\s*$)/g, "");
} 
String.prototype.LTrim = function() 
{ 
return this.replace(/(^\s*)/g, ""); 
} 
String.prototype.RTrim = function() 
{ 
return this.replace(/(\s*$)/g, ""); 
}
 



function GetCookie(namex){
var cookieString = new String(document.cookie)
 
var cookieHeader = namex + "="
var beginPosition = cookieString.indexOf(cookieHeader)
if (beginPosition != -1){
cookieString = cookieString.substring(beginPosition + cookieHeader.length);
if (cookieString.indexOf(";")>-1){
cookieString = cookieString.substring(0, cookieString.indexOf(";"));
}
return unescape(cookieString);
}
return "";
}

 

function getElement(aID)
{
return (document.getElementById) ? document.getElementById(aID): document.all[aID];
}

 

function makeRequest(url){
http_request=false;
if(window.XMLHttpRequest){//Mozilla,Safari,...
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){
http_request.overrideMimeType('text/xml');
}
}else if(window.ActiveXObject){//IE
try{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
if(!http_request){
alert('Giving up:(Cannot create an XMLHTTP instance)');
return false;
}
return http_request;
}
 
 
 
function diggit(id,diggnum)
{
	if (document.cookie)
	{
		var dugg = GetCookie("duggid");
		if (dugg!="")
		{
			re = new RegExp("-" + id + "#" + diggnum + "#-", "ig");
			if (re.test(dugg))
			{
				re2 = new RegExp(id + "-", "ig");
				var c = dugg.replace(re2, "");
                SetCookie("duggid", c,1);
			}
			else
			{
                SetCookie("duggid", dugg + id + "#" + diggnum  + "#-",1);
			}
		}
		else
		{
            SetCookie("duggid", "-" + id + "#" + diggnum  + "#-",1);
		}
	}
    else
	{
		SetCookie("duggid", "-" + id + "#" + diggnum + "#-",1);
	}
	return true;
}

 
function hc(qid,uid,site){

getElement("span_"+qid).innerHTML = '<img src="/img/loading.gif" width="25" height="25" />';
var url = site + "interested.php?qid="+qid+"&uid="+uid; 

var xhttp=makeRequest();

xhttp.onreadystatechange=function(){
if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
{ 
var res = decodeURIComponent(xhttp.responseText);
 
if (res.indexOf("error")>-1)
{
getElement("span_"+qid).innerHTML = res; 
}
else if (res.indexOf("err:")>-1)
{
alert(res.replace("err:", ""));
getElement("span_"+qid).innerHTML = res; 
}
else
{
getElement("span_"+qid).innerHTML = res; 
}


getElement("h_"+qid).innerHTML = 'Voté'; 
var diggnum = xhttp.responseText;
 
 diggit(qid,diggnum);	
  
}
}

xhttp.open("GET",url,true);
xhttp.send(null);
}


function trackaction(email,name,str,type,info,site,qid,uid){

var url = site + "trackaction.php?type="+type+"&info="+encodeURIComponent(info)+"&str="+encodeURIComponent(str)+"&email="+encodeURIComponent(email)+"&name="+encodeURIComponent(name)+"&qid="+qid+"&uid="+uid; 

var xhttp=makeRequest();
xhttp.onreadystatechange=function(){

}

xhttp.open("GET",url,true);
xhttp.send(null);
}