var gTemplate02Hack = -1;
jQuery(document).ready(function() {

	if (jQuery('base').attr('href')) {
		gTemplate02Hack = jQuery('base').attr('href').toString();
		lPos = gTemplate02Hack.indexOf('/templates/template');
		if (lPos > 0) {
			lPos += "/templates/template".length;
			gTemplate02Hack = gTemplate02Hack.substring(lPos,lPos+2) * 1;
		}
}
		jQuery('#mainContent').height(jQuery(window).height()-165);
		showCVPart('welkom');

	});

	jQuery(window).resize(function() {
		jQuery('#mainContent').height(jQuery(window).height()-165);
	});




	function showCVPart(pName) {

		jQuery('#movieIcon').css({display: 'none'});

		if (gTemplate02Hack == 3 && pName == 'welkom') {
			pName = 'welkom3';
		} else if (gTemplate02Hack == 4 && pName == 'welkom') {
			pName = 'welkom4';
		}

		jQuery('.cvPart').hide();
		jQuery('table.LeftLink a').removeClass("Sel");
		jQuery('table.LeftLink a').each(function(e) {
			var bla = jQuery(this).attr("onclick");
			if (bla != undefined && bla.toString().indexOf(pName) != -1) {
				jQuery(this).addClass("Sel");
			}
		});

		if (pName == 'compleet') {
			var lTop = 0;
			jQuery('#movieIcon').css({display: 'block'});
			jQuery('.cvPart').each(function(i) {
				if (this.id != 'cvPartiFrame') {
					this.style.display = 'block';
				}
				});

		} else {
			jQuery('#cvPart' + pName).css({top: '0px'});
			jQuery('#cvPart' + pName).show();
		}


	}

	function loadHits() {
		loadPAGE('hits');
	}

	function loadBeoordeling() {
		loadPAGE('beoordeling');
	}

	function loadInvitation() {
		loadPAGE('invitatie');
	}

	function loadVideo() {
		loadPAGE('video');
	}

	function loadReaction() {
		loadPAGE('reactie');
	}

	function loadJudge() {
		loadPAGE('judge');
	}

	function loadPAGE(page){
		var lFrameHeight=100;
/*
		if (gTemplate02Hack == 6) {
			lFrameHeight = 100;
		}
		*/
		switch (page) {
			case 'hits':
				jQuery("#cvPartiFrame").html("<iframe src=\"/stats.php?onderdeel=hits\" width=\"100%\" height=\"" + lFrameHeight + "%\" frameborder=\"0\" border=\"0\" scrolling=\"no\" ></iframe>");
			break;
			case 'beoordeling':
				jQuery("#cvPartiFrame").html("<iframe src=\"/cv_toonbeoordeling.php\" width=\"100%\" height=\"" + lFrameHeight + "%\" frameborder=\"0\" border=\"0\" scrolling=\"no\"  ></iframe>");
			break;
			case 'invitatie':
				jQuery("#cvPartiFrame").html("<iframe src=\"/nodiguit.php\" width=\"100%\" height=\"" + lFrameHeight + "%\" frameborder=\"0\" border=\"0\" scrolling=\"no\" ></iframe>");
			break;
			case 'video':
				jQuery("#cvPartiFrame").html("<iframe src=\"/cv_video.php\" width=\"100%\" height=\"" + lFrameHeight + "%\" frameborder=\"0\" border=\"0\" scrolling=\"no\" ></iframe>");
			break;
			case 'reactie':
				jQuery("#cvPartiFrame").html("<iframe src=\"/reageer.php\" width=\"100%\" height=\"" + lFrameHeight + "%\" frameborder=\"0\" border=\"0\" scrolling=\"no\" ></iframe>");
			break;
			case 'judge':
				jQuery("#cvPartiFrame").html("<iframe src=\"/cv_beoordeling.php\" width=\"100%\" height=\"" + lFrameHeight + "%\" frameborder=\"0\" border=\"0\" scrolling=\"no\" ></iframe>");
			break;
		}

		showCVPart('iFrame');
		setCorrectiFrameSize();
	}


function setCorrectiFrameSize()	{
		// Set specific variable to represent all iframe tags.
		var iFrames = document.getElementsByTagName('iframe');

		// Resize heights.
		function iResize()
		{
			// Iterate through all iframes in the page.
			for (var i = 0, j = iFrames.length; i < j; i++)
			{
				// Set inline style to equal the body height of the iframed content.
				iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';
				jQuery(iFrames[i]).contents().find("body").css({'background-color':'transparent'});
			}
		}

		// Check if browser is Safari or Opera.
		if ($.browser.safari || $.browser.opera)
		{
			// Start timer when loaded.
			jQuery('iframe').load(function()
				{
					setTimeout(iResize, 0);
				}
			);

			// Safari and Opera need a kick-start.
			for (var i = 0, j = iFrames.length; i < j; i++)
			{
				var iSource = iFrames[i].src;
				iFrames[i].src = '';
				iFrames[i].src = iSource;
			}
		}
		else
		{
			// For other good browsers.
			jQuery('iframe').load(function()
				{
					// Set inline style to equal the body height of the iframed content.
					this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
					jQuery(this).contents().find("body").css({'background-color':'transparent'});
				}
			);
		}
	}

	function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

