// JavaScript Document

function getparm( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}



// these pages assume 2 parameters
var proj = getparm("project") ;
var project = ((!proj) ? 1 : proj ) ;  // if not project - default is project 1
var toppic = getparm("pic");

var thumb1=5, thumb2=6, thumb3=7;

function setthumbs( pic )
{   
// all projects that only have 3 pics?! 
if ((project == 2) || (project == 2)) {
	thumb1 = 1;
	thumb2 = 2;
	thumb3 = 3;
} else
{  
	thumb1 = x = (pic % 4) + 1 ;
	thumb2 = ((++x > 4)? x=1: x);
	thumb3 = ((++x > 4)? x=1: x);

/*
	1 - 234
	2 - 341
	3 - 412
	4 - 123
	
	if 3 pics - then let t3 be 'pic'
	
	1 - 123
	2 - 123
	3 - 123
	*/
}
} 

// Nextpage var
var lastproject = 9;
var maxprojects = 9;
// + makes it an integer!! 
var nextproject = ((+project+1 > maxprojects ) ? 1 : +project+1);

function goto_nextpage() {
	
	/* this needs fixing - for pojrect/pic */
	
// document.write("hello there"+nextproject);
fullURL = parent.document.URL;
prefixURL = fullURL.substring(0, fullURL.indexOf('?'));
// projectnum =  fullURL.substring(fullURL.indexOf('?')+1, fullURL.length);
// nextproject = project + 1;

// if (projectnum == lastproject ) {window.location = prefixURL+"?1"}; 

window.location = prefixURL+"?project="+nextproject;
}


if (!toppic) {toppic = 1};
setthumbs ( toppic );  
