// JavaScript Document
//NAMESPACE EVERYTHING IN THIS FILE Module
var Module = {};
Module.OnDemandAgg = {};
Module.OnDemandAgg.module_content_1;
Module.OnDemandAgg.module_content_2;
Module.OnDemandAgg.module_content_3;
Module.OnDemandAgg.module_content_4;
Module.OnDemandAgg.module_content_5;
Module.OnDemandAgg.build_mod_1=function(){
	if(Module.OnDemandAgg.module_content_1.type == 'takeover'){
		if(Module.OnDemandAgg.module_content_1.content){
			$('bottomLeftModule1').update(Module.OnDemandAgg.module_content_1.content);
		}else if(Module.OnDemandAgg.module_content_1.takeover_type == 'new'){
			Module.OnDemandAgg.module_1 = new New_Module($('bottomLeftModule1'), 'left', Module.OnDemandAgg.module_content_1.artist_id, Module.OnDemandAgg.module_content_1.loc_id);
		}else if(Module.OnDemandAgg.module_content_1.takeover_type == 'vod'){
			Module.OnDemandAgg.module_1 = new VOD_Module($('bottomLeftModule1'), 'left', Module.OnDemandAgg.module_content_1.track_id, Module.OnDemandAgg.module_content_1.pic, Module.OnDemandAgg.module_content_1.teaser);
		}else if(Module.OnDemandAgg.module_content_1.takeover_type == 'news'){
			Module.OnDemandAgg.module_1 = new NEWS_MODULE($('bottomLeftModule1'), 'left');
		}else{
			$('bottomLeftModule1').hide();
		}
	}else{
		Module.OnDemandAgg.module_1 = new NCDB_Module($('bottomLeftModule1'), 'left', Module.OnDemandAgg.module_content_1.type, Module.OnDemandAgg.module_content_1.artist_program_id, Module.OnDemandAgg.module_content_1.media_id);
	}
};
Module.OnDemandAgg.build_mod_2=function(){
	if(Module.OnDemandAgg.module_content_2.type == 'takeover'){
		if(Module.OnDemandAgg.module_content_2.content){
			$('bottomLeftModule2').update(Module.OnDemandAgg.module_content_2.content);
		}else if(Module.OnDemandAgg.module_content_2.takeover_type == 'new'){
			Module.OnDemandAgg.module_2 = new New_Module($('bottomLeftModule2'), 'left', Module.OnDemandAgg.module_content_2.artist_id, Module.OnDemandAgg.module_content_2.loc_id);
		}else if(Module.OnDemandAgg.module_content_2.takeover_type == 'vod'){
			Module.OnDemandAgg.module_2 = new VOD_Module($('bottomLeftModule2'), 'left', Module.OnDemandAgg.module_content_2.track_id, Module.OnDemandAgg.module_content_2.pic, Module.OnDemandAgg.module_content_2.teaser);
		}else if(Module.OnDemandAgg.module_content_2.takeover_type == 'news'){
			Module.OnDemandAgg.module_2 = new NEWS_MODULE($('bottomLeftModule2'), 'left');
		}else{
			$('bottomLeftModule2').hide();
		}
	}else{
		Module.OnDemandAgg.module_2 = new NCDB_Module($('bottomLeftModule2'), 'left', Module.OnDemandAgg.module_content_2.type, Module.OnDemandAgg.module_content_2.artist_program_id, Module.OnDemandAgg.module_content_2.media_id);
	}
};
Module.OnDemandAgg.build_mod_3=function(){
	if(Module.OnDemandAgg.module_content_3.type == 'takeover'){
		if(Module.OnDemandAgg.module_content_3.content){
			$('bottomLeftModule3').update(Module.OnDemandAgg.module_content_3.content);
		}else if(Module.OnDemandAgg.module_content_3.takeover_type == 'new'){
			Module.OnDemandAgg.module_3 = new New_Module($('bottomLeftModule3'), 'left', Module.OnDemandAgg.module_content_3.artist_id, Module.OnDemandAgg.module_content_3.loc_id);
		}else if(Module.OnDemandAgg.module_content_3.takeover_type == 'vod'){
			Module.OnDemandAgg.module_3 = new VOD_Module($('bottomLeftModule3'), 'left', Module.OnDemandAgg.module_content_3.track_id, Module.OnDemandAgg.module_content_3.pic, Module.OnDemandAgg.module_content_3.teaser);
		}else if(Module.OnDemandAgg.module_content_3.takeover_type == 'news'){
			Module.OnDemandAgg.module_3 = new NEWS_MODULE($('bottomLeftModule3'), 'left');
		}else{
			$('bottomLeftModule3').hide();
		}
	}else{
		Module.OnDemandAgg.module_3 = new NCDB_Module($('bottomLeftModule3'), 'left', Module.OnDemandAgg.module_content_3.type, Module.OnDemandAgg.module_content_3.artist_program_id, Module.OnDemandAgg.module_content_3.media_id);
	}
};
Module.OnDemandAgg.build_mod_4=function(){
	if(Module.OnDemandAgg.module_content_3.type == 'takeover'){
		if(Module.OnDemandAgg.module_content_4.content){
			$('bottomMiddleModule1').update(Module.OnDemandAgg.module_content_4.content);
		}else if(Module.OnDemandAgg.module_content_4.takeover_type == 'new'){
			Module.OnDemandAgg.module_4 = new New_Module($('bottomMiddleModule1'), 'middle', Module.OnDemandAgg.module_content_4.artist_id, Module.OnDemandAgg.module_content_4.loc_id);
		}else if(Module.OnDemandAgg.module_content_4.takeover_type == 'vod'){
			Module.OnDemandAgg.module_4 = new VOD_Module($('bottomMiddleModule1'), 'middle', Module.OnDemandAgg.module_content_4.track_id, Module.OnDemandAgg.module_content_4.pic, Module.OnDemandAgg.module_content_4.teaser);
		}else if(Module.OnDemandAgg.module_content_4.takeover_type == 'news'){
			Module.OnDemandAgg.module_4 = new NEWS_MODULE($('bottomMiddleModule1'), 'middle');
		}else{
			$('bottomMiddleModule1').hide();
		}
	}else{
		Module.OnDemandAgg.module_4 = new NCDB_Module($('bottomMiddleModule1'), 'middle', Module.OnDemandAgg.module_content_4.type, Module.OnDemandAgg.module_content_4.artist_program_id, Module.OnDemandAgg.module_content_4.media_id);
	}
};
Module.OnDemandAgg.build_mod_5=function(){
	if(Module.OnDemandAgg.module_content_5.type == 'takeover'){
		if(Module.OnDemandAgg.module_content_5.content){
			$('bottomMiddleModule2').update(Module.OnDemandAgg.module_content_5.content);
		}else if(Module.OnDemandAgg.module_content_5.takeover_type == 'new'){
			Module.OnDemandAgg.module_5 = new New_Module($('bottomMiddleModule2'), 'middle', Module.OnDemandAgg.module_content_5.artist_id, Module.OnDemandAgg.module_content_5.loc_id);
		}else if(Module.OnDemandAgg.module_content_5.takeover_type == 'vod'){
			Module.OnDemandAgg.module_5 = new VOD_Module($('bottomMiddleModule2'), 'middle', Module.OnDemandAgg.module_content_5.track_id, Module.OnDemandAgg.module_content_5.pic, Module.OnDemandAgg.module_content_5.teaser);
		}else if(Module.OnDemandAgg.module_content_5.takeover_type == 'news'){
			Module.OnDemandAgg.module_5 = new NEWS_MODULE($('bottomMiddleModule2'), 'middle');
		}else{
			$('bottomMiddleModule2').hide();
		}
	}else{
		Module.OnDemandAgg.module_5 = new NCDB_Module($('bottomMiddleModule2'), 'middle', Module.OnDemandAgg.module_content_5.type, Module.OnDemandAgg.module_content_5.artist_program_id, Module.OnDemandAgg.module_content_5.media_id);
	}
};
Module.OnDemandAgg.init = function(){
	try{
		Module.OnDemandAgg.module_content_1 = new CPS_Query('odagg_left_1');
		Module.OnDemandAgg.module_content_2 = new CPS_Query('odagg_left_2');
		Module.OnDemandAgg.module_content_3 = new CPS_Query('odagg_left_3');
		Module.OnDemandAgg.module_content_4 = new CPS_Query('odagg_middle_1');
		Module.OnDemandAgg.module_content_5 = new CPS_Query('odagg_middle_2');
		Module.OnDemandAgg.module_content_1.eventManager.attachEventHandler( "module_loaded", Module.OnDemandAgg.build_mod_1);
		Module.OnDemandAgg.module_content_2.eventManager.attachEventHandler( "module_loaded", Module.OnDemandAgg.build_mod_2);
		Module.OnDemandAgg.module_content_3.eventManager.attachEventHandler( "module_loaded", Module.OnDemandAgg.build_mod_3);
//		Module.OnDemandAgg.module_content_4.eventManager.attachEventHandler( "module_loaded", Module.OnDemandAgg.build_mod_4);
		Module.OnDemandAgg.module_content_5.eventManager.attachEventHandler( "module_loaded", Module.OnDemandAgg.build_mod_5);
		Module.OnDemandAgg.module_content_1.eventManager.attachEventHandler( "module_null", function(){$('bottomLeftModule1').hide();});
		Module.OnDemandAgg.module_content_2.eventManager.attachEventHandler( "module_null", function(){$('bottomLeftModule2').hide();});
		Module.OnDemandAgg.module_content_3.eventManager.attachEventHandler( "module_null", function(){$('bottomLeftModule3').hide();});
	//		module_content_4.eventManager.attachEventHandler( "module_null", function(){$('bottomMiddleModule1').hide();});
		Module.OnDemandAgg.module_content_5.eventManager.attachEventHandler( "module_null", function(){$('bottomMiddleModule2').hide();});
	}catch(e){
		setTimeout(function(){Module.OnDemandAgg.init();}, 10);	
	}
}
Module.OnDemandAgg.init();