function urlencode(t) {
	return encodeURIComponent(t);
}
function editcookie(t) {
	var c=getprev(t);
	var url="/inc/editcookie.php?site="+urlencode(ccsite)+"&cookie="+urlencode(c.name)+"&value="+urlencode(c.value)+"&c="+urlencode(cccook);
	var x=getxml();
	if (!x) {
		alert("Error connecting");
		return false;
	}
	t.style.visibility="hidden";
	x.open('GET',url,true);
	x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
	x.onreadystatechange=function() { ccgot(x,t); };
	x.send("");
}
function ccgot(x,t) {
	if (x.readyState==4) {
		if (x.status==200) {
			alert("Set - "+x.responseText);
		} else {
			t.style.visibility="visible";
			alert("Not Set");
		}
	}
}
function recick() {
	if (document.reci.getbacklinks.value=="")
		return false==alert('Please enter your URL');
	if (document.reci.reciprocal.value=="")
		return false==alert('Please enter at least one address to check');
	return true;
}
function addcookie() {
	var n=prompt("Please enter cookie name","")
	if (n=="")
		return false;
	var v='<div>'+n+' = <input name="'+n+'" type="text" value="" onkeydown="cchange(this)">';
	v+='<input type="button" onclick="editcookie(this)" value="Set"></div>';
	document.getElementById("cookies").innerHTML=document.getElementById("cookies").innerHTML+v;
}
function cchange(t) {
	getnext(t).style.visibility="visible";
}
function coda(t) {
	var c=getprev(t.parentNode);
	var ct="";
	if (c.title=="")
		ct=document.title;
	else
		ct=c.title;
	if (ct=="")
		ct="Coda Clip";
	document.location='codaclips://%3C%3C**Title:'+urlencode(ct)+'**%3E%3E'+urlencode(c.value);
}
var IE=document.all ? true : false

function codepopup(t,e) {
	var c=getprev(t.parentNode);
	var v=document.getElementById("htext");
	if (typeof(v)=="undefined" || v==null) {
		v=document.createElement("textarea");
		v.setAttribute("id","htext");
		v.onmouseout=function() {this.style.visibility='hidden'; this.style.display='none';};
		document.getElementsByTagName('body')[0].appendChild(v);
	}
	v.style.left=(e.clientX-150)+'px';
	if (IE)
		v.style.top=(findpos(t)[1]-150)+'px';
	else
		v.style.top=(e.pageY-150)+'px';
	v.style.visibility="visible";
	v.style.display='block'
	v.value=c.value;
	v.focus();
	v.select();
}
function codepop(t,e) {
	var v=document.getElementById("htext");
	v.onmouseout=function() {this.style.visibility='hidden'; this.style.display='none';};
	v.style.left=(e.clientX-150)+'px';
	if (IE)
		v.style.top=(findpos(t)[1]-150)+'px';
	else
		v.style.top=(e.pageY-150)+'px';
	v.style.visibility="visible";
	v.style.display='block'
	v.focus();
	v.select();
}
function textmate(t) {
	var c=getprev(t.parentNode);
	var ct="";
	if (typeof(c.title)=="undefined" || c.title=="")
		ct=document.title;
	else
		ct=c.title;
	if (ct=="")
		ct="Textmate Snippet";
	var v=gethform('/inc/textmate.php');
	v.snippet.value=c.value;
	v.sname.value=ct;
	v.submit();
}
function dtext(t) {
	var c=getprev(t.parentNode);
	var ct="";
	if (typeof(c.title)=="undefined" || c.title=="")
		ct=document.title;
	else
		ct=c.title;
	if (ct=="")
		ct="Text file";
	var v=gethform('/inc/downloadtext.php');
	v.snippet.value=c.value;
	v.sname.value=ct;
	v.submit();
}
function dzoom(t) {
	var c=getprev(t.parentNode)
	var s=c.style.fontSize;
	//var s=c.
	if (s=="12px" || s=="")
		s='16px';
	else if (s=="16px")
		s='18px';
	else if (s=="18px")
		s='12px';
	c.style.fontSize=s;
}
function dtr(t,o) {
    t.style.opacity=o;                      
    t.style.MozOpacity=o;                   
    t.style.filter='alpha(opacity='+(opacity*100)+')'; 	
}
function gethform(haction,htype) {
	var v=document.hform;
	if (typeof(v)=="undefined" || v==null) {
		v=document.createElement("form");
		v.setAttribute("method","post");
		v.style.display='none';
		v.style.visibility='hidden';
		v.setAttribute("name","hform");
		var n=document.createElement("textarea");
		n.setAttribute("name","snippet");
		v.appendChild(n);
		n=document.createElement("input");
		n.setAttribute("name","suid");
		v.appendChild(n);
		n=document.createElement("input");
		n.setAttribute("name","sname");
		v.appendChild(n);		
		n=document.createElement("input");
		n.setAttribute("name","stype");
		v.appendChild(n);
		document.getElementsByTagName('body')[0].appendChild(v);
	}
	v.stype.value=(typeof(htype)=="undefined") ? "txt" : htype;
	v.action=haction;
	v.suid.value=randomUUID();
	return v;
}
function randomUUID() {
  var s=[],itoh='0123456789ABCDEF';
  for (var i=0; i<36; i++)
  	s[i]=Math.floor(Math.random()*16);
  s[14]=4;
  s[19]=(s[19] & 3) | 8;
  for (i=0; i<36; i++)
  	s[i]=itoh[s[i]];
  s[8]=s[13]=s[18]=s[23]='-';
  return s.join('');
}
function xana(u) {
	window.open(u);
}
function expand(obj) {
	if (obj.className=="explode")
		obj.className="implode"
	else
		obj.className="explode"
}
function implode(obj) {
	document.getElementById(obj).className="explode";
}
function checkdomain(strURL,tld,optbuy,pr) {
var x=getxml();
if (!x)
	return false
if (!pr)
	var pr=""
else
	pr="&pr=1"
x.open('GET', '/inc/checkavail.php?domain='+strURL+'&ob='+optbuy+pr, true);
x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
x.onreadystatechange = function() { cbcheckdomain(x,tld); };
x.send("");
}
function getxml() {
var x=false;
if (window.XMLHttpRequest) {
	x=new XMLHttpRequest();
	if (x.overrideMimeType)
		x.overrideMimeType('text/xml');
} else if (window.ActiveXObject) {
	try {
		x=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			x=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
}
if (!x)
	return false;
return x;
}
function cbcheckdomain(r,gtld) {
	if (r.readyState== 4 && r.status==200) {
		document.getElementById(gtld).innerHTML=r.responseText;
	}
}
function getprev(idno) {
	var i=idno.previousSibling;
	while(i!=null && i.innerHTML == null) {
		i=i.previousSibling;
	}
	return i;
}
function getfirstnode(h,tag) {
tag=tag.toUpperCase();
h=h.childNodes;
for(var i=0;i<h.length; i++) {
	if (typeof(h[i].tagName)!='undefined' && h[i].tagName==tag) {
		return h[i];
	}
}
return null;
}
function getnext(idno) {
	var i=idno.nextSibling;
	while(i!=null && i.innerHTML==null) {
		i=i.nextSibling;
	}
	return i;
}


function domainname(th) {
	th=th.parentNode;
	th=th.parentNode;
	return getfirstnode(th,"td");
}
function getdomain(a) {
	var b=getnext(a);
	var d=a.innerHTML;
	var wlist=(typeof(watchlist)!="undefined")?true:false;
	var e=getnext(getnext(getnext(b))).innerHTML;
	if (e=='')
		return false;
	b.innerHTML='<img src="/images/loading.gif">';
	var x=getxml();
	if (!x) {
		b.innerHTML='<img src="/images/error.gif">';
		return false;
	}
	x.open('GET','/inc/'+((wlist)?'checkwatch':'checkdomain')+'.php?domain='+d,true);
	x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
	x.onreadystatechange=function() { domaingot(x,b); };
	x.send("");
}
function getwhois(d) {
	window.open('/inc/checkavail.php?whois='+d,'','width=400,height=400,status=no,menubar=no,copyhistory=no,directories=no,location=no,toolbar=no,scrollbars=yes');
	return false;
}
function hllink(d) {
	d.className="jlhover";
}
function ullink(d) {
	d.className="jl";
}
function urlreplace(key,value) {
	key=escape(key);
	value=escape(value);
	var kvp=document.location.search.substr(1).split('&');
	var i=kvp.length;
	var x;
	while (i--) {
		x=kvp[i].split('=');
		if (x[0]==key) {
			x[1]=value;
			kvp[i]=x.join('=');
			break;
		}
	}
    if (i<0)
		kvp[kvp.length]=[key,value].join('=');
    document.location.search=kvp.join('&'); 
}
function findpos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
function dcheck() {
	if (moreok>0) {
		alert("Please wait");
		return false;
	}
	var l=document.getElementById('dlist').value.replace(/\n/g,',').replace(/	/g,',').replace(/ /g,'').toLowerCase().split(",");
	if (l.length<2 && l[0]=="") {
		alert("Please enter at least one domain");
		return false;
	}
	if (l.length>50) {
		alert("Maximum of 50 allowed at a time");
		return false;	
	}
	document.getElementById('dlist').value="";
	document.domains.csv.disabled=false;
	var d=document.getElementById("tldcont");
	var e;
	var f=[];
	var h=[];
	var g;
	var i;
	var c;
	var oldd;
	for (n=0; (n<l.length); n++) {
		if (l[n]!="") {
			e=[];
			l[n].replace(/^([^\.]+)\.?(.*?)$/,function(nm,nk,nv) {
				e[0]=nk;
				if (nv!='')
					e[1]=nv;
			});
			g="";
			if (e.length>1) {
				if (inarray(supported,e[1]))
					g=e[1]+",";
				if (e[0]=="")
					e[0]=oldd;
			}
			c=-1;
			for (i=0; (i<f.length); i++) {
				if (f[i]==e[0]) {
					h[i]=((typeof(h[i])!="undefined")?h[i]:"")+g;
					c=i;
				}
			}
			if (c==-1) {
				h[f.length]=g;
				f[f.length]=e[0];
			}
			oldd=e[0];
		}
	}
	g='';
	for (i=0; i<f.length; i++) {
		if (h[i]=="") {
			o=(exts.length<3) ? exts.length : 3;
			if (o<1) {
				alert('No TLDs selected');
				return false;
			}
			for (n=0; n<o; n++)
				h[i]+=exts[n]+",";
		}
		g+='<img onclick="deldom(this)" src="/images/delete.png" style="clear:both;cursor:pointer;float:left" alt="Delete" title="Delete"></span>';
		g+='<h2 title="'+h[i]+'">'+f[i].toUpperCase()+"</h2>";
		c=h[i].split(',');
		var p='';
		for (n=0,l=c.length-1; n<l; n++) {
			p=((n % 2)==1) ? ' dback' : '';
			g+='<div class="dmin'+p+'"><div>.'+c[n]+'</div><span class="dload">&nbsp;</span></div>';	
		}
		if (exts.length>3)
			g+='<p id="dmore" onclick="dmore(this,'+moreid+')">More...</p>';
		moreid++;
	}
	d.innerHTML=g+d.innerHTML.replace(/<h2/g,'<h2 style="color:#000;font-size:14px"');
	checkallload();
	return false;
}
function deldom(t) {
	var a=new Array();
	a.push(t);
	a.push(getnext(t));
	var d=document.getElementById('tldcont');
	var e=a[1].nextSibling;
	while (e.tagName=="P" || e.tagName=="DIV" && typeof(e.tagName)!="undefined") {
		a.push(e);
		e=e.nextSibling;
	}
	//a.push(e);
	for (e=0; e<a.length; e++) {
		d.removeChild(a[e]);
	}
}
function dmore(t,mid) {
	if (moreok>0) {
		alert("Please wait");
		return false;
	}
	var d=document.getElementById("tldcont");
	var f=getprev(t);
	while (f.tagName!="H2") {
		f=getprev(f);
	}
	h=whichtlds(f.title);
	j=h[2].length;
	v=(j>6) ? 6 : j;
	o=h[3]-1;
	g='';
	for (n=0; n<v; n++) {
		p=(((n+o) % 2)==1) ? ' dback' : '';
		g+='<div class="dmin'+p+'"><div>.'+h[2][n]+'</div><span class="dload">&nbsp;</span></div>';
		f.title+=h[2][n]+',';
		h[3]--;
	}
	p=d.innerHTML.split('dmore(this,'+mid+')');
	while (p[0].charAt(p[0].length-1)!="<")
		p[0]=p[0].slice(0,-1);
	p[0]=p[0].slice(0,-1);
	if (typeof(p[1])!="undefined") {
		while (p[1].charAt(0)!="/")
			p[1]=p[1].substr(1);
		p[1]=p[1].substr(3);
	}
	if (h[3]>0)
		g+='<p id="dmore" onclick="dmore(this,'+mid+')">More...</p>';
	d.innerHTML=p[0]+g+p[1];
	checkallload();
}
function checkallload() {
	var d=document.getElementById("tldcont");
	var e=d.getElementsByTagName('h2');
	var x;
	var f;
	var n;
	var c;
	var s;
	for (var i=0, j=e.length; i<j; i++){
		x=e[i].innerHTML.toLowerCase();
		f=getnext(e[i]);
		while (f!=null && f.tagName=="DIV") {
			s=getnext(f.childNodes[0]);
			if (s.className=="dload") {
				c=x+f.childNodes[0].innerHTML;
				s.className="dload2";
				//s.innerHTML=c;
				dcheckd(c,s);
				moreok++;
			}
			f=getnext(f);
		}
	}
	return false;
}
function downloaddomains() {
	var d=document.getElementById("tldcont");
	var e=d.getElementsByTagName('h2');
	var c="";
	var x;
	for (var i=0, j=e.length; i<j; i++) {
		x=e[i].title.slice(0,-1);
		x=(!x.match(",")) ? '.'+x : '';
		c+=e[i].innerHTML+x+',';
	}
	var v=gethform('/inc/downloadtext.php');
	v.snippet.value=c.slice(0,-1);
	v.sname.value="Domains";
	v.submit();
}
function dcheckd(c,s) {
	var x=getxml();
	s.title="";
	if (!x) {
		s.className='derr';
		s.title="Error connecting";
		moreok--;
		return false;
	}
	x.open('GET','/inc/dcheck.php?domain='+c,true);
	x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
	x.onreadystatechange=function() { dgot(x,s,c); };
	x.send("");
}
function dgot(x,s,c) {
	if (x.readyState==4) {
		if (x.status==200) {
			var v=x.responseText;
			if (v=='1') {
				s.className='dyes';
				s.title='Available to buy';
				s.innerHTML=dregistrar(c);
			} else if (v=='0') {
				s.className='dno';
				s.title='Not available';
				s.innerHTML='<a href="#" onclick="return getwhois(\''+c+'\')" class="whois">Whois</a>';
			} else {
				s.className='derr';
				s.title=v;
				s.innerHTML='<a href="#" onclick="return drecheck(this,\''+c+'\')" class="whois">Recheck</a>';
			}
		} else {
			s.className="derr";
			s.title="Unable to check domain";
			s.innerHTML='<a href="#" onclick="return drecheck(this,\''+c+'\')" class="whois">Recheck</a>';
		}
		moreok--;
	}
}
function dregistrar(c) {
	f=c.replace(/^.*?\./,'').replace(/\./g,'');
	v=document.getElementById('dref');
	s=v.selectedIndex;
	d=regs[f];
	q=0;
	if (typeof(d)=='undefined' || d.length==0) {
		q=2;
	} else {
		for (n=0,y=d.length; n<y; n++) {
			if (d[n]==s)
				q=1;
		}
		if (q==0 && d.length==1)
			q=3;
	}
	if (q==1) {
		o='<a href="/redirect.php?domain='+c+'&url='+registrars[s]+'" target="_blank">'+registrars[s]+'</a>';
	} else if (q==2) {
		o='';
	} else if (q==0) {
		o='<select onchange="otherreg(this)" title="'+c+'">';
		o+='<option value="">Please select</option>';
		for (n=0,y=d.length; n<y; n++) {
			o+='<option value="'+registrars[d[n]]+'">'+registrars[d[n]]+'</option>';
		}
		o+='</select>';
	} else {
		o='<a href="/redirect.php?domain='+c+'&url='+registrars[d[0]]+'" target="_blank">'+registrars[d[0]]+'</a>';
	}
	return o;
}
function drecheck(t,d) {
	t=t.parentNode;
	if (moreok>0) {
		alert("Please wait");
		return false;
	}
	t.className="dload";
	t.innerHTML="&nbsp;";
	checkallload();
	return false;
}
function whichtlds(a) {
	var notin=[];
	var init=[];
	var dtnext=[];
	a=a.replace(/,$/,'').split(',');
	for (k in a) {
		if (inarray(exts,a[k]))
			init.push(a[k]);
		else
			notin.push(a[k]);
	}
	for (k in exts) {
		t=exts[k];
		if (!inarray(init,t))
			dtnext.push(t);
	}
	return [notin,init,dtnext,dtnext.length];
}
function inarray(v,t) {
	for (i in v) {
		if (v[i]==t)
			return true;
	}
	return false;
}
function dtlds() {
window.open('/inc/listtld.php?exts='+urlencode(extsorder),"","width=540,height=500,scrollbars=yes");	
}
function otherreg(t) {
	if (t.selectedIndex==0)
		return;
	var p=t.options[t.selectedIndex].value;
	var v=t.title;
	v='/redirect.php?domain='+v+'&url='+p;
	t.selectedIndex=0;
	window.open(v);
}
function drefchanged(t) {
	var d=document.getElementById("tldcont");
	var e=d.getElementsByTagName('span');
	for (var i=0,j=e.length; i<j; i++) {
		if (e[i].className=="dyes") {
			r=e[i].childNodes[0];
			if (r) {
				if (r.tagName=='A')
					r=r.href.replace(/^.*?domain=([^&]+).*?$/,'$1');
				else
					r=r.title;
				e[i].innerHTML=dregistrar(r);
			}
		}
	}
}
function expand(t) {
	t.setAttribute("onclick","contract(this)");
	t.style.backgroundImage="url(/images/arrowdown.png)";
	getnext(t).style.display="block";
}
function contract(t) {
	t.setAttribute("onclick","expand(this)");
	t.style.backgroundImage="url(/images/arrowright.png)";
	getnext(t).style.display="none";
}
function xanq(t) {
	xana(t.parentNode.title);	
}
function getanchor(t) {
	var x=getxml();
	if (!x) {
		alert("Error connecting");
		return false;
	}
	t.setAttribute("id","");
	t.setAttribute("onclick","");
	t.innerHTML='<img src="/images/loading.gif"/>';
	x.open('GET','/inc/getbl.php?url='+csite+'&dest='+urlencode(t.previousSibling.title),true);
	x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
	x.onreadystatechange=function() { ancgot(x,t); };
	x.send("");
}
function ancgot(x,t) {
	if (x.readyState==4) {
		if (x.status==200) {
			var a=x.responseXML.documentElement,h;
			var b=a.getElementsByTagName("links")[0].childNodes[0].nodeValue;
			if (b==0) {
				var j=a.getElementsByTagName("error")
				if (j.length>0) {
					j=parseInt(j[0].childNodes[0].nodeValue);
					if (j==0)
						t.innerHTML="Timeout";
					else
						t.innerHTML="Error "+j;
				} else
					t.innerHTML="Not found";
				t.setAttribute("id","red");
			} else {
				t.setAttribute("id","");
				var c=a.getElementsByTagName("anchor");
				var d=a.getElementsByTagName("url");
				var e=a.getElementsByTagName("follow");
				var f=a.getElementsByTagName("position");
				t.innerHTML=c[0].childNodes[0].nodeValue;
				t.title=d[0].childNodes[0].nodeValue;
				var g=t.nextSibling;
				g.innerHTML='<img src="/images/'+((e[0].childNodes[0].nodeValue==1) ? "yes" : "no")+'.gif"/>';
				g=g.nextSibling;
				g.innerHTML=f[0].childNodes[0].nodeValue;
				var i='Unique Domains : '+a.getElementsByTagName("domains")[0].childNodes[0].nodeValue;
				var j=a.getElementsByTagName("totallinks")[0].childNodes[0].nodeValue;
				g.nextSibling.title=i;
				g.nextSibling.innerHTML=j;
				if (b>1) {
					t=t.parentNode;
					var v=getprev(t.parentNode.parentNode.parentNode);
					v.title=parseInt(v.title)+(b-1);
					for (n=1; n<b; n++) {
						g=document.createElement('tr');
						h=document.createElement('td');
						g.appendChild(h);
						h=document.createElement('td');
						h.title=d[n].childNodes[0].nodeValue;
						h.innerHTML=c[n].childNodes[0].nodeValue;
						g.appendChild(h);
						h=document.createElement('td');
						h.innerHTML='<img src="/images/'+((e[n].childNodes[0].nodeValue==1) ? "yes" : "no")+'.gif"/>';
						g.appendChild(h);
						h=document.createElement('td');
						h.innerHTML=f[n].childNodes[0].nodeValue;
						g.appendChild(h);
						h=document.createElement('td');
						h.innerHTML=j;
						h.title=i;
						g.appendChild(h);
						insertAfter(t.parentNode,g,t);
						t=g;
					}
				}
			}
		} else {
			t.setAttribute("id","recheck");
			t.setAttribute("onclick","getanchor(this)");
			alert("Error connecting");
		}
	}	
}
function insertAfter(p,n,r) {
	if (r.nextSibling==null)
		p.appendChild(n);
	else
  		p.insertBefore(n,r.nextSibling);
}
function gotpral(x,t,b) {
	if (x.readyState==4) {
		var c=((b==1) ? "Pagerank" : "Alexa")
		if (x.status==200) {
			t.innerHTML=c+' : '+x.responseText;
			if (b==1)
				t.setAttribute("rel","");
		} else {
			t.setAttribute("id",'red');
			t.innerHTML=c+' : Error';
		}
	}
}
function exportbacklinks() {
	var t=document.getElementById("backlink");
	var h=t.getElementsByTagName("h3");
	var d=t.getElementsByTagName("em");
	var e=t.getElementsByTagName("td");
	var j=h.length;
	if (j<1) {
		alert("Nothing to download");
		return;
	}
	var cem=0;
	var ctd=0;
	var a="";
	var b,c,f;
	var pr=new RegExp("Pagerank : ([0-9]{1,2})");
	var al=new RegExp("Alexa : ([0-9,]*)");
	for (n=0; n<j; n++) {
		b=h[n].title;
		t=h[n].innerHTML;
		a+=quote(t.toUpperCase());
		c=d[cem++];
		f=c.getAttribute("rel");
		if (f!="")
			c="http://google.com/search?client=navclient-auto&ch="+f+"&features=Rank&q=info:"+t;
		else
			c=pr.exec(c.innerHTML)[1];
		a+=quote(c,1);
		for (;;) {
			f=e[ctd++].childNodes[1];
			f=((typeof(f)=="undefined") ? "" : f.innerHTML);
			b-=1;
			c=e[ctd++].innerHTML;
			if (c!="") {
				a+=quote(f);
				a+=quote(c);
				if (e[ctd++].innerHTML.match(/yes/))
					a+=quote("Yes");
				else
					a+=quote("No");
				a+=quote(e[ctd++].innerHTML);
				a+=quote(e[ctd++].innerHTML);
				a+=quote(e[ctd-1].title.substr(17),1);
			} else {
				a+=quote(f)+quote("",1);
				ctd+=3;
			}
			if (b==0)
				break;
		}
	}
	var v=gethform('/inc/downloadtext.php','csv');
	v.snippet.value=a;
	v.sname.value='Backlinks';
	v.submit();
}
function quote(s,last) {
	return '"'+s.replace(/"/g,'""')+'"'+((typeof(last)=="undefined") ? "," : "\r\n");	
}
function suggesthost(t) {
	var t=getprev(t);
	var s=t.value;
	if (s!="") {
		var x=getxml();
		if (!x)
			t.value="Error";
		x.open('GET','/redirect.php?suggest='+s,true);
		x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
		x.send("");
	}
	lightbox('suggestthanks',1000);
}
var clightbox='';

function lightbox(id,to,width,height) {
	clightbox=id;
	if (typeof(width)=="undefined")
		var width=400;
	if (typeof(height)=="undefined")
		var height=220;
	var h=document.getElementById("previewpane");
	if (typeof(h)=="undefined" || h==null) {
		var tbody = document.getElementsByTagName("body")[0];
		h=document.createElement('div');
        h.style.position='absolute';
        h.style.top='0px';
        h.style.left='0px';
        h.style.overflow='hidden';
        h.style.display='none';
    	h.style.opacity=0.70;                      
    	h.style.MozOpacity=0.70;                   
    	h.style.filter='alpha(opacity=70)';
    	h.style.width='100%';
    	h.style.height='100%';
		h.setAttribute("onmousedown","closelightbox()");
    	h.style.backgroundColor='#000';  
        h.id='previewpane';
    	h.style.zIndex=5000;
		var m=document.createElement('div');
        m.id='previewbox';
		m.setAttribute("ondblclick","closelightbox()");
		tbody.appendChild(m);
    	tbody.appendChild(h);
    	h=document.getElementById('previewpane');
	}
	document.body.style.overflow='hidden';
	m=document.getElementById("previewbox");
	document.body.setAttribute("onkeydown","if (event.keyCode==27) { closelightbox() }");
	m.style.width=width+"px";
	m.style.height=height+"px";
	m.style.marginLeft=-(width/2)-50+"px";
	m.style.marginTop=-(height/2)-50+"px";
	if (id!='')
		m.innerHTML=document.getElementById(id).innerHTML;
	h.style.top=(document.all?document.documentElement.scrollTop:window.pageYOffset)+'px';
    h.style.display='block';
	m.style.display="block";
	if (typeof(to)!="undefined" && to>0)
		setTimeout("closelightbox()",to);
}
function lightboxurl(url,width,height) {
	if (typeof(width)=="undefined")
		var width=600;
	if (typeof(height)=="undefined")
		var height=500;
	lightbox('',0,width,height);
	document.getElementById("previewbox").innerHTML='<iframe src="'+url+'" width="98%" height="98%" frameborder="0" style="background:#fff"></iframe>';
}
function closelightbox(save) {
	if (typeof(save)!='undefined')
		document.getElementById(clightbox).innerHTML=document.getElementById("previewbox").innerHTML;
	document.getElementById("previewpane").style.display='none';
	document.getElementById("previewbox").style.display='none';
	document.body.setAttribute("onkeydown",'');
	document.body.style.overflow='auto';
	clightbox='';
}
function getsapr() {
	var t=document.getElementById("saprdiv");
	lightbox('saprdiv');
	if (t.childNodes[0].tagName=="IMG") {
		var h=document.getElementById("previewbox");
		var x=getxml();
		if (!x) {
			alert("Error connecting");
			return false;
		}
		x.open('GET','/inc/getpral.php?url='+urlencode(fopage)+'&t=1&hash='+prcode,true);
		x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
		x.onreadystatechange=function() { gotsapr(x,t,h); };
		x.send("");
	}
}
function getpral(t,b) {
var c=(b==1) ? "Pagerank" : "Alexa";
var x=getxml();
if (!x) {
	alert("Error connecting");
	return false;
}
var a=getprev(t.parentNode).innerHTML;
t.innerHTML=c+' : <img src="/images/loading.gif" style="width:12px;height:12px"/>';
t.setAttribute("onclick","");
var v=t;
if (b==2)
	v=getprev(v);
x.open('GET','/inc/getpral.php?url='+a+'&t='+b+'&hash='+urlencode(v.getAttribute('rel')),true);
x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
x.onreadystatechange=function() { gotpral(x,t,b); };
x.send("");		
}
function dp(n,d) {
	var a=Math.pow(10,d);
	return (Math.round(n*a)/a).toString();
}
function gotsapr(x,t,h) {
	if (x.readyState==4) {
		if (x.status==200) {
			var j='<h2>PageRank Information</h2>';
			j+='<div class="saprout">';
			var pr=parseInt(x.responseText);
			j+='<p>PageRank</p><p>'+x.responseText+"</p>";
			j+='<p>Total Links</p><p>'+tlinks+"</p>";
			j+='<p>Follow Links</p><p>'+flinks+"</p>";
			//var o=((Math.pow(pr+1,3)*4)/olinks)/5324;
			//j+='<p>Strength</p><p>'+(Math.round((o)*100000)/1000)+"</p>";
			var prl=(Math.round((pr/flinks)*900)/1000);
			j+='<p>PR per link</p><p>'+(Math.round((pr/flinks)*900)/1000)+"</p>";
			j+='<p>PR for 2 links</p><p>'+(Math.round((pr/(flinks+1))*900)/500)+"</p>";
			j+='<br id="clr"/><br/><p>Total PR for internal links</p><p>'+(Math.round((pr/flinks)*ilinks*900)/1000)+"</p>";
			j+='<p>Total PR for external links</p><p>'+(Math.round((pr/flinks)*olinks*900)/1000)+"</p>";
			j+='</div>';
			if (prl>0) {
				var i=document.getElementById("prleak").getElementsByTagName("p");
				var r;
				for (var n=0,k=i.length; n<k; n++) {
					if ((n % 2)==0)
						r=dp(parseInt(i[n].getAttribute('rel'))*prl,3);
					else
						i[n].innerHTML=r;
				}
				j+='<div onclick="lightbox(\'prleak\')" style="cursor:pointer;float:right">PR Leakage</div>'	
			}
			t.innerHTML=j;
			h.innerHTML=j;
		} else {
			h.innerHTML="Error";
		}
	}	
}
function postform(t,c) {
	var v=getprev(t).childNodes[1];
	var url=v.value+"?";
	var f;
	v=getnext(v)
	var m=v.value;
	for (var i=0; i<c; i++) {
		v=getnext(v);
		f=v.childNodes[1];
		url+=f.title+"="+urlencode(f.value)+"&";
	}
	url="/?q=siteanalysis&s="+urlencode(url.slice(0,-1))+((m=="POST") ? "&post=1" : "");
	document.location=url;
}