if(top.location!=window.location)top.location='http://www.jdetector.com';
// JavaScript Document
$(document).ready(function(){
$("#Home").show();
$("#menu a").click(function () {
	var nume = $(this).text();					 
	$("#menu a").each(function () {
		var tab = $(this).text();					 
		$(this).removeClass("active");
		$("#"+tab).hide();
  	});
	$(this).addClass("active");
	$("#"+nume).show();
});
$("#link a").click(function () {
$("#Home").hide();
$("#BuddyList").show();
});
});
function scan2()
{
	var id = $('#yid').val();
	top.location="http://www.ymland.com/detector/?yid="+id;
} 
function scan() {

	if (typeof(xhr) != "undefined") xhr.abort();
	var id = $('#yid').val();
	if (id == "") {
		
		$("#info0").html("<div >Please enter Y! ID</div>");
		$("#info1").html("");
		return false;
	}
	$("#info0").html("<div style='margin-left:100px;'><img src=\"images/loader.gif\" /></div>");
	$("#info1").html("");
	//$('#info0').slideDown('normal');
	xhr = $.ajax({
	  url: "status.php",
	  data: "yahooid="+id,
	  cache: false,
	  success: function(html){
		var ret=html.split("#.#.#");
		$("#info0").html(ret[0]);
		$("#info1").html(ret[1]);
		$('#yid').val("");
      },
	  error: function(html) {

		$("#info0").html("<div >There was a problem with the request</div>");
		$("#info1").html("");
	  }
	});
}
function sendmail() {
	$.ajax({
   		type: "POST",
	    url: "send.php",
	    data: $("#contact").serialize(),
	    success: function(msg){
	       $("#sendstatus").html(msg);
		   alert(msg);
	   }
 	});
}

function strpos (haystack, needle, offset) 
{
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}
function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );


    while ( idx > -1 ) {
        str = str.replace( from, to );
        idx = str.indexOf( from, idx+1 );
    }

    return str;
}
function addElement() 
{
	var ni = document.getElementById('sdiv');
	var newdiv = document.createElement('div');
	var divIdName = 'sdiv';
	newdiv.setAttribute('id',divIdName);
	newdiv.innerHTML = '';
	newdiv.style.position='absolute';
	newdiv.style.border='1px dashed black';
	newdiv.style.background='#FFFFFF';
	newdiv.style.width='auto';
	newdiv.style.zIndex='99';
	newdiv.style.color='#6495ED';
	newdiv.style.fontWeight='bold';
	newdiv.style.display='none';
	newdiv.style.maxHeight='100px';
	newdiv.style.overflow="auto";
	ni.appendChild(newdiv);
	nodisplay=0;
}

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 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 addSugestion(val)
{
    val=val.replace(" ","");
	val=val.replace("%20","");
	var oldcook = getCookie('ymsgrsg');
	if(strpos(oldcook,val,0)!==false)return;
	var cook = oldcook + '1sep2' + escape(val);
	setCookie('ymsgrsg',cook,30);
}
function delSugestion(val)
{
	var oldcook = getCookie('ymsgrsg');
	val = '1sep2'+escape(val);
	var cook = oldcook.replace(val,"");
	setCookie('ymsgrsg',cook,30);

}
function show()
{
	var sugestions = getCookie('ymsgrsg').split('1sep2');
	var str='<table>';
	for( var i in sugestions )
	{
		if(sugestions[i]!='')
			
				str = str + "<tr><td><div style='padding-left:10px;padding-right:20px' onmouseover='this.style.background=\"#66FFFF\";this.style.cursor=\"pointer\"' onmouseout='this.style.background=\"\"' onclick='document.getElementById(\"yid\").value=\"" + sugestions[i] + "\";scan();'><b>" + sugestions[i]+ "</b></div></td><td><div onmouseover='this.style.background=\"#66FFFF\";this.style.cursor=\"pointer\"' onmouseout='this.style.background=\"\"' onclick='delSugestion(\"" + sugestions[i] + "\"); show();'> x </div></td></tr>";
	}
str=str+"</table><a target='_blank'  onmouseover='this.style.cursor=\"pointer\"' href='#' style='text-decoration:none;'> <font color='red' size='2'><b></b></font></div>";
	if(str==''||nodisplay==1)
		document.getElementById('sdiv').style.display='none';
	else
	{
		document.getElementById('sdiv').style.display='block';
		document.getElementById('sdiv').innerHTML = str;
	}
	
}
function initMakeup()
{

	//alert("Hello, and sorry for this message, but we realy need your help to promote this website\nPlease tell about my website at least 2 friends.\nThis message will expire on: 28.03.2010 (And we are sorry for this message again)");
	addElement();
	document.getElementById('form1').setAttribute("autocomplete", "off");
	document.getElementById('form1').onsubmit = function() 
		{
			if(document.getElementById('yid').value!='Enter Yahoo ID')addSugestion(document.getElementById('yid').value);
			show();
			scan();
			return false;
		}
	show();
	document.getElementById('google_ads').style.zIndex=10;
	document.getElementById('yid').focus();
	
}
