

//-- Slide down drop down menu	
var blnSlideDownMenu = false;
var blnSlideDownNav = false;

$(function() {	
	$("div.menu ul li").mouseover(function() {
		$(this).find("ul.submenu").slideDown(30);

		$(this).hover(function(){}, function(){
			$(this).find("ul.submenu").slideUp('fast');
		});
	});
});

$(function() {	
	$("div.nav ul li").mouseover(function() {
		$(this).find("ul.submenu").slideDown(30);

		$(this).hover(function(){}, function(){
			$(this).find("ul.submenu").slideUp('fast');
		});
	});
});

$(function() {	
	$("ul.sitemap li").mouseover(function() {
		$(this).children().slideDown(30);

		$(this).hover(function(){}, function(){
			$(this).find("ul.submenu").slideUp();
		});
	});
});

// FANCYBOX VOOR DE FOTO'S
jQuery(document).ready(function() {

	$("a.fancy").fancybox({
	'titlePosition'  : 'inside',
	'transitionIn'	:	'elastic',
	'transitionOut'	:	'elastic'
	});
	
	$("a.iframe").fancybox({
		'width' : 1050,
		'height' : 650,
		'autoScale' : false,
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'type' : 'iframe' 
	});
	
	$('form').submitKeyPress();
});

/**
* Dit is een klasse die de click kan opvangen van een input veld.
* @version 0.1
* @author Waldo Cosman
* @copyright DigitalMind BVBA
* @date 2009/09/15
*
*/

//-- Als er op het input veld geklikt wordt, zal de tekst die erin staat verdwijnen, als je er uit gaat en er is nog steeds een tekst ingegeven, dan komt het vorige woord terug.
(function($)
{
	$.fn.emptyInputField = function(options)
	{
		var strValue =  $(this).attr("value");

		$(this).focus(function()
		{
			if($(this).attr("value") == strValue && strValue != "")
			{
				$(this).attr("value","");
			}
		});

		$(this).blur(function()
		{
			if($(this).attr("value") == "")
			{
				$(this).attr("value", strValue);
			}
		})

	};
})(jQuery);


//-- EXTERNAL LINKS

$(document).ready(function()
{
	$("a[href=#]").click(function()
	{
		return false;
	})

	$("a[rel=external]").click(function()
	{
		$(this).attr("target", "_blank");
	})
});


//-- Limit text
function limitText(limitField, limitCount, limitNum)
{
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	}
	else
	{
		limitCount.value = limitNum - limitField.value.length;
	}
}

function showDetail(objRow, strCaseId) {
	$(".detail").each(function() {
		$(this).hide();	
	});
	
	$("table tr").each(function() {
		$(this).removeClass("selected");
	});
	
	$("#" + strCaseId).fadeIn();
	$(objRow).addClass("selected");
}

function DownloadFile(strFile){
	window.location = "/" + strFile + "/download";
}

function DownloadExtern(strFile, intCategory){
	window.open("/" + strFile + "/" + intCategory + "/extern", "_blank");
}

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
        '6BF52A52-394A-11D3-B153-00C04F79FAA6',
        'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
        'application/x-mplayer2',
        p
    );
}

function writeShockWave(p) {
    writeEmbed(
	    '166B1BCA-3F9C-11CF-8075-444553540000',
	    'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	    'application/x-director',
        p
    );
}

function writeQuickTime(p) {
    writeEmbed(
        '02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
        'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
        'video/quicktime',
        p
    );
}

function writeRealMedia(p) {
    writeEmbed(
        'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
        'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
        'audio/x-pn-realaudio-plugin',
        p
    );
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}


jQuery.fn.submitKeyPress = function() {
  if ($.browser.msie){
    $(this).find('input').keypress(function(e){
      // If the key pressed was enter
      if (e.which == '13') {
        $(this).closest('form')
        .find('button[type=submit],input[type=submit]')
        .filter(':first').click();
      }
    });
  }
}
