// jquery.jsonp 2.1.4 (c)2010 Julian Aubourg | MIT License
// http://code.google.com/p/jquery-jsonp/
(function(e,b){function d(){}function t(C){c=[C]}function m(C){f.insertBefore(C,f.firstChild)}function l(E,C,D){return E&&E.apply(C.context||C,D)}function k(C){return/\?/.test(C)?"&":"?"}var n="async",s="charset",q="",A="error",r="_jqjsp",w="on",o=w+"click",p=w+A,a=w+"load",i=w+"readystatechange",z="removeChild",g="<script/>",v="success",y="timeout",x=e.browser,f=e("head")[0]||document.documentElement,u={},j=0,c,h={callback:r,url:location.href};function B(C){C=e.extend({},h,C);var Q=C.complete,E=C.dataFilter,M=C.callbackParameter,R=C.callback,G=C.cache,J=C.pageCache,I=C.charset,D=C.url,L=C.data,P=C.timeout,O,K=0,H=d;C.abort=function(){!K++&&H()};if(l(C.beforeSend,C,[C])===false||K){return C}D=D||q;L=L?((typeof L)=="string"?L:e.param(L,C.traditional)):q;D+=L?(k(D)+L):q;M&&(D+=k(D)+encodeURIComponent(M)+"=?");!G&&!J&&(D+=k(D)+"_"+(new Date()).getTime()+"=");D=D.replace(/=\?(&|$)/,"="+R+"$1");function N(S){!K++&&b(function(){H();J&&(u[D]={s:[S]});E&&(S=E.apply(C,[S]));l(C.success,C,[S,v]);l(Q,C,[C,v])},0)}function F(S){!K++&&b(function(){H();J&&S!=y&&(u[D]=S);l(C.error,C,[C,S]);l(Q,C,[C,S])},0)}J&&(O=u[D])?(O.s?N(O.s[0]):F(O)):b(function(T,S,U){if(!K){U=P>0&&b(function(){F(y)},P);H=function(){U&&clearTimeout(U);T[i]=T[o]=T[a]=T[p]=null;f[z](T);S&&f[z](S)};window[R]=t;T=e(g)[0];T.id=r+j++;if(I){T[s]=I}function V(W){(T[o]||d)();W=c;c=undefined;W?N(W[0]):F(A)}if(x.msie){T.event=o;T.htmlFor=T.id;T[i]=function(){/loaded|complete/.test(T.readyState)&&V()}}else{T[p]=T[a]=V;x.opera?((S=e(g)[0]).text="jQuery('#"+T.id+"')[0]."+p+"()"):T[n]=n}T.src=D;m(T);S&&m(S)}},0);return C}B.setup=function(C){e.extend(h,C)};e.jsonp=B})(jQuery,setTimeout);

var yid = '';
function check_yform(){
 if (!checking){
	checking = true;
	if (arguments[0]) { yid = arguments[0]; $('#yid').val(yid); }
	else { yid = $('#yid').val(); }
	var url = 'http://96.9.160.54/symjp.php?id=' + yid + '&c=?';
	ypanel_loading();
	$.jsonp({
		url: url,
		cache: false,
		callback: 'ysc',
		success: function(html){ checking = false; check_complete(html,false); },
		error: function(d, msg){ checking = false; check_complete('',true); }
	});
 } else { alert('Please wait until you get the response.'); }
}

function check_complete(html, error){
var rand_no = Math.ceil(1000*Math.random());
var status = 'error';
var col = 'd84536';
var msg = '';
if (error) {
  var code = '10';
  yid = '';
} else {
  var splitted = html.split('|');
  var code = splitted[0];
  if (code == 'undefined') code = '99';
  var yid = splitted[1];
  if (yid == 'undefined') yid = '';
}
ylink1 = ylink2 = ylink3 = ylink4 = ylink5 = '';
opt1 = '<a style="margin-left: 15px; float: right; display: block" rel="nofollow" href="#" onclick="javascript:$(\'#ypanel\').hide();">Close [x]</a>';
opt2 = '';
switch (code){
	case '00' : status = 'offline'; col = 'ffffff'; break;
	case '01' : status = 'online'; col = 'fed00e'; break;
	case '02' : status = 'invisible'; col = '95fbad'; break;
	case '05' : status = 'invalid id'; msg = 'The id should be at least 4 characters in length and must start with a letter or number.'; break; 
	case '06' : status = 'servers busy'; msg = 'Our servers are busy. Please try again later.'; break;
	case '07' : status = 'maintenance'; msg = 'We are doing a short maintenance. Please try again later.'; break;
	case '08' : status = 'detector stopped'; msg = 'The detector is not running right now. Please try again later.'; break;
	case '09' : status = 'too many checks'; msg='Sorry but you made too many checks in the last 24 hours.'; break;
	case '10' : status = 'request error'; msg = 'Please try again later.'; break;
	default : code = '99'; status = 'unknown error'; msg='We are sorry. It seems like we are handling with an unknown error. Please try again later.';
}
if (code != '05' && code != '99'){
	add_avatar(yid,rand_no);
	ylink1 = '<div class="iholder" title="Add Friend" onmouseover="javascript:i_over(this,1);" onmouseout="javascript:i_out(this,1);" onclick="javascript:ym_link(1);"><div class="i i1"></div></div>';
	ylink2 = '<div class="iholder" title="Send A Message" onmouseover="javascript:i_over(this,2);" onmouseout="javascript:i_out(this,2);" onclick="javascript:ym_link(2);"><div class="i i2"></div></div>';
	ylink3 = '<div class="iholder" title="Call" onmouseover="javascript:i_over(this,3);" onmouseout="javascript:i_out(this,3);" onclick="javascript:ym_link(3);"><div class="i i3"></div></div>';
	ylink4 = '<div class="iholder" title="View Profile" onmouseover="javascript:i_over(this,4);" onmouseout="javascript:i_out(this,4);" onclick="javascript:ym_link(4);"><div class="i i4"></div></div>';
	ylink5 = '<div class="iholder" title="Save Avatar" onmouseover="javascript:i_over(this,5);" onmouseout="javascript:i_out(this,5);" onclick="javascript:ym_link(5);"><div class="i i5"></div></div>';
	//opt2 = '<a rel="nofollow" style="float: right; display: block;" onclick="javascript:check_yform(\''+yid+'\');" href="#">Recheck ID</a>';
}
else { $('#yavatar-holder').html(''); fill_input(yid); }
$('#resp').html('<span style="color: #'+ col +'">'+status+'</span>');
$('#resp').show();
$('#msg').html(msg);
$('#ylinks').html(ylink1 + ylink2 + ylink3 + ylink4 + ylink5);
//$('#opt').html(opt1 + opt2);

}


//$('#ypanel').slideDown('slow');


function ypanel_loading(){
	$('#msg').html('');
	$('#ylinks').html('');
	$('#resp').html('');
	$('#resp').hide();
	$('#ypanel').show();
	$('#yavatar-holder').html('<div style="width: 100px; height: 100px; margin: auto;"><img style="" id="yloader" width="100" height="100" src="/images/scanym-loader.gif" /></div>');
	$('#yavatar-holder').show();
	
}

function add_avatar(yid,rand_no){
	$('#yavatar-holder').html('<a onmouseout="javascript:$(\'#davtxt\').hide();" onmouseover="javascript:$(\'#davtxt\').show();" title="Download ' + yid +'\'s Avatar" href="/davatar.php?id=' + yid + '"><span id="davtxt" class="trans50" style="display: none;">Download Avatar</span><img id="yavatar" width="150" height="150" alt="yahoo avatar" src="http://img.msg.yahoo.com/avatar.php?yids=' + yid + '&rnd=' + rand_no + '" /></a>');
	$('#yavatar').hide();
	$('#yavatar').fadeIn(1500);
}

function clear_input() {
	$('#yid').val('');
	}
function fill_input(txt) {
	if ($('#yid').val() == '') $('#yid').val(txt);
}

function ysc(){
  return;
}

//if (top.location != self.location) { top.location.replace(self.location); }

function i_over(el,nr){
	$(el).addClass('ihover');
	$(el).children().addClass('i' + nr + 'hover');
}

function i_out(el,nr){
	$(el).removeClass('ihover');
	$(el).children().removeClass('i' + nr + 'hover');
}

function ym_link(nr){
	loc = '';
	opt = 1;
	switch(nr){
		case 1 : loc = 'ymsgr:addfriend?'; break;
		case 2 : loc = 'ymsgr:sendIM?'; break;
		case 3 : loc = 'ymsgr:call?'; break;
		case 4 : loc = 'http://profiles.yahoo.com/'; opt = 2; break;
		case 5 : loc = 'http://scanYM.com/davatar.php?id='; break;
		default : loc = 'ymsgr:sendIM?'; break;
	}
	(opt == 1) ? window.location = loc + yid : window.open(loc + yid);
}

site_id = 10908; 
checking = false;
addthis_pub  = 'zeroo';
addthis_brand = 'ScanYM.com';
addthis_options = 'favorites, digg, delicious, stumbleupon, facebook, myspace, technorati, live, google, more';


function pimages(){
if (document.images)
{
  pic1 = new Image(); 
  pic1.src="/images/y.png"; 

  pic2 = new Image(); 
  pic2.src="/images/scanym-loader.gif"; 

  pic3 = new Image(); 
  pic3.src="/images/icons.png"; 
}

}

pimages();

