var int;

function Show(img)
{	
	document.getElementById("largePic").src = img.src.replace("sma","stora");
	int=window.setInterval("wait()",50);
		
  
	document.getElementById("container1").style.display="none";		
}

function wait()
{
	
	if(document.getElementById("largePic").complete)
	{
		int=window.clearInterval(int);
		document.getElementById("container2a").style.display="block";		
  	document.getElementById("container2b").style.display="block";
	}
}

function Hide()
{
  if (document.getElementById("container2a").style.display == "block")
  {
		document.getElementById("container1").style.display="block";
    document.getElementById("container2a").style.display="none";
    document.getElementById("container2b").style.display="none";

		/*
    document.getElementById("container1").style.opacity=1;
    document.getElementById("container1").filters.alpha.opacity=100;
		*/
  }
}

function imgNavShow(location)
{
	switch (location)
	{
		case "prev":
		
		/*	document.getElementById("areaPrev").style.display="block";*/
			document.getElementById("areaPrev").style.visibility="";
		break;
	  case "next":
			/*document.getElementById("areaNext").style.display="block";*/
			document.getElementById("areaNext").style.visibility="";
		break;
		/*
	  case "close":
	  	document.getElementById("areaClose").style.display="block";
		break;
		*/
	} 
}

function imgNavHide(location)
{
	switch (location)
	{
		case "prev":
/*			document.getElementById("areaPrev").style.display="none";*/
						document.getElementById("areaPrev").style.visibility="hidden";
		break;
	  case "next":
	/*		document.getElementById("areaNext").style.display="none";*/
						document.getElementById("areaNext").style.visibility="hidden";
		break;
		/*
	  case "close":
	  	document.getElementById("areaClose").style.display="none";
		break;
		*/
	}  
}

function imgNavPrev()
{
  var activeImgsrc = document.getElementById("largePic").getAttribute("src");
  var activeImg = activeImgsrc.replace("stora","sma");
	var x;
	var imgNextLink;
	var imgThumbs = document.getElementsByName("thumbImage");
/*
  alert(activeImg);

	alert(imgThumbs.length)
*/	
	for( i = 0; i < imgThumbs.length; i++)
  {
    imgsrc = imgThumbs[i].getAttribute("src");		
    if(activeImg.indexOf(imgsrc) != -1)
		{
			 if(i == 0)
			 {
					document.getElementById("largePic").src = imgThumbs[imgThumbs.length -1].getAttribute("src").replace("sma","stora");
       }
       else
       {
         document.getElementById("largePic").src = imgThumbs[i-1].getAttribute("src").replace("sma","stora");
       }
    }
	}
}

function imgNavNext()
{	
//alert("startnext");
	var activeImgsrc = document.getElementById("largePic").getAttribute("src");
	
  var activeImg = activeImgsrc.replace("stora","sma");

	
	var imgThumbs = document.getElementsByName("thumbImage");
/*
	var x;
	var imgNextLink;

  alert(activeImgsrc);alert(activeImg);alert(imgThumbs.length);alert(imgThumbs[i].getAttribute("src") +" "+activeImg);
*/
	
	for( i = 0; i < imgThumbs.length; i++)
  {
		
		imgsrc = imgThumbs[i].getAttribute("src");		
	//	alert(activeImgsrc + "\n"+ imgsrc);
    if(activeImg.indexOf(imgsrc) != -1)
		{
			 if(i == imgThumbs.length -1)
			 {
					document.getElementById("largePic").src = imgThumbs[0].getAttribute("src").replace("sma","stora");
       }
       else
       {
         document.getElementById("largePic").src = imgThumbs[i+1].getAttribute("src").replace("sma","stora");
       }
    }
	}
}

 /*
function starttimer()
{
  
  container2.style.width = container2.style.width + 1%;
  if(container2.width == 100%)
  {
    clearTimeout(timer);
  }
  else
  {
    timer=setTimeout("starttimer()",10);
  }
  
}
 */

function loadGalleryPage()
{	
	/*
	int=window.setInterval("wait2()",50);
	*/
	/*alert("sdfg");*/
	document.getElementById("container2a").style.display="none";
	document.getElementById("container2b").style.display="none";
  document.getElementById("container1").style.display="block";	 

	document.getElementById("areaNext").style.visibility="hidden";
	document.getElementById("areaPrev").style.visibility="hidden";		  
}

function wait2()
{
	alert("false");
	var imgThumbs = document.getElementsByName("thumbImage");
	var imgSize = imgThumbs.length;
	var done = true;
	for( i = 0; i < imgThumbs.length; i++)
  {	
	//alert(imgThumbs[i].complete);
	
    if(imgThumbs[i].complete == false)
		{
			 done = false;
    }
		
	}
	
	if(done = true)
	{
		int=window.clearInterval(int);
		document.getElementById("container1").style.display="block";		
		document.getElementById("container2a").style.display="none";		
	}
}


function mainOpacitySet(image)
{
	image.style.opacity=0.4;
	image.filters.alpha.opacity=40;
}


function mainOpacityClear(image)
{
	image.style.opacity=1;
	image.filters.alpha.opacity=100;
}



function galleryOpacitySet(image)
{
	image.style.opacity=0.7;
	image.filters.alpha.opacity=70;
}


function galleryOpacityClear(image)
{
	image.style.opacity=1;
	image.filters.alpha.opacity=100;
}


function displayMenu()
{
	bas = "http://www.ulrikafinnberg.com/"
	  document.write('<table style="width:100%;"> <tr> <td align="center">');
		document.write('<table class="menu">');
  document.write('<tr>');
  document.write('<td class="meny" onclick="window.location.assign(\'http://www.ulrikafinnberg.com/fotografen/index.html\')\;">');
    document.write('Fotografen');    
  document.write('</td>');
  document.write('<td class="meny" onclick="window.location.assign(\'http://www.ulrikafinnberg.com/galleri/index.html\')\;">');
        document.write('Portfolio');
  document.write('</td>');
  document.write('<td class="meny" onclick="window.location.assign(\'http://www.ulrikafinnberg.com/kvinnfolki/index.html\')\;">');
    document.write('Kvinnfolki');
  document.write('</td>');
  document.write('<td class="meny" onclick="window.location.assign(\'http://www.ulrikafinnberg.com/kontakt/index.html\')\;">');
    document.write('Kontakt');
  document.write('</td>');
  document.write('<td class="meny" onclick="window.open(\'http://ulrikafinnberg.blogg.se\')\;">');
    document.write('Blogg');
  document.write('</td>');
	document.write('<td class="menyIDOVOODOO" onclick="window.open(\'http://www.idovoodoo.se\')\;">');
    document.write('IDOVOODOO');
  document.write('</td>');
  document.write('</td>');
	document.write('<td class="meny" onclick="window.open(\'http://www.nordicphotos.com/se/PhotographerImage/648\')\;">');
    document.write('NordicPhotos');
  document.write('</td>');
  document.write('</tr>');
  document.write('</table>');
	  document.write('</td></tr></table>');
}

function change(imageId,seekString,changeString)
{
	
		var source = document.getElementById(imageId).src;
		var source1 = source.replace(seekString,changeString);
		document.getElementById(imageId).src = source1;
		
}

var message="Alla rättigheter ägs av Ulrika Finnberg\nAll rights reserved to Ulrika Finnberg\nCopyrighted to Ulrika Finnberg";


///////////////////////////////////
function clickIE4()
{
  if (event.button==2)
  {
    alert(message);
    return false;
  }
}

function clickNS4(e)
{
  if (document.layers||document.getElementById&&!document.all)
  {
    if (e.which==2||e.which==3)
    {
      alert(message);
      return false;
    }
  }
}

if (document.layers)
{
  document.captureEvents(Event.MOUSEDOWN);
  document.onclick=clickNS4;
}
else if (document.all&&!document.getElementById)
{
  document.onclick=clickIE4;
}

document.oncontextmenu= new Function("alert(message);return false")