// JavaScript Document


function CloseLightBox(){
	
	if(document.getElementById('LightBox')){
		document.getElementById('lightBoxBlockerDiv').style.display='none';
		document.getElementById('lightBoxBlockerDiv').style.visibility='hidden';
		
		document.getElementById('LightBox').style.display='none';
		document.getElementById('LightBox').style.visibility='hidden';
	}
}

var currentPhoto=0;
function LoadImage(name){
//if(document.getElementById('middleimage')){
//document.getElementById('middleimage').src='cms/image_bank/mediumcrop/'+name;
//}
}

function ShowLightBox(photonum){
	currentPhoto=photonum;
	
	if(document.getElementById('LightBox')){
		document.getElementById('lightBoxBlockerDiv').style.display='block';
		document.getElementById('lightBoxBlockerDiv').style.visibility='visible';
		document.getElementById('LightBox').style.display='block';
		document.getElementById('LightBox').style.visibility='visible';
		//alert(document.scroll);
		window.scroll(0,50);
		//SetHighlight(currentPhoto);
		
		ChangePhoto(document.getElementById('Photo'+currentPhoto),currentPhoto);
		
		
		
		
	}
}

function ChangePhoto(thesrc,num){
	//objectdump(thesrc);
	//alert(num);
	//alert(thesrc.title);
	if(thesrc.title != ''){
		document.getElementById('LightBoxImage').src='cms/image_bank/large/'+thesrc.title;
		//move the arrows
		imgwidth=document.getElementById('LightBoxImage').width;
		imgheight=document.getElementById('LightBoxImage').height;
		//alert(imgheight);
		left=(640-imgwidth)/2;
		document.getElementById('PreviousImage').style.left=left+'px';
		document.getElementById('PreviousImage').style.height=imgheight+'px';
		//	alert('newleft'+ left);
		left=left+(imgwidth-100);
		document.getElementById('NextImage').style.left=left+'px';
		document.getElementById('NextImage').style.height=imgheight+'px';
	
		
		
		//alert('newleft'+ left);
	}else{
		document.getElementById('LightBoxImage').src='cms/image_bank/large/'+thesrc.name;
	}
	//alert(thesrc);
	//document.getElementById('photoalt').innerHTML=alttags[num];
	
}

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){
	//alert('asdf');
	currentPhoto=num;
	//SetHighlight(currentPhoto);
	
	ChangePhoto(document.getElementById('Photo'+currentPhoto),currentPhoto);
}


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

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




function ThrowErrorPic(theimage,num){
		if(num ==1){
			theimage.src = "images/tourphotos/noimage.jpg";
		}else if(num==2){
			theimage.src = "images/NoImage_MEDIUM.gif";
		}else{
			theimage.src = "images/NoImage_ICON.gif";
		}

}
function ShowImageThumb(number,src,dir){
	if(dir==1){
		path='small';
		xadjust=-72;yadjust=-15;
	}else if (dir ==2){
		path='medium';
		xadjust=5;yadjust=-25;
	}else if (dir ==3){
		path='large';
		xadjust=-72;yadjust=-15;
	}else{
		path='thumb';
		xadjust=-72;yadjust=-15;
	}
	thediv=document.getElementById('imgHolder');
	theimage=document.getElementById('imgHolderImage');
	if(number == 1){
		//show
		theimage.src='cms/image_bank/'+path+'/'+src;
		//alert('cms/image_bank/'+path+'/'+src);
		thediv.style.left=document.cursorX+xadjust;
		thediv.style.top=document.cursorY+yadjust;
		thediv.className='ShowImageDiv';
				
	}else{
		//hide
		thediv.className='hiddenDiv';
	}


}
// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}
function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    //return cursor;
	document.cursorX=cursor.x;
	document.cursorY=cursor.y;
}
document.onmousemove=getPosition;
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 getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    //return cursor;
	document.cursorX=cursor.x;
	document.cursorY=cursor.y;
}
document.onmousemove=getPosition;



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;
	}
}


