var dicWidth		= 175;
var dicHeight		= 136;

function doDicIntro(sDicVideo, sDivDicVideoPosition)
{
	if (! (bDicEnabled && document.getElementById(sDivDicVideoPosition) && (String(sDicVideo).length > 0)))
	{
       	document.getElementById('divDicIntro').style.left	= '-999px';
        document.getElementById('divDicIntro').innerHTML	= '';

		return false;
	}

	var nVisibleHeight	=	1.00;
	var aCoords			=	findPos(document.getElementById(sDivDicVideoPosition));
	var	nXpos			=	aCoords[0];
	var	nYpos			=	aCoords[1] - dicHeight;

	//Offsets
	switch(sDivDicVideoPosition)
	{
		case 'divDicIntroPosition1':	nXpos += 300;	nYpos +=  2; break;
		case 'divDicIntroPosition2':	nXpos += 118;	nYpos += 14; break;
	}

	var nInitialState	=	4;
	if		(getValueById('dic[active]') != 1)	{	nInitialState	=	2; }
	else if (bVisitedbefore) 					{	nInitialState	=	2; }
	else			 							{	nInitialState	=	1; }

	document.getElementById('divDicIntro').style.left	=	nXpos + 'px';
	document.getElementById('divDicIntro').style.top	=	nYpos + 'px';
	document.getElementById('divDicIntro').style.height	=	Math.round(dicHeight * nVisibleHeight) + 'px';
    document.getElementById('divDicIntro').innerHTML	= 
       '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + dicWidth + '" height="' + dicHeight + '" id="flashIntroDIC">' +
       '	<param name="movie"		value="dic/dicIntroPlayer.swf">' +
       '	<param name="flashvars"	value="videoPath=videos/' + sDicVideo + '.flv&initialState=' + nInitialState + '&">' +
       '	<param name="quality"	value="high">' +
       '	<param name="wmode"		value="transparent">' +
       '	<embed src="dic/dicIntroPlayer.swf" quality="high" allowscriptaccess="always" wmode="transparent" flashvars="videoPath=videos/' + sDicVideo + '.flv&initialState=' + nInitialState + '&" type="application/x-shockwave-flash" width="' + dicWidth + '" height="' + dicHeight + '" swliveconnect="true" id="flashIntroDIC" name="flashIntroDIC"></embed>' +
       '</object>';
}

function doShowDicInfo(sDicVideo, sDivDicVideoPosition)
{
	if (! sDicVideo)						{ return false; }
    if (getValueById('dic[active]') != 1)	{ return false; }

    var nVisibleHeight	=	0.75;
    var aCoords			=	findPos(document.getElementById(sDivDicVideoPosition));
	var	nXpos			=	aCoords[0] + 250;
	var	nYpos			=	aCoords[1] - Math.round(dicHeight * nVisibleHeight);

	if (thisMovie("flashIntroDIC")) { thisMovie("flashIntroDIC").dicInactivate(); }
    showFlashDIC(sDicVideo, nXpos, nYpos, nVisibleHeight);
}

function doHideDicInfo()
{
    if (getValueById('dic[active]') != 1) { return false;}

    hideFlashDIC();
	if (thisMovie("flashIntroDIC")) { thisMovie("flashIntroDIC").dicActivate(); }
}

function showFlashDIC(id, x, y, nVisibleHeight)
{
    if (getValueById('dic[active]') != 1) { return false;}

    if(document.getElementById('divDicInfo'))
    {
		if (isNaN(nVisibleHeight)) {	nVisibleHeight = 1.00;	}

	    hideFlashDIC();

		if(document.getElementById('dicIFrame'))
		{
			document.getElementById('dicIFrame').style.width	= dicWidth - 40 + 'px';
			document.getElementById('dicIFrame').style.height	= Math.round(dicHeight * nVisibleHeight) + 'px';
			document.getElementById('dicIFrame').style.left		= (x + 20) + 'px';
			document.getElementById('dicIFrame').style.top		= y + 'px';
			document.getElementById('dicIFrame').style.display	= 'block';
		}

        document.getElementById('divDicInfo').innerHTML = 
           '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + dicWidth + '" height="' + dicHeight + '" id="flashDIC">' +
           ' <param name="movie" value="dic/dicPlayer.swf">' +
           ' <param name="flashvars" value="videoPath=videos/' + id + '.flv&">' +
           ' <param name="quality" value="high">' +
           ' <param name="wmode" value="transparent">' +
           ' <embed src="dic/dicPlayer.swf" quality="high" wmode="transparent" flashvars="videoPath=videos/' + id + '.flv&" type="application/x-shockwave-flash" width="' + dicWidth + '" height="' + dicHeight + '" swliveconnect="true" id="flashDIC" name="flashDIC"></embed>' +
           ' </object>';

       	document.getElementById('divDicInfo').style.left	=	x + 'px';
        document.getElementById('divDicInfo').style.top		=	y + 'px';
        document.getElementById('divDicInfo').style.height	=	Math.round(dicHeight * nVisibleHeight) + 'px';
    }
}

function hideFlashDIC()
{
	document.getElementById('divDicInfo').innerHTML		= '';
	document.getElementById('divDicInfo').style.left	= '-999px';

	document.getElementById('dicIFrame').style.display	= 'none';
}

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
    {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
        {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function dicSubmitCheck(sDivDicErrorPosition)
{
    var success = doSubmitCheck();
    if ((!success) && (getValueById('dic[active]') == 1) && document.getElementById(sDivDicErrorPosition))
    {
    	if (thisMovie("flashIntroDIC")) { thisMovie("flashIntroDIC").dicActivate(); }

		// choose one of the 3 available incorrect form video's
		var videoNr	=	Math.floor(3 * Math.random()) + 1;
        var coords	=	findPos(document.getElementById(sDivDicErrorPosition));
		var	x		=	coords[0];
		var	y		=	coords[1] - dicHeight;
	
		//Offsets
		switch(sDivDicErrorPosition)
		{
			case 'divDicIntroPosition1':	x += 300;	y +=  2; break;
			case 'divDicIntroPosition2':	x += 118;	y += 14; break;
		}

        showFlashDIC('incorrectform' + videoNr, x, y);
    }
    
    return success;
}

function enableDIC()
{
	setValueById('dic[active]', 1);

	if (thisMovie("flashIntroDIC")) { thisMovie("flashIntroDIC").dicPlay(); }
}

function disableDIC()
{
	setValueById('dic[active]', 2);

//	if (thisMovie("flashIntroDIC")) { thisMovie("flashIntroDIC").dicInactivate(); }
    if (thisMovie("flashIntroDIC")) { thisMovie("flashIntroDIC").dicActivate(); }
    hideFlashDIC();
}

function thisMovie(movieName)
{
    if (navigator.appName.indexOf("Microsoft") != -1)	{ return window[movieName]; }
    else												{ return document[movieName]; }
}

