// junction to hide and show the focus areas detail box
function ShowHide(thediv){
					//show the box if hidden
   					if(document.getElementById(thediv).style.visibility=='hidden'){
    					document.getElementById(thediv).style.visibility='visible';
   						document.getElementById(thediv).style.display='block';
						document.getElementById('more_' + thediv).innerHTML='Close Details';
   					//hide the box
					}else{
    					document.getElementById(thediv).style.visibility='hidden';
    					document.getElementById(thediv).style.display='none';
						document.getElementById('more_' + thediv).innerHTML='More +';
   					}
  				} 
//function to make the cursor hand on the fake thumbnails
function makeHand(theItem) {
	theItem.style.cursor = 'hand';
}


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='tourphotos';
		xadjust=20;yadjust=-125;
	}else if (dir ==2){
		path='tourphotos';
		xadjust=-370;yadjust=-125;
	}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){
		//show
		theimage.src='images/'+path+'/'+src+'.jpg';
		//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';
	}


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

function sub_active(thediv){
	document.getElementById(thediv).style.backgroundImage='url(media/navon_arrow.gif)';
}
function sub_deactive(thediv){
	document.getElementById(thediv).style.backgroundImage='none';
}
function baseline(thenum){
			document.getElementById('sorter'+thenum).style.borderBottom='1px solid #ffffff';
}
function baseout(thenum){
			document.getElementById('sorter'+thenum).style.borderBottom='1px solid #000000';
}
function updatePic(divid,path,pic){
	strURL='includes/buildpic.php?pic='+pic+'&path='+path;
	divver(divid,strURL);

}
function updateSearchPic(divid,path,pic){
	strURL='includes/buildsearchpic.php?pic='+pic+'&path='+path;
	
	divver(divid,strURL);
}
function divver(divid,strURL) {
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
				updatevalues(self.xmlHttpReq.responseText,divid);
			}
		}
	self.xmlHttpReq.send('test');
}

function updatevalues(thevalue,divid){
	document.getElementById(divid).innerHTML=thevalue;
}


function ShowLightBox(imgsrc,photonum){
	currentPhoto=photonum;
	
		//alert(imgsrc);
	 document.getElementById('largeImage').src=imgsrc;
	 	//window.scroll(0,50);
	 show('imageBlocker');
	 
	
	 //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('imageBlocker');
	hide('imageHolder');
}
  
function ChangePhoto(thesrc){
	//objectdump(thesrc);
	//alert(thesrc.title);
	document.getElementById('largeImage').src=thesrc.title;
	
	//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));
	
			//GET SOME STUFF
			thetype=document.getElementById('type_'+currentPhoto).innerHTML;
			thepath=document.getElementById('path_'+currentPhoto).innerHTML;
			thefile=document.getElementById('pfile_'+currentPhoto).innerHTML;
			if(thetype=="updatePic"){
				updatePic('bigpic',thepath,thefile);
			}else{
				updateSearchPic('bigpic',thepath,thefile);
				
			}
}


function PreviousPhoto(){
			currentPhoto--;
			//alert(currentPhoto);
			//alert(totalImages);
			if(currentPhoto < 0 ){
				currentPhoto=totalImages;	
			}
				SetHighlight(currentPhoto);
			ChangePhoto(document.getElementById('Photo'+currentPhoto));
			//GET SOME STUFF
			thetype=document.getElementById('type_'+currentPhoto).innerHTML;
			thepath=document.getElementById('path_'+currentPhoto).innerHTML;
			thefile=document.getElementById('pfile_'+currentPhoto).innerHTML;
			if(thetype=="updatePic"){
				updatePic('bigpic',thepath,thefile);
			}else{
				updateSearchPic('bigpic',thepath,thefile);
				
			}
		
}

function NextPhoto(){
			currentPhoto++;
			//alert(currentPhoto);
			
			if(currentPhoto > totalImages){
				currentPhoto=0;	
			}
			SetHighlight(currentPhoto);
			ChangePhoto(document.getElementById('Photo'+currentPhoto));
			//GET SOME STUFF
			thetype=document.getElementById('type_'+currentPhoto).innerHTML;
			thepath=document.getElementById('path_'+currentPhoto).innerHTML;
			thefile=document.getElementById('pfile_'+currentPhoto).innerHTML;
			if(thetype=="updatePic"){
				updatePic('bigpic',thepath,thefile);
			}else{
				updateSearchPic('bigpic',thepath,thefile);
				
			}
}

