
/* Title:		blog_header.js
** Description:	The automization of header and sidebar for http://woodrow.de.vu/
** Author:		Woodrow Shigeru
** contact:		Woodrow.Shigeru@gmx.net
** created:		2oo6-1o-o7
** modified:	2oo8-o1-16
*/

function load_blog_header()
{
	document.write( "&nbsp;<table align=center width=100% cols=3 cellspacing=0 cellpadding=0 border=0>" );
	document.write( "<tr><td width=700>" );
	document.write( "&nbsp;&nbsp; <a href='http://woodrowshigeru.blogspot.com/' target=Main><img border=1 width=50 height=50 src='"+ Path +"images/woodrow_logo-03s.jpg' title='Main Logo' style='border-color: black;'></a> " );
	document.write( "<img border=1 width=50 height=50 src='"+ Path +"images/me_avatar.jpg' class='swapit' title='myAvatar' name='avatar' onMouseOver='hoverImg( this.name, true );' onMouseOut='hoverImg( this.name, false );'> " );
	document.write( random_order() );
	document.write( "<img width=50 height=50 src='"+ Path +"images/khintergrund-04.jpg' style='width: 50; height: 50; border: 1px solid black;'> " );
	document.write( "<img width=50 height=50 src='"+ Path +"images/khintergrund-04.jpg' style='width: 50; height: 50; border: 1px solid #876027;'> " );
	document.write( "<img width=50 height=50 src='"+ Path +"images/khintergrund-04.jpg' style='width: 50; height: 50; border: 1px solid #cd9037;'> " );
	//---- gefolgt von drei Trickbildern, die leer sind (oder khintergrund-04 haben), aber grau(er)en Rahmen haben ----

	document.write( "</td><td width=* align=center><font face='Verdana' Size=1 color=gray><b><span id='nooto'>&lt;-- enjoy full view<!--. test of string-length. Karen, ich liebe dich. Aber ich kriege es einfach nicht gebacken, mit anderen Menschen auszukommen, also werde ich traurigerweise niemals mit dir auskommen, so fuerchte ich. Dabei wuerde ich es doch so gerne. Warum muss alles so kompliziert sein? Nur weil ich dich lachen sehen und mich von der besten Seite zeigen will. Life Sucks! Hoffentlich verliebe ich mich nie wieder--></span></b></font></td><td width=5%>&nbsp;</td></tr>" );
	document.write( "</table>" );

}

function load_header_logo()
{
	document.write( '<p><div align=center><img src="'+ Path +'images/woodrow-03.jpg" title="Woody\'s HomeBlog" width=432 height=126></div>' );
}

function load_left_beginning( WithCounter )
{
	document.write( "<font size=2 face='Verdana'>" );
	document.write( "<br><table cols=2 width=100% cellspacing=0 cellpadding=10 border=0>" );
	document.write( "<tr><td width=200 valign=top align=center rowspan=2>" );
	document.write( "<div class='leftbar' align=center>" );

	//----- userbars --------------------------------------
	document.write( "<p>&nbsp;<p>&nbsp;<p>" );
	document.write( "<a href='http://woodrowshigeru.deviantart.com/'><img src='"+ Path +"images/feature_deviant-art.jpg' width=75 height=33 border=0 title='my deviantArt Site'></a>&nbsp;" );
	document.write( "<a href='http://woodrowshigeru.blogspot.com/2006/04/woodrowrssenabled.html'><img src='"+ Path +"images/feature_rss-support.jpg' width=75 height=33 border=0 title='RSS Site Feed Support Info'></a><br>" );
	document.write( "<a href='"+ Path +"legend.html'><img src='"+ Path +"images/feature_header-legend.jpg' width=75 height=33 border=0 title='Psot Header Legend'></a>&nbsp;" );
	document.write( "<a href='http://user.phil-fak.uni-duesseldorf.de/~cieslik/procudo/procudo.html' target='_self'><img src='"+ Path +"images/feature_procudo.jpg' width=75 height=33 border=0 title='Cutscene Downloads'></a><br>" );
	document.write( "<a href='http://www.flickr.com/photos/woodrowshigeru/'><img src='"+ Path +"images/feature_flickr.jpg' width=75 height=33 border=0 title='my Flickr Photos'></a>&nbsp;" );
	document.write( "<a href='"+ Path +"repair_url.html' target='_self'><img src='"+ Path +"images/feature_repair-url.jpg' width=75 height=33 border=0 title='my URL Repairer'></a>" );
	//----- end of userbars -------------------------------

	//----- calendar date ---------------------------------
	document.write( "<p>" );
	document.write( heute() );
	document.write( "<br><a href='"+ Path +"update-history.html' class='leftbar' target='_self' title='yy-mm-dd'>" );
	document.write( last_update() );
	document.write( "</a>" );
	//----- end of calendar date --------------------------

	//----- additional navigation goodies -----------------
	document.write( "<p><a href='"+ Path +"home.html' class='leftbar' target='_self'>home</a> | <a href='"+ Path +"links2_descr.html' class='leftbar' target='_self'>links</a> | <a href='mailto:Woodrow.Shigeru@gmx.net' class='leftbar'>mail</a>" );

	if( WithCounter )
		document.write( "<p><img border=0 src='http://www.losstrack.com/slim.php?page=http://www.geocities.com/hans_schmock/test.html&digit=v5' title='Counter'>" );


	//---- javascript bestimmt, in welcher Sprache die Titel dargestellt werden sollen ... irgendwann ... -------
	document.write( "<p><img width=21 height=13 border=0 src='"+ Path +"images/flag_english_active.jpg' title='Englisch'>&nbsp;&nbsp;" );
	document.write( "<img width=21 height=13 border=0 src='"+ Path +"images/flag_german_active.jpg' title='Deutsch'>&nbsp;&nbsp;" );
	document.write( "<img width=21 height=13 border=0 src='"+ Path +"images/flag_japanese_active.jpg' title='Japanisch'>" );
	//----- end of additional navigation goodies ----------

	//----- random links ----------------------------------
	document.write( "<p>&nbsp;<br><div align=left><b><font color=#787878>my Random Links:</font></b></div><br><div align=center>" );
	banners_of_the_day();
	document.write( "</div>" );
	//----- end of random links ---------------------------

	document.write( "</div> </td><td width=10 rowspan=2>&nbsp;</td><td width=*>&nbsp;</td><td width=75>&nbsp;</td></tr>" );
	document.write( "<tr><td width=100 colspan=2 valign=top>" );
}

function load_left_closure()
{
//	document.write( "</td><td>&nbsp;</td></tr></table>" );
	document.write( "</td></tr></table>" );
	document.write( "</font>" );

	//----- woodenBottomer --------------------------------
	document.write( "<br><hr width=60% align=left>" );
	document.write( "<font size=1 face='Verdana'>" );
	document.write( "© 2oo7 by <a href='mailto:Woodrow.Shigeru@gmx.net'>Woodrow</a><br></font>" );

}

//??===========================================================================

 // swaps / toggles the images on an onMouseOver/Out-Event (general)
 // IsHover: true means 'hover' :: false means 'not hover'
function hoverImg( ImgName, IsHover )
{
	var Hilf = ( IsHover == false ) ? image_index( ImgName ) : image_index( ImgName ) + document.images.length;

	document[ ImgName ].src = SwapList[ Hilf ] +".jpg";
//	document.getElementById("divausgabe").innerText = SwapList;
}

 // basically this is "get (image) element's index by element's name"
function image_index( ImgName )
{
	var i = 0;
	while ( ( i < document.images.length ) && ( document.images[i].name != ImgName ) )
		i++;

	return i;
}

function altAsTitle()
{
	var i;
	for (i = 0; i < document.images.length; i++)
		if ( document.images[i] )
			document.images[i].alt = document.images[i].title;
}

//----- end of aid functions ------------------------------

 // creates a random order of 3 banners without repetition
function create_random_order()
{
	var i = 0, r, Last = 0, j;

	 // find the limit (last given Banner)
	while( BannerLinks[ Last ][0] != undefined )
	  Last++;

	 // choose randomly 3 different banners
	for( i = 0; i < 3; i++ )
	{
		do
		{	 // choose randomly a number in the range of available banners
			r = Math.floor( Math.random() * Last );

			 // check if already chosen (avoid repititions)
			j = 0;
			while( ( Used[j] != undefined ) && ( Used[j] != r ) )
			  j++;
		}
		while( Used[j] != undefined );

		 // now this one's settled
		Used[i] = r;
	}

	 // afterwards, preliminarily preload the chosen pics
	if( document.images )
	{

		SwappedNames[16] = Path +"images/light/links2_"+	BannerLinks[ Used[0] ][1];
		SwappedNames[17] = Path +"images/links2_"+			BannerLinks[ Used[0] ][1];
		SwappedNames[18] = Path +"images/light/links2_"+	BannerLinks[ Used[1] ][1];
		SwappedNames[19] = Path +"images/links2_"+			BannerLinks[ Used[1] ][1];
		SwappedNames[20] = Path +"images/light/links2_"+	BannerLinks[ Used[2] ][1];
		SwappedNames[21] = Path +"images/links2_"+			BannerLinks[ Used[2] ][1];
	}
}

 // removes the ugly border from my Profile Image
function profile_img_without_border()
{
	 // find index of the profile image
	var i = 0;
	var Hilf = "http://user.phil-fak.uni-duesseldorf.de/~cieslik/me_ava_transp.png";
	while ( ( i < document.images.length ) && ( document.images[i].src != Hilf ) )
		i++;

	if ( document.images[i] != undefined )
	{
		document.images[i].style = "border: 0;";
		document.images[i].width  = 50;
		document.images[i].height = 50;
	}
}

//===== global vars ===========================================================

	var Path = '';																	// for local designing & testing
		Path = 'http://user.phil-fak.uni-duesseldorf.de/~cieslik/homeblog/';		// points to the base folder
	var Used = new Array(2);			// the array that saves the pic order once randomly chosen
	var FotoRay = new Array(7);			// the array for the foto gallery


	var SwapList = new Array();			// holds a list of all images in the document
										// + the images to take for substitution (all without path and file-extension)
										// if a cell is undefined, then this image is not supposed to be swappable.

	var SwappedNames = new Array();		// holds a list of the (shortened) filenames of all images involved in the swapping process
										// in a certain order: even -> original images, odd -> hover-images

	SwappedNames[0]  = Path +"images/me_avatar";
	SwappedNames[1]  = Path +"images/light/me_avatar";
	 // leave space for the logos / fotos  // obsolete comment

	create_random_order();				// first thing to do


 // initialize this document - means: preload all relevant images, fill SwapList
function init()
{
	 // preload all images with one variable: img. just preload them
	for ( var i = 0; i < SwappedNames.length; i++ )
	{	var img = new Image();
		img.src = SwappedNames[i] +".jpg";
	}
//	document.getElementById("divausgabe").innerText = i;

	 // fill SwapList in the right order: document.images-indexi are equivalent to SwapList-indexi,
	 // hover-images follow that same pattern after document.images.length (count of all images in the document)
	 // => SwapList is twice as long as document.images
	var j = 0;
	var dil = document.images.length;
	for ( i = 0; i < dil; i++ )
		if ( document.images[i].className == "swapit" )
		{	SwapList[i]		= SwappedNames[j];
			SwapList[i+dil]	= SwappedNames[j+1];
			j = j+2;
		}
	 // if this section is too unclear, check the commentary notes of SwapList and SwappedNames, which are located above

	altAsTitle();
	profile_img_without_border();
//	document.getElementById("divausgabe").innerText = "start of init()"+ document.images[2].alt;
}
