window.addEventListener?window.addEventListener("load",init,false):window.attachEvent("onload",init);

function init() 
{
	if (!document.getElementsByTagName) return; 
    var anchors = document.getElementsByTagName("a"); 
    for (var i=0; i<anchors.length; i++) 
    {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") 
        {
            anchor.target = "_blank";
        }
    }
}

/* Photoalbum Functions */
var check_width;
var	check_height;
var c_width;
var c_height;
var x_increment;
var y_increment;
var interval;

function loadMail()
{
	var mail = 'info@allroundspuitwerken.nl';
	if (document.getElementById('mail_link'))
	{
		document.getElementById('mail_link').setAttribute('href', 'mailto:'+mail);
		document.getElementById('mail_link').innerHTML = 'M: '+mail;
	}
    if (document.getElementById('mail_link2'))
	{
		document.getElementById('mail_link2').setAttribute('href', 'mailto:'+mail);
		document.getElementById('mail_link2').innerHTML = mail;
	}	
}

function showImg(src, width, height)
{
	if (typeof window.innerWidth != 'undefined')
 	{
		// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
    	var check_width = window.innerWidth;
    	var check_height = window.innerHeight;
 	}
 	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
 	{
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
    	var check_width = document.documentElement.clientWidth;
    	var check_height = document.documentElement.clientHeight;
 	}
 	else
 	{
 		// older versions of IE
    	var check_width = document.getElementsByTagName('body')[0].clientWidth;
    	var check_height = document.getElementsByTagName('body')[0].clientHeight;
	}
	document.getElementById('screen_filter').style.width = check_width + 'px';
	document.getElementById('screen_filter').style.height = check_height + 'px';
	check_width -= 50;
	check_height -= 50;
	
	var photo_width = width;
	var photo_height = height;
	
	if (photo_width > check_width)
	{
		photo_width = check_width;
		photo_height = parseInt(photo_height-(photo_height*((width-check_width)/width)));
	}
	if (photo_height > check_height)
	{
		photo_width = parseInt(photo_width-(photo_width*((photo_height-check_height)/photo_height)));
		photo_height = check_height;
	}
	
	var content = document.getElementById('floatainer_content');
	content.innerHTML = '<img src="'+src+'" width="'+photo_width+'" height="'+photo_height+'" style="margin: 4px;"/>';
	if (content.style.display == 'none')
	{
		c_width = 2;
		c_height = 2;
        x_increment = parseInt(photo_width/40);
        y_increment = parseInt(photo_height/40);
        interval = setInterval("resizeElement('floatainer', "+(photo_width+8)+", "+(photo_height+8)+")", 20);
	}
	else
	{
		closeElement('floatainer');
	}
}

function closeElement(id)
{
	document.getElementById('screen_filter').style.width = '0px';
	document.getElementById('screen_filter').style.height = '0px';
	var container = document.getElementById(id);
	toggleContent(id);
	c_width = 0;
	c_height = 0;
	container.style.display = 'none';
	container.style.width = '0px';
	container.style.height = '0px';
	container.style.margin = '0px';
}

function resizeElement(id, endwidth, endheight)
{
    var container = document.getElementById(id);
	if (c_width != endwidth)
	{
		if (c_width < endwidth)
		{
            if ((c_width+x_increment) < endwidth)
            {
                container.style.width = (c_width+x_increment)+'px';
                c_width = c_width+x_increment;
            }
            else
            {
                container.style.width = endwidth+'px';
                c_width = endwidth;
            }
		}
        else
		{
			container.style.width = endwidth+'px';
			c_width = endwidth;
		}
	}
	if (c_height != endheight)
	{
		if (c_height < endheight)
		{
            if ((c_height+y_increment) < endheight)
            {
                container.style.height = (c_height+y_increment)+'px';
                c_height = c_height+y_increment;
            }
            else
            {
                container.style.height = endheight+'px';
                c_height = endheight;
            }
        }
        else
		{
			container.style.height = endheight+'px';
			c_height = endheight;
		}		
	}
	container.style.margin = '-'+(c_height/2)+'px 0px 0px -'+(c_width/2)+'px';
	if (container.style.display == 'none')
	{
		container.style.display = 'block';
	}
	if (c_width == endwidth && c_height == endheight)
	{
		clearInterval(interval);
		toggleContent(id);
	}
}

function toggleContent(id)
{
	var content;
	var close;

	if (content = document.getElementById(id+'_content'))
	{
		if (content.style.display == 'none')
		{
			content.style.display = 'block';
		}
		else
		{
			content.style.display = 'none';
		}
	}
	if (close = document.getElementById(id+'_close'))
	{
		if (close.style.display == 'none')
		{
			close.style.display = 'block';
		}
		else
		{
			close.style.display = 'none';
		}
	}
}
