// Let's make document.getElementById shorter ;-) (by-id)
function bid(name)
{
	return document.getElementById(name);
}

// <body> onload
function bodyStart()
{
	toolTip();
	// bid('sugester_widget').removeAttribute('title');
}

// Tooltip
function toolTip()
{
	// Check
	for(var i=0,d,dE,D=document,span;d=D.getElementsByTagName('*')[i++];)
	{
		if(d.getAttribute('title'))
		{
			d.onmouseover=function(e)
			{
				if(this.getAttribute('title')!=undefined)
				{
					// Tags
					var inner=this.getAttribute('title');
					var inner=inner.replace(/\[n\]/g,'<br>');
					var inner=inner.replace(/\[b=(.*)\]/g,'<b>$1</b>');
					var inner=inner.replace(/\[img=(.*)\]/g,'<img src="$1" alt="X">');
					
					// Add tooltop
					var e=e||event;
					box=D.createElement('span');
					box.id='tooltip';
					box.innerHTML=inner;
					with(box.style)
					{
						position='absolute';
						top=e.clientY+(dE=D.documentElement).scrollTop+15+'px';
						left=e.clientX+dE.scrollLeft+15+'px';
					}
					// Old box? (Gecko [maybe not only] bug) - part 1
					if(this.title!=null&&this.title!='')
					{
						this.title_ex=this.title;
					}
					this.title='';
					D.body.appendChild(box);
				}
			}
			d.onmouseout=function()
			{
				if(this.getAttribute('title')!=undefined&&this.title_ex!=undefined)
				{
					this.title=this.title_ex;
					D.body.removeChild(box);
					// Old box? (Gecko [maybe not only] bug) - part 2
					if(bid('tooltip')!=null)
					{
						D.body.removeChild(bid('tooltip'));
					}
				}
			}
		}
	}
}

// Find
function findIt()
{
	var wtf=bid('find').value;
	if(wtf)
	{
		parent.location.href='wyszukiwarka-'+wtf+'-0';
	}
	else
	{
		alert('Wpisz słowo lub frazę dla wyszukiwania.\nNie można szukać niczego... Chyba, że wpiszesz "niczego" ;-)');
	}
}

// SEO Link (ver. and display)
function seoLink(url,className,anchor,title)
{
	document.write('<img src="download/indicator-eeeeee-16x16.gif" alt="Czekaj..."> Weryfikacja linku...');
	// ... Here WILL be AJAX ;-)
	// ... but now, just:
	setTimeout('bid("'+url+'").innerHTML=\'<a href="http://'+url+'" class="'+className+'" title="'+title+'" rel="nofollow">'+anchor+'</a>\';',(100+Math.round(1000*Math.random()))+'0');
}

// Clean domain (new entry)
function domainClean()
{
	var domain=bid('domain');
	var cleanA=domain.value.split('/');
	var cleanB=cleanA[0].split('&');
	var cleanC=cleanB[0].split('*');
	var cleanD=cleanC[0].split('%');
	var cleanE=cleanD[0].split('@');
	var cleanF=cleanE[0].split(';');
	var cleanG=cleanF[0].split('#');
	var cleanH=cleanG[0].split('"');
	var cleanI=cleanH[0].split('\'');
	var cleanJ=cleanI[0].split('<');
	var cleanK=cleanJ[0].split('>');
	var cleanL=cleanK[0].split(':');
	var cleanM=cleanL[0].toLowerCase();
	domain.value=cleanM;
	bid('domainCleanA').innerHTML='http://'+cleanM+'/';
	if(bid('domainCleanB')!=null)
	{
		bid('domainCleanB').innerHTML='http://'+cleanM+'/';
	}
}

// Clean seo-link (new entry)
function seoClean()
{
	if(bid('seo')!=null)
	{
		var seo=bid('seo');
		var cleanA=seo.value.split('"');
		var cleanB=cleanA[0].split('\'');
		var cleanC=cleanB[0].split('<');
		var cleanD=cleanC[0].split('>');
		seo.value=cleanD[0];
		bid('seoClean').innerHTML=cleanD[0];
	}
}

// Delete example value
function exampleValue(box)
{
	if(box.getAttribute('class').match('^(.*)exampleValue(.*)'))
	{
		box.value='';
		box.setAttribute('class',box.getAttribute('class').replace(/(.*)exampleValue(.*)/,'$1$2'));
	}
}

// Tabs
function tabs(menu,tabName)
{
	// Just hide all
	bid('tab-comments').style.display='none';
	bid('tab_comments').setAttribute('class','tabsInactive');
	bid('tab-preview').style.display='none';
	bid('tab_preview').setAttribute('class','tabsInactive');
	bid('tab-visitors').style.display='none';
	bid('tab_visitors').setAttribute('class','tabsInactive');
	
	// Show selected
	bid('tab-'+tabName).style.display='block';
	menu.setAttribute('class','tabsActive');
	menu.blur();
}

// Comment length
function commentLength(commentLength)
{
	if(commentLength!=0)
	{
		bid('commentLength').innerHTML='Wpisano <b>'+commentLength+'</b> znaków, minimum to <b>50</b> znaków.';
	}
	else
	{
		bid('commentLength').innerHTML='&nbsp;';
	}
}

/* OLD *

// ---------------------------------------------------------------------------- //
// Skrypt otwarty.pl mini
// ---------------------------------------------------------------------------- //

function OtwartyMiniBlank()
{
	tagA = document.getElementsByTagName('a');
	for( i = 0; i < tagA.length; i++ )
	{
		if( tagA[ i ].className.match("^out_link") )
		{
			tagA[ i ].target = "_blank";
		}
	}
}
window.onload = OtwartyMiniBlank;
*/
