var featuresOpen = false;

var menuImages = new Array(6);
menuImages[0] = "./images/df_nav_01_advertisers.gif";
menuImages[1] = "./images/df_nav_02_publishers.gif";
menuImages[2] = "./images/df_nav_03_stats.gif";
menuImages[3] = "./images/df_nav_04_about.gif";
menuImages[4] = "./images/df_nav_05_featured_games.gif";
menuImages[5] = "./images/df_nav_06_featured_campaigns.gif";

var contentFiles = new Array(6);
contentFiles[0] = "./content/advertisers.html";
contentFiles[1] = "./content/publishers.html";
contentFiles[2] = "./content/statistics.html";
contentFiles[3] = "./content/about_us.html";
contentFiles[4] = "./content/featured_games.html";
contentFiles[5] = "./content/featured_campaigns.html";


for (i=0; i < menuImages.length; i++) {
	var preload = new Image();
	preload.src = menuImages[i];
}

function showContent(imgIndex) {
	if((imgIndex>=4) && (!featuresOpen)){	// open features box if closed
		showFeatures(imgIndex);
	}
	else if ((imgIndex>=4) && (featuresOpen)){	// swap flash content if features open
		if(imgIndex==5){
			FlashReplace.replace("flashContent", "./featured_campaigns.swf", "flashSlideshow", 723, 267, 10 , {wmode : "opaque"});
		} else {
			FlashReplace.replace("flashContent", "./featured_games.swf", "flashSlideshow", 723, 267, 10 , {wmode : "opaque"});
		}
	}
	else if((imgIndex<=3) && (featuresOpen)){	// close features box if open
		hideFeatures();
	}
	
	document.getElementById('newsTitle').innerHTML = '<img src="./images/news_label_industry.png">';
	if(document.getElementById('mainContent_news').innerHTML != document.getElementById('industry_news').innerHTML){
		document.getElementById('mainContent_news').innerHTML = document.getElementById('industry_news').innerHTML;
	}
		

	
	document['navImg'].src = menuImages[imgIndex];
	loadContent(contentFiles[imgIndex], "mainContent_left");
}

function showFeatures(imgIndex){
	  $('#features').animate({
		height: 267
	  }, 500, function() {
		// Animation complete.
	  var slideShow = "./slideshow_games.html";
	  if(imgIndex==5){slideShow = "./slideshow_campaigns.html";}
		loadContent(slideShow, "features");
	  });
	  featuresOpen = true;
}


function hideFeatures(){
	  document.getElementById('flashContent').style['display']= 'none';
	  $('#features').animate({
		height: 0
	  }, 500, function() {
		document.getElementById('flashContent').innerHTML = "";
	  });
	  featuresOpen = false;
}

function imgSwap(imgName, imgSrc){
	document[imgName].src = imgSrc;
}


function callFancy(my_href) {
	var j1 = document.getElementById("hiddenclicker");
	j1.href = my_href;
	$('#hiddenclicker').trigger('click');
}


$(document).ready(function() {
 $("a.overlay-flash").fancybox({
 'overlayColor' : "#ffffff",
 'padding'    : 0,
 'zoomOpacity'   : true,
 'zoomSpeedIn'   : 100,
 'zoomSpeedOut'   : 100,
 'overlayOpacity'  : 0.75,
 'frameWidth'   : 530,
 'frameHeight'   : 400,
 'hideOnContentClick' : true
 });
});


