/*
 * $ Default javascript file
 *
 * Copyright (c) 2007 That's-id Multimedia
 */

/*------------------------------------------------------------------------------
	Methode om CSS background-image cache te forceren voor IE6
------------------------------------------------------------------------------*/

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

//flashDetectVersion = "9.0";

/*------------------------------------------------------------------------------
	onLoad handler
------------------------------------------------------------------------------*/
function onLoad(root, formTokens)
{
	
	if(typeof root!='string') root = 'body';

	if (root=='body')
	{
		
		$('.triggerPopup').setPopup('form', {
			content: {url: '/publicaties/188'},
			vAlign: 'top',
			animation: 'none',
			postShowHandler: function(){ onLoad('#popup_form'); }
		});

		$('.subscribePopup').setPopup('subscribe', {
			content: {url: '/publicaties/196'},
			formValidation: true,
			animation: 'none',
			postShowHandler: function(){onLoad('#popup_subscribe'); }
		});/**/

		if (typeof supersleight == 'object') {
			supersleight.run();
		}
	} else {
		//loadPopupSIFR();
		if (typeof supersleight == 'object') {
			supersleight.limitTo(root.substring(1));
			supersleight.run();
		}
	}
		
	if (typeof $(root+' img[rel=mo]').addRollOverHandler == 'function') $(root+' img[rel=mo]').addRollOverHandler();
	$(root+' .showOnLoaded').css('visibility','visible');

	//form validation
	if (typeof $.validator == 'object' && typeof formTokens == 'object') {
    	$.validator.tokenEnable(formTokens);
	}

// TOOLTIP, used in 'team.tpl'
// http://flowplayer.org/tools/tooltip/index.html

	// initialize tooltip
	//$("#dyna img[title]").tooltip({
	if ($(".trigger").tooltip) {
		$(".trigger").tooltip({
		
			 // set the position
			 position: 'center right',
	
			// tweak the position
			offset: [0, 8],
		
			 // use effect (slide, toggle, etc.)
			 effect: 'toggle',
			 relative: true,
		
				events: {
					tooltip: ""     // hide the tooltip element	onMouseOver
				}
		});

		// initialize tooltip 2
		//$("#dyna img[title]").tooltip({
		$(".trigger2").tooltip({
		
			 // set the position
			 position: 'center left',
	
			// tweak the position
			 offset: [0, -8],
		
			 // use effect (slide, toggle, etc.)
			 effect: 'toggle',
			 relative: true,
		
				events: {
					tooltip: ""     // hide the tooltip element	onMouseOver
				}
		});
	}

}

/*------------------------------------------------------------------------------
	AJAX handlers
------------------------------------------------------------------------------*/

function setIndex(pub_Id, page, archive)
{
	$.get('/dynamics/getindex.php',{ pub_Id: pub_Id, page: page, archive: archive },
		function(msg) {
			document.getElementById('index_container').innerHTML=msg;
			//parseSelector();
		}
	);
}

function loadServiceBlok(id)
{
	$.ajax({
		url: '/publicaties/'+id,
		cache: false,
		success: function(msg) {
			$('#serviceBlok').show();
			$('#serviceBlok .layoutMiddenvlak').html(msg);
			onLoad('#serviceBlok');
		}
	});
}

function loadPopup(id)
{
	$.get('/publicaties/'+id, {},
		function(msg) {
			$.overlay.showPopup('pub', {
				content: msg,
				formValidation: true,
				animation: 'none',
				postShowHandler: function(){ onLoad('#popup_pub'); }
			});
		}
	);
}


/*------------------------------------------------------------------------------
	Various
------------------------------------------------------------------------------*/

function checkCookies(redirect)
{
	var cookieName = 'testCookie' + (new Date().getTime());

	document.cookie = cookieName + '=cookieValue';
	var cookiesEnabled = document.cookie.indexOf(cookieName) != -1;
	if (!cookiesEnabled)
	{
		location.href=redirect;
	}
}




