// JavaScript Document

	var objPopUp = null;
	
	function toogle(objectID, ImageName){
  

	
	mainimage = document.getElementById('medimage');
	mainimage.src = 'images/' + ImageName;

//downloadhires link tag for hires photo
    
	downloadlink = document.getElementById('downloadhires');
	link = 'checkcookie(' + "'images/" + ImageName + "');return false" ;   	
	
	downloadlink.attributes['onclick'].value = link;
	objPopUp = document.getElementById(objectID);
		objPopUp.className = "navon";

	//loop through the 6 ids to set the others
	//var myobject;
  
	
	photolinks = document.getElementById('leftthumbs').getElementsByTagName('a');

	var alink;
	for(i=0; i<photolinks.length; i++)
	{
		
		//alert(alink);
		//mylink = photolinks[i].getElementsByTagName('a')[0];
		if(photolinks[i].id != objectID)
		{
			alink = photolinks[i].id;
			//alert(alink);
			photolinks[i].className = "navoff";
		} 
	}

	
}  //End of toogle function

function next(){
	
	var currentid = 1;
	photolinks = document.getElementById('leftthumbs').getElementsByTagName('a');

	var alink;
	for(i=0; i<photolinks.length; i++)
	{
		
			//photolinks[i].className = "navoff";
		    if (photolinks[i].className == "navon")
			{
				alink = i + 1;
				if(alink >= photolinks.length)
				{
				  alink = 0;
				}
				photolinks[i].className = "navoff";
				
			}
		
	}

	photolinks[alink].className = "navon";
	
	
	mainimage = document.getElementById('medimage');
	
	theimage = photolinks[alink].getAttribute('limage');
	mainimage.src = 'images/' + theimage;
	
	
	downloadlink = document.getElementById('downloadhires');
	link = 'checkcookie(' + "'images/" + theimage + "');return false" ;   	
	
	downloadlink.attributes['onclick'].value = link;
	
}
function previous(){
	
	
	photolinks = document.getElementById('leftthumbs').getElementsByTagName('a');

	var alink;
	for(i=0; i<photolinks.length; i++)
	{
		
			//photolinks[i].className = "navoff";
		    if (photolinks[i].className == "navon")
			{
				alink = i - 1;
				//alert(alink);
				if(alink <= 0)
				{
				  alink = photolinks.length - 1;
				}
				photolinks[i].className = "navoff";
				
			}
		
	}

	photolinks[alink].className = "navon";
	
	
	mainimage = document.getElementById('medimage');
	theimage = photolinks[alink].getAttribute('limage');
	mainimage.src = 'images/' + theimage;
		downloadlink = document.getElementById('downloadhires');
	link = 'checkcookie(' + "'images/" + theimage + "');return false" ;   	
	
	downloadlink.attributes['onclick'].value = link;
	
}


function checkcookie(detail)

{
  var cookieValue = "";

  var search = 'media' + "=";
	
  if(document.cookie.length > 0)

  { 

    offset = document.cookie.indexOf(search);

    if (offset != -1)

    { 

      offset += search.length;

      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))

    }

  }
  
  if (cookieValue.length >= 4)
  {
	  detail = detail.replace(/-l/,"");
	  detail = 'saveas.asp?x=' + detail;
	  location=detail;

	
  }
  else
  {
	
	 //Media cookie does not exist, redirect to regrisration form
   	location = 'HiRes Download';
  }

}

function showdiv(id){
  infobox = document.getElementById(id);
  infobox.style.visibility = 'visible';
}

function hidediv(id){
  infobox = document.getElementById(id);
  infobox.style.visibility = 'hidden';
}
