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 checkPassEmail(theform){
if(theform.email.value == ''){
	alert('Please enter your Email Address');
	theform.email.focus();
	return false;
}else if (!isEmailAddress(theform.email.value)){
	alert('Please enter a Valid Email Address');
	theform.email.focus();
	return false;
}
return true;
}
function fPass(){
if(document.getElementById('forgotPasswordForm').style.display =='none'){


show('forgotPasswordForm');
}else{
hide('forgotPasswordForm');
}


}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Cyanide_7 |  */
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}


function checkKey(e,theform){
   //event = event || window.event;
   //event=e;
   //alert(e.keyCode);
     if (e.keyCode == 13) {
        // alert('Enter key pressed');
		 checkLogin(theform);
        return false;
     }
     return true;
}
 

function stopRKey(evt) { 
  var evt = (evt) ? evt : ((event) ? event : null); 
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;} 
} 





function checkLogin(theform){

if(theform.username.value == ''){
	alert('Please Enter Your Username.');
	theform.username.focus();
	return false;
}
if(theform.password.value == ''){
	alert('Please Enter Your Password.');
	theform.password.focus();
	return false;
}

theform.submit();
}

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 isDate(str)
{
	var milliseconds=Date.parse(str);
	return !(isNaN(milliseconds));
}

function currencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return CommaFormatted(s);
}


function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}


function isNumber(str,allowFP)
{
	if (typeof(allowFP)=='undefined') allowFP=false;

	if (typeof(str)=='number'){
		if (allow_fp) return true;
		else return str==Math.floor(str);
	}

	if (typeof(str)!='string') return false;

 	str=trim(str);
	if (str.length==0) return false;

	var result=true;
	if (window.RegExp){
		var regstr="^[+-]?[0-9]*";
		if (allowFP) regstr+="\\.?[0-9]*([eE-][+-]?[0-9]+)?";
		regstr+="$";
		var reg = new RegExp(regstr);
		result=reg.test(str);
	}else{
		result=false;
	}
	return result;
}


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;
	}
}
function trim(s)
{
	if (typeof(s)=='string'){
		var i,len=s.length;
		for (i=len-1;i>=0 && s.charAt(i)<=' ';--i){}
		len=i+1;
		for (i=0;i<len && s.charAt(i)<=' ';++i){}
		if (i<len) s=s.substring(i,len);
		else s="";
	}
	return s;
}