/* Portfolio: */

window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;

	imgs = d.getElementById("ref_container").getElementsByTagName("div");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;
	
	setTimeout(so_xfade,5500);
	
}

function so_xfade() 
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) 
	{
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,5500);
	} 
	else 
	{
		setTimeout(so_xfade,50);
	}
	
	function setOpacity(obj) 
	{
		if(obj.xOpacity>.99) 
		{
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}

/* Begrippen: */

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

function showDescription(text, e)
{
	var description = document.getElementById('word_description');
	var cursor = getPosition(e);
	description.style.left = cursor.x+'px';
	description.style.top = (cursor.y+12)+'px';
	description.innerHTML = text;
	description.style.display = 'block';
}

function resetDescription()
{
	var description = document.getElementById('word_description');
	description.style.left = '0px';
	description.style.top = '0px';
	description.innerHTML = '';
	description.style.display = 'none';
}

/* Contact: */

function showContact()
{
	var mail = document.getElementById('mail');	
	var tel = document.getElementById('tel');	
	var address = document.getElementById('address');	
	
	mail.innerHTML = '<a href="mailto:info@active-bits.nl">info@active-bits.nl</a>';
	tel.innerHTML = '06 248 257 56 (10:00 - 17:00 Wo-Vr)<br/><br/>06 154 301 82 (18:00 - 21:00 Ma-Vr)';
	address.innerHTML = 'Damastroosstraat 27<br/>5761 GL<br/>Bakel';
}

function showContactEn()
{
	var mail = document.getElementById('mail');	
	var tel = document.getElementById('tel');	
	var address = document.getElementById('address');	
	
	mail.innerHTML = '<a href="mailto:info@active-bits.nl">info@active-bits.nl</a>';
	tel.innerHTML = '(+31)6 248 257 56 (10:00 - 17:00 Wed-Fri)<br/><br/>(+31)6 154 301 82 (18:00 - 21:00 Mon-Fri)';
	address.innerHTML = 'Damastroosstraat 27<br/>5761 GL, Bakel<br/>The Netherlands';
}

/* Photo */

function showPhoto(url,width,height,caption)
{
	var pop_width = width;
	var pop_height = height;
	var check_width = 0;
	var check_height = 0;
 
    if (typeof window.innerWidth != 'undefined')
 	{
		check_width = window.innerWidth;
    	check_height = window.innerHeight;
 	}
 	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
 	{
		check_width = document.documentElement.clientWidth;
    	check_height = document.documentElement.clientHeight;
 	}
 	else
 	{
 		check_width = document.getElementsByTagName('body')[0].clientWidth;
    	check_height = document.getElementsByTagName('body')[0].clientHeight;
 	}
    
    chk_width = (check_width-50);
	chk_height = (check_height-50);
		
	if (pop_width > chk_width)
	{
		pop_width = chk_width;
		pop_height = parseInt(pop_height-(pop_height*((width-chk_width)/width)));
	}
	if (pop_height > chk_height)
	{
		pop_width = parseInt(pop_width-(pop_width*((pop_height-chk_height)/pop_height)));
		pop_height = chk_height;
	}
    
    if (document.getElementById('youtube') != null)
    {
        document.getElementById('youtube').style.display = 'none';
    }
    var scrll_top = document.body.scrollTop;
    if (typeof document.documentElement != 'undefined' && document.documentElement.scrollTop != 0)
    {
        scrll_top = document.documentElement.scrollTop;
    }
	document.getElementById('inline_screen').style.width = check_width + 'px';
    document.getElementById('inline_screen').style.height = check_height + 'px';
    document.getElementById('inline_screen').style.top = scrll_top + 'px';
    document.getElementById('inline_photo').style.display = 'none';
    document.getElementById('inline_photo').style.width = pop_width + 'px';
    document.getElementById('inline_photo').style.height = pop_height + 'px';
    document.getElementById('inline_photo').innerHTML = '<img src="' +url+ '" width="' + pop_width + 'px" height="' + pop_height + 'px" alt="' + caption + '"/><div>' + caption + '</div>';
   	document.getElementById('inline_photo').style.top = (scrll_top +((chk_height/2)-(pop_height/2))+5) + 'px';
    document.getElementById('inline_photo').style.left = (((chk_width/2)-(pop_width/2))+25) + 'px';
    document.getElementById('inline_photo').style.display = 'block';
    document.body.style.overflow = 'hidden';
}

function hidePhoto()
{
	document.getElementById('inline_screen').style.width = '0px';
	document.getElementById('inline_screen').style.height = '0px';
	document.getElementById('inline_photo').style.display = 'none';
    document.getElementById('inline_photo').innerHTML = '';
    document.body.style.overflow = 'auto';
    if (document.getElementById('youtube'))
    {
        document.getElementById('youtube').style.display = 'block';
    }
}