var hexmap = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
var ud="undefined";
var ef = false;
var alimama_dc = doc();
var alimama_iniframe = 1;
function alimama_client(){	
	mt = {};
	nb = navigator.userAgent.toLowerCase();
	mt.isOpera = (nb.indexOf('opera') > -1);
	mt.isIE = (!mt.isOpera && nb.indexOf('msie') > -1);
	mt.isFF = (!mt.isOpera &&!mt.isIE&&nb.indexOf('firefox') > -1);
	return mt;
}
function alimama_addevent(o,c,h)
{
	a_client=alimama_client();
	if(a_client.isIE){
		o.attachEvent('on'+c,h);
	}else{
		o.addEventListener(c,h,false);
	}
	return true;
}
function hex(a){
	if(a<256) return "%"+hexmap[a>>4]+hexmap[a&0xf];
	else return hex(a>>8)+hex(a&0xf);
}
var alimama_cans=true;
function getx (obj){
        var curleft = 0;
       try{
        if (obj.parentNode)
        {
          while (obj.parentNode)
          {
            if (typeof obj.offsetLeft != ud)
            { 
            	curleft += obj.offsetLeft;
            }
            obj = obj.parentNode;
          }
        }
        else if (obj.x) {
          curleft += obj.x;
        }
       }catch(err)
       {
          curleft = 0;
        }
        return curleft;
}
function gety (obj){
	var curtop = 0;
    try{
        if (obj.parentNode)
        {
          while (obj.parentNode)
          {
            if (typeof obj.offsetTop != ud)
            { 
            	curtop += obj.offsetTop;
            }	
             obj = obj.parentNode;
          }
        }
        else if (obj.y){
          curtop += obj.y;
	}
     }catch(err)
     {
        curtop = 0;
     }
    return curtop;
}
function encodeUTF8(d) {
	var utft = "";var a=d.toString();
	for(var n=0; n<a.length; n++)
	{
		var c=a.charCodeAt(n);
		if(c<128)
			utft += hex(c);
		else if(127<c && c<0x800)
		{
			utft += hex((c>>6)|192);
			utft += hex((c&63)|128);
		} else if(0x7ff<c && c<0x10000)
		{
			utft += hex((c>>12)|224);
			utft += hex(((c>>6)&63)|128);
			utft += hex((c&63)|128);
		} else if(0xffff<c && c<0x200000)
		{
			utft += hex((c>>18)|0xf0);
			utft += hex(((c>>12)&63)|128);
			utft += hex(((c>>6)&63)|128);
			utft += hex((c&63)|128);
		} else if(0x1FFFFF<c && c<0x4000000)
		{
			utft += hex((c>>24)|0xf8);
			utft += hex(((c>>18)&63)|128);
			utft += hex(((c>>12)&63)|128);
			utft += hex(((c>>6)&63)|128);
			utft += hex((c&63)|128);
		} else if(0x3FFFFFF<c && c<0x80000000)
		{
			utft += hex((c>>30)|0xfc);
			utft += hex(((c>>24)&63)|128);
			utft += hex(((c>>18)&63)|128);
			utft += hex(((c>>12)&63)|128);
			utft += hex(((c>>6)&63)|128);
			utft += hex((c&63)|128);
		}
	}
	return utft;
}
var qv=new Array();

qv[0]="wd";
qv[1]="p";
qv[2]="q";
qv[3]="keyword";
qv[4]="kw";
qv[5]="w";
qv[6]="key";
qv[7]="word";
qv[8]="query";
qv[9]="q1";
qv[10]="name";

function alimama_b(a)
{
	if( typeof encodeURIComponent=="function" )
	{
		return encodeURIComponent(a.toString());
	} else return encodeUTF8(a.toString());
}

function meta_keywords(name)
{
	try
	{
		if(alimama_h()) return alimama_dc.getElementsByName(name)[0].getAttribute("content");
		return document.getElementsByName(name)[0].getAttribute("content");
	}
	catch(err)
	{
		return "";
	}
}

var mknames=new Array("keywords","Keywords","KEYWORDS");
function mk()
{
	var mk="";
	try 
	{
		for(var i=0;i<mknames.length;i++)
		{
			mk=meta_keywords(mknames[i]);
			if(mk!="") break;
		}
		mk=mk.replace(/[/| £¬¡¢¡¡]/g,',');
		if (mk.length>200)
		{
			var tmpstr = mk.substring(192,mk.length-1);
			var pos = tmpstr.indexOf(",");
			mk = mk.substring(0, pos+192);
		}
	}	
	catch(err)
	{
		mk="";
	}
	return mk;
}

function alimama_t()
{ 
	var alimama_t="";
	if(alimama_h())
	{
		try
		{
			alimama_t=alimama_dc.title;
		}catch(err)
		{
			alimama_t="";
		}
	} else 
	{
		alimama_t=document.title;
	}
	return alimama_t;
}
function alimama_h()
{
	try
	{
		if(alimama_iniframe==1 || alimama_iniframe=="yes")
		{
			return true;
		} else
		{
			if(document.title == "")
			{
				return true;
			} else
			{
				return false;
			}
		}
	}
	catch(err)
	{
	}
	return false;   
}
function alimama_u() 
{ 
	if(!alimama_h()) return document.location.href;

	if(ef) return alimama_dc.referrer;
	return alimama_dc.location.href;
}
function alimama_e() 
{ 
	var r="";
	if(alimama_h())
	{
		try
		{
			r=alimama_dc.referrer;
		}catch(err)
		{
			r="";
		}
	} else{
		r=document.referrer;
	}
	if(r==null)	r = "";
	return r;
}
function alimama_s(a)
{
	var r = a;
	if(r != "" && r != null)
	{
		for(var i=0; i<qv.length; i++)
		{
			var kw = new RegExp("[^1-9a-zA-Z]"+qv[i]+"=\([^&]*\)");
			var alimama_k = r.match(kw);
			if(alimama_k != null)
			{
				kw = new RegExp("^[0-9]*$");
				if(alimama_k[1].match(kw) == null)
				{
					return alimama_k[1];
				}
			}
		}
	}
	return "";  
}

function alimama_k()
{
	var alimama_k=alimama_s(alimama_u());
	if(alimama_k=="")
	{
		return alimama_s(alimama_e());
	}else
	{
		return alimama_k;
	}
}
function doc()
{
	try
	{
		var x=top.document.location;
		return top.document;
	}catch(err)
	{
		ef=true;
	}

	for(var wd=window;;)
	{
		var p = wd.parent;
		try
		{
			var x=p.document.location;
		}catch(err)
		{
			return wd.document;
		}
		wd = p;
	}
}

function alimama_p()
{
	var ps = (typeof alimama_type == ud)? "":"&t="+alimama_type;
	ps += (typeof alimama_titlecolor == ud)?"":"&tc="+alimama_titlecolor;
	ps += (typeof alimama_descolor == ud)?"":"&dc="+alimama_descolor;
	ps += (typeof alimama_bgcolor == ud)?"":"&bgc="+alimama_bgcolor;
	ps += (typeof alimama_bordercolor == ud)?"":"&bdc="+alimama_bordercolor;
	ps += (typeof alimama_linkcolor == ud)?"":"&lc="+alimama_linkcolor;
	return ps;
}
function cl()	
{
	alimama_pid = "";
	alimama_type = "";
	alimama_size = "";
	alimama_bgcolor = "";
	ahoo_bordercolor = "";
	alimama_titlecolor = "";
	alimama_descolor = "";
	alimama_linkcolor = "";
	alimama_admargin = "";
	alimama_displink = "";
	alimama_isbanner = "";
	alimama_adsnum = "";
	alimama_titlebgcolor = "";
	alimama_desbgcolor = "";
	alimama_simple = "";
	alimama_rows = "";
	alimama_cols = "";
	alimama_Halign = "";
	alimama_Valign = "";
	alimama_kbgcolor = "";
	alimama_kcolor = "";
		
	alimama_lbgcolor = "";
	alimama_rbgcolor = "";
	alimama_styletype = "";
	alimama_had = "";
	alimama_vad = "";
	sx = "";
	sy = "";
}
if(typeof alimama_count == ud)
{
   window.alimama_count = 1;
}
else
{
   window.alimama_count = window.alimama_count + 1;
   if(window.alimama_count > 20)
   {
   	alimama_cans = false;
   }
}
try
{
	if ( typeof window.top.top_time == ud)
	{
   		window.top.top_time = new Date();
   		window.top.top_time.valueOf();
   		if(!window.top.alimama_tcount)
	    {
	   		window.top.alimama_tcount = 1;
	    }
	}else
	{
		now_date = new Date();
		if (now_date.valueOf() - window.top.top_time.valueOf() > 10000)
		{
			window.top.alimama_tcount = 1
		}else
		{
			if(!window.top.alimama_tcount)
		   {
		   		window.top.alimama_tcount = 1;
		   }
		   else
		   {
		      window.top.alimama_tcount = window.top.alimama_tcount + 1;
		      if(window.top.alimama_tcount > 20) 
		      alimama_cans = false;
   			}			
		}
		window.top.top_time = now_date;
	}
}catch(err){}
try{
	if (typeof window.alimama_count != ud && typeof window.top.alimama_tcount !=ud )
	{
		if (window.alimama_count>=window.top.alimama_tcount)
		{
		        adc = window.alimama_count;
		}else
		{
		        adc = window.top.alimama_tcount;
		}
	}else
	{
		mrand = Math.floor(Math.random()*20)+5;
		adc =mrand;		
	}
}catch(err){
	mrand = Math.floor(Math.random()*20)+5;
	adc =mrand;
}

if(typeof yc == ud){
	var yc = new Object;
}
if(yc[alimama_pid]){
	yc[alimama_pid] = yc[alimama_pid]+1; 
}else{
	yc[alimama_pid] = 1;
}
if (yc[alimama_pid]>1)
{
	alimama_cans = false;
}
try
{
	if(!window.top.yc[alimama_pid])
   {
   		window.top.yc[alimama_pid] = 1;
   }
   else
   {
      window.top.yc[alimama_pid] = window.top.yc[alimama_pid] + 1;
      if(window.top.yc[alimama_pid] > 2) 
      alimama_cans = false;
   }
}catch(err){}


var alimama_tmp_iframe_id = "alimamatmpf"+Math.random();
document.write("<iframe name='"+alimama_tmp_iframe_id+"' id='" + alimama_tmp_iframe_id + "' width='0' height='0' src='' border=0 frameborder=0  marginwidth='0' marginheight='0' scrolling='no'></iframe>")
try{
	var frm_obj = document.getElementById(alimama_tmp_iframe_id);
	var obj2 = window;
	sx = getx(frm_obj);
	sy = gety(frm_obj);
	var i= 0;
	if (obj2.parent.window && typeof obj2.parent.window != ud)
	{

		while (obj2.location != window.top.location)
		{
		    sx += getx.call(obj2.parent,obj2.frameElement);
			sy += gety.call(obj2.parent,obj2.frameElement);
			obj2 = obj2.parent.window;
		}
	}
}catch (err)
{
	sx = 0;
    sy = 0;
}
var c = navigator.userAgent.toLowerCase();
try{
	var topurl=top.location.href;
	if(c.indexOf('firefox/ss')>-1 && topurl.indexOf('alimamapid=')){
		if (topurl.substr(topurl.indexOf("alimamapid=")+11) == alimama_pid)
		{
			isfiress = "&iss=1";
			document.write("<a name="+alimama_pid+"></a>")
		}else
		{
			isfiress = "&iss=0";
		}
	}else{ 
		isfiress = "&iss=0";
	}
}catch(err)
{
	isfiress = "&iss=0";
}
var ua = "";
if (c.indexOf("msie 6")>-1)
{
	ua = "M6";
}else if (c.indexOf("msie 7")>-1)
{
	ua = "M7";
}else if (c.indexOf("firefox/1")>-1)
{
	ua = "F1";
}else if (c.indexOf("firefox/2")>-1)
{
	ua = "F2";
}
else if (c.indexOf("firefox/ss")>-1)
{
	ua = "A";
}else if (c.indexOf("firefox")>-1)
{
	ua = "F2"	
}else
{
	ua = "O";
}
try{
	screenx = window.screen.width;
	screeny = window.screen.height;
}catch(err)
{
	screenx = 0;
	screeny = 0;
}
resolution = screenx+"x"+screeny;
adu = "http://p.mm.cn.yahoo.com/alimama.php?" + "u=" + alimama_b(alimama_u()) + isfiress+"&i=" + alimama_pid + "&w=" + alimama_width + "&h=" + alimama_height + "&ua="+ ua + "&re="+resolution +"&sz=" + alimama_sizecode +  alimama_p() + "&k=" + alimama_k() + "&tt=" + alimama_b(alimama_t()) + "&r=" + alimama_b(alimama_e()) +"&sx=" + sx + "&sy=" + sy + "&ac=" + adc +  "&mk=";
var alimama_ifrmae_id = "alimamaf"+Math.random();
if(alimama_cans)
{
	document.write("<iframe name='"+alimama_ifrmae_id+"' id='"+alimama_ifrmae_id+"' width=" + alimama_width + " height=" + alimama_height + " border=0 frameborder=0  marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" src=\""+adu.substring(0, 2048)+"\"></iframe>");
}
function alimama_xl(obj)
{
	try{
		_frm_obj = obj;
		_obj2 = window;
		_sx = getx(_frm_obj);
		var i= 0;
		if (_obj2.parent.window && typeof _obj2.parent.window != ud)
		{
			while (_obj2.location != window.top.location)
			{
			    _sx += getx.call(_obj2.parent,_obj2.frameElement);
				_obj2 = _obj2.parent.window;
			}
		}
	}catch (err)
	{
	    _sx = 0;
	}
	return _sx;
}
function alimama_yl(obj)
{
	try{
		_frm_obj = obj;
		_obj2 = window;
		_sy = gety(_frm_obj);
		var i= 0;
		if (_obj2.parent.window && typeof _obj2.parent.window != ud)
		{
			while (_obj2.location != window.top.location)
			{
				_sy += gety.call(_obj2.parent,_obj2.frameElement);
				_obj2 = _obj2.parent.window;
			}
		}
	}catch (err)
	{
	    _sy = 0;
	}
	return _sy;
}
function alimama_xylog(o1,o2,pid,sizecode,alimama_width,alimama_height)
{
	try{
	_tsx = alimama_xl(o1);
	_tsy = alimama_yl(o1);
	o2.setAttribute("src","http://p.mm.cn.yahoo.com/alimamal.php?u=" + alimama_b(alimama_u())+"&i=" + pid + "&ua="+ ua + "&re="+resolution +"&sz=" + sizecode  + "&r=" + alimama_b(alimama_e()) +"&sx=" + _tsx + "&sy=" + _tsy+"&w="+alimama_width+"&h="+alimama_height);
	}catch(err){}
}
var alimama_xylog2 = function(o1,o2,pid,sizecode,alimama_width,alimama_height)
{
  return function()
  {
    alimama_xylog(o1,o2,pid,sizecode,alimama_width,alimama_height);
  }
}
if(alimama_cans)
{
	alimama_addevent(window,"load",alimama_xylog2(frm_obj,document.getElementById(alimama_tmp_iframe_id),alimama_pid,alimama_sizecode,alimama_width,alimama_height));
}
cl();
