function addLoadEvent( func ) {
	var oldonload = window.onload;
	if ( typeof window.onload != "function" ) {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


function ill() {
	var jox = document.getElementById( "jox" );
	var smyckebilder = document.getElementById( "smyckebilder" ).getElementsByTagName( "div" );

	visa_sida();
	he_dit_bilder( 96 );

	/**************************************************************************************/

	function visa_sida() {
		var text = document.getElementById( "text" );
		var sidnummer = document.getElementById( "illnummer" ).getElementsByTagName( "a" ); 
		
		sidnummer[0].className = "nummer";

		for( i = 0; i < sidnummer.length; i++ ) {
			sidnummer[i].onclick = function() {
				
				if( this.getAttribute( "id" ) == 1 ) {
					visa_illsmycken( 1, 96 );
				}

				if( this.getAttribute( "id" ) == 2 ) {
					visa_illsmycken( 2, 92 );
				}
				
				if( this.getAttribute( "id" ) == 3 ) {
					visa_illsmycken( 3, 88 );
				}

				if( this.getAttribute( "id" ) == 4 ) {
					visa_illsmycken( 4, 84 );
				}

				if( this.getAttribute( "id" ) == 5 ) {
					visa_illsmycken( 5, 80 );
				}
				
				if( this.getAttribute( "id" ) == 6 ) {
					visa_illsmycken( 6, 76 );
				}

				if( this.getAttribute( "id" ) == 7 ) {
					visa_illsmycken( 7, 72 );
				}

				if( this.getAttribute( "id" ) == 8 ) {
					visa_illsmycken( 8, 68 );
				}

				if( this.getAttribute( "id" ) == 9 ) {
					visa_illsmycken( 9, 64 );
				}

				if( this.getAttribute( "id" ) == 10 ) {
					visa_illsmycken( 10, 60 );
				}

				if( this.getAttribute( "id" ) == 11 ) {
					visa_illsmycken( 11, 56 );
				}

				if( this.getAttribute( "id" ) == 12 ) {
					visa_illsmycken( 12, 52 );
				}

				if( this.getAttribute( "id" ) == 13 ) {
					visa_illsmycken( 13, 48 );
				}

				if( this.getAttribute( "id" ) == 14 ) {
					visa_illsmycken( 14, 44 );
				}

				if( this.getAttribute( "id" ) == 15) {
					visa_illsmycken( 15, 40 );
				}

				if( this.getAttribute( "id" ) == 16 ) {
					visa_illsmycken( 16, 36 );
				}

				if( this.getAttribute( "id" ) == 17 ) {
					visa_illsmycken( 17, 32 );
				}

				if( this.getAttribute( "id" ) == 18 ) {
					visa_illsmycken( 18, 28 );
				}

				if( this.getAttribute( "id" ) == 19 ) {
					visa_illsmycken( 19, 24 );
				}

				if( this.getAttribute( "id" ) == 20 ) {
					visa_illsmycken( 20, 20 );
				}	

				if( this.getAttribute( "id" ) == 21 ) {
					visa_illsmycken( 21, 16 );
				}
				
				if( this.getAttribute( "id" ) == 22 ) {
					visa_illsmycken( 22, 12 );
				}

				if( this.getAttribute( "id" ) == 23 ) {
					visa_illsmycken( 23, 8 );
				}

				if( this.getAttribute( "id" ) == 24 ) {
					visa_illsmycken( 24, 4 );
				}

				if( this.getAttribute( "id" ) == 25 ) {
					visa_illsmycken( 25, 0 );
				}
			}
		}

		function visa_illsmycken( aktuell_sida, bildnummer ) {
			//aktuell_sida = numret på sidan med smycken som ska visas
			//bildnummer = id för den första lilla bilden på sidan

			for( i = 0; i < sidnummer.length; i++ ) {
				if( sidnummer[i].getAttribute( "id" ) == aktuell_sida ) {
					sidnummer[i].className = "nummer";
				}
				else {
					sidnummer[i].className = "";				
				}
			}	
			he_dit_bilder( bildnummer );
		}	
	}
	
	/**************************************************************************************/

	function he_dit_bilder( id ) {
		var liten_bild;
		var liten_a;
		
		for( i = 0; i < smyckebilder.length; i++ ) {
			liten_bild = document.createElement( "img" );
			liten_bild.setAttribute( "src", "smycken/" + id + ".jpg" );
			liten_bild.setAttribute( "id", id );
			
			liten_a = document.createElement( "a" );
			liten_a.setAttribute( "href", "illsmycken_stora.php?nr=" + id + "#illsmycke" + id );
			liten_a.setAttribute( "title", "Illsmycke #" + id );

			liten_a.appendChild( liten_bild );
			
			smyckebilder[i].appendChild( liten_a );
			id++;
		}
	}	

	/**************************************************************************************/

}


addLoadEvent( ill );

