objAry=new Array();
var sTout = null;
var dB=document.getElementById('displaybox');
if(window.location.hash=='#RSI')setTimeout(function(){window.location.href='http://www.ivotings.com/#RateSuggestedItems';},3333);
function cE(c,n)
{	if(!n)n='div'; E = document.createElement(n); 
	if(c)E.className = c; return E;
}
function tN(v)
{	return document.createTextNode(v);
}
function filler(e)
{	if(e=='init'){obj=document.top5listForm.elements[0];obj.onchange=filler;}
	else if(!e)var e=window.event;if(e.target)obj=e.target;else if(e.srcElement)obj=e.srcElement;
	sR=document.getElementById('listsContests');sRds=sR.getElementsByTagName('div');cvr=document.getElementById('Fl'+obj.value);
	for(i=0;i<sRds.length;i++)if(sRds[i].className=='cover')sRds[i].style.display='none';
	if(cvr)cvr.style.display='block';
	else{bUrl='http://www.ivotings.com/search/item/get/limited';Fl=gt.xmlHttp();
	Fl.open('GET',bUrl+'/list/'+obj.value,true);
	Fl.onreadystatechange = function() 
	{	if(Fl.readyState == 4 && Fl.status == 200)
		{	V=eval('('+Fl.responseText+')');cvr=cE('cover');cvr.id='Fl'+obj.value;
			if(V.length>0)
			{	for(i=0;i<V.length;i++)
				{	
D=cE('w100 fl padb15 bdr pd7');Da=cE('number');Da.appendChild(tN(i+1+'.'));Db=cE('userimage');
DbI=cE('','img'); DbI.src='http://www.ivotings.com/public/images/contest/'+V[i]['L'];/*DbI.height=102;DbI.width=106;*/
Db.appendChild(DbI);Dc=cE('userdetail fl');DcH=cE('','h2');
DcHA=cE('','a');DcHA.appendChild(tN(V[i]['N']));DcHA.href='http://www.ivotings.com/items/'+V[i]['I'];
DcH.appendChild(DcHA);DcP=cE('','P');taGs=V[i]['T'];
if(taGs)for(j=0;j<taGs.length;j++)
{	DcPAa=cE('','a');DcPAa.href='http://www.ivotings.com/tag/'+taGs[j];DcPAa.target='_blank';DcPAa.appendChild(tN(taGs[j]));
	DcP.appendChild(DcPAa);if(j+1<taGs.length)DcP.appendChild(tN(', '));else DcP.appendChild(tN('. '));
}J=V[i]['S'];
DcDa=cE('icondetail');Ka=cE('iconbox');KaK=cE(J[8]+' tt','a');KaK.href='javascript:;';KaK.appendChild(tN(J[0]));
KaS=cE('','span'); KaS.appendChild(tN(J[1]+' ratings'));
if(J[1]>9)tipIs=' Approval rate is calculated by taking all postive ratings ('+J[2]+') and dividing it by the total number of ratings ('+J[1]+') ';else tipIs=' Approval rate only gets calculated with a minimum of 10 ratings.';KaK.setAttribute('tip',tipIs);
Ka.appendChild(KaK);Ka.appendChild(KaS);Kb=cE('iconbox lgtbluebg');
KbK=cE('thumbs');KbKKa=cE('thumbsupsmall');KbKKa.appendChild(tN(J[2]));KbKKb=cE('thumbsdownsmall');KbKKb.appendChild(tN(J[3]));
KbK.appendChild(KbKKa);KbK.appendChild(KbKKb);Kb.appendChild(KbK);Kc=cE('iconbox');
KcK=cE(J[4]);KcK.appendChild(tN(J[5]));Kc.appendChild(KcK);Kd=cE('iconbox lgtbluebg');KdKa=cE('girlrating tt');
KdKaS=cE(J[9],'span');KdKaS.appendChild(tN(J[6]));KdKa.appendChild(KdKaS);KdKaS.setAttribute("tip","Approval rate by female users");
KdKb=cE('boyrating tt');KdKbS=cE(J[10],'span');KdKbS.appendChild(tN(J[7]));
KdKbS.setAttribute("tip","Approval rate by male users");
KdKb.appendChild(KdKbS);Kd.appendChild(KdKa);Kd.appendChild(KdKb);
DcDa.appendChild(Ka);DcDa.appendChild(Kb);
Reqs=cE('required');Reqs.appendChild(tN('Please login to see statistics.'));
DcDa.appendChild(Reqs);
KdKbS.onmouseover=KdKbS.onmouseout=KdKaS.onmouseover=KdKaS.onmouseout=KaK.onmouseover=KaK.onmouseout=gt.toolTip;
Dc.appendChild(DcH);Dc.appendChild(DcP);Dc.appendChild(DcDa);
D.appendChild(Da);D.appendChild(Db);D.appendChild(Dc);cvr.appendChild(D);sR.appendChild(cvr);
				}
			}
			else
			{	Ed=cE('w100 fl padb15 bdr');EdH=cE('','h3');EdH.appendChild(tN('No contests in this list.'));Ed.appendChild(EdH);
				cvr.appendChild(Ed);sR.appendChild(cvr);
			}
		}
	}
	Fl.send(null);}
}
var ok=document.getElementById('adduser');ok.elements[0].onkeyup=suggestion;
if(ok){var imgs=ok.getElementsByTagName('img');var vAlS=ok.getElementsByTagName('div')[1];
imgs[0].onclick=function()
{	if(ok.elements[0].value!='')
	{	D=document.getElementById("sTD");dIn=D.getElementsByTagName("div");
		for(i=0;i<dIn.length;i++)if(dIn[i].className=="cp" && dIn[i].innerHTML==ok.elements[0].value)
		{vAlS.innerHTML=ok.elements[0].value+','+vAlS.innerHTML;ok.elements[0].value='';}
	}
}
imgs[1].onclick=function(){if(vAlS.innerHTML!='')window.location.href='http://www.ivotings.com/search/user#/like/'+vAlS.innerHTML.slice(0,vAlS.innerHTML.length-1);}}
function selectPage()
{	G=gt.xmlHttp();G.open('GET','http://www.ivotings.com/user/compare/data/users',true);
	G.onreadystatechange = function(){if(G.readyState == 4 && G.status == 200){J=eval('('+G.responseText+')');uComp(J[0],J[1]);}}
	G.send(null);whatGoingNow(1);filler('init');dBpn=dB.parentNode.getElementsByTagName('div')[1].getElementsByTagName('a');
	dBpn[0].onclick=new Function("topUsers('users30d')");dBpn[1].onclick=new Function("topUsers('users')"); topUsers('users30d')
}
function uComp(Ua,Ub)
{	if(Ua&&Ub){	var US=document.getElementById('usersection');var cvr=null;
	USd=US.getElementsByTagName('div');for(i=0;i<USd.length;i++)if(USd[i].id==Ua+'.'+Ub)cvr=USd[i];
	if(cvr){for(i=0;i<USd.length;i++)if(USd[i].id!='')USd[i].style.display='none';cvr.style.display='block';}else{R = gt.xmlHttp();
	R.open('GET','http://www.ivotings.com/user/compare/the/'+Ua+'/with/'+Ub+'/data/raw',true);
	R.onreadystatechange = function()
	{	if(R.readyState == 4 && R.status == 200)
		{	for(i=0;i<USd.length;i++)if(USd[i].id!='')USd[i].style.display='none';
			J=eval('('+R.responseText+')');cvr=cE();cvr.id=Ua+'.'+Ub;
			if(!J.R){uComp(J.NU[0],J.NU[1]);return false;}
			sTout = setTimeout("uComp('"+J.NU[0]+"','"+J.NU[1]+"')",15000);
			Da=cE('users');DaDa=cE('w145 orangecolor');
			DaDaI=cE('','img');DaDaI.style.height=DaDaI.style.width='33px';DaDaI.align='middle';DaDaI.src='http://www.ivotings.com/public/images/users/'+J.U[0];
			DaDa.appendChild(DaDaI);DaDa.appendChild(tN(Ua));
			DaDb=cE('w27');DaDbDa=cE('leftarrow');
			DaDbDaA=cE('','a');DaDbDaA.href='#'+Ua+'/'+Ub;DaDbDaA.onclick=new Function("Archive('prev','"+cvr.id+"','"+J.NU[0]+"','"+J.NU[1]+"')");
			DaDbDaAS=cE('','span');DaDbDaAS.appendChild(tN('#'));DaDbDaA.appendChild(DaDbDaAS);DaDbDa.appendChild(DaDbDaA);
			DaDbDb=cE('rightarrow');DaDbDbA=cE('','a');DaDbDbA.href='#'+J.NU[0]+'/'+J.NU[1];
			if(J.NU)DaDbDbA.onclick=new Function("Archive('next','"+cvr.id+"','"+J.NU[0]+"','"+J.NU[1]+"')");
			DaDbDbAS=cE('','span');DaDbDbAS.appendChild(tN('#'));DaDbDbA.appendChild(DaDbDbAS);
			DaDbDb.appendChild(DaDbDbA);DaDb.appendChild(DaDbDa);DaDb.appendChild(DaDbDb);DaDc=cE('w145 orangecolor');
			DaDcI=cE('','img');DaDcI.style.height=DaDcI.style.width='33px';DaDcI.align='middle';DaDcI.src='http://www.ivotings.com/public/images/users/'+J.U[1];
			DaDc.appendChild(DaDcI);DaDc.appendChild(tN(Ub));Da.appendChild(DaDa);Da.appendChild(DaDb);Da.appendChild(DaDc);
			Db=cE('users');DbU=cE('','ul');
			if(J.R.F)DbU.appendChild(aAraw(J.R.F,'star'));if(J.R.P)DbU.appendChild(aAraw(J.R.P,'thumbup'));if(J.R.N)DbU.appendChild(aAraw(J.R.N,'thumbdown'));
			Db.appendChild(DbU);cvr.appendChild(Da);cvr.appendChild(Db);US.appendChild(cvr);
		}
	}
	R.send(null);}}
}
function aAraw(J,C)
{	DbUL=cE(C+' oh','li');
	for(j=0;j<J.length;j++)
	{	aA=cE('tdn','a');aA.href='http://www.ivotings.com/items/'+J[j][0];
		aA.appendChild(tN(J[j][1]));DbUL.appendChild(aA);
		if((j+1)<J.length)DbUL.appendChild(tN(', '));
	}	return DbUL;
}
function suggestion(e)
{	if(!e) var e = window.event;if (e.target) obj = e.target;else if (e.srcElement) obj = e.srcElement;
	S=gt.xmlHttp();D=document.getElementById("sTD");dIn=D.getElementsByTagName("div");
	for(i=0;i<dIn.length;i++){if(dIn[i].className=="temp")dIn[i].style.display="none";}
	dIn=document.getElementById('nS'+obj.value);if(dIn)dIn.style.display="block";
	else
	{	S.open('GET', "http://www.ivotings.com/contest/suggestions/name/only/for/"+obj.value, true);
		S.onreadystatechange = function()
		{	if(S.readyState == 4 && S.status == 200)
			{	Z=cE('temp');Z.id='nS'+obj.value;
				if(S.responseText.length>0)
				{	data = eval('('+S.responseText+')');
					S=cE('cp');S.appendChild(tN('Choose from the items below'));Z.appendChild(S);
					for(i=0;i<data.length;i++)
					{	S=cE('cp');S.appendChild(tN(data[i]['n']));
						S.onclick=new Function("chose('"+data[i]['n']+"')");Z.appendChild(S);
				}	}
				else
				{	S=cE('cp');S.appendChild(tN('Item does not exist.'));Z.appendChild(S);
				}	
				D.appendChild(Z);ok.elements[0].onblur=new Function("setTimeout(function(){Z.style.display='none';},2000);");
			}
		}
		S.send(null);
	}	
}
var sTF=null; var sAT=null;
var Wgorn=document.getElementById('wgorn');
function whatGoingNow(lT)
{	W=gt.xmlHttp();W.open('GET', "http://www.ivotings.com/index/index/wgorn/"+lT, true);
	W.onreadystatechange = function()
	{	if(W.readyState == 4 && W.status == 200)
		{	I=eval('('+W.responseText+')');Won=Wgorn.getElementsByTagName('li');if(Won[4])Wgorn.removeChild(Won[4]);
			Temp=getElementsByAttribute("span","class","tooltip");for(i=0;i<Temp.length;i++){pN=Temp[i].parentNode;if(pN.className=='tt')pN.className='';pN.removeChild(Temp[i]);}
for(i=0;i<I.length;i++)
{	wS=cE(I[i].s+' spanlink w280','li');SAa=cE('tt','a');
	if(I[i].ua && I[i].ua!=''){x=cE('tooltip','span');x.appendChild(cE('top','span'));xS=cE('middle','span');xS.appendChild(tN(I[i].ua));x.appendChild(xS);
		x.appendChild(cE('bottom','span'));SAa.appendChild(x);}
	SAa.href='http://www.ivotings.com/users/'+I[i].uf;SAa.appendChild(tN(' '+I[i].un+' '));
	SI=cE('','img');SI.style.height=SI.style.width=SI.height=SI.width=19;SI.align='absmiddle';SI.src='http://www.ivotings.com/public/images/users/'+I[i].ui;
	SAb=cE('','a');SAb.href='http://www.ivotings.com/items/'+I[i].ci;SAb.appendChild(tN(' '+I[i].cn+' '));
	wS.appendChild(SAa);wS.appendChild(SI);wS.appendChild(tN(' voted '+I[i].vr+' '));wS.appendChild(SAb);
	Temp=cE();Temp.appendChild(wS);Wgorn.innerHTML=Temp.innerHTML+Wgorn.innerHTML;
}	setTimeout("whatGoingNow("+(lT+1)+")",2500);}}
	W.send(null);
}
function chose(e){ok.elements[0].value=e;Z.style.display='none';}
function Archive(act,id,a,b)
{	if(sTout) clearTimeout(sTout);obj=null;j=0;USv=new Array();
	for(i=0;i<USd.length;i++)if(USd[i].id!='')USv[j++]=USd[i];
	for(i=0;i<USv.length;i++)
	{	if(USv[i].id==id)
		{	USv[i].style.display='none';
			if(act=='next')obj=USv[i+1]; else obj=USv[i-1];
		}
	}	if(obj)obj.style.display='block';else if(a && b)uComp(a,b);
		else{id=USv[1].id.split('.');uComp(id[0],id[1]);}
}
function topUsers(e)
{	tU=gt.xmlHttp();tU.open('GET', "http://www.ivotings.com/index/index/calledfor/"+e, true);
	tU.onreadystatechange = function()
	{	if(tU.readyState == 4 && tU.status == 200)
		{	tU=eval('('+tU.responseText+')');dB.innerHTML='';UL=cE('','ul');UL.id=e;
			for(i=0;i<tU.length;i++){LI=cE('lgtbluebg','li');IMG=cE('','img');IMG.src='http://www.ivotings.com/public/images/users/'+tU[i][0];
			H4=cE('','h4');H4A=cE('','a');H4A.href='http://www.ivotings.com/users/'+tU[i][1];H4A.appendChild(tN(tU[i][1]));H4.appendChild(H4A);
			LI.appendChild(IMG);LI.appendChild(H4);LI.appendChild(tN(tU[i][2]));UL.appendChild(LI);}dB.appendChild(UL);
		}
	}
	tU.send(null);
}