var $ = function(div_id)
{
	return document.getElementById(div_id);
}
function isset(varname)
{
	return(typeof(window[varname])!='undefined');
}
function showDiv(id)
{
	$(id).style.display = 'block';
}
function showHide(id)
{
	if($(id).style.display == 'block')
	{
		opacity(id, 100, 0, 500);
		window.setTimeout("document.getElementById('"+id+"').style.display = 'none';", 500);
	}
	else
	{
		window.setTimeout("document.getElementById('"+id+"').style.display = 'block';", 100);
		opacity(id, 0, 100, 500);
	}
}
function hideShow(id)
{
	if($(id).style.display == 'block')
	{
		$(id).style.display = 'none';
	}
	else
	{
		$(id).style.display = 'block';
	}
}
function str_replace( search, replace, subject )
{
    return subject.split(search).join(replace);
}
function trim(value) {
	value = value.replace(/^\s+/,'');
	value = value.replace(/\s+$/,'');
	return value;
}
/* Opacity */
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 + ")";
}
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function addBookmark(bookmark_url)
{
	var title = 'Advisearch';
	if (window.sidebar)
	{
		window.sidebar.addPanel(title, bookmark_url,"");
	}
	else if( document.all )
	{
		window.external.AddFavorite( bookmark_url, title);
	}
	else if( window.opera && window.print )
	{
		return true;
	}
}

function changeHome( type_home )
{
	if(type_home == 'particulier')
	{
		$('keuze_uitleg').innerHTML = 'U komt in het gedeelte terecht waarin de adviseurs/specialisten zich richten op particulieren.';
	}
	else if(type_home == 'zakelijk')
	{
		$('keuze_uitleg').innerHTML = 'U komt in het gedeelte terecht waarin de adviseurs/specialisten zich richten op bedrijven.';
	}
	else
	{
		$('keuze_uitleg').innerHTML = '';
	}
	$('homepage').style.background = 'url(images/home_'+type_home+'.gif) no-repeat top left';
}


function OpenLiveChat(href)
{
	var popW = 850;
	var popH = 650;
	var new_href = href+'&reset=1';

	var leftPos=(screen.width/2)-(popW/2);
	var topPos=(screen.height/2)-(popH/2);

	window.open(new_href, 'Livechat', 'width='+popW+',height='+popH+',location=no,status=no,menubar=no,directories=no,toolbar=no,resizable=no,scrollbars=no,left='+leftPos+',top='+topPos);
}
