<?PHP
	header("Content-Type: text/javascript");
?>

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
	else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++){
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	return true;
}

function outgoing_links()
{
	var links = document.getElementsByTagName("a");
	var urlRe = new RegExp("http:\/\/((www\.)?)([a-zA-Z0-9\\_\\-\\.]*)\.([a-zA-Z]{1,5})/");
	for(var i=0;i<links.length;i++) 
    {
    	if (links[i].onclick == undefined)
		{
        	fullPath = links[i].href.toLowerCase();
			last4 = fullPath.substring(fullPath.length-4, fullPath.length);
            if (links[i].href.toLowerCase().indexOf("mailto:") > -1)
           	{
            	
           		links[i].onclick=function()
                {
                	href = this.href.toLowerCase();
                    emailLink = href.replace("mailto:","");
                    pageTracker._trackEvent('Mails', 'Click', emailLink);
                };
           	}
            else if(links[i].href.toLowerCase().indexOf("adirondackharvest.com") == -1 && urlRe.test(links[i].href))
            {
            	links[i].onclick=function()
                {
                	href = this.href;
                    re = /^https?:\/\/(www\.)?([^/]+)?/i;
                    href.match( re );
                    domainOnly =  RegExp.$2;
                    pageTracker._trackEvent('Outgoing links', 'Click', domainOnly);
                };
           	}
            else if( (last4 == ".pdf" || last4==".doc" ) )
           	{
            	links[i].onclick=function()
                {
                	href = this.href;
                    splhref = href.split('/');
                    fileOnly = splhref[splhref.length-1];
                    pageTracker._trackEvent('Downloads', 'PDF', fileOnly); 
                };
             }
                 
		}
	}
}


