function ThrowErrorPic(theimage,num){
		if(num ==1){
			theimage.src = "images/defaults/640px_defaultimage.gif";
		}else if(num==2){
			theimage.src = "images/defaults/320px_defaultimage.gif";
		}else if(num==9){
			theimage.src = "images/defaults/75pxHabitatDefault.gif";
		}else if(num==10){
			theimage.src = "../images/defaults/130px_agent.gif";
		}else{
			theimage.src = "images/defaults/130px_defaultimage.gif";
		}

}
function ShowLightBox(theimage,photonum){
currentPhoto=photonum;

	 document.getElementById('largeImage').src=theimage.src.replace('thumb','large');
	 document.getElementById('largeImageAlt').innerHTML=theimage.alt;
	 	//window.scroll(0,50);
		SetHighlight(currentPhoto);
	 show('lightBoxBlockerDiv');
	 
	
	 //alert(window.scrollY);
	 if(window.scrollY){
	 newtop=window.scrollY+20; // GECKO
	 }else{
		 // objectdump(document.documentElement); //IE
		//alert(document.documentElement.scrollHeight);
		newtop=document.documentElement.scrollTop+20;
	 }
	 document.getElementById('imageHolder').style.top=newtop+'px';
	show('imageHolder');
	
	
	
}
  
function HideLightBox(){
		hide('lightBoxBlockerDiv');
	hide('imageHolder');
	
	
}
  

function ChangePhoto(thesrc){
	//objectdump(thesrc);
	//alert(thesrc.name);
	//alert(thesrc.src.replace('thumb','large'));
	document.getElementById('largeImage').src=thesrc.src.replace('thumb','large');
	 document.getElementById('largeImageAlt').innerHTML=thesrc.alt;
	
	//alert(thesrc);	
	
}

function SetHighlight(num){
		//alert(num);
	for(i=0; i <= totalImages;i++){
		document.getElementById('numLink'+i).style.border='none';
	}
	
	document.getElementById('numLink'+num).style.border='solid #FFFFFF 1px;';
}

function SetPhoto(num){
	currentPhoto=num;
	SetHighlight(currentPhoto);
	
	ChangePhoto(document.getElementById('Photo'+currentPhoto));
}


function PreviousPhoto(){
			currentPhoto--;
			//alert(currentPhoto);
			//alert(totalImages);
			if(currentPhoto < 0 ){
				currentPhoto=totalImages;	
			}
				SetHighlight(currentPhoto);
			ChangePhoto(document.getElementById('Photo'+currentPhoto));
		
}

function NextPhoto(){
			currentPhoto++;
			//alert(currentPhoto);
			
			if(currentPhoto > totalImages){
				currentPhoto=0;	
			}
			SetHighlight(currentPhoto);
			ChangePhoto(document.getElementById('Photo'+currentPhoto));
		
}





function ShowDn(num,nav,button,withwidget){
//alert(withwidget);
document.images[button].src=eval(nav+'_button_dn['+num+'].src');
if(withwidget !== ''){
//alert('fff'+withwidget+'ff');
	//document.images['widget0'].src= widget_dn[withwidget].src;
	document.images['widget' + num].src = widget_dn[withwidget].src;
}

}
function ShowUp(num,nav,button,withwidget){
document.images[button].src=eval(nav+'_button_up['+num+'].src');
if(withwidget  !== ''){
	document.images['widget' + num].src = widget_up[withwidget].src;
}
}


	 var cwin = null;
	 function openWin(theUrl, name, width, height, tools) {
	   cwin = window.open('', name,
	  tools+'width=' + width + ',height='+height);
	  if (cwin != null) {
	   if (cwin.opener == null)
	    cwin.opener = self;
	   cwin.location.href= theUrl;
	
	    cwin.focus();
	  }
	 }
	 function closeWin(theWin) {
	  theWin.close();
	 }
function show(object) 
  {
  if(navigator.vendor && navigator.vendor.indexOf("Apple") >=0){
  document.getElementById(object).style.display = 'inline-block';
  }else{
  document.getElementById(object).style.display = 'block';
  }
   
   document.getElementById(object).style.visibility = 'visible';
 
  }
           
 function hide(object) 
  {
  
   document.getElementById(object).style.display = 'none';
   document.getElementById(object).style.visibility = 'hidden';

  }
  function isEMailAddress(str)
{
		return isValidText(str,"^([\\w\\._-]+)@([\\w_-]+\\.)+([\\w_]+)$");
}







function isValidText(str,regex)
{
	if (window.RegExp){
		if (typeof(regex)=='string')
			regex=new RegExp(regex);
		return regex.test(str);
	}else{
		window.alert("RegExp not available!");
		return true;
	}
}
