/*
 * $ Default javascript file
 *
 * Copyright (c) 2008 That's-id Multimedia
 */

function init()
{
	$('body img[rel=mo]').addRollOverHandler();
	if (typeof($.validator) == 'object') {
		$('form').validatorEnable({validatorKey: 'validated'});
	}
		
	if (typeof $.tooltip == 'object') {
		$('div.formInfo').tooltip({bodyHandler: function(){
			return $(this).children('div.content').html();
		}});
	}
	
	 
	if ( typeof( window[ 'js_supersleigh_loaded' ] ) != "undefined" ) {
		supersleight.run();
	}
	
	if (typeof $.overlay == 'object') {
		
		$('.subscribeNews').setPopup('newsletter', {
			content: {url: '/newsletter/subscribe'},
			width:608,
			height: 240,
			animation: 'none',
			formValidation: true
		}); //,	postShowHandler: function(){alert('loaded')}
		
		/*
		$.overlay.defaultOptions.minHeight = 100;
		$.overlay.defaultOptions.maxWidth = 1024;
		$.overlay.defaultOptions.maxHeight = 768;
		$.overlay.event.bind('show', function(e,$popup,options){ alert(options.name);  });
			
		$('a[rel=popup]').openPopup();
		*/ 
	}
	
	
}


/*------------------------------------------------------------------------------
	Methode om CSS background-image cache te forceren voor IE6
------------------------------------------------------------------------------*/

/*
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
*/

/*------------------------------------------------------------------------------
	AJAX handlers
------------------------------------------------------------------------------*/

function setIndex(pub_Id, page)
{
	$.get('/dynamics/getindex.php', {pub_Id: pub_Id, page: page},
		function(msg) {
			document.getElementById('index_container').innerHTML=msg;
		});
}


/*------------------------------------------------------------------------------
	Various
------------------------------------------------------------------------------*/

function checkCookies(redirect)
{
	var cookieName = 'testCookie';
	document.cookie = cookieName + '=cookieValue';
	var cookiesEnabled = document.cookie.indexOf(cookieName) != -1;
	if (!cookiesEnabled)
	{
		location.href=redirect;
	}
}

function openPopup(url)
{
	var width=740, height=500;
	var popup = window.open(url+'?popup=1', 'popup', 'status=0,toolbar=0,location=0,menubar=0,scrollbars=yes,height='+height+',width='+width);
//	popup.moveTo(
//		parseInt((screen.width - width) / 2),
//		parseInt((screen.height - height) / 2)
//	);
	
	return false;
}
