var isIE=((navigator.appName == 'Microsoft Internet Explorer') && (document.all));

// [ZT] Extension de la classe String: simule la fonction php strpad()
String.prototype.strpad = function(c,n)
{
	if ((c == null) || (c == ''))
	{
		c=' ';
	}
	var t___mp=this.str_repeat(c,n);
	return t___mp+this+t___mp;
}

// [ZT] Extension de la classe String: simule la fonction php str_repeat()
String.prototype.str_repeat = function(c,n)
{
	var rpt___res='';
	if (n == null)
	{
		n=1;
	}
	for (var i=0 ; i<n ; i++)
	{
		rpt___res+=c;
	}
	return rpt___res;
}

// [ZT] Extension de la classe String: vrifie si une chane est infixe (= contenue dans) une autre.
String.prototype.hasInfix = function(s)
{
	return (this.indexOf(s) > -1);
}

// [ZT] Extension de la classe String: teste si une chaine est nulle (=vide, nulle ou erronne)
String.prototype.isNull=function()
{
	return ((this == null) || (this == '') || (this == 'undefined') || (this == 'NaN'));
}

// Correcteur de transparence d'images PNG pour IE version < 7.0
// Code original par N@mani, transmis par Darth Killer, modifie par Ze Thriller
// Ajout d'une image interne pour eviter la deformation des petites images (independemment du zoom du texte)
function correctPNG()
{
	if ((isIE) && (navigator.appVersion.indexOf('MSIE 7') == -1) && (navigator.appVersion.indexOf('MSIE 8') == -1))
	{
		var i, img, imgName, iClass, imgID, imgClass, imgTitle, imgStyle, strNewHTML
		for (i=0; i<document.images.length; i++)
		{
			img = document.images[i]
			imgName = img.src.toUpperCase()

			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				iClass = " "+img.className+" "
				if (iClass.indexOf(" nopngparse ") == -1)
				{
					imgID = (img.id) ? "id='" + img.id + "' " : ""
					imgClass = (img.className) ? "class='" + img.className + "' " : ""
					imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
					imgStyle = "display:inline-block;" + img.style.cssText
					if (img.align == "left") imgStyle = "float:left;" + imgStyle
					if (img.align == "right") imgStyle = "float:right;" + imgStyle
					if (img.parentElement.href) imgStyle = "cursor:pointer;" + imgStyle

					strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px; " + imgStyle + ";"
					+ " filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"><img src=\""+root_path+"images/2007/misc/spacer.gif\" alt=\"\" width=\"1\" height=\"1\" style=\"margin: 0; padding: 0;\" \/><\/span>"

					img.outerHTML = strNewHTML

					i = i-1
				}
			}
		}

		try
		{
			document.getElementById('p_panel_container').style.display='none';
		}
		catch(e)
		{
		}
	}
}

// [ZT] Simule l'attribut target (non disponible en XHTML 1.0 Strict).
function nw_links_simul()
{
	var lnk, i, cn, a, b, inf;

	lnk=document.getElementsByTagName('a');

	for (i in lnk)
	{
		with (lnk[i])
		{
			try
			{
				a=getAttribute('className');
				a=((a == null) ? '' : a);
			}
			catch(e)
			{
				a='';
			}

			try
			{
				b=getAttribute('class');
				b=((b == null) ? '' : b);
			}
			catch(e)
			{
				b='';
			}

			a=a.strpad();
			b=b.strpad();

			try
			{
				inf=((a.hasInfix(' nw_nomark ')) || (b.hasInfix(' nw_nomark ')));

				if ((a.hasInfix(' nw ')) || (b.hasInfix(' nw ')) || (inf))
				{
					target = '_blank';
					title = ((title == '') ? '' : ' (')+'Ce lien s\'ouvrira dans une nouvelle fenetre'+((title == '') ? '.' : ')');
					if ((isIE) && (!inf))
					{
						if ((a.hasInfix(' link_admin ')) || (b.hasInfix(' link_admin ')) || (a.hasInfix(' link_admin2 ')) || (b.hasInfix(' link_admin2 ')))
						{
							innerHTML +='<img src="'+root_path+'images/2007/misc/link_nw_red.png" width="14" height="10" alt="" \/>';
						}
						else if ((a.hasInfix(' link_topic_name ')) || (b.hasInfix(' link_topic_name ')))
						{
							innerHTML +='<img src="'+root_path+'images/2007/misc/link_nw_orange.png" width="14" height="10" alt="" \/>';
						}
						else if ((a.hasInfix(' link_modo ')) || (b.hasInfix(' link_modo ')) || (a.hasInfix(' link_green ')) || (b.hasInfix(' link_green ')))
						{
							innerHTML +='<img src="'+root_path+'images/2007/misc/link_nw_green.png" width="14" height="10" alt="" \/>';
						}
						else if ((a.hasInfix(' link_topsites ')) || (b.hasInfix(' link_topsites ')))
						{
							innerHTML +='<img src="'+root_path+'images/2007/misc/link_nw_topsites.png" width="14" height="10" alt="" \/>';
						}
						else if ((a.hasInfix(' link_yellow ')) || (b.hasInfix(' link_yellow ')))
						{
							innerHTML +='<img src="'+root_path+'images/2007/misc/link_nw_yellow.png" width="14" height="10" alt="" \/>';
						}
						else
						{
							innerHTML +='<img src="'+root_path+'images/2007/misc/link_nw.png" width="14" height="10" alt="" \/>';
						}
					}
				}
			}
			catch(e)
			{
			}
		}
	}
}

// [ZT] Met "aux normes" le comportement des labels.
// Ne sert que pour de tres vieilles versions d'IE.
function labels_for_IE()
{
	if ((document.all) && (navigator.appVersion.indexOf('MSIE 7') == -1) && (navigator.appVersion.indexOf('MSIE 6') == -1))
	{
		var labels=document.getElementsByTagName('label'),lbl,tg,tName,tType;
		for (lbl in labels)
		{
			try
			{
				tg=document.getElementById(lbl.htmlFor);
				tName=tg.tagName.toLowerCase();
				tType=((tg.type) ? tg.type.toLowerCase() : null);

				if ((tName == 'input') || (tName == 'textarea'))
				{
					if (lbl.onclick != '')
					{
						if (tName == 'input')
						{
							if (tType == 'checkbox')
							{
								lbl.onclick += ' document.getElementById(\''+lbl.htmlFor+'\').checked = !document.getElementById(\''+lbl.htmlFor+'\').checked;';
							}
							else if (tType == 'radio')
							{
								lbl.onclick += ' document.getElementById(\''+lbl.htmlFor+'\').checked = true;';
							}
							else if (tType == 'text')
							{
								lbl.onclick += ' document.getElementById(\''+lbl.htmlFor+'\').focus();';
							}
						}
						else
						{
							lbl.onclick += ' document.getElementById(\''+lbl.htmlFor+'\').focus();';
						}
					}
					else
					{
						if (tName == 'input')
						{
							if (tType == 'checkbox')
							{
								lbl.onclick = 'document.getElementById(\''+lbl.htmlFor+'\').checked = !document.getElementById(\''+lbl.htmlFor+'\').checked;';
							}
							else if (tType == 'radio')
							{
								lbl.onclick = 'document.getElementById(\''+lbl.htmlFor+'\').checked = true;';
							}
							else if (tType == 'text')
							{
								lbl.onclick = 'document.getElementById(\''+lbl.htmlFor+'\').focus();';
							}
						}
						else
						{
							lbl.onclick = 'document.getElementById(\''+lbl.htmlFor+'\').focus();';
						}
					}
				}
			}
			catch(e)
			{
			}
		}
	}
}

// [ZT] Coloration speciale des champs textes / textarea lorsqu'ils ont le focus.
function focus_fields()
{
	if ((navigator.appName == 'Microsoft Internet Explorer') && (document.all))
	{
		var f1=document.getElementsByTagName('input');
		var f2=document.getElementsByTagName('textarea');
		var i, l1, l2, ev_func1, ev_func2, tmp;

		l1=f1.length;
		l2=f2.length;

		for (i=0 ; i<l1 ; i++)
		{
			with (f1[i])
			{
				if ((type.toLowerCase() == 'text') && (className.toLowerCase().indexOf('ghost_input') == -1))
				{
					try
					{
						ev_func1=onfocus.toString();
					}
					catch(e)
					{
						ev_func1='';
					}

					if (ev_func1 != '')
					{
						tmp=/^function anonymous\(\)\n\{\n(.+)\n\}$/mgi.exec(ev_func1);
						ev_func1=tmp[1].toString();
					}

					try
					{
						ev_func2=onblur.toString();
					}
					catch(e)
					{
						ev_func2='';
					}

					if (ev_func2 != '')
					{
						tmp=/^function anonymous\(\)\n\{\n(.+)\n\}$/mgi.exec(ev_func2);
						ev_func2=tmp[1].toString();
					}


					f1[i].onfocus_old=ev_func1;
					f1[i].onblur_old=ev_func2;

					onfocus=function()
					{
						eval(this.onfocus_old);

						with (this.style)
						{
							borderColor='#000080';
							color='#002276';
							backgroundColor='#EBF5FF';
						}
					};

					onblur=function()
					{
						eval(this.onblur_old);

						with (this.style)
						{
							borderColor='#000000';
							color='#000000';
							backgroundColor='#FFFFFF';
						}
					};
				}
			}
		}

		for (i=0 ; i<l2 ; i++)
		{
			with (f2[i])
			{
				if (className.toLowerCase().indexOf('ghost_input') == -1)
				{
					try
					{
						ev_func1=onfocus.toString();
					}
					catch(e)
					{
						ev_func1='';
					}

					if (ev_func1 != '')
					{
						tmp=/^function anonymous\(\)\n\{\n(.+)\n\}$/mgi.exec(ev_func1);
						ev_func1=tmp[1].toString();
					}

					try
					{
						ev_func2=onblur.toString();
					}
					catch(e)
					{
						ev_func2='';
					}

					if (ev_func2 != '')
					{
						tmp=/^function anonymous\(\)\n\{\n(.+)\n\}$/mgi.exec(ev_func2);
						ev_func2=tmp[1].toString();
					}


					f2[i].onfocus_old=ev_func1;
					f2[i].onblur_old=ev_func2;

					onfocus=function()
					{
						eval(this.onfocus_old);

						with (this.style)
						{
							borderColor='#000080';
							color='#002276';
							backgroundColor='#EBF5FF';
						}
					};

					onblur=function()
					{
						eval(this.onblur_old);

						with (this.style)
						{
							borderColor='#000000';
							color='#000000';
							backgroundColor='#FFFFFF';
						}
					};
				}
			}
		}
	}
}

// [ZT] IE & drives uniquement: modifie la page d'accueil du navigateur.
function PF_homePage(obj)
{
	try
	{
		with (obj)
		{
			style.behavior='url(#default#homepage)';
			setHomePage('http://www.pokemon-france.com/');
		}
	}
	catch(e)
	{
		alert('Impossible de modifier la page d\'accueil.'+"\n"+'Votre navigateur ne semble pas gerer cette fonctionnalite.');
	}
}

// [ZT] Action lors du passage de la souris sur les icones de news.
function mover_newsicon(n,soft_mode)
{
	document.getElementById('news'+n+'_big').style.visibility='visible';
	if (n > 1)
	{
		with (document.getElementById('news'+(n-1)+'_small').style)
		{
			zIndex=hnews_status.orig_zIndex[n-2]-2;
		}
	}
}

// [ZT] Action lors de la sortie de la souris des icones de news.
function mout_newsicon(n,soft_mode)
{
	document.getElementById('news'+n+'_big').style.visibility='hidden';
	if (n > 1)
	{
		with (document.getElementById('news'+(n-1)+'_small').style)
		{
			zIndex=hnews_status.orig_zIndex[n-2];
		}
	}
}

function header_news_snapshot(n)
{
	this.nb=n;
	this.orig_zIndex=new Array();
}

var hnews_status=new header_news_snapshot(5);
for (var i=0 ; i<hnews_status.nb ; i++)
{
	hnews_status.orig_zIndex[i]=50-i;
}

// [ZT] Aucune idee de l'utilite, mais bon. :p
function popup_playcast(page,nom)
{
	window.open(page,nom, "toolbar=no, status=no, scrollbars=no, resizable=no, width=775, height=660");
}

// [Mut] Masquage des spoils.
function cacherSpoils()
{
	var divs = document.getElementsByTagName('div');
	for (i in divs)
	{
		with (divs[i])
		{
			try
			{
				if (className == 'spoiler2')
				{
					style.display = 'none';
				}
			}
			catch(e)
			{
			}
		}
	}
}

// [Mut] Affichage des spoils
function spoiler(texte)
{
	var texte_cache = texte.childNodes[0];
	if (texte_cache.style.display == 'none' && confirm('Voulez-vous vraiment afficher ce texte ?'))
		{
			texte_cache.style.display = 'block';
			texte.style.cursor = 'default';
		}

}

// [ZT] Code original par Darth Killer
function mail_nospam(user, domain, css_class, link_text)
{
	document.write('<a href="mailto:'+user+'@'+domain+'"'+((!css_class.isNull()) ? ' class="'+css_class+'"' : '')+'>'+link_text+'<\/a>');
}

// [ZT] Onglets de l'en-tete
function header_tabs(s_init)
{
	this.active_tab=((s_init == null) || (s_init == 'undefined') || (s_init < -1) ? -1 : s_init);
	this.colors_list=new Array('white', 'black', 'green', 'red', 'yellow', 'purple', 'blue', 'orange');
}

header_tabs.prototype.change=function(idx)
{
	if (this.active_tab > -1)
	{
		document.getElementById('h_tab2_'+this.active_tab).style.display='none';
	}

	document.getElementById('c1_'+this.colors_list[this.active_tab]).style.display='none';
	document.getElementById('c5_'+this.colors_list[this.active_tab]).style.display='none';

	this.active_tab=idx;

	document.getElementById('h_tab2_'+idx).style.display='inline';
	document.getElementById('c1_'+this.colors_list[idx]).style.display='block';
	document.getElementById('tabs2_container2').className='t_down t_'+this.colors_list[idx]+'_down';
	document.getElementById('tabs2_container3').className='t_down t_'+this.colors_list[idx]+'_down t_2ndlevel';
	document.getElementById('tabs2_container4').className='t_down t_'+this.colors_list[idx]+'_down';

	document.getElementById('c5_'+this.colors_list[idx]).style.display='block';
};

// [ZT] Panel des categories de liens (accueil)
var info_p={
	current_cat : -1,
	current_element : null,
	panel_visible : false,

	slide : function(cat_id)
	{
		if (info_p.current_cat == -1)
		{
			document.getElementById('icon_cadre').style.display='block';
		}
		else
		{
			document.getElementById('icon_cat'+info_p.current_cat).style.display='none';
			document.getElementById('submenu'+info_p.current_cat).style.display='none';
		}

		if ((info_p.current_element != null) && (info_p.current_cat != cat_id))
		{
			document.getElementById('submenu'+info_p.current_element).style.display='none';
			info_p.current_element=null;
		}

		document.getElementById('icon_cat'+cat_id).style.display='block';
		document.getElementById('submenu'+cat_id).style.display='block';
		document.getElementById('p_title_label').innerHTML=info_p._info_text(false, cat_id);

		info_p.current_cat=cat_id;
	},

	slide2 : function(id_str)
	{
		if (info_p.current_element !== null)
		{
			document.getElementById('submenu'+info_p.current_element).style.display='none';
		}
		document.getElementById('submenu'+id_str).style.display='block';
		info_p.current_element=id_str;
	},

	_panel_mover : function()
	{
		if (info_p.current_element !== null)
		{
			document.getElementById('submenu'+info_p.current_element).style.display='none';
			info_p.current_element=null;
		}
		if (info_p.current_cat != -1)
		{
			document.getElementById('submenu'+info_p.current_cat).style.display='none';
			document.getElementById('icon_cat'+info_p.current_cat).style.display='none';
			info_p.current_cat=-1;
		}

		document.getElementById('icon_cadre').style.display='none';
		document.getElementById('p_title_label').innerHTML='&nbsp;';
	},

	main : {
		toggle : function(id)
		{
			document.getElementById(id).style.display=((info_p.panel_visible) ? 'none' : 'block');
			info_p.panel_visible=!info_p.panel_visible;
			if (!info_p.panel_visible)
			{
				info_p._panel_mover();
			}
		}
	},

	_info_text : function(mode, cat_id)
	{
		if (!mode)
		{
			switch (cat_id)
			{
				case -1:
					return '';
				case 1:
					return 'Encyclop&eacute;die';
				case 2:
					return 'Anime';
				case 3:
					return 'Portail';
				case 4:
					return 'Jeux Vid&eacute;o';
				case 5:
					return 'Cartes &agrave; jouer';
				case 6:
					return 'FanClub';
			}
		}
		else
		{
			switch (cat_id)
			{
				case -1:
					return '';
				case 1:
					return '';
				case 2:
					return '';
				case 3:
					return '';
				case 4:
					return '';
				case 5:
					return '';
				case 6:
					return '';
			}
		}
	}
};

var i_tabs = {
	current : 1,

	change : function(id)
	{
		if (id != i_tabs.current)
		{
			try
			{
				document.getElementById('i_tab'+i_tabs.current).className='fond_onglet ong_disabled';
				document.getElementById('i_tab_content'+i_tabs.current).style.display='none';

				document.getElementById('i_tab'+id).className='fond_onglet ong_active';
				document.getElementById('i_tab_content'+id).style.display='block';
			}
			catch(e)
			{
				return;
			}
			if (id == 2)
			{
				i_tabs.com_categs.scroller.reset();
				document.getElementById('com_container').style.height=(document.getElementById('com_cat1').offsetHeight).toString()+'px';
			}
			i_tabs.current=id;
		}
	},

	com_categs : {
		change : function(id)
		{
			if ((id != i_tabs.com_categs.scroller.active) && (!i_tabs.com_categs.scroller._moving) && (!i_tabs.com_categs.dimmer._moving))
			{
				i_tabs.com_categs.scroller.moveTo(id);
			}
		},

		scroller : {
			active : 1,
			scrollNumSteps : 24,
			_moving : false,
			_scrollStepSize : 1,
			_scrollFrom : 0,
			_scrollTo : 1,

			reset : function()
			{
				document.getElementById('com_container').scrollTop=0;
				i_tabs.com_categs.scroller._moving=false;
				i_tabs.com_categs.scroller.active=1;
			},

			moveTo : function(id)
			{
				var target_voffset, current_voffset;

				try
				{
					if (isIE)
					{
						target_voffset=document.getElementById('com_cat'+id).getElementsByTagName('img')[0].offsetTop-5;
					}
					else
					{
						target_voffset=document.getElementById('com_cat'+id).getElementsByTagName('img')[0].y-5;
					}
					//document.getElementById('com_cat'+id).offsetTop;
				}
				catch(e)
				{
					return;
				}

				current_voffset=document.getElementById('com_container').scrollTop;

				if (current_voffset == target_voffset)
				{
					return;
				}

				i_tabs.com_categs.scroller._scrollStepSize=(target_voffset-current_voffset)/i_tabs.com_categs.scroller.scrollNumSteps;
				i_tabs.com_categs.scroller._scrollFrom=current_voffset;
				i_tabs.com_categs.scroller._scrollTo=target_voffset;
				i_tabs.com_categs.scroller._moving=true;
				i_tabs.com_categs.scroller.active=id;

				i_tabs.com_categs.scroller._scroll();

				return;
			},

			_scroll : function()
			{
				with (document.getElementById('com_container'))
				{
					var s=scrollTop;

					scrollTop+=i_tabs.com_categs.scroller._scrollStepSize;

					if ((Math.abs(Math.round(s+i_tabs.com_categs.scroller._scrollStepSize) - i_tabs.com_categs.scroller._scrollTo) < Math.abs(i_tabs.com_categs.scroller._scrollStepSize)) || (scrollTop == s))
					{
						if (isIE)
						{
							scrollTop=Math.max(0, document.getElementById('com_cat'+i_tabs.com_categs.scroller.active).getElementsByTagName('img')[0].offsetTop-5);
						}
						else
						{
							scrollTop=Math.max(0, document.getElementById('com_cat'+i_tabs.com_categs.scroller.active).getElementsByTagName('img')[0].y-5);
						}
						i_tabs.com_categs.scroller._moving=false;
						i_tabs.com_categs.dimmer.stretch(i_tabs.com_categs.scroller.active);
						return;
					}
					else
					{
						window.setTimeout("i_tabs.com_categs.scroller._scroll()", 60);
					}
				}
			}
		},

		dimmer : {
			numSteps : 24,
			_moving : false,
			_stepSize : 1,
			_from : 0,
			_to : 1,

			stretch : function(id)
			{
				var hc, ht;

				hc=parseInt(document.getElementById('com_container').style.height);
				ht=document.getElementById('com_cat'+id).offsetHeight;

				i_tabs.com_categs.dimmer._from=hc;
				i_tabs.com_categs.dimmer._to=ht;

				i_tabs.com_categs.dimmer._stepSize=(ht-hc)/i_tabs.com_categs.dimmer.numSteps;

				if (Math.abs(i_tabs.com_categs.dimmer._stepSize) < 1)
				{
					return;
				}

				i_tabs.com_categs.dimmer._moving=true;
				i_tabs.com_categs.dimmer._shrink_expand();
			},

			_shrink_expand : function()
			{
				var s=parseInt(document.getElementById('com_container').style.height);

				document.getElementById('com_container').style.height=(s+i_tabs.com_categs.dimmer._stepSize).toString()+'px';

				//alert('Shrink/expand:'+"\n"+Math.abs(Math.round(s+i_tabs.com_categs.dimmer._stepSize) - i_tabs.com_categs.dimmer._to)+"\n"+Math.abs(i_tabs.com_categs.dimmer._stepSize)+"\n\n"+i_tabs.com_categs.dimmer._from+"\n"+i_tabs.com_categs.dimmer._to);

				if ((Math.abs(Math.round(s+i_tabs.com_categs.dimmer._stepSize) - i_tabs.com_categs.dimmer._to) <= Math.abs(i_tabs.com_categs.dimmer._stepSize)) || ((s <= 150) && (i_tabs.com_categs.dimmer._stepSize < 0)) || ((s >= 600) && (i_tabs.com_categs.dimmer._stepSize > 0)))
				{
					if (s > 150)
					{
						document.getElementById('com_container').style.height=(i_tabs.com_categs.dimmer._to).toString()+'px';
					}
					i_tabs.com_categs.scroller._moving=false;
					i_tabs.com_categs.dimmer._moving=false;
					return;
				}
				else
				{
					window.setTimeout("i_tabs.com_categs.dimmer._shrink_expand()", 60);
				}
			}
		}
	}
};

function pftv(video_file)
{

var player = "http://www.pokemon-france.com/pftv/player.swf" ; // Chargement du Player
var skin = "http://www.pokemon-france.com/pftv/snel.swf"; // Chargement du Skin
var load = "http://www.pokemon-france.com/pftv/Player_PF.jpg"; // Chargement de l'image d'accueil


document.write('<embed src="'+player+'" width="540" height="335" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" flashvars="file='+video_file+'&autostart=false&image='+load+'&skin='+skin+'" />');

}
