/***********************************************
* Image Thumbnail viewer- © Dynamic Drive (www.dynamicdrive.com)
* Last updated Sept 26th, 03'. This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

// Modifisert av Vidar Ødegård for KRIK Sula (c) 2004 - 2005
// Omfatter nå både bilde- og videovisning

var ie=document.all
var ns6=document.getElementById&&!document.all
var webwidth=(14+776+14)/2

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function enlarge(which, e, position, imgwidth, imgheight, fotoalt, bilderarray){
if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+webwidth-imgwidth[which]/2 : ietruebody().scrollLeft+webwidth-imgwidth[which]/2
vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight[which]/2 : pgyoffset+ietruebody().clientHeight/2-imgheight[which]/2
if (window.opera && window.innerHeight) //compensate for Opera toolbar
vertpos=pgyoffset+window.innerHeight/2-imgheight[which]/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
}
crossobj.style.left=horzpos+"px"
crossobj.style.top=vertpos+"px"    

// Beregner størrelser
width2=25
width21=80
width22=10
width23=70
width24=40
width1=imgwidth[which]-width2-width21-width22-width23-width24
triks=imgheight[which]-2+4

bildenr=which+1

if(which==0) {
forrige=which
ftekst = ' -- '
}
else{
forrige=which-1
ftekst = ''
}

// Finner forrige/neste bilde
meste=Pic.length-1
videre=which-1+4

if(videre > meste) {
videre=meste-1+2
}

if(which==meste) {
neste=which
ntekst = ' -- '
}
else{
neste=which+1
ntekst = ''
}

if(fotoalt[which]=='Ungdomskoret.com&nbsp;portrett'){
ttekst = '&nbsp;<b></b>'
}
else if(imgwidth[which] < imgheight[which]){
ttekst = '&nbsp;<b>Ungdomskoret.com</b>'
}
else{
ttekst = '&nbsp;<b>Ungdomskoret.com</b>'
}

crossobj.innerHTML='<table width="'+imgwidth[which]+'" border="0" cellspacing="0" cellpadding="0"><tr><td width="'+width1+'"><div align="left" id="dragbar" width="'+width1+'">'+ttekst+'</div></td><td width="'+width21+'"><div width="'+width21+'" align="right" id="dragbar2" onClick="return enlarge(forrige,event,\'center\',Vidde,Hoyde,Navn,Pic)"><b><< '+ftekst+'</b>&nbsp;</div></td><td width="'+width22+'"><div width="'+width22+'" align="right" id="dragbar2">&nbsp;<b>|</b>&nbsp;</div></td><td width="'+width23+'"><div width="'+width23+'" align="left" id="dragbar2" onClick="return enlarge(neste,event,\'center\',Vidde,Hoyde,Navn,Pic)">&nbsp;<b>'+ntekst+' >></b></div></td><td width="'+width24+'"><div width="'+width24+'" align="right" id="dragbar2" onclick="SlideShow(\'bildefullskjerm.php?vis='+Pic[which]+'\')""><img class="u" src="images/fullskjerm_bilder.png" width="28" height="14" alt=""/></div></td><td width="'+width2+'"><div width="'+width2+'" align="right" id="dragbar2" onClick="closepreview()"><img class="u" src="images/kryss.png" width="28" height="14" alt=""/></div></td></tr><tr><td class="imgstrek" colspan="6"></td></tr></table><div style="position: absolute; left: 0px; top: '+triks+'px; width:'+imgwidth[which]+'px; height: 15px;" align="right" id="bildealt">&nbsp;</div><div style="position: absolute; left: 0px; top: '+triks+'px; width:'+imgwidth[which]+'px; height: 15px;" align="center" id="bildealt">'+bildenr+' av '+Pic.length+'</div><table width="'+imgwidth[which]+'" border="0" cellspacing="0" cellpadding="0"><tr><td class="lasterbilde" width="'+imgwidth[which]+'"><img onClick="return enlarge(neste,event,\'center\',Vidde,Hoyde,Navn,Pic)" alt="" class="u" src="'+Pic[which]+'"/></td></tr></table>'
crossobj.style.visibility="visible"
   preLoad2 = new Image()
   preLoad2.src = 'images/fullskjerm_bilder.png'
   preLoad3 = new Image()
   preLoad3.src = 'images/kryss.png'
   var preLoad = new Array()
   for (i = neste; i < videre; i++){
      preLoad[i] = new Image()
      preLoad[i].src = Pic[i]
   }

return false
}
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}

function venlarge(which, e, position, imgwidth, imgheight, fotoalt){
if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+webwidth-imgwidth/2 : ietruebody().scrollLeft+webwidth-imgwidth/2
vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
if (window.opera && window.innerHeight) //compensate for Opera toolbar
vertpos=pgyoffset+window.innerHeight/2-imgheight/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
}
crossobj.style.left=horzpos+"px"
crossobj.style.top=vertpos+"px"    

width2=25
width24=40
width1=imgwidth-width2-width24
triks=imgheight-4

ttekst = '&nbsp;<b>Ungdomskoret.com</b>'

crossobj.innerHTML='<table width="'+imgwidth+'" border="0" cellspacing="0" cellpadding="0"><tr><td width="'+width1+'"><div align="left" id="dragbar" width="'+width1+'">'+ttekst+'</div></td><td width="'+width24+'"><div width="'+width24+'" align="right" id="dragbar2" onclick="Fullskjerm()"><img class="u" src="images/fullskjerm_bilder.png" width="28" height="14" alt="Denne knappen er dessverre ikke støttet av alle nettlesere. Dersom den ikke fungerer kan du enten dobbelklikke på videoen eller høyreklikk, velge Zoom og Full skjerm"/></div></td><td width="'+width2+'"><div width="'+width2+'" align="right" id="dragbar2" onClick="closevideo()"><img class="u" src="images/kryss.png" width="28" height="14" alt=""/></div></td></tr><tr><td class="imgstrek" colspan="3"></td></tr></table><div style="position: absolute; left: 0px; top: '+triks+'px; width:'+imgwidth+'px; height: 15px;" align="right" id="bildealt">'+fotoalt+'&nbsp;&nbsp;</div><object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="Player" width="640" height="545"><param name="URL" value="'+which+'"><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="50"><param name="mute" value="0"><param name="uiMode" value="full"><param name="stretchToFit" value="1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="0"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=media&sba=plugin" filename="'+which+'" allowchangedisplaysize="1" width="640" height="550" enabletracker="1" displaybackcolor="0" displayforecolor="0" showstatusbar="1" clicktoplay="1" showaudiocontrols="1" showpositioncontrols="1" showtracker="1" showcontrols="1" animationatstart="0" transparentatstart="1" autostart="1" alt="Film i Windows Media Player-format" name="Player"></embed></object>'
crossobj.style.visibility="visible"

return false
}
else
return true
}

function closevideo(){
crossobj.style.visibility="hidden"
crossobj.innerHTML=''
}

function closepreview(){
crossobj.style.visibility="hidden"
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+"px"
crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
