document.onkeyup = KeyCheck;       
id=null;
flag=false;

function KeyCheck(e)
{

   var KeyID = (window.event) ? event.keyCode : e.keyCode;
   switch(KeyID)
   {
      case 37:
      previous(images_array);
      break;
      
      case 38:
      up();
      break;
      
      case 39:
      next(images_array);
      break;
      
      case 40:
      down();
      break;
   }
}

function Register() {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.JoinMailingList.email.value)) {
    var email = document.JoinMailingList.email.value
		open_pop('submission.php?email='+email+'','MailList','420','350','no','no');
    return true;
  } else { alert("Invalid E-mail Address! Please re-enter.")
	return (false)
  }
}

function open_main_WDW(theURL,winName,w,h,scroll,resize) { //v2.0
var winl = (screen.width - w) / 2 ;
var wint = (screen.height - h) / 2 - 30;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize+''
win=window.open(theURL,winName,winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function open_pop(theURL,winName,w,h,scroll,resize) { //v2.0
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize+''
win=window.open(theURL,winName,winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function trajlon(imgName) {
document[imgName].src= eval(imgName + "on.src");
}
   
function trajloff(imgName) {
document[imgName].src= eval(imgName + "off.src");
}
 
function imgtargetswap(imgName, imgObjName) {
document[imgName].src = eval(imgObjName + ".src");
}
 
function trajlongallery(imgName) {
document["s" + imgName].src= eval("s" + imgName + "on.src");
}
   
function trajloffgallery(imgName) {
   if (document.getElementById('iid').innerText != imgName) {
    document["s" + imgName].src= eval("s" +imgName + "off.src");
    }
}

function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

var fade_started=0; 
var imagetest; 
var target_image; 
function fadeTransStart(id, imagefile, t1) { 
	if (fade_started==0 && document.getElementById(id).src != imagefile) { 
	fadeTrans(id, imagefile, t1); 
	} 
} 

function fadeTransComplete()  { 
fade_started=0; 
} 

function fadeTrans(id, imagefile, t1) { 
	if(fade_started==0) { 
	fade_started=1; 
	opacity(id,99,1,t1); 
	
	setTimeout("fadeTransEnd('"+id+"', "+t1+")",t1); 
	} 
} 

function fadeTransEnd (id, t1) {
	document.getElementById(id).src = imagetest; 
	opacity(id,1,99,t1); 
	setTimeout("fadeTransComplete()",t1); 
}

function opacity(id, startOpac, endOpac, t1) { 
    var speed = Math.round(t1 / 100); 
    var timer = 0;
    if (startOpac > endOpac) {
     	for(i = startOpac; i >= endOpac; i-=2) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
     	}
     } else if (startOpac < endOpac) {
     	for(i = startOpac; i <= endOpac; i+=2) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
     	}
     }
}

function imgtargetswapmenu(imgObjName, target_image) {

	if (typeof document.getElementById('mid').innerText == 'undefined') {
	document.getElementById('mid').innerText = originalid;
	} 
lastimgObjName = document.getElementById('mid').innerText;
document.getElementById('mid').innerText = imgObjName;
/*document.images["m" + imgObjName].src = eval("s" + imgObjName + "on.src");*/
 	if (imgObjName != lastimgObjName) {
/*	document["s" + lastimgObjName].src= eval("s" + lastimgObjName + "off.src");*/
 	imagetest = eval("m" + imgObjName + ".src");
 		if (fade_started == 1) {
 		imagetest = eval("m" + imgObjName + ".src");
 		 setTimeout("fadeTransStart('menuimage', imagetest, '600')", 600); 
 		} else {
 		imagetest = eval("m" + imgObjName + ".src");
 		setTimeout("fadeTransStart('menuimage', imagetest, '600')", 300);
 		}
 	}
}


function imgtargetswapgallery(imgObjName, newid, originalid, target_image) {
id = parseInt(newid);
	if (typeof document.getElementById('iid').innerText == 'undefined') {
	document.getElementById('iid').innerText = originalid;
	} 
lastimgObjName = document.getElementById('iid').innerText;
document.getElementById('iid').innerText = imgObjName;
document.images["s" + imgObjName].src = eval("s" + imgObjName + "on.src");
 	if (imgObjName != lastimgObjName) {
 	document["s" + lastimgObjName].src= eval("s" + lastimgObjName + "off.src");
 	imagetest = eval("m" + imgObjName + ".src");
 		if (fade_started == 1) {
 		imagetest = eval("m" + imgObjName + ".src");
 		setTimeout("fadeTransStart('mainimage', imagetest, '600')", 600);
 		} else {
 		imagetest = eval("m" + imgObjName + ".src");
 		setTimeout("fadeTransStart('mainimage', imagetest, '600')", 300);
 		}
 	}
}

function next(images_array, target_image) {
if (typeof document.getElementById('iid').innerText == 'undefined') {
document.getElementById('iid').innerText = images_array[0][0];
}
if (flag==false) {
flag = true;
	if (id >= images_array.length-1) {
	id = 0;
	} else {
	id = id + 1;
	}
	
document.images["s" + document.getElementById('iid').innerText].src = eval("s" + document.getElementById('iid').innerText + "off.src");
document.images["s" + images_array[id][0]].src = eval("s" + images_array[id][0] + "on.src");
imagetest = eval("m" + images_array[id][0] + ".src");
fadeTransStart('mainimage', eval("m" + images_array[id][0] + ".src"), '600');
document.getElementById('iid').innerText = images_array[id][0];
setTimeout("flag=false", 1200);
}
}
 
function previous(images_array, target_image) {
if (typeof document.getElementById('iid').innerText == 'undefined') {
document.getElementById('iid').innerText = images_array[0][0];
}
if (flag==false) {
flag = true;
	if (id <= 0) {
	id = images_array.length-1;
	} else {
	id = id - 1;
	}
document.images["s" + document.getElementById('iid').innerText].src = eval("s" + document.getElementById('iid').innerText + "off.src");
document.images["s" + images_array[id][0]].src = eval("s" + images_array[id][0] + "on.src");
imagetest = eval("m" + images_array[id][0] + ".src");
fadeTransStart('mainimage', eval("m" + images_array[id][0] + ".src"), '600');
document.getElementById('iid').innerText = images_array[id][0];
setTimeout("flag=false", 1200);
}
}

function imgswap(primary, imgname1)
{
eval("document." + primary + ".src = '" + imgname1 + "'");
}	

function fullscreen()
 {
 if (window.screen) {
window.moveTo(0,0);
window.resizeTo(screen.width, screen.height);
ajlPhoto = 'photographer/'; 
setTimeout('document.location.replace(ajlPhoto)',3000);
}
}



/****************************************************************************
DHTML library from DHTMLCentral.com
*   Copyright (C) 2001 Thomas Brattli 2001
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by Thomas Brattli 2001
***************************************************************************/

//Browsercheck (needed) ***************
function lib_bwcheck(){
  this.ver=navigator.appVersion
  this.agent=navigator.userAgent
  this.dom=document.getElementById?1:0
  this.opera5=this.agent.indexOf("Opera 5")>-1
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6
  this.mac=this.agent.indexOf("Mac")>-1
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
  return this
}
bw=new lib_bwcheck() //Browsercheck object

//Debug function ******************
function lib_message(txt){alert(txt); return false}

//Lib objects  ********************
function lib_obj(obj,nest){
  if(!bw.bw) return lib_message('Old browser')
  nest=(!nest) ? "":'document.'+nest+'.'
  this.evnt=bw.dom? document.getElementById(obj):
    bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;
  if(!this.evnt) return lib_message('The layer does not exist ('+obj+')'
    +'- \nIf your using Netscape please check the nesting of your tags!')
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;
  this.ref=bw.dom||bw.ie4?document:this.css.document;
  this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;
  this.y=parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0
  this.w=this.evnt.offsetWidth||this.css.clip.width||
    this.ref.width||this.css.pixelWidth||0;
  this.h=this.evnt.offsetHeight||this.css.clip.height||
    this.ref.height||this.css.pixelHeight||0
  this.c=0 //Clip values
  if((bw.dom || bw.ie4) && this.css.clip) {
  this.c=this.css.clip; this.c=this.c.slice(5,this.c.length-1);
  this.c=this.c.split(' ');
  for(var i=0;i<4;i++){this.c[i]=parseInt(this.c[i])}
  }
  this.ct=this.css.clip.top||this.c[0]||0;
  this.cr=this.css.clip.right||this.c[1]||this.w||0
  this.cb=this.css.clip.bottom||this.c[2]||this.h||0;
  this.cl=this.css.clip.left||this.c[3]||0
  this.obj = obj + "Object"; eval(this.obj + "=this")
  return this
}

//Moving object to **************
lib_obj.prototype.moveIt = function(x,y){
  this.x=x;this.y=y; this.css.left=x;this.css.top=y
}

//Clipping object to ******
lib_obj.prototype.clipTo = function(t,r,b,l,setwidth){
  this.ct=t; this.cr=r; this.cb=b; this.cl=l
  if(bw.ns4){
    this.css.clip.top=t;this.css.clip.right=r
    this.css.clip.bottom=b;this.css.clip.left=l
  }else{
    if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
    this.css.clip="rect("+t+","+r+","+b+","+l+")";
    if(setwidth){this.css.pixelWidth=this.css.width=r;
    this.css.pixelHeight=this.css.height=b}
  }
}

//Drag drop functions start *******************
dd_is_active=0; dd_obj=0; dd_mobj=0
function lib_dd(){
  dd_is_active=1
  if(bw.ns4){
    document.captureEvents(Event.MOUSEMOVE|Event.MOUSEDOWN|Event.MOUSEUP)
  }
  document.onmousemove=lib_dd_move;
  document.onmousedown=lib_dd_down
  document.onmouseup=lib_dd_up
}
lib_obj.prototype.dragdrop = function(obj){
  if(!dd_is_active) lib_dd()
  this.evnt.onmouseover=new Function("lib_dd_over("+this.obj+")")
  this.evnt.onmouseout=new Function("dd_mobj=0")
  if(obj) this.ddobj=obj
}
lib_obj.prototype.nodragdrop = function(){
  this.evnt.onmouseover=""; this.evnt.onmouseout=""
  dd_obj=0; dd_mobj=0
}
//Drag drop event functions
function lib_dd_over(obj){dd_mobj=obj}
function lib_dd_up(e){dd_obj=0}
function lib_dd_down(e){ //Mousedown
  if(dd_mobj){
    x=(bw.ns4 || bw.ns6)?e.pageX:event.x||event.clientX
    y=(bw.ns4 || bw.ns6)?e.pageY:event.y||event.clientY
    dd_obj=dd_mobj
    dd_obj.clX=x-dd_obj.x;
    dd_obj.clY=y-dd_obj.y
  }
}
function lib_dd_move(e,y,rresize){ //Mousemove
  x=(bw.ns4 || bw.ns6)?e.pageX:event.x||event.clientX
  y=(bw.ns4 || bw.ns6)?e.pageY:event.y||event.clientY
  if(dd_obj){
    nx=x-dd_obj.clX; ny=y-dd_obj.clY
    if(dd_obj.ddobj) dd_obj.ddobj.moveIt(nx,ny)
    else dd_obj.moveIt(nx,ny)
  }
  if(!bw.ns4) return false
}
//Drag drop functions end *************

function createUserVerify() {
  if (document.submitnewuser.Upassword.value.length < 6) {
    alert("Password too short! Please must be atleast 6 characters");
    return false;
  }
  if (document.submitnewuser.Upassword.value != document.submitnewuser.Upasswordcheck.value) {
    alert("Password incorrect! Please verify password");
    return false;
  }
  if (document.submitnewuser.name.value == "") {
    alert("Please fill in a name");
    return false;
  }
  if (document.submitnewuser.Uusername.value == "") {
    alert("Please fill in a Username/Email");
    return false;
  }
  submitnewusermsg="Please verify the information you entered:\n Name: " + document.submitnewuser.name.value + "\n Username/Email: " + document.submitnewuser.Uusername.value + "\n"
  return confirm(submitnewusermsg);
}

function assignVerify() {
  if (document.assigning.uid.value == "#") {
    alert("Please assign a Client");
    return false;
  }
  if (document.assigning.pid.value == "#") {
    alert("Please assign a Project");
    return false;
  }
}

function newProjectVerify() {
  if (document.submitnewproject.name.value == "") {
    alert("Please input a name for the project");
    return false;
  }
}


function deleteUserVerify() {	

  if (document.deleteuser.uid.value == "#") {
    alert("Please select a user to delete");
    return false;
  }
  return confirm('Are you sure you want to delete this user? ')
}
