browserOK = true;
pics = new Array();

if (browserOK) {
var nm=navigator.appName+navigator.appVersion;
browserOK=((nm.indexOf("Netscape3.")>-1||nm.indexOf("Netscape4.")>-1||nm.indexOf("Explorer4.")>-1)?1:0);
}

var objCount = 0; // number of (changing) images on web-page

function preload(name, first, second) {

  // preload images and place them in an array

  if (browserOK) {
    pics[objCount] = new Array(3);
    pics[objCount][0] = new Image();
    pics[objCount][0].src = first;
    pics[objCount][1] = new Image();
    pics[objCount][1].src = second;
    pics[objCount][2] = name;
    objCount++;
  }
}

function on(name){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null)
        if (name != pics[i][2]) {
          // set back all other pictures
          if (pics[i][0].complete)
            document.images[pics[i][2]].src = pics[i][0].src;
        } else {
            // show the second image because cursor moves across this image
            if (pics[i][1].complete)
              document.images[pics[i][2]].src = pics[i][1].src;
        }
    }
  }
}

function off(){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      // set back all pictures
      if (document.images[pics[i][2]] != null)
        if (pics[i][0].complete)
            document.images[pics[i][2]].src = pics[i][0].src;
    }
  }
}

preload("nav1", "images/nav1.jpg", "images/nav1a.jpg");
preload("nav2", "images/nav2.jpg", "images/nav2a.jpg");
preload("nav3", "images/nav3.jpg", "images/nav3a.jpg");
preload("nav4", "images/nav4.jpg", "images/nav4a.jpg");
preload("nav5", "images/nav5.jpg", "images/nav5a.jpg");
preload("nav6", "images/nav6.jpg", "images/nav6a.jpg");


//textspot array
var swaptext = new Array();
swaptext[1] = "this is a text link 1";
swaptext[2] = "this is a text link 2";
swaptext[3] = "this is a text link 3";
swaptext[4] = "";

function changeText (textID, textMsg) {

  document.all(textID).innerText = textMsg;

}

function OpenWindow(t,p){
        var myUrl = t;
        var params = p;
        var newWindow = window.open( myUrl, '_showit', params );
        newWindow.focus();
}

var numPages = 0, curPage = 0;

function closeGallery() {
	jQuery('#overlay').stop().animate({opacity:'0.0'},500,function() {
		jQuery('#overlay').css({display:'none'});
	});
	jQuery('#gallery').css({display:'none'});
}

function openGallery(id,num) {
	jQuery('#overlay').stop().css({height:jQuery(document).height()+'px',cursor:'pointer',opacity:'0.0',display:'block'}).animate({opacity:'0.7'},500);
	//jQuery('#gallery').stop().css({top:(jQuery(document).scrollTop()+jQuery(window).height()/2)+'px',opacity:'0.0',display:'block'}).animate({opacity:'1'},500);
	jQuery('#gallery').stop().css({top:(jQuery(document).scrollTop()+jQuery(window).height()/2)+'px',display:'block'});
	jQuery('#overlay').click(function() {
		jQuery('#overlay').stop().animate({opacity:'0.0'},500,function() {
			jQuery('#overlay').css({display:'none'});
		});
		jQuery('#gallery').css({display:'none'});
/*
		jQuery('#gallery').stop().animate({opacity:'0.0'},500,function() {
			jQuery('#gallery').css({display:'none'});
		});
*/
	});
	numPages = Math.ceil(num/6); curPage = 0;
	jQuery.post('gallery.php', {action:'gallery',id:id}, function(data) {
		jQuery('#border').attr({innerHTML:data});
		if (numPages > 1) {
			jQuery('#prev').css({backgroundPosition:'-96px 0px',cursor:'default'});
			jQuery('#next').css({backgroundPosition:'0px 0px',cursor:'pointer'});
			document.getElementById('prev').onclick = function() { };
			document.getElementById('next').onmouseover = function() { this.style.backgroundPosition = '-32px 0px'; };
			document.getElementById('next').onmouseout = function() { this.style.backgroundPosition = '0px 0px'; };
			document.getElementById('next').onclick = function() { slide(1); };
		} else {
			jQuery('#prev').css({backgroundPosition:'-96px 0px',cursor:'default'});
			jQuery('#next').css({backgroundPosition:'-96px 0px',cursor:'default'});
			document.getElementById('prev').onclick = function() { };
			document.getElementById('next').onclick = function() { };
		}
	});
}

function slide(dir) {
	curPage = curPage + dir;
	jQuery('#list').animate({left:(-curPage*624)+'px'},500);

	if (curPage == 0) {
		jQuery('#prev').css({backgroundPosition:'-96px 0px',cursor:'default'});
		document.getElementById('prev').onmouseover = function() {  };
		document.getElementById('prev').onmouseout = function() {  };
		document.getElementById('prev').onclick = function() { };
		jQuery('#next').css({backgroundPosition:'0px 0px',cursor:'pointer'});
		document.getElementById('next').onmouseover = function() { this.style.backgroundPosition = '-32px 0px'; };
		document.getElementById('next').onmouseout = function() { this.style.backgroundPosition = '0px 0px'; };
		document.getElementById('next').onclick = function() { slide(1); };

	} else if (curPage == numPages-1) {
		jQuery('#prev').css({backgroundPosition:'0px 0px',cursor:'pointer'});
		document.getElementById('prev').onmouseover = function() { this.style.backgroundPosition = '-32px 0px'; };
		document.getElementById('prev').onmouseout = function() { this.style.backgroundPosition = '0px 0px'; };
		document.getElementById('prev').onclick = function() { slide(-1); };
		jQuery('#next').css({backgroundPosition:'-96px 0px',cursor:'default'});
		document.getElementById('next').onmouseover = function() {  };
		document.getElementById('next').onmouseout = function() {  };
		document.getElementById('next').onclick = function() { };
	} else {
		jQuery('#prev').css({backgroundPosition:'0px 0px',cursor:'pointer'});
		document.getElementById('prev').onmouseover = function() { this.style.backgroundPosition = '-32px 0px'; };
		document.getElementById('prev').onmouseout = function() { this.style.backgroundPosition = '0px 0px'; };
		document.getElementById('prev').onclick = function() { slide(-1); };
		jQuery('#next').css({backgroundPosition:'0px 0px',cursor:'pointer'});
		document.getElementById('next').onmouseover = function() { this.style.backgroundPosition = '-32px 0px'; };
		document.getElementById('next').onmouseout = function() { this.style.backgroundPosition = '0px 0px'; };
		document.getElementById('next').onclick = function() { slide(1); };
	}
}