// Rounded corners IE fix
DD_roundies.addRule('div#footer', '10px 10px 0 0'); 
DD_roundies.addRule('pre', '10px'); 

// Icon text changer
function iconText(elm)	{
	var texts = new Array();
	texts["ico_crossBrowser"] = "De sites van websiteman functioneren in elke moderne browser.";
	texts["ico_Adobe"] = "websiteman werkt met Adobe&reg; Creative Suite&reg; 4 Design Premium";
	texts["ico_Debian"] = "Onze servers draaien Debian Linux";
	texts["ico_iDEAL"] = "De webshop van websiteman ondersteunt betaling via iDEAL.";
	texts["ico_intel"] = "websiteman: Intel&reg; inside.";
	texts["ico_PayPal"] = "De webshop van websiteman ondersteunt betaling via PayPal&trade;.";
	
	$("footerIconText").update(texts[elm.id]);
	for (var item in texts)
	{
		if ($(item))
			$(item).setStyle({'backgroundPosition' : 'top left'});
	}
	elm.setStyle({'backgroundPosition' : 'bottom center'});
}

// Menu function 
var effect;

function morph(div, px, duration)
{
	effect = new Effect.Morph(div, {
		style: 'width: '+px+'px;', 
		duration: duration 
	});
}

// Show submenu
function hideSubmenus()
{
	$$('div.submenu').each(function(value, index) { morph(value.id, 0, 0.4); }); // hide all other subs
}

function showSubmenu(id)	
{
	if (effect)
		effect.cancel();
	
	$$('div.submenu').without($('submenu'+id)).each(function(value, index) { morph(value.id, 0, 0.4); }); // hide all other subs
	
	morph('submenu'+id, 160, 0.2);
}

function hideSubmenu(id)
{
	if (effect)
		effect.cancel();
	
	if (!hasActiveItem(id))
		morph('submenu'+id, 0, 0.4);

	showActiveSubmenu();
}

function hasActiveItem(id)
{
	return ($('submenu'+id).select('a.menu_item2').size() > 0);
}

function showActiveSubmenu()
{
	if (effect)
		effect.cancel();
	
	hideSubmenus();
	$$('div.submenu').each(function(value, index) { if (hasActiveItem(value.id.replace('submenu', '')))
		showSubmenu(value.id.replace('submenu', ''));
		return;
	});	
}

// Show/hide footer
function showFooter()
{
	effect = new Effect.Morph('slide', {
		style: 'height: 300px;'
	});
}

function hideFooter() 
{
	effect = new Effect.Morph('slide', {
		style: 'height: 75px;'
	});
}

// Portfolio changer
function pfChanger()
{
	var duration = 1.5; 
	var visible = 7000; 
	var counter = 1;
	
	var elms = $$('div.portfolioImg');
	elms.each(function(elm, index) {
		if (counter % 2 == 0)
			elm.addClassName('right');
		
		var amount = Math.ceil(counter/2);
		var last = (elms.length == counter);
		
		setTimeout("new Effect.Appear($('"+elm.identify()+"'), { duration: "+duration+" })", visible*(amount-1));
		setTimeout("new Effect.Fade($('"+elm.identify()+"'), { duration: "+duration+" })", visible*amount);
		
		if (last)
			setTimeout("pfChanger()", visible*amount);
		
		if (!last)
			counter++;
		else
			counter = 1;
	} );
}

function mail(code)
{
	var decoded = "";

	splitString = code.split(".");
	for (var i = 0; i < splitString.length; i++)
	{
		decoded += String.fromCharCode(splitString[i]-10);	
	}

	window.location.href = "mailto:" + decoded;
}