// JSON parser
function parseJSON( string )
{
	try
	{
		return /^("(\\.|[^"\\\n\r])*"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+$/.test(string) 
				&& eval('(' + string + ')');
	}
	catch (err) 
	{
		alert( 'De server gaf een onverwachte result-set terug.\n Technische details:\n\n' + err.description );		
	}
	
	return false;
}

function $_tag( id, tag )
{
	if( typeof( id ) == 'object' ) 
		return id.getElementsByTagName( tag );
	else
		return $( id ).getElementsByTagName( tag );
}

function inputFocus( obj, standaard )
{
	if( obj.value == standaard )
		obj.value = "";
		
	obj.className = 'zoekenActief';		
}

function inputBlur( obj, standaard )
{
	if( obj.value == "" )
		obj.value = standaard
		
	obj.className = 'zoekenInactief';
}

function opacity(id, opacStart, opacEnd, millisec, both_ways, append)
{
    var speed = Math.round(millisec / 100);
    var timer = 0;

    if(opacStart > opacEnd)
    {
        for(i = opacStart; i >= opacEnd; i--)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;


        }

        if ( i <= 0 && both_ways )
        {
             opacity( id, opacEnd, opacStart, millisec, false, append );
        }
    }
    else if(opacStart < opacEnd)
    {
        if ( both_ways )
        {
             $( id ).innerHTML = append;
        }

        for(i = opacStart; i <= opacEnd; i++)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

var filmHTML = '<object type="application/x-shockwave-flash" width="640" height="400" data="http://www.hondsrugcollege.nl/templates/hondsrugcollege/sources/swf/flvplayer.swf?file=http://www.hondsrugcollege.nl/uploads/videos/hondsrugtvcommercial.flv"><param name="movie" value="http://www.hondsrugcollege.nl/templates/hondsrugcollege/sources/swf/flvplayer.swf?file=http://www.hondsrugcollege.nl/uploads/videos/hondsrugtvcommercial.flv" /><param name="allowScriptAccess" value="sameDomain" /><param name="quality" value="high" /><param name="FlashVars" value="autostart=true&lightcolor=0x000000&backcolor=0x000000&frontcolor=0xCCCCCC&displayheight=800&screencolor=0x000000&stretching=exactfit" /><param name="allowfullscreen" value="true" /></object>';

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 openPromoVideo( )
{
	changeOpac( 0, 'layerTransparant');
	$( '#layerTransparant' ).show();
	$( '#hcFilm' ).html(filmHTML);
	
	// Hondje weghalen, want Flash doet lekker niks met de z-index waarde! :-(
	//s$( 'hondje' ).style.display = 'none';
	
	opacity( 'layerTransparant', 0, 40, 300 );
	$( '#layerOuter' ).show();
}

function sluitPromoVideo( )
{
	opacity( 'layerTransparant', 40, 0, 300 );
	$( '#hcFilm' ).html("");
	setTimeout( '$( \'#layerTransparant\' ).hide();', 300 );
	$( '#layerOuter' ).hide();
	//$( 'hondje' ).style.display = 'block';
}

function techniekdag( voor )
{
	if( voor == "technasium" )
	{
		$( 'avond' ).style.display = 'none';	
		$( 'uitleg' ).style.display = 'block';
	}
	else
	{
		$( 'avond' ).style.display = 'block';
		$( 'uitleg' ).style.display = 'none';
	}
}