
// gör att huvudmenyns aktiva länk 'togglar' submenyn, 
// var 'nr' sätts = 1 i onLoader(), var 'sidor' sätts på varje sida.

/*function fToggle() {
	nr++; // sätts till 1 i fBildStart() som körs i onLoader()
	fSub(nr); // gå till rätt subSida
	if (nr==sidor) { // kommit till sista subSidan?
		nr=0; // hoppa till subsida 1
	}
}
*/

function writeLayer(){
// uppdatera datum, mailadress och telefonnr här:
	e='info@villancico.se';
	t='30 43 29';

// (från http://www.pageresource.com/dhtml/ryan/part3-1.html)
	webmaster=' &copy; M Str&ouml;m';
	if(sprak=='en'){txt=webmaster;}
	else if(sprak=='es'){txt=webmaster;}
	else if(sprak=='sv'){txt=webmaster;}
	if(sprak=='sv'){tfnnr='Peter Pontvik: 08 - '+t;}
	else if((sprak=='es')||(sprak=='en')){tfnnr='Peter Pontvik: +46 (0)8 '+t;}
	mailadress='<a class="liten" onFocus="if(this.blur)this.blur()" href="mailto:'+e+'">'+e+'</a>';
	if(document.getElementById){
		document.getElementById('tfn').innerHTML=tfnnr;
		document.getElementById('mail').innerHTML=mailadress;
		document.getElementById('updat').innerHTML=txt;
	}else if(document.all){
		document.all['tfn'].innerHTML=tfnnr;
		document.all['mail'].innerHTML=mailadress;
		document.all['updat'].innerHTML=txt;
	}else if(document.layers){
		with(document.layers['vanster'].document.layers['tfn'].document){
			open();
			write('<p class="liten">'+tfnnr);
			close();
		}
		with(document.layers['vanster'].document.layers['mail'].document){
			open();
			write('<p class="liten">'+mailadress);
			close();
		}
		with(document.layers['vanster'].document.layers['updat'].document){
			open();
			write('<p class="liten">'+txt);
			close();
		}
	}
}

/*	
// tryck Home, och hamna i korrekt frameset. gar till startsidan om frameset redan e ok.
function fHome(sprak){
	if (top.location.href != 'http://www.villancico.se') {
    	top.location.href = 'http://www.villancico.se';
	} 
	else {
		//alert(sprak);
		location.href='index_'+sprak+'.html';
	}
}*/
	
function onLoader(){
	laddaBilder(); //preloading
	writeLayer(); // skriver in logo, tfn, mail och datum
	writeLogo(sprak);
	nr=1; // TEST
	
	/* inte nr = 1 ovan, utan plocka nr fr substring ...
	alert(document.location.search.substring(0,1));
	if (document.location.search.substring(0,1) != '?'){ // = finns sub$?
		nr=document.location.search.substring(6); // nr blir = siffran i sub$
		alert(nr);
	} else {
		nr=6;
	}
	*/

	fBild(nr); //skriver in img-taggen i bildens <div>. fBildStart kör bara fBild ... som inte funkar att köra direkt!?

	if(document.getElementById){ // Rödfärga ettan i submenyn OM browsern tar elementById/all (ej NS4):
		document.getElementById('submeny1').style.color='#006633';
	}else if(document.all){
		document.all['submeny1'].style.color='#006633';
	}
}

// skriver in logotaggen, inte pa indexsidan = inte i 'writeLayer()' som körs där:
function writeLogo(sprak){
	logotagg='<a onFocus="if(this.blur)this.blur()" href="index_'+sprak+'.html"><img src="../bild/logo320.gif" border=0 width=320 height=86></a>';
	if(document.getElementById){
		document.getElementById('logo').innerHTML=logotagg;
	}else if(document.all){
		document.all['logo'].innerHTML=logotagg;
	}else if(document.layers){
		with(document.layers['vanster'].document.layers['logo'].document){
		open();
		write(logotagg);
		close();
		}
	}
}

// FLASH POPUPS:
// anv bara pa lyssnasidor:
if (sida='lyssna'){
	// skriv in swf-titlarna ( - .swf/.html):
	swf1='aleph';
	swf2='bacas';
	swf3='hyhyhy';
	swf4='aquiaqui';
	swf5='convidando';
	swf6='sielamor';
	swf7='tleycantimo';
	swf8='tarantela';
	// open embedded swfs, alla olika i samma window:
	function oFlash1(){put=window.open('../flash/'+swf1+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	function oFlash2(){put=window.open('../flash/'+swf2+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	function oFlash3(){put=window.open('../flash/'+swf3+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	function oFlash4(){put=window.open('../flash/'+swf4+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	function oFlash5(){put=window.open('../flash/'+swf5+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	function oFlash6(){put=window.open('../flash/'+swf6+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	function oFlash7(){put=window.open('../flash/'+swf7+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	function oFlash8(){put=window.open('../flash/'+swf8+'.html','flash','location=no,scrollbars=no,resizable=yes,width=210,height=10,left=' + (screenw * 0.5) + ',top=' + (screenh * 0.7));put.focus();}
	// used for placing the window:
	var screenw = screen.availWidth;
	var screenh = screen.availHeight;
}

/* byter färger i submenyn */
function subStyle(nr) {
	if(document.getElementById){
		document.getElementById('submeny1').style.color='#000000';
		document.getElementById('submeny2').style.color='#000000';
		document.getElementById('submeny3').style.color='#000000';
		document.getElementById('submeny4').style.color='#000000';
		document.getElementById('submeny5').style.color='#000000';
		document.getElementById('submeny6').style.color='#000000';
		document.getElementById('submeny7').style.color='#000000';
		document.getElementById('submeny8').style.color='#000000';
		document.getElementById('submeny'+nr).style.color='#006633';
	}
}

/********************************************************************************
Copyright (C) 1999 Thomas Brattli
This script is made by and copyrighted to Thomas Brattli at www.bratta.com
Visit for more great scripts. This may be used freely as long as this msg is intact!
I will also appriciate any links you could give me.
********************************************************************************/
//Default browsercheck, added to all scripts!
function checkBrowser(){
        this.ver=navigator.appVersion
        this.dom=document.getElementById?1:0
        this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
        this.ie4=(document.all && !this.dom)?1:0;
        this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
        this.ns4=(document.layers && !this.dom)?1:0;
        this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
        return this
}
bw=new checkBrowser()
//With nested layers for netscape, this function hides the layer if it's visible and visa versa
function showHide(div,nest){
        obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
        if(obj.visibility=='visible' || obj.visibility=='show') obj.visibility='hidden'
        else obj.visibility='visible'
}
//Shows the div
function show(div,nest){
        obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
        obj.visibility='visible'
}
//Hides the div
function hide(div,nest){
        obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
        obj.visibility='hidden'
}

// ta bort alla texter:
function hideAll(){
	hide('text1','hoger');
	hide('text2','hoger');
	hide('text3','hoger');
	hide('text4','hoger');
	hide('text5','hoger');
	hide('text6','hoger');
	hide('text7','hoger');
	hide('text8','hoger');
}

// gör en text synlig OCH byter bild:
function fSub(nr){
	hideAll();
	show('text'+nr,'hoger');
	subStyle(nr); 
	//alert('nr='+nr);
// här har jag ett problem med "barock i conq's spår" - bildvisning av cd8.jpg måste läggas in ...
	if (bilder != 0) { //fratt fimpa fText ... gick inte att va utan pga gomda subsidor! ... & fratt fToggle() ska funka!
		fBild(nr);
	}
}

// gör en text synlig men byter inte bild. 
function fText(nr){
	hideAll();
	show('text'+nr,'hoger');
	subStyle(nr);
}

// byter bild:
function fBild(nr) {
	bildtagg='<img border=0 width=360 height=270 src="../bild/'+sida+nr+'.jpg">';
   	if(document.layers){
		with(document.layers['vanster'].document.layers['bild'].document){
			open();
			write(bildtagg);
			close();
		}
	}else if(document.getElementById){
		document.getElementById('bild').innerHTML=bildtagg;
	}else if(document.all){
		document.all['bild'].innerHTML=bildtagg;
	}
}

// byter bild till vilken jpg som helst i mappen bild/blandat - utan speciella filnamn:
function fBildnamn(bildnamn) {
	bildtagg='<img border=0 width=360 height=270 src="../bild/blandat/'+bildnamn+'.jpg">';
   	if(document.layers){
		with(document.layers['vanster'].document.layers['bild'].document){
			open();
			write(bildtagg);
			close();
		}
	}else if(document.getElementById){
		document.getElementById('bild').innerHTML=bildtagg;
	}else if(document.all){
		document.all['bild'].innerHTML=bildtagg;
	}
}

// fixar css/resizebuggen i ns4 // borttagen ur <body>
function winResize() {
if(navigator.appName == "Netscape") {
	window.location.reload();}
}

// laddar bilderna som anges i function laddaBilder()
function preload(imgObj,imgSrc) {
	if (document.images)
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
}