var ClearTextB=true;
var loadingB=false;
var yahooid="";
var lastscan="0";
var latestids=getCookie("latestids");

function setCookie(c_name,value,expiredays)
{
	var exdate= new Date();exdate["setDate"](exdate["getDate"]()+expiredays);
	document["cookie"]=c_name+"="+escape(value)+((expiredays==null)?"":";expires="+exdate["toGMTString"]());
} 
function getCookie(c_name)
{
	if(document["cookie"]["length"]>0)
	{
		c_start=document["cookie"]["indexOf"](c_name+"=");
		if(c_start!=-1)
		{
			c_start=c_start+c_name["length"]+1;
			c_end=document["cookie"]["indexOf"](";",c_start);
			if(c_end==-1)
			{
				c_end=document["cookie"]["length"];
			} 
			return unescape(document["cookie"]["substring"](c_start,c_end));
		} 
	} 
	return "";
} 

function ClearText()
{
	if(ClearTextB)
	{
		document["getElementById"]("idbox")["value"]="";
		ClearTextB=false;
	} 
} 

function removeatsign(t)
{
	var i=t["indexOf"]("@yahoo",0);
	if(i>1){return t["substring"](0,i);} else {return t;}
}

function showlatestids()
{
	var idtoshow="";
	var idtoshow2="";
	var latestidstoshow="";
	var idcount=0;
	var idtoshowlength=0;
	for(i=0;i<latestids["length"];i++)
	{
		if(latestids["charAt"](i)==",")
		{
			idcount++;
			//latestidstoshow+="\x3Ctr\x3E\x3Cth onclick=\x22document.getElementById(\x27idbox\x27).value=\x27"+idtoshow+"\x27;idboxKeyPress(13,true);\x22\x3E\x3Ca style=\x22cursor:pointer;\x22\x3E"+idtoshow2+"\x3C/a\x3E\x3C/th\x3E\x3Ctd onclick=\x22removefromlatestids(\x27"+idtoshow+"\x27);showlatestids();\x22\x3E\x26nbsp;\x3C/td\x3E\x3C/tr\x3E";
			latestidstoshow+="<li><table width=\"100%\" style=\"cursor:pointer;color:#00629A;font:11px normal Verdana,Arial,Helvetica,sans-serif;\" onclick=\"document.getElementById('idbox').value='"+idtoshow+"';idboxKeyPress(13,true);\" onmouseover=\"$(this).css('background-color','#3B5998');$(this).css('color','#FFFFFF');\" onmouseout=\"$(this).css('background-color','#FFFFFF');$(this).css('color','#00629A');\"><tr><td width=\"24px\"><img src=\"http://img.msg.yahoo.com/avatar.php?yids="+idtoshow+"\" width=\"22px\" height=\"22px\"/></td><td align=\"left\">"+idtoshow2+"</td><td><img style=\"float:right\" onclick=\"removefromlatestids('"+idtoshow+"');showlatestids();\" onMouseOver=\"im_in_removeImg=true;startTime_cancelRemoving=new Date().getTime();this.src='img/delete.png';$(this).parents('table').attr('onclick','').unbind('click');\" onMouseOut=\"im_in_removeImg=false;this.src='img/delete[d].png';var myTable=$(this).parents('table');setTimeout( function() {var elapsed = new Date().getTime() - startTime_cancelRemoving;if((elapsed>200) && (im_in_removeImg==false))myTable.click(function() {document.getElementById('idbox').value='"+idtoshow+"';idboxKeyPress(13,true);})},230);\" src=\"img/delete[d].png\"></td></tr></table></li>";
			idtoshow="";
			idtoshow2="";
			idtoshowlength=0;
		} 
		else
		{
			idtoshowlength++;
			if(idtoshowlength<=18)
			{
				idtoshow+=latestids["charAt"](i);
				idtoshow2+=latestids["charAt"](i);
			}
			else
			{
				if(idtoshowlength==19)
				{
					idtoshow+=latestids["charAt"](i);
					idtoshow2+="...";
				}
				else
				{
					idtoshow+=latestids["charAt"](i);
				}
			}
		}
	}
	document["getElementById"]("latest")["innerHTML"]=latestidstoshow;
}

function addidtolatestids(id)
{
	var latestidscount=0;
	for(i=0;i<latestids["length"];i++)
	{
		if(latestids["charAt"](i)==","){latestidscount++;}
	}
	if((latestids["indexOf"](id+",")==-1)&&(latestids["indexOf"](","+id)==-1))
	{
		while(latestidscount>10)
		{
			removefirstidfromlatestids();
			latestidscount--;
		}
		latestids=latestids+id+",";
	}
	setCookie("latestids",latestids,365);
	document["getElementById"]("latest")["style"]["visibility"]="visible";
	if(getCookie('latestids_lastdate')=='')
		setCookie("latestids_lastdate",'show',2);
}

function removefromlatestids(id)
{
	latestids=latestids["replace"](id+",","");
	latestids=latestids["replace"](","+id,"");
	setCookie("latestids",latestids,365);
}

function removefirstidfromlatestids()
{
	var i=latestids["indexOf"](",",0);
	if(i>1)
	{
		var firstid=latestids["substring"](0,i);
		removefromlatestids(firstid);
	}
}

function getPage(pURL)
{
	if(window["XMLHttpRequest"])
	{
		xmlhttp= new XMLHttpRequest();
	}
	else
	{
		if(window["ActiveXObject"])
		{
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	if( typeof (xmlhttp)=="object")
	{
		xmlhttp["onreadystatechange"]=postFileReady;
		xmlhttp["open"]("GET",pURL,true);
		xmlhttp["send"](null);
	}
}

function postFileReady()
{
	if(xmlhttp["readyState"]==4)
	{
		if(xmlhttp["status"]==200)
		{
			loadingB=false;
			//document["getElementById"]("resultloading")["style"]["visibility"]="hidden";
			showImage();
			var status=xmlhttp["responseText"];
			var status1='';
			var status2='';
			var secondstatus=false;
			var i=0;
			for(i=0;i<status["length"];i++)
			{
				if((status["charAt"](i)=='-') && (secondstatus==false))
					secondstatus=true;
				else
				{
					if(secondstatus==false)
						status1=status1+status["charAt"](i);
					else
						status2=status2+status["charAt"](i);
				}
			}
			if(status2!='')
			{
				var dont_show_status2=false;
				var status2_kind='Available';
				if(status2["charAt"](0)=='1')
					status2_kind='Available';
				else if(status2["charAt"](0)=='2')
					status2_kind='Busy';
				else if(status2["charAt"](0)=='3')
					status2_kind='Idle';
				else
					dont_show_status2=true;
				if(dont_show_status2==false)
				{
					var status2_message='';
					for(i=1;i<status2["length"];i++)
						status2_message=status2_message+status2["charAt"](i);
					document["getElementById"]('dialog2')["innerHTML"]='  <font style="color:#000000"><b>'+yahooid+'</b> is '+status2_kind+'.<br>His/Her status message is "'+status2_message+'". </font><br/><br/><input type="button" value="Close it" onclick="closestatus();" class="close"/>';
					showstatus2();
				}
			}
			if(status1=="1")
			{
				//fade("scanner1");
				lastscan=3;
				//fade("scanner"+lastscan);
				//fade("status"+lastscan);
				document["getElementById"]('text_result')["innerHTML"]="This Yahoo ID is Invisible";
			}
			else 
			{
				if(status1=="0")
				{
					//fade("scanner1");
					lastscan=2;
					//document["getElementById"]("status"+lastscan)["innerHTML"]="Offline";
					//fade("scanner"+lastscan);
					//fade("status"+lastscan);
					document["getElementById"]('text_result')["innerHTML"]="This Yahoo ID is Offline";
				}
				else 
				{
					if(status1=="777")
					{
						//fade("scanner1");
						lastscan=4;
						//fade("scanner"+lastscan);
						//fade("status"+lastscan);
						document["getElementById"]('text_result')["innerHTML"]="This Yahoo ID is Available";
					}
					else 
					{
						if(status1=="length")
						{
							//fade("scanner1");
							lastscan=2;
							//document["getElementById"]("status"+lastscan)["innerHTML"]="Invalid ID";
							//fade("scanner"+lastscan);
							//fade("status"+lastscan);
							document["getElementById"]('text_result')["innerHTML"]="You have entered an invalid Yahoo! ID";
						} 
						else 
						{
							//fade("scanner1");lastscan=2;
							//document["getElementById"]("status"+lastscan)["innerHTML"]="System Busy";
							//fade("scanner"+lastscan);
							//fade("status"+lastscan);
							document["getElementById"]('text_result')["innerHTML"]="We are using new mechanisms so we may have problem sometimes, The problem may be solved in less than 5minutes.";
						}
					}
				}
			}
		}
		else 
		{
			loadingB=false;
			//document["getElementById"]("resultloading")["style"]["visibility"]="hidden";
			//fade("scanner1");
			lastscan=2;
			//document["getElementById"]("status"+lastscan)["innerHTML"]="Connection Problem";
			//fade("scanner"+lastscan);
			//fade("status"+lastscan);
			document["getElementById"]('text_result')["innerHTML"]="Connection Problem";
		}
	}
}

function showImage()
{
	document["getElementById"]("avatar")["style"]["visibility"]="visible";
	document["getElementById"]("avatar")["innerHTML"]="\x3Ca href=\x22image.php?uid="+Base64["encode"](yahooid)+"\x26"+Math["floor"](Math["random"]()*100000)+"\x22\x3E"+"\x3Cimg width=\x2296px\x22 height=\x2296px\x22 src=\x22image.php?uid="+Base64["encode"](yahooid)+"\x26"+Math["floor"](Math["random"]()*100000)+"\x22\x3E";
}
function loading(s)
{
	var loadstate="";
	if(s=="|")
	{
		loadstate="\x5C";
	} 
	else 
	{
		if(s=="\x5C")
		{loadstate="-";}
		else 
		{
			if(s=="-"){loadstate="/";} 
			else {if(s=="/"){loadstate="|";}}
		} 
	} 
	if(loadingB)
	{
		//document["getElementById"]("resultloading")["innerHTML"]="Checking "+"\x26nbsp;\x26nbsp;"+loadstate;
		document["getElementById"]("text_result")["innerHTML"]="Checking Yahoo! ID"+"\x26nbsp;\x26nbsp;"+loadstate;
		if(loadstate=="\x5C"){loadstate="\x5C\x5C";}
		setTimeout("loading(\x22"+loadstate+"\x22);",200);
	}
}

function idboxKeyPress(e,b)
{
	document["getElementById"]("checkBtn")["focus"]();
	document["getElementById"]("idbox")["focus"]();
	var characterCode;
	if(b==false)
	{
		if(e&&e["which"])
		{
			characterCode=e["which"];
		} 
		else 
		{
			characterCode=e["keyCode"];
		} 
	} 
	if((characterCode==13)||(b))
	{
		if((loadingB==false)&&(document["getElementById"]("idbox")["value"]!="")&&(document["getElementById"]("idbox")["value"]!="Victim\x27s YAHOO! ID"))
		{
			if(lastscan!=0)
			{
				//fade("scanner1");
				//fade("scanner"+lastscan);
				//fade("status"+lastscan);
			} 
			yahooid=document["getElementById"]("idbox")["value"];
			yahooid=removeatsign(yahooid);
			yahooid=yahooid["replace"](",","");
			yahooid=yahooid["replace"]("\x3C","");
			yahooid=yahooid["replace"]("\x3E","");
			addidtolatestids(yahooid);
			showlatestids();
			document["getElementById"]("avatar")["style"]["visibility"]="hidden";
			//document["getElementById"]("resultloading")["style"]["visibility"]="";
			loadingB=true;
			setTimeout("loading(\x22|\x22);",1);
			var statusmessage='';
			if(document["getElementById"]("statusmessage")["checked"])
				statusmessage='yes';
			document["getElementById"]("statusmessage")["checked"]=false;
			getPage("index.php?statusmessage="+statusmessage+"&uid="+Base64["encode"](yahooid)+"\x26rand="+Math["floor"](Math["random"]()*100000));
			return false;
		} 
	} 
	else
	{
		return true;
	} 
}

var TimeToFade=1000.0;function fade(eid){var element=document["getElementById"](eid);if(element==null){return ;} ;if(element["FadeState"]==null){if(element["style"]["opacity"]==null||element["style"]["opacity"]==""||element["style"]["opacity"]=="1"){element["FadeState"]=2;} else {element["FadeState"]=-2;} ;} ;if(element["FadeState"]==1||element["FadeState"]==-1){element["FadeState"]=element["FadeState"]==1?-1:1;element["FadeTimeLeft"]=TimeToFade-element["FadeTimeLeft"];} else {element["FadeState"]=element["FadeState"]==2?-1:1;element["FadeTimeLeft"]=TimeToFade;setTimeout("animateFade("+ new Date()["getTime"]()+",\x27"+eid+"\x27)",33);} ;} ;function animateFade(lastTick,eid){var curTick= new Date()["getTime"]();var elapsedTicks=curTick-lastTick;var element=document["getElementById"](eid);if(element["FadeTimeLeft"]<=elapsedTicks){element["style"]["opacity"]=element["FadeState"]==1?"1":"0";element["style"]["filter"]="alpha(opacity = "+(element["FadeState"]==1?"100":"0")+")";element["FadeState"]=element["FadeState"]==1?2:-2;return ;} ;element["FadeTimeLeft"]-=elapsedTicks;var newOpVal=element["FadeTimeLeft"]/TimeToFade;if(element["FadeState"]==1){newOpVal=1-newOpVal;} ;element["style"]["opacity"]=newOpVal;element["style"]["filter"]="alpha(opacity = "+(newOpVal*100)+")";setTimeout("animateFade("+curTick+",\x27"+eid+"\x27)",33);} ;var Base64={_keyStr:"+/=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",encode:function (input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._utf8_encode(input);while(i<input["length"]){chr1=input["charCodeAt"](i++);chr2=input["charCodeAt"](i++);chr3=input["charCodeAt"](i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;} else {if(isNaN(chr3)){enc4=64;} ;} ;output=output+this["_keyStr"]["charAt"](enc1)+this["_keyStr"]["charAt"](enc2)+this["_keyStr"]["charAt"](enc3)+this["_keyStr"]["charAt"](enc4);} ;return output;} ,decode:function (input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input["replace"](/[^A-Za-z0-9\+\/\=]/g,"");while(i<input["length"]){enc1=this["_keyStr"]["indexOf"](input["charAt"](i++));enc2=this["_keyStr"]["indexOf"](input["charAt"](i++));enc3=this["_keyStr"]["indexOf"](input["charAt"](i++));enc4=this["_keyStr"]["indexOf"](input["charAt"](i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);} ;if(enc4!=64){output=output+String.fromCharCode(chr3);} ;} ;output=Base64._utf8_decode(output);return output;} ,_utf8_encode:function (string){string=string["replace"](/\r\n/g,"\x0A");var utftext="";for(var n=0;n<string["length"];n++){var c=string["charCodeAt"](n);if(c<128){utftext+=String.fromCharCode(c);} else {if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);} else {utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);} ;} ;} ;return utftext;} ,_utf8_decode:function (utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext["length"]){c=utftext["charCodeAt"](i);if(c<128){string+=String.fromCharCode(c);i++;} else {if((c>191)&&(c<224)){c2=utftext["charCodeAt"](i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;} else {c2=utftext["charCodeAt"](i+1);c3=utftext["charCodeAt"](i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;} ;} ;} ;return string;} };
