function handpointer(src) {
	if (navigator.appName.indexOf("Internet Explorer") == -1) {
		src.style.cursor = "pointer";
	} else {
		src.style.cursor = "hand";
	}
}

function openwin(popurl, ww, hw) {
	var newWin;
	if (ww=="") {ww = 330; }
	if (hw=="") {hw = 590; }
	newWin = window.open(popurl, '','width='+ww+', height='+hw+', scrollbars=yes, resizable=yes');
	newWin.focus();	

} 

//<![CDATA{
function myOnSubmitEventHandler() {
	try {
		document.getElementById('editor1').EscapeUnicode = true;
		document.getElementById('xhtml1').value = document.getElementById('editor1').value;		
	}
	catch(er) {
		document.getElementById('xhtml1').value = document.getElementById('alternate1').value;
	}
}
//]]>

function docwin(where) {
	myWindow = window.open (where, 'calwin', 'width=350, height=250, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=yes');
	myWindow.focus();
}

/************************ DRAWER functions ***************************************/
//document.getElementById("expandable").style.display = "none";
aa=255;
function colorfade(tId) {
	if(aa>0) {
		// aa color value. Decreasing by 5 units. 
		aa -=5;
//alert ("ID:" + tId);
		// Sets the color value. 
		document.getElementById(tId).style.color="rgb("+aa+","+aa+","+aa+")";

		// Call colorfade again...
		setTimeout("colorfade('"+tId+"')",20);	
	} 
}

function toggle(toggler) {
	if(document.getElementById) {
		targetElement = toggler.parentNode.nextSibling;
		//alert("Target: " + targetElement.className);
		if(targetElement.className == undefined) {
			targetElement = toggler.parentNode.nextSibling.nextSibling;				
		}	

		if (targetElement.style.display == "block") {			
			targetElement.style.display = "none";
		} else {
			targetElement.style.display = "block";
		}
	} 
}

function swap(targetId,buttonId) {
  
  if (document.getElementById) {
        target = document.getElementById(targetId);
        buttonName = document.getElementById(buttonId);
        
        if (target.style.display == "none") {
        	 
            target.style.display = "";
            
        } else {  
        	//fade(200);   
        	 
            target.style.display = "none";
			
        }
        if (document.getElementById(buttonId) != undefined) {    
	        if (target.style.display == "none") {
	            buttonName.src = "./images/more.gif";
	            buttonName.alt = "View more details";
	
	        } else {
	            buttonName.src = "./images/less.gif";
	            buttonName.alt = "Hide details";
	
	        }
        }
        aa=255;
        colorfade(targetId);  
//alert(">>" + target);
  }
}

function swapPhoto(photoSRC) {
    document.images.imgPhoto.src = "./gallery/" + photoSRC;
    scrollTo(0,0);
}

/*--------- Ajax Calendar ---------------------*/
var req;

function navigate(month,year) {
        var url = "inc/calendar.php?month="+month+"&year="+year;
        if(window.XMLHttpRequest) {
                req = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
        }
        req.open("GET", url, true);
        req.onreadystatechange = callback;
        req.send(null);
}

function callback() {        
        obj = document.getElementById("calendar");
        setFade(0);
        
		if(req.readyState == 4) {
                if(req.status == 200) {
                        response = req.responseText;
                        obj.innerHTML = response;
                        fade(0);
                } else {
                        alert("There was a problem retrieving the data:\n" + req.statusText);
                }
        }
}

function fade(amt) {
	if(amt <= 100) {
		setFade(amt);
		amt += 10;
		setTimeout("fade("+amt+")", 5);
    }
}

function setFade(amt) {
	obj = document.getElementById("calendar");
	
	amt = (amt == 100)?99.999:amt;
  
	// IE
	obj.style.filter = "alpha(opacity:"+amt+")";
  
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = amt/100;
  
	// Mozilla and Firefox
	obj.style.MozOpacity = amt/100;
  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = amt/100;
}


/******************************************* TOOTIP BALLOON ************************************************/	
function showToolTip(e,text){
	if(document.all)e = event;
	
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
}	

function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';
	
}

function startGallery() {
	var myGallery = new gallery($('myGallery'), {
		timed: false,
		useHistoryManager: true
		});
	HistoryManager.start();
}
/*window.addEvent('domready', startGallery); */

//<![CDATA[
/* -- a fix for image flickering in IE6 --  */
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
//]]>

/************************************************************************************************************/

