var xmlHttp,xmlHttp1,xmlHttp2,theID;

function doCheck(id)
{
		
	if(navigator.appName != "Microsoft Internet Explorer")
	{	
		document.getElementById('cover').innerHTML='';
		shiftOpacity('cover', 100);			
	}
	
	document.getElementById('google_add').style.display='block';
	document.getElementById('add_this').style.display='block';
	
	var t=setTimeout("document.getElementById('cover').style.display = 'none'",100);
	
	document.getElementById('curent_status').innerHTML='<a href="javascript:getIDAndCheck(\''+id+'\');"><span style="color:#4E8ABE;text-decoration:underline;">  <b>&raquo; Check <span style="color:green;">'+id+'</span> ? &laquo;</b></span></span></a>'
	document.getElementById('avatar_holder').innerHTML='';
	$("#curent_status").fadeIn(150).fadeOut(150).fadeIn(150).fadeOut(150).fadeIn(150).fadeOut(150).fadeIn(150);
	
	//Hi5 Related
	 document.getElementById('avatar_holder_hi5').innerHTML='<div style="position:absolute;"><a target="_blank"  style="text-decoration:underline;"><img height="99" src="pro1/logo-hi5_n.jpg" style="margin: 3px 0pt 0pt 3px;"/></a>';
     document.getElementById('hi5_account').innerHTML='<a href="javascript:detectHI5(\''+id+'\');"><span style="color: #4E8ABE; text-decoration: underline;"><b>&raquo; Detect HI5 &laquo;</b></span></a>';
	 
	 document.getElementById('id_hi5_options').innerHTML='<div style="position:absolute;"><a target="_blank" href="http://www.hi5.com" title="Send Email"><img src="images/send_mail.gif"  alt="trimite mail" /></a><a target="_blank" href="http://www.hi5.com" title="Send Gift"><img src="images/send_gift.gif"  alt="trimite cadou" /></a><a target="_blank" href="http://www.hi5.com" title="View Friends"><img src="images/friends.gif"  alt="vezi prieteni" /></a><a target="_blank" href="http://www.hi5.com" title="View Pictures"><img src="images/pictures.gif" alt="vezi fotografiile" /></a></div>';
	 document.getElementById('google_add_hi5').style.display='block';
	 document.getElementById('add_this_hi5').style.display='block';
	

}
function getIDAndCheck(theID){
	document.getElementById('yahooid').value=theID;
	if (theID != null){
		


		document.idcheck.submit();
	}	
}
function detectHI5(id){
	var url1="pro1/hi5v1.php"
	_postDatesHi5('curent_status',url1,id);
}

function _postDates(divID,url,id)
{
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var params="id="+id;
    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.onreadystatechange=function stateChanged() 
                                                    { 
                                                      if ( xmlHttp.readyState==4)
                                                      {
														document.getElementById('avatar_holder').innerHTML="<div style='position:absolute;'><a onMouseOver=\"Tip('<img src=http://img.msg.yahoo.com/avatar.php?yids="+id+"&format=jpg width=150 height=150>', WIDTH, 150, PADDING, 6, BGCOLOR, '#ffffff')\" onMouseOut=\"UnTip()\"><img src=' http://img.msg.yahoo.com/avatar.php?yids="+id+"&format=jpg'width='99px' height='99px;' style='padding:3px 0px 0px 3px;' /></a></div>";	
														
														
														document.getElementById('id_options').innerHTML='<div style="position:absolute;"><a href="ymsgr:sendIM?'+id+'&m=" title="Send message"><img src="images/send_message.gif" alt="trimite mesaj" /></a><a href="ymsgr:addfriend?'+id+'" title="Add in your YM list"><img src="images/add_buddy.gif" alt="trimite mesaj" /></a><a href="download.php?id='+id+'" title="Download avatar"><img src="images/save_avatar.gif" alt="trimite mesaj" /></a></div>';						
														
														
														var rt=xmlHttp.responseText
														document.getElementById('google_add').style.display='block';
														document.getElementById('add_this').style.display='block';
														
														  if(rt==1){
                                                  	     document.getElementById('curent_status').innerHTML='<span style="color:#4E8ABE;text-decoration:underline;"><b>'+id+'</b></span> is <span style="color:#4E8ABE;text-decoration:underline;"><b>ONLINE</b></span>'
                                                      	 }
														 else if(rt==2){
															 document.getElementById('curent_status').innerHTML='<span style="color:#4E8ABE;text-decoration:underline;"><b>'+id+'</b></span> is <span style="color:#4E8ABE;text-decoration:underline;"><b>INVISIBLE</b></span>'
														 }
														 else if(rt==3){
															 document.getElementById('curent_status').innerHTML='<span style="color:#4E8ABE;text-decoration:underline;"><b>'+id+'</b></span> is <span style="color:#4E8ABE;text-decoration:underline;"><b>OFFLINE</b></span>'
														 }
														 else if(rt==4){
															 document.getElementById('curent_status').innerHTML='ID INVALID'
														 }
														 else if(rt==6){
															  document.getElementById('curent_status').innerHTML='<span style="color:#4E8ABE;text-decoration:underline;"><b>To many checks!</b></span>'
														 }
														 
													   }
														 
                                                    }
    xmlHttp.send(params);       

	document.getElementById('avatar_holder').innerHTML='<img width="99px" height="99px" style="padding:3px 0px 0px 3px;" src="images/loading.gif" />'
	
}


function _postDatesHi5(divID,url,id)
{
xmlHttp1=GetXmlHttpObject();

if (xmlHttp1==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var params="id="+id;
    xmlHttp1.open("POST",url,true);
    xmlHttp1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp1.setRequestHeader("Content-length", params.length);
    xmlHttp1.setRequestHeader("Connection", "close");
    xmlHttp1.onreadystatechange=function stateChanged() 
                                                    { 
                                                      if ( xmlHttp1.readyState==4)
                                                      {															  
														var rt1=xmlHttp1.responseText;													
														
														var temp = new Array();
														temp = rt1.split(' ');
														var st='';
														var start1=0;
														var final1=0;
														var start2=0;
														var final2=0;
														var start3=0;
														var final3=0;
														
														for (i=0; i<temp.length; i++){		
														st=temp[i];
														
															if (st=='start1'){
																start1=i;																
															}
															if (st=='final1'){
																final1=i;
															}
																
															if (st=='start2'){
																start2=i;
															}
															if (st=='final2'){
																final2=i;
															}
																
															if (st=='start3'){
																start3=i;
															}
															if (st=='final3'){
																final3=i;
															}
														}
														
														str1="";
														str2="";
														str3="";
														
														for (i=start1+1; i<final1; i++){
															str1=str1+temp[i]+" ";
														}
														for (i=start2+1; i<final2; i++){
															str2=str2+temp[i]+" ";
														}
														for (i=start3+1; i<final3; i++){
															str3=str3+temp[i]+" ";
														}
														
														 document.getElementById('avatar_holder_hi5').innerHTML=str1;
														 document.getElementById('hi5_account').innerHTML=str2;
														 document.getElementById('id_hi5_options').innerHTML=str3;
														 document.getElementById('google_add_hi5').style.display='block';
														 document.getElementById('add_this_hi5').style.display='block';
														}
														 
                                                    }
    xmlHttp1.send(params);
	document.getElementById('avatar_holder_hi5').innerHTML='<img width="99px" height="99px" style="padding:3px 0px 0px 3px;" src="images/loading.gif" />'
 }

function _postDatesHi51(id)
{
														
														 document.getElementById('avatar_holder_hi5').innerHTML='<div style="position:absolute;"><a target="_blank"  style="text-decoration:underline;"><img height="99" src="pro1/logo-hi5_n.jpg" style="margin: 3px 0pt 0pt 3px;"/></a>';
														 document.getElementById('hi5_account').innerHTML='<a href="javascript:detectHI5(\''+id+'\');"><span style="color: #4E8ABE; text-decoration: underline;"><b>&raquo; Detect HI5 &laquo;</b></span></a>';
														 document.getElementById('id_hi5_options').innerHTML='<div style="position:absolute;"><a target="_blank" href="http://www.hi5.com" title="Send Email"><img src="images/send_mail.gif"  alt="trimite mail" /></a><a target="_blank" href="http://www.hi5.com" title="Send Gift"><img src="images/send_gift.gif"  alt="trimite cadou" /></a><a target="_blank" href="http://www.hi5.com" title="View friends"><img src="images/friends.gif"  alt="vezi prieteni" /></a><a target="_blank" href="http://www.hi5.com" title="View Pictures"><img src="images/pictures.gif" alt="vezi fotografiile" /></a></div>';
														 document.getElementById('google_add_hi5').style.display='block';
														 document.getElementById('add_this_hi5').style.display='block';
    
	//document.getElementById('avatar_holder_hi5').innerHTML='<img width="99px" height="99px" style="padding:3px 0px 0px 3px;" src="images/loading.gif" />'
 }



function _check(){
					
					var idr=document.getElementById("yahooid").value;
					var id=idr.split("@",1).toString();
				   // var id=idtmp.toString();
		
					if (id == "Enter yahoo ID here...")
					{
						alert("You must first enter yahoo ID!");
						document.getElementById('yahooid').value="Introdu Id-ul aici...";
					}
					else
					if (id.indexOf(" ") != -1)
					{
						alert("UserID can't contain space!");
						document.getElementById('yahooid').value="Introdu Id-ul aici...";
					}
					else
					if ((id.length > 32) || (id.length < 4))
					{
						alert("UserID length can't be less than 4 and more than 32 characters!");
						document.getElementById('yahooid').value="Introdu Id-ul aici...";
					}
					else
					{
						
						if(navigator.appName != "Microsoft Internet Explorer")
						{	
							document.getElementById('cover').innerHTML='';
							shiftOpacity('cover', 1000);			
						}
						
						var t=setTimeout("document.getElementById('cover').style.display = 'none'",1000);
						
						var url="pro4/xspyerdetectinvisible00051x51.php";
						
						_postDatesHi51(id);
						_postDates('curent_status',url,id);

						document.getElementById('yahooid').value="Introdu Id-ul aici...";
						document.getElementById('curent_status').innerHTML='';
					}
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function resetf()
{
	document.getElementById('yahooid').value="";
}

function loadf()
{
	var input=document.getElementById('yahooid').value;
	if(input=="")
		document.getElementById('yahooid').value="Introdu id-ul aici...";
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
		
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 


function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 100, 0, millisec);		
    } else {
        
    }
} 

