/**
 * Sterren voor de klas Main Class
 *
 */
var SVDK = new Class({
	
	moVideo : {},

	Init : function() {
		
		// Add video SWF
		this.moVideo = new Swiff('http://download.omroep.nl/teleacnot/teleac/sterrenvoordeklas/swf/main_first.swf', {
			id: 'swfMainVideo',
			container: $('centerTopColumn'),
			width: "480",
			height: "427",
			wMode: 'opaque',
			params: {allowScriptAccess:"always", base:"http://download.omroep.nl/teleacnot/teleac/sterrenvoordeklas/"}
		});
		
		// Add quotes wsf
		var o_quotes = new Swiff('http://download.omroep.nl/teleacnot/teleac/sterrenvoordeklas/swf/Quotes.swf', {
			id: 'swfQuotes',
			container: $('quotes'),
			width: "298",
			height: "267",
			wMode: 'opaque',
			params: {base:"http://download.omroep.nl/teleacnot/teleac/sterrenvoordeklas/"}
		});
		
		// Add animation swf
		var o_animation = new Swiff('http://download.omroep.nl/teleacnot/teleac/sterrenvoordeklas/swf/LvhJAnimatie.swf', {
			id: 'swfAnimation',
			container: $('animation'),
			width: "260",
			height: "130",
			wMode: 'opaque',
			params: {base:"http://download.omroep.nl/teleacnot/teleac/sterrenvoordeklas/"}
		});
		
		
		// Start quiz rollover
		$('startBtn').addEvent('mouseenter', function(e) {
			$('startBtn').removeClass('startBtnOff');
			$('startBtn').addClass('startBtnOn');
		});
		
		$('startBtn').addEvent('mouseleave', function(e) {
			$('startBtn').removeClass('startBtnOn');
			$('startBtn').addClass('startBtnOff');
		});
		
		$('startBtn').addEvent('click', function(e) {
			GP_AdvOpenWindow( 'http://www.werkeninhetonderwijs.nl/jijvoordeklas/popup_spel.htm',
												'spel',
												'fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no',
												772,
												432,
												'center',
												'ignoreLink',
												'',
												0,
												''
										  );
		});
		
		// Episodes list
		var a_elements = $('episodes').getElements('li');
		a_elements.each(function(oEl, iID) {
			
			if(oEl.hasClass('linkActive')) {
				var o_link = oEl.getElement('a');
				o_link.addClass('textActive');
				
				oEl.addEvent('mouseenter', function(e) {
					var o_event = new Event(e);
					var o_target = $(o_event.target);
					if(o_target.match('li')) {
						var o_link = o_target.getElement('a');
						o_link.addClass('textRollover');
						o_target.addClass('linkRollover');
						o_p = o_target.getElement('p');
						o_p.addClass('textRollover');
					} else if(o_target.match('a')){
						o_target.addClass('textRollover');
						var o_li = o_target.getParent('li');
						o_li.addClass('linkRollover');
						o_p = o_li.getElement('p');
						o_p.addClass('textRollover');
					} else {
						o_target.addClass('textRollover');
						var o_li = o_target.getParent('li');
						o_li.addClass('linkRollover');
						o_a = o_li.getElement('a');
						o_a.addClass('textRollover');
					}
				});
				
				oEl.addEvent('mouseleave', function(e) {
					var o_event = new Event(e);
					var o_target = $(o_event.target);
					if(o_target.match('li')) {
						var o_link = o_target.getElement('a');
						o_link.removeClass('textRollover');
						o_target.removeClass('linkRollover');
						o_p = o_target.getElement('p');
						o_p.removeClass('textRollover');
					} else if(o_target.match('a')) {
						o_target.removeClass('textRollover');
						var o_li = o_target.getParent('li');
						o_li.removeClass('linkRollover');
						o_p = o_li.getElement('p');
						o_p.removeClass('textRollover');
					} else {
						o_target.removeClass('textRollover');
						var o_li = o_target.getParent('li');
						o_li.removeClass('linkRollover');
						o_a = o_li.getElement('a');
						o_a.removeClass('textRollover');
					}
				});
			} else {
				oEl.addClass('linkInActive');
			}
		});
		
	}
	
	,StartTips : function() {
		$("swfMainVideo").GoToTips();
	}

});

// Create Class instance
var o_SVDK = new SVDK();

/**
 * DOM Ready callback
 *
 *
 */
window.addEvent('domready', function(oEvent){
  // Initialize the instance
  o_SVDK.Init();
});

/**
 * Sitestat
 *
 */
function ns_flashcounter(ns_flashn) {
	var ns_flash="http://nl.sitestat.com/klantnaam/sitenaam/s?"+ns_flashn+"&amp;ns_type=flash"+"&amp;ns__t="+(new
	Date()).getTime();
	document.ns_flashp.src=ns_flash;
}

/**
 * QUIZ popup
 *
 */

function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) {

	sitestat("http://nl.sitestat.com/klo/teleac/s?ps.sterrenvoordeklas.home&category=sterrenvoordeklas&ns_webdir=sterrenvoordeklas&thema=educatief&ns_type=clickout&ns_url=theURL");
	
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  

  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;

  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;

  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {

    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}

		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}

		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 

		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						

    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}

  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";

  if (window["popupWindow"] == null) window["popupWindow"] = new Array();

  var wp = popupWindow.length;

  popupWindow[wp] = window.open(theURL,winName,features);

  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  

  if (document.all || document.layers || document.getElementById) {

    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}

    if (alwaysOnTop && alwaysOnTop != "") {

    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);

    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }

    if (autoCloseTime && autoCloseTime > 0) {

    	popupWindow[wp].document.body.onbeforeunload = function() {

  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);

    		window.onbeforeunload = null;	}  

   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }

  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   

  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;

}

