//################################################################################
//#			NAME: 		functionLoader
//#			CALLED BY:	Page Layout Manager (Post Form) [WebGUI Template]
//#			PURPOSE:	A single function that launches all necessary functions
//#						to run the form. Keeps the form page a little cleaner.
//################################################################################
function functionLoader(titleVal) {
	parseFields(1);
	parseFields(2);
	parseFields(3);
	parseFields(4);
	parseFields(5);
	populateMe(titleVal);
	attachValidation();
	validateForm();
	backgroundImages(document.getElementById('themeName').value,'miniLayout',320);
}


//################################################################################
//#			NAME: 		updateFields
//#			CALLED BY:	functionLoader, validateForm
//#			PURPOSE:	Obtains the values of a given layout, top, left and width
//#						and concatenates them into a single value, and assigns 
//#						them to a user defined variable. Secondly, it feeds these
//#						values to the miniLayout function.
//################################################################################
function updateFields(positionVal) {
	var topVal = document.getElementById('top' + positionVal).value;
	var leftVal = document.getElementById('left' + positionVal).value;
	var widthVal = document.getElementById('width' + positionVal).value;	
	
	var combineEm = topVal + "," + leftVal + "," + widthVal;
	
	document.getElementById("userDefined" + positionVal + "_formId").value = combineEm;
	miniLayout(positionVal,topVal,leftVal,widthVal);
}


//################################################################################
//#			NAME: 		parseFields
//#			CALLED BY:	functionLoader
//#			PURPOSE:	Grabs the concatenated top, left and width values and
//#						splits them up again to populate the input boxes when the
//#						page is loaded.
//################################################################################
function parseFields(userField) {
	var valArray = document.getElementById("userDefined" + userField + "_value").value.split(",");
	var elementArray = new Array(document.getElementById('top' + userField),document.getElementById('left' + userField),document.getElementById('width' + userField));
	for(i=0;i<valArray.length;i++) {
		elementArray[i].value = valArray[i];	
	}
	
}


//################################################################################
//#			NAME: 		populateMe
//#			CALLED BY: 	functionLoader
//#			PURPOSE:	Two WebGUI navigation assets create two javascript arrays
//#						that contain all of the names of user created themes, and
//#						then the names of themes to not be displayed. The function
//#						takes the values from the arrays and uses them to populate
//#						a dropdown box
//################################################################################
function populateMe(noTitle) {
	var themeNames = new Array("Theme ManagerLayout","exampleLayout","marsLayout","americanindiansLayout","flushingLayout","surveillanceLayout","tsunamiLayout","oceansLayout","lincolnLayout","chinausLayout","pittsburghLayout","alternativeenergyLayout","africandevelopmentLayout","dissentLayout","baseballLayout","gonorthLayout","greensburgLayout","jazzLayout","childsoldiersLayout","aidsLayout","nationalparksLayout","womeningovtLayout","undeclarationLayout","aidlatinamericaLayout","topuniversitiesLayout","identityLayout","cabinetLayout","endangeredLayout","obamaLayout","landingLayout","landolakesLayout","natoLayout","nonviolenceLayout","summitLayout","climatechangeLayout","journalismundersiegeLayout","communitycollegesLayout","moneytransfersLayout","swinefluLayout","portraitsiranLayout","passportsLayout","contrastscapitalismLayout","constitutionLayout","graphicnovelLayout","financecorruptionLayout","womencourageLayout","waterusageLayout","carbonLayout","anticorruptionLayout","cairoLayout","piracyLayout","revivetradeLayout","slampoetryLayout","space_commercializationLayout","digitallibraryLayout","moscowLayout","moscow_testLayout","moscowtrialLayout","obama_trialLayout","g8_2009Layout","july4th2009Layout","michelleobamaLayout","bikesworldLayout","obamaghanaLayout","russianartLayout","nanotechnologyLayout","usg_clickLayout","foiaLayout","anatomy_juryLayout","architect_greenLayout","agoa_2009_engLayout","nativeamerbizLayout","ramadanLayout","latinmusicLayout","carsshiftgreenLayout","hispanosartesLayout","cellphoneLayout","globalengineeringLayout","smartgridLayout","cap_and_tradeLayout","hiphopLayout","climate_healthLayout","consumer_layoutLayout","ungaLayout","conspiracyLayout","hispanicsusLayout","food_securityLayout","cybersecurityLayout","hispanic_purchaseLayout","search_rescueLayout","protestersaskLayout","adaptationLayout","anticorruptionbordersLayout","Eastern_BlocLayout","aceawards2009Layout","nativeamericanvoicesLayout","girls_educationLayout","teaching_toleranceLayout","cop15Layout","obama_nobelLayout","nuclearfreeworldLayout","eexchange1Layout","mitigationLayout","russian_coinsLayout","understanding_climate_changeLayout","eexchange_nuclearLayout","nukeguysLayout","religious_freedomLayout","eexchange3_forumLayout","entrepreneursconnectLayout","notable_african_americansLayout","preserving_minority_cultureLayout","scienceenvoysLayout","preserving_world_culturesLayout","youasked_febLayout","oprah_schoolLayout","talkingraceLayout","haitiLayout","govt_entrepreneurLayout","woc2010Layout","climate_waterLayout","youasked_carsLayout","ag_edLayout","jazz_americaLayout","youasked_marchLayout","planting_treesLayout","michelle_mexicoLayout","cultural_preservation_scaLayout","earthday2010Layout","entrepreneurship_summitLayout","debate_internetLayout","cc_partnershipsLayout","nuclear_understandLayout","youasked_federalismLayout","huck_finnLayout","twain_abroadLayout","youasked_archivesLayout","hispbuyingpower2Layout","youasked_indiansLayout","seeyouLayout","soccerLayout");		//Supplies the populated themeNames array
	var usedLayouts = new Array("obamaLayout","identityLayout","alternativeenergyLayout","communitycollegesLayout","climatechangeLayout","surveillanceLayout","money_transfersLayout","moneytransfersLayout","swinefluLayout","portraitsiranLayout","passportsLayout","contrastscapitalismLayout","constitutionLayout","graphicnovelLayout","financecorruptionLayout","womencourageLayout","waterusageLayout","aidlatinamericaLayout","oceansLayout","dissentLayout","africandevelopmentLayout","undeclarationLayout","pittsburghLayout","summitLayout","carbonLayout","anticorruptionLayout","cairoLayout","piracyLayout","revivetradeLayout","chinausLayout","slampoetryLayout","space_commercializationLayout","americanindiansLayout","baseballLayout","flushingLayout","landolakesLayout","nationalparksLayout","lincolnLayout","tsunamiLayout","childsoldiersLayout","womeningovtLayout","cabinetLayout","aidsLayout","topuniversitiesLayout","gonorthLayout","greensburgLayout","natoLayout","marsLayout","endangeredLayout","digitallibraryLayout","moscowLayout","moscowtrialLayout","obama_trialLayout","july4th2009Layout","michelleobamaLayout","g8_2009Layout","bikesworldLayout","obamaghanaLayout","russianartLayout","nanotechnologyLayout","usg_clickLayout","foiaLayout","anatomy_juryLayout","architect_greenLayout","agoa_2009_engLayout","nativeamerbizLayout","ramadanLayout","latinmusicLayout","carsshiftgreenLayout","cellphoneLayout","globalengineeringLayout","smartgridLayout","cap_and_tradeLayout","hiphopLayout","climate_healthLayout","consumer_layoutLayout","ungaLayout","conspiracyLayout","hispanicsusLayout","food_securityLayout","cybersecurityLayout","hispanic_purchaseLayout","search_rescueLayout","protestersaskLayout","adaptationLayout","anticorruptionbordersLayout","Eastern_BlocLayout","aceawards2009Layout","nativeamericanvoicesLayout","girls_educationLayout","teaching_toleranceLayout","cop15Layout","obama_nobelLayout","nuclearfreeworldLayout","eexchange1Layout","mitigationLayout","russian_coinsLayout","understanding_climate_changeLayout","eexchange_nuclearLayout","journalismundersiegeLayout","nonviolenceLayout","religious_freedomLayout","eexchange3_forumLayout","entrepreneursconnectLayout","notable_african_americansLayout","preserving_minority_cultureLayout","scienceenvoysLayout","youasked_febLayout","oprah_schoolLayout","talkingraceLayout","haitiLayout","govt_entrepreneurLayout","woc2010Layout","preserving_world_culturesLayout","climate_waterLayout","youasked_carsLayout","ag_edLayout","jazz_americaLayout","youasked_marchLayout","planting_treesLayout","michelle_mexicoLayout","cultural_preservation_scaLayout","earthday2010Layout","entrepreneurship_summitLayout","debate_internetLayout","cc_partnershipsLayout","nuclear_understandLayout","youasked_federalismLayout","huck_finnLayout","twain_abroadLayout","youasked_archivesLayout","hispbuyingpower2Layout","youasked_indiansLayout","seeyouLayout","soccerLayout");		//Supplies the populated usedLayouts array
	var themeName = document.getElementById('themeName').options;
	
	if(noTitle != 'Thread') {
		themeName[themeName.length] = new Option(noTitle, noTitle);
		themeName[themeName.length] = new Option("", "");
	}
	
	for (i=1;i<themeNames.length; i++) {
		if(noTitle != themeNames[i]) {
			for(x=0;x<usedLayouts.length;x++) {
				if(usedLayouts[x] == themeNames[i]) {
					repeatedLayout = 1;
					break;				
				}
				else
					repeatedLayout = 0;
			}
			if(!repeatedLayout) 
				themeName[themeName.length] = new Option(themeNames[i],themeNames[i]);	
		}
	}
}


//################################################################################
//#			NAME: 		miniLayout
//#			CALLED BY:	updateFields
//#			PURPOSE:	Positions boxes on a mock layout that is 1/3rd the scale
//#						of an actual america.gov layout
//################################################################################
function miniLayout(miniVal,topVal,leftVal,widthVal) {
	var miniVal = document.getElementById("mini" + miniVal);
	if((topVal != '') && (leftVal != '') && (widthVal != '')) {
		miniVal.style.top = Math.round(topVal / 3) + "px";
		miniVal.style.left = Math.round(leftVal / 3) + "px";
		miniVal.style.width = Math.round(widthVal / 3) + "px";
		miniVal.style.display = "block";
	}
	else {
		miniVal.style.top = "0px";
		miniVal.style.left = "0px";
		miniVal.style.width = "0px";
		miniVal.style.display = "none";
	}
}


//################################################################################
//#			NAME: 		validateForm
//#			CALLED BY: 	attachValidation, functionLoader
//#			PURPOSE:	Primarily this is to validate that each layout has all 3
//#						necessary values, left, top and width when the submit
//#						button is pressed. Error notifications are displayed in 
//#						red. This is also called to initially place the boxes
//#						in the mini layout.
//################################################################################
function validateForm() {
	var numOf = 5;
	var valid = true;
	var errorVal = document.getElementById('errorConsole');
	errorVal.innerHTML = '';
	
	for(i=1;i<=numOf;i++) {
		var topVal = document.getElementById('top' + i).value;
		var leftVal = document.getElementById('left' + i).value;
		var widthVal = document.getElementById('width' + i).value;
		var labelVal = document.getElementById('label' + i);
		
		if((topVal == '') || (leftVal == '') || (widthVal == '')) {
			if((topVal == '') && (leftVal == '') && (widthVal == '')) {
				//No values were entered, so don't do anything
			}
			else
			{	
				errorVal.style.color = 'red';
				errorVal.innerHTML = errorVal.innerHTML + "<div style='padding:5px 15px'>You must enter left, top and width values for layout " + i + "</div>"
				labelVal.style.color = 'red';
				valid = false;
			}
		}
		else {
			labelVal.style.color = 'black';
			updateFields(i);
			continue;
		}
		
	}
	//alert(valid);
	return valid;
}
	

//################################################################################
//#			NAME: 		attachValidation
//#			CALLED BY: 	functionLoader
//#			PURPOSE:	Attachs an onsubmit event to fire off the validateForm
//#						function
//################################################################################
function attachValidation() {
	var attachForm = document.getElementById('layoutManagerPost');	
	attachForm = attachForm.getElementsByTagName('form');
	attachForm[0].onsubmit = function () { return validateForm(); };
}


//################################################################################
//#			NAME: 		backgroundImages
//#			CALLED BY: 	Page Layout Manager (Thread), functionLoader()
//#			PURPOSE:	Places the correct background image for the layout. This 
//#						function is AssetProxied into the updatefields.js Snippet
//#						because it is actually a Collaboratoin System template,
//#						so its MIME type isn't text/javascript
//################################################################################
function backgroundImages(themeName,elementId,bckImgWidth) {
	//var themeName = themeName;
	var counter = 140;
	var themeArray = new Array(140);
	var imgHeight;
			
	for(i=0;i<counter;i++)
		themeArray[i] = new Array(2);
			
	
	themeArray[1-1][0] = "seeyouLayout";			//Theme Name	
	themeArray[1-1][1] = "/uploads/09/Zb/09Zb7ycDQx0EoSTI_yoHsA/seeyou_inthe_usa_bg.JPG";		//Background Image
	
	themeArray[2-1][0] = "soccerLayout";			//Theme Name	
	themeArray[2-1][1] = "/uploads/ES/aR/ESaRQfLqwJlHbWtA1cYvzA/democracy_is_soccer_bg.JPG";		//Background Image
	
	themeArray[3-1][0] = "youasked_indiansLayout";			//Theme Name	
	themeArray[3-1][1] = "/uploads/54/c5/54c5NMqgxPnWNfpVyUDPnw/indianland_bg.jpg";		//Background Image
	
	themeArray[4-1][0] = "hispbuyingpower2Layout";			//Theme Name	
	themeArray[4-1][1] = "/uploads/Wm/uQ/WmuQfBt441Y9sAkv2eeFSQ/HispanicPurchasingPower2-bkgd.jpg";		//Background Image
	
	themeArray[5-1][0] = "youasked_archivesLayout";			//Theme Name	
	themeArray[5-1][1] = "/uploads/O1/Uo/O1UozWRuRqY44nSHlKiZYw/generic_whos_right_bg.jpg";		//Background Image
	
	themeArray[6-1][0] = "debate_internetLayout";			//Theme Name	
	themeArray[6-1][1] = "/uploads/7d/Pl/7dPlS-WR04U4Y0AhUvikPA/pubs_exchange4_bg.jpg";		//Background Image
	
	themeArray[7-1][0] = "twain_abroadLayout";			//Theme Name	
	themeArray[7-1][1] = "/uploads/dO/2Q/dO2QawWO5XJlJa8_211e7w/MT_abroad_bg.jpg";		//Background Image
	
	themeArray[8-1][0] = "huck_finnLayout";			//Theme Name	
	themeArray[8-1][1] = "/uploads/jt/Fp/jtFphY-IxjYraSw2gK49XA/huck_finn_bg.jpg";		//Background Image
	
	themeArray[9-1][0] = "youasked_federalismLayout";			//Theme Name	
	themeArray[9-1][1] = "/uploads/yj/nE/yjnE0glv6dwYaS0sOMX4Ag/youasked_federalism_new.jpg";		//Background Image
	
	themeArray[10-1][0] = "entrepreneurship_summitLayout";			//Theme Name	
	themeArray[10-1][1] = "/uploads/2v/MR/2vMRj64PXcdfwHPRvg6J2g/ent_summit_bg.jpg";		//Background Image
	
	themeArray[11-1][0] = "notable_african_americansLayout";			//Theme Name	
	themeArray[11-1][1] = "/uploads/ch/xi/chxiVZAC-UI4VZtL23ZUlw/mtaylor_background.jpg";		//Background Image
	
	themeArray[12-1][0] = "nuclear_understandLayout";			//Theme Name	
	themeArray[12-1][1] = "/uploads/wX/op/wXopn3l6rqA331c6_kaR9A/us_nukestrategy_bg2.jpg";		//Background Image
	
	themeArray[13-1][0] = "journalismundersiegeLayout";			//Theme Name	
	themeArray[13-1][1] = "/uploads/oN/5p/oN5pDcENT6x0YQt9BoLXPQ/journalism_background_DPF.jpg";		//Background Image
	
	themeArray[14-1][0] = "cc_partnershipsLayout";			//Theme Name	
	themeArray[14-1][1] = "/uploads/V_/Rj/V_RjbGc_6YsPjZp5gmNPvw/climatechange_background.jpg";		//Background Image
	
	themeArray[15-1][0] = "planting_treesLayout";			//Theme Name	
	themeArray[15-1][1] = "/uploads/cz/I1/czI1upLKLjIXsPpmqYh1iw/trees_bg.jpg";		//Background Image
	
	themeArray[16-1][0] = "earthday2010Layout";			//Theme Name	
	themeArray[16-1][1] = "/uploads/rO/sX/rOsXhkjcgSK-QBZE5_K5kA/ed_water_bg.jpg";		//Background Image
	
	themeArray[17-1][0] = "cultural_preservation_scaLayout";			//Theme Name	
	themeArray[17-1][1] = "/uploads/Mh/ih/Mhih30Dp2mYC1fFCQAydYA/preserving-culture_sca.jpg";		//Background Image
	
	themeArray[18-1][0] = "michelle_mexicoLayout";			//Theme Name	
	themeArray[18-1][1] = "/uploads/4I/qd/4Iqd5x3DKYp8K-23NGXHyw/mo_mexico_bg.jpg";		//Background Image
	
	themeArray[19-1][0] = "youasked_marchLayout";			//Theme Name	
	themeArray[19-1][1] = "/uploads/Ih/kU/IhkUmzTnG1BNN0s5pVlElA/holliwood_bg.jpg";		//Background Image
	
	themeArray[20-1][0] = "jazz_americaLayout";			//Theme Name	
	themeArray[20-1][1] = "/uploads/OF/x0/OFx0QhsoE4u2HzlJ9-3NbQ/jazz_bg.jpg";		//Background Image
	
	themeArray[21-1][0] = "ag_edLayout";			//Theme Name	
	themeArray[21-1][1] = "/uploads/v7/U3/v7U3TuU-k5Ii0NOXufiqkQ/agricultural_ed_bg.jpg";		//Background Image
	
	themeArray[22-1][0] = "govt_entrepreneurLayout";			//Theme Name	
	themeArray[22-1][1] = "/uploads/bX/7e/bX7ezynVnsk3Ap6ik2DuhQ/entrepreneurs_bg.jpg";		//Background Image
	
	themeArray[23-1][0] = "climate_waterLayout";			//Theme Name	
	themeArray[23-1][1] = "/uploads/uj/H5/ujH5jxp_8Ppo93hA-WtHvw/water_background.jpg";		//Background Image
	
	themeArray[24-1][0] = "youasked_febLayout";			//Theme Name	
	themeArray[24-1][1] = "/uploads/uV/Pi/uVPicAlmX8tf6j7SujHpig/youasked_nyc_bg.JPG";		//Background Image
	
	themeArray[25-1][0] = "youasked_carsLayout";			//Theme Name	
	themeArray[25-1][1] = "/uploads/li/lP/lilPOWbGRbjv8mupU4lVaw/youasked_cars_bg.JPG";		//Background Image
	
	themeArray[26-1][0] = "preserving_world_culturesLayout";			//Theme Name	
	themeArray[26-1][1] = "/uploads/qh/MX/qhMXaaUHZ1tDyzXMqQ2PzA/preserv_world_cultures_eu_bg.jpg";		//Background Image
	
	themeArray[27-1][0] = "woc2010Layout";			//Theme Name	
	themeArray[27-1][1] = "/uploads/rP/A7/rPA7SZ3t1Gyzb1z9aI3yag/women_feature_background.jpg";		//Background Image
	
	themeArray[28-1][0] = "haitiLayout";			//Theme Name	
	themeArray[28-1][1] = "/uploads/N2/gl/N2glEXRlDOQ1URllK-_Csw/haiti_bg.jpg";		//Background Image
	
	themeArray[29-1][0] = "talkingraceLayout";			//Theme Name	
	themeArray[29-1][1] = "/uploads/pC/L0/pCL0Ip1K87iuvARDtHuRuQ/diversity_feature_bg.jpg";		//Background Image
	
	themeArray[30-1][0] = "preserving_minority_cultureLayout";			//Theme Name	
	themeArray[30-1][1] = "/uploads/Z_/8z/Z_8z8FAwrxHbWpIJhd3SMQ/preserving_minority_bg.jpg";		//Background Image
	
	themeArray[31-1][0] = "oprah_schoolLayout";			//Theme Name	
	themeArray[31-1][1] = "/uploads/J4/Eq/J4Eq0mdvHibiB-W__iRMJg/oprah_bg.jpg";		//Background Image
	
	themeArray[32-1][0] = "scienceenvoysLayout";			//Theme Name	
	themeArray[32-1][1] = "/uploads/_c/gY/_cgYHu35ylwhI-jLz9OG2A/envoys_bg.jpg";		//Background Image
	
	themeArray[33-1][0] = "religious_freedomLayout";			//Theme Name	
	themeArray[33-1][1] = "/uploads/qV/-U/qV-Uc0mvePZWizSOqXFeww/bg2.jpg";		//Background Image
	
	themeArray[34-1][0] = "entrepreneursconnectLayout";			//Theme Name	
	themeArray[34-1][1] = "/uploads/xA/Mt/xAMtq7gYvZdJ8x2PrTIgvA/entrepreneursconnect-bg.jpg";		//Background Image
	
	themeArray[35-1][0] = "eexchange3_forumLayout";			//Theme Name	
	themeArray[35-1][1] = "/uploads/MN/6f/MN6fz551aZebVpG4jntmwQ/pubxchange3_bg.jpg";		//Background Image
	
	themeArray[36-1][0] = "nukeguysLayout";			//Theme Name	
	themeArray[36-1][1] = "/uploads/z8/qL/z8qLLHmUvtikXhgDkmlyUQ/whosright_bg_comp.jpg";		//Background Image
	
	themeArray[37-1][0] = "eexchange_nuclearLayout";			//Theme Name	
	themeArray[37-1][1] = "/uploads/Qf/CR/QfCRdmoZP49Zolj1FhCImQ/whosright_bg.jpg";		//Background Image
	
	themeArray[38-1][0] = "understanding_climate_changeLayout";			//Theme Name	
	themeArray[38-1][1] = "/uploads/Q-/Ef/Q-EfGYlge_mBjBIy01PZqg/understanding_climate_change_bk.jpg";		//Background Image
	
	themeArray[39-1][0] = "russian_coinsLayout";			//Theme Name	
	themeArray[39-1][1] = "/uploads/w0/I0/w0I0FWRukgHasbCogarknw/russian_coins_bg.jpg";		//Background Image
	
	themeArray[40-1][0] = "adaptationLayout";			//Theme Name	
	themeArray[40-1][1] = "/uploads/0O/3W/0O3W6rCwmdepfk2BWz38Fg/how-do-people-adapt_bg_noboxes2.jpg";		//Background Image
	
	themeArray[41-1][0] = "eexchange1Layout";			//Theme Name	
	themeArray[41-1][1] = "/uploads/sV/EU/sVEUYPySlb3rAU5ig5i-tA/whosright_bg.jpg";		//Background Image
	
	themeArray[42-1][0] = "mitigationLayout";			//Theme Name	
	themeArray[42-1][1] = "/uploads/-Q/_z/-Q_zTJadTH9lQabuFIBggQ/mitigation_bg.jpg";		//Background Image
	
	themeArray[43-1][0] = "nuclearfreeworldLayout";			//Theme Name	
	themeArray[43-1][1] = "/uploads/kT/w7/kTw7EcVVoHv7bqS6BwQJPw/feature_bg.jpg";		//Background Image
	
	themeArray[44-1][0] = "teaching_toleranceLayout";			//Theme Name	
	themeArray[44-1][1] = "/uploads/rf/ug/rfugQ1mvCVIfPFt9GAY2bw/tolerance_bg_v2.jpg";		//Background Image
	
	themeArray[45-1][0] = "obama_nobelLayout";			//Theme Name	
	themeArray[45-1][1] = "/uploads/82/1a/821aJiPiW5obzgXA9k6VDw/obama_bg_1box.jpg";		//Background Image
	
	themeArray[46-1][0] = "cop15Layout";			//Theme Name	
	themeArray[46-1][1] = "/uploads/mL/Ng/mLNgiiEDupw8cl4txHyzbQ/cop15_bkgd_up.jpg";		//Background Image
	
	themeArray[47-1][0] = "Eastern_BlocLayout";			//Theme Name	
	themeArray[47-1][1] = "/uploads/8L/hG/8LhGYX3CPpcdJPTZtorD3Q/democracy_bg1-edit.jpg";		//Background Image
	
	themeArray[48-1][0] = "girls_educationLayout";			//Theme Name	
	themeArray[48-1][1] = "/uploads/Ql/WK/QlWKw2fu1zqAAXTqMc8rQw/girls_edu_bg.jpg";		//Background Image
	
	themeArray[49-1][0] = "nativeamericanvoicesLayout";			//Theme Name	
	themeArray[49-1][1] = "/uploads/we/l4/wel47pXtDYQlHeGKkvQRog/nativeamerican_bg.jpg";		//Background Image
	
	themeArray[50-1][0] = "conspiracyLayout";			//Theme Name	
	themeArray[50-1][1] = "/uploads/nV/yd/nVydmd7d4tFwcA3qBw3EGw/ConspiracyTheories-bkgd.jpg";		//Background Image
	
	themeArray[51-1][0] = "aceawards2009Layout";			//Theme Name	
	themeArray[51-1][1] = "/uploads/1V/QM/1VQMa0p2qEqYyT_2bQGaAg/2009awardsforexcellence-bkgd.jpg";		//Background Image
	
	themeArray[52-1][0] = "anticorruptionbordersLayout";			//Theme Name	
	themeArray[52-1][1] = "/uploads/w1/0H/w10HD6qnVdKseprd6u1F_A/anti_corruption_bg.jpg";		//Background Image
	
	themeArray[53-1][0] = "protestersaskLayout";			//Theme Name	
	themeArray[53-1][1] = "/uploads/Rb/Bw/RbBwXeTT98PuzKSCJzD1CA/protstorsask3-bkgd.jpg";		//Background Image
	
	themeArray[54-1][0] = "search_rescueLayout";			//Theme Name	
	themeArray[54-1][1] = "/uploads/1S/i3/1Si3vSxeSkgBU1_Gk50ImQ/searchandrescue1-bkgd.jpg";		//Background Image
	
	themeArray[55-1][0] = "hispanic_purchaseLayout";			//Theme Name	
	themeArray[55-1][1] = "/uploads/qT/Lx/qTLxvcbqbgrH-TjlKDF_JQ/HispanicPurchasingPower2-bkgd.jpg";		//Background Image
	
	themeArray[56-1][0] = "cybersecurityLayout";			//Theme Name	
	themeArray[56-1][1] = "/uploads/Ns/3b/Ns3bG3lDMyxN3Y9A4dbvpg/cyber_security4-bkgd.jpg";		//Background Image
	
	themeArray[57-1][0] = "food_securityLayout";			//Theme Name	
	themeArray[57-1][1] = "/uploads/6Q/cj/6QcjyUIca7jCMTba0OD7pg/foodsecurityBkgnd.jpg";		//Background Image
	
	themeArray[58-1][0] = "climate_healthLayout";			//Theme Name	
	themeArray[58-1][1] = "/uploads/RD/Cq/RDCqjypWSYrSCmicN4quLg/climate_health7-bkgd.jpg";		//Background Image
	
	themeArray[59-1][0] = "hispanicsusLayout";			//Theme Name	
	themeArray[59-1][1] = "/uploads/29/s0/29s0_JBnzlspVKiLlfVGrA/hispanicculture-bkgd.jpg";		//Background Image
	
	themeArray[60-1][0] = "ungaLayout";			//Theme Name	
	themeArray[60-1][1] = "/uploads/57/md/57md5UjsSpyw_a3iY4h5Tw/TheUSandUN2-bkgd.jpg";		//Background Image
	
	themeArray[61-1][0] = "consumer_layoutLayout";			//Theme Name	
	themeArray[61-1][1] = "/uploads/JS/1W/JS1Ww83RpB0TrE3OgtyeoQ/NewConsumption1-bkgd.jpg";		//Background Image
	
	themeArray[62-1][0] = "ramadanLayout";			//Theme Name	
	themeArray[62-1][1] = "/uploads/yc/i3/yci35EE1BqfCwsB7bo1YEQ/ramadan_layout.jpg";		//Background Image
	
	themeArray[63-1][0] = "smartgridLayout";			//Theme Name	
	themeArray[63-1][1] = "/uploads/w4/SB/w4SBCgHuka601CshEOPJGQ/smartgrid_bkgd.jpg";		//Background Image
	
	themeArray[64-1][0] = "hiphopLayout";			//Theme Name	
	themeArray[64-1][1] = "/uploads/rd/F_/rdF_bJSWDOR6v4P5TbuUgA/empowered_bkgd_en.jpg";		//Background Image
	
	themeArray[65-1][0] = "cap_and_tradeLayout";			//Theme Name	
	themeArray[65-1][1] = "/uploads/L2/ze/L2zetNj1awVWklW5mJSQtw/debatingcapandtrade4-bkgd.jpg";		//Background Image
	
	themeArray[66-1][0] = "africandevelopmentLayout";			//Theme Name	
	themeArray[66-1][1] = "/uploads/T5/gq/T5gqx0Jyazf4hu-Vh-KOiA/blackbusiness_bkgd.jpg";		//Background Image
	
	themeArray[67-1][0] = "nativeamerbizLayout";			//Theme Name	
	themeArray[67-1][1] = "/uploads/YE/v5/YEv5uncw9CL05Oi8Zy_dSQ/AmericanIndiansinBusiness2-bkgd.jpg";		//Background Image
	
	themeArray[68-1][0] = "globalengineeringLayout";			//Theme Name	
	themeArray[68-1][1] = "/uploads/Zz/ZX/ZzZXUEI4HJkj8NDVgkWefQ/globalengineering-bkgd.jpg";		//Background Image
	
	themeArray[69-1][0] = "cellphoneLayout";			//Theme Name	
	themeArray[69-1][1] = "/uploads/SE/hc/SEhc-5mhaiyh5IR7lZqvog/cell_bkgd_EDIT.jpg";		//Background Image
	
	themeArray[70-1][0] = "latinmusicLayout";			//Theme Name	
	themeArray[70-1][1] = "/uploads/UB/bC/UBbCDtRfQwCTKWaTBThrOw/musicfam-bkgrd.JPG";		//Background Image
	
	themeArray[71-1][0] = "landolakesLayout";			//Theme Name	
	themeArray[71-1][1] = "/uploads/QH/Ll/QHLlQw10W6e8KMQ2VQED0Q/Land-O-Lakes_bkgd.jpg";		//Background Image
	
	themeArray[72-1][0] = "hispanosartesLayout";			//Theme Name	
	themeArray[72-1][1] = "";		//Background Image
	
	themeArray[73-1][0] = "carsshiftgreenLayout";			//Theme Name	
	themeArray[73-1][1] = "/uploads/82/r2/82r2Knc5iql8sz5NtSBufw/carsshifttogreen-bkgd2.jpg";		//Background Image
	
	themeArray[74-1][0] = "usg_clickLayout";			//Theme Name	
	themeArray[74-1][1] = "/uploads/Gq/vs/GqvsSbo1e9Nv5Z5bUzHyPA/USGattheClick-bkgd.jpg";		//Background Image
	
	themeArray[75-1][0] = "agoa_2009_engLayout";			//Theme Name	
	themeArray[75-1][1] = "/uploads/r7/WG/r7WGUf6Aax7Zllnm1uDPbA/AGOA2009RealizingthePotential4-bkgd.jpg";		//Background Image
	
	themeArray[76-1][0] = "architect_greenLayout";			//Theme Name	
	themeArray[76-1][1] = "/uploads/MP/C7/MPC7aXlTYsfJPo_M6gJ52g/grnbdg-bkgd.jpg";		//Background Image
	
	themeArray[77-1][0] = "anatomy_juryLayout";			//Theme Name	
	themeArray[77-1][1] = "/uploads/XQ/5y/XQ5yjwLOBeGIf-beeHZEdg/AnatomyofaJury-bkgd.jpg";		//Background Image
	
	themeArray[78-1][0] = "foiaLayout";			//Theme Name	
	themeArray[78-1][1] = "/uploads/LO/aA/LOaA1ep1XXFS8rPeTgJZIQ/foia-bkgd.jpg";		//Background Image
	
	themeArray[79-1][0] = "nanotechnologyLayout";			//Theme Name	
	themeArray[79-1][1] = "/uploads/Jy/9U/Jy9UmsYKoE6XOmvAD1Yfag/ScienceandArtofNanotechnology-bkgd.jpg";		//Background Image
	
	themeArray[80-1][0] = "carbonLayout";			//Theme Name	
	themeArray[80-1][1] = "/uploads/Fq/bK/FqbKQBaR2Ngw8RBBTgOK5w/Map-Cycle_bkgd.jpg";		//Background Image
	
	themeArray[81-1][0] = "russianartLayout";			//Theme Name	
	themeArray[81-1][1] = "/uploads/19/dL/19dLwbJG7JAvXask0KkUEQ/Russian-InfluenceUSArts5-bkgd1.jpg";		//Background Image
	
	themeArray[82-1][0] = "bikesworldLayout";			//Theme Name	
	themeArray[82-1][1] = "/uploads/VO/Au/VOAuO7N9ppt-LsUfDCtmhg/BikesfortheWorld2-bkgd.jpg";		//Background Image
	
	themeArray[83-1][0] = "michelleobamaLayout";			//Theme Name	
	themeArray[83-1][1] = "/uploads/wp/ll/wpllDA-T5FuV63SP1mdE5g/michelleobama_bkgnd.jpg";		//Background Image
	
	themeArray[84-1][0] = "moscowLayout";			//Theme Name	
	themeArray[84-1][1] = "/uploads/pW/ls/pWls6i9XmRuJaXBZhwXhFg/obama_russia_bkgnd.jpg";		//Background Image
	
	themeArray[85-1][0] = "moscowtrialLayout";			//Theme Name	
	themeArray[85-1][1] = "/uploads/_d/-7/_d-7o3NyLZ4e0y8J7fjgIQ/obama_russia_bkgnd_ru.jpg";		//Background Image
	
	themeArray[86-1][0] = "obamaghanaLayout";			//Theme Name	
	themeArray[86-1][1] = "/uploads/X9/2_/X92_eB_lpmiGTsC3MpbkoA/Ghana-Obama3-bkgd.jpg";		//Background Image
	
	themeArray[87-1][0] = "g8_2009Layout";			//Theme Name	
	themeArray[87-1][1] = "/uploads/PL/d3/PLd32LazzbFnoxTDgVAlYA/G8Summit.jpg";		//Background Image
	
	themeArray[88-1][0] = "july4th2009Layout";			//Theme Name	
	themeArray[88-1][1] = "/uploads/HV/S_/HVS_yu44jnKwtsHOPdp1GA/4thofjuly-bkgd.jpg";		//Background Image
	
	themeArray[89-1][0] = "obama_trialLayout";			//Theme Name	
	themeArray[89-1][1] = "/uploads/ug/Gk/ugGkvIR7j3MthfOV6Oxh6g/MeetBarackObama_bkgd.jpg";		//Background Image
	
	themeArray[90-1][0] = "obamaLayout";			//Theme Name	
	themeArray[90-1][1] = "/uploads/1S/jp/1SjpYU5Nzmqft4iWqNrJEg/MeetBarackObama_bkgd.jpg";		//Background Image
	
	themeArray[91-1][0] = "digitallibraryLayout";			//Theme Name	
	themeArray[91-1][1] = "/uploads/6u/3B/6u3B6sfQNVL2a7X7CV0PdQ/digitallibrary-bkgd.jpg";		//Background Image
	
	themeArray[92-1][0] = "moscow_testLayout";			//Theme Name	
	themeArray[92-1][1] = "/uploads/Jo/Pn/JoPnmofEDeiNjoVJYuJbCA/obama_russia_bkgnd_ru.jpg";		//Background Image
	
	themeArray[93-1][0] = "waterusageLayout";			//Theme Name	
	themeArray[93-1][1] = "/uploads/Eb/7p/Eb7pZar2Mx9duhW592SX2A/coloradoriver6-bkgd.jpg";		//Background Image
	
	themeArray[94-1][0] = "slampoetryLayout";			//Theme Name	
	themeArray[94-1][1] = "/uploads/9B/Qm/9BQmmEqikZ0clE5HiUgDDw/slampoetry-bkgd.jpg";		//Background Image
	
	themeArray[95-1][0] = "cabinetLayout";			//Theme Name	
	themeArray[95-1][1] = "/uploads/w8/V3/w8V3Ph_nbHRxeqh9NUxQlg/ObamasCabinet_bkgd.jpg";		//Background Image
	
	themeArray[96-1][0] = "space_commercializationLayout";			//Theme Name	
	themeArray[96-1][1] = "/uploads/zz/yy/zzyyW75LeXC0rOpS-SNRPw/space3-bkgd.jpg";		//Background Image
	
	themeArray[97-1][0] = "revivetradeLayout";			//Theme Name	
	themeArray[97-1][1] = "/uploads/sp/jR/spjRf4yZsJ7SFbgzAyJ7Mw/tradefinance-bkgd.jpg";		//Background Image
	
	themeArray[98-1][0] = "graphicnovelLayout";			//Theme Name	
	themeArray[98-1][1] = "/uploads/d7/Y3/d7Y30GJ4M85QQmC8WMFRVA/graphic-novels-bkgd.jpg";		//Background Image
	
	themeArray[99-1][0] = "cairoLayout";			//Theme Name	
	themeArray[99-1][1] = "/uploads/Ao/q5/Aoq5MQ6w1KsGt6MUywJRVQ/cairo2.gif";		//Background Image
	
	themeArray[100-1][0] = "piracyLayout";			//Theme Name	
	themeArray[100-1][1] = "/uploads/1y/jo/1yjoF4CXZdilPcHtM_3dVw/combatingpiracy-bkgd.jpg";		//Background Image
	
	themeArray[101-1][0] = "anticorruptionLayout";			//Theme Name	
	themeArray[101-1][1] = "/uploads/eG/yt/eGytT2j-pmNc0gBKcmNFRw/corruption-bkgd3b.jpg";		//Background Image
	
	themeArray[102-1][0] = "financecorruptionLayout";			//Theme Name	
	themeArray[102-1][1] = "/uploads/VL/jC/VLjCCb8k-5nPmiGCq8CbKQ/corruption-bkgd3b.jpg";		//Background Image
	
	themeArray[103-1][0] = "aidlatinamericaLayout";			//Theme Name	
	themeArray[103-1][1] = "/uploads/Aw/Qp/AwQp9BoPmCithEBKu2ab-w/Campaign-helpinghands-bkgd.jpg";		//Background Image
	
	themeArray[104-1][0] = "womencourageLayout";			//Theme Name	
	themeArray[104-1][1] = "/uploads/rq/nq/rqnqX1e4PnYgEff3se24QA/womenofcourage-bkgd.jpg";		//Background Image
	
	themeArray[105-1][0] = "swinefluLayout";			//Theme Name	
	themeArray[105-1][1] = "/uploads/PG/2T/PG2TW3jUWw9F0ZRTbtvcJw/swineflu-bkgd_2.jpg";		//Background Image
	
	themeArray[106-1][0] = "contrastscapitalismLayout";			//Theme Name	
	themeArray[106-1][1] = "/uploads/fK/_M/fK_M1eFZmRwbTgOx9ti8Xw/contrastincapitalism4-bkgd.jpg";		//Background Image
	
	themeArray[107-1][0] = "portraitsiranLayout";			//Theme Name	
	themeArray[107-1][1] = "/uploads/81/gV/81gV-mMAkETg0Irg_-OIsQ/imagesfromiran-bkgd3.jpg";		//Background Image
	
	themeArray[108-1][0] = "constitutionLayout";			//Theme Name	
	themeArray[108-1][1] = "/uploads/e4/Fe/e4Fez29gZ14TCZV0fyT0WQ/constitution-bkgd4.jpg";		//Background Image
	
	themeArray[109-1][0] = "communitycollegesLayout";			//Theme Name	
	themeArray[109-1][1] = "/uploads/tv/Tm/tvTmAl-HqGkGeBONN0HLBA/1community-colleges3-bkgd.jpg";		//Background Image
	
	themeArray[110-1][0] = "passportsLayout";			//Theme Name	
	themeArray[110-1][1] = "/uploads/4B/ua/4Buacf1jnZTlhu0qEXSnmA/passportvisas-bkgd.jpg";		//Background Image
	
	themeArray[111-1][0] = "moneytransfersLayout";			//Theme Name	
	themeArray[111-1][1] = "/uploads/jt/xQ/jtxQssdrjS7W6oTvzMlKog/remittances2.jpg";		//Background Image
	
	themeArray[112-1][0] = "climatechangeLayout";			//Theme Name	
	themeArray[112-1][1] = "/uploads/xa/77/xa77z6Fnc_v27AuawaNBFQ/Campaign-climate-bkgd-2.jpg";		//Background Image
	
	themeArray[113-1][0] = "summitLayout";			//Theme Name	
	themeArray[113-1][1] = "/uploads/H5/EU/H5EU2R3hdqifUzP3jf4ZoQ/summit_americas_bkgnd.jpg";		//Background Image
	
	themeArray[114-1][0] = "nonviolenceLayout";			//Theme Name	
	themeArray[114-1][1] = "/uploads/rv/6A/rv6AR-xSnHWAXWAIbiaj6w/nonviolence_bkgnd.jpg";		//Background Image
	
	themeArray[115-1][0] = "americanindiansLayout";			//Theme Name	
	themeArray[115-1][1] = "/uploads/vH/1V/vH1VPEgg_JKBq3o6PfYOhA/AmericaIndian_layout_final_.jpg";		//Background Image
	
	themeArray[116-1][0] = "natoLayout";			//Theme Name	
	themeArray[116-1][1] = "/uploads/kl/EP/klEPlowLYV6IiYkPCwK3Ug/nato_bckgrnd.jpg";		//Background Image
	
	themeArray[117-1][0] = "chinausLayout";			//Theme Name	
	themeArray[117-1][1] = "/uploads/zo/q7/zoq7MP3sGF7h98wJLAiusw/us_china_3.jpg";		//Background Image
	
	themeArray[118-1][0] = "undeclarationLayout";			//Theme Name	
	themeArray[118-1][1] = "/uploads/4S/1M/4S1MXghAWkctB9Fj_JnWqw/UN_declaration2_bkgnd.jpg";		//Background Image
	
	themeArray[119-1][0] = "womeningovtLayout";			//Theme Name	
	themeArray[119-1][1] = "/uploads/Ae/lv/AelvwGEIWRlLujBXlHbAnA/Campaign-cracking-bkgd.jpg";		//Background Image
	
	themeArray[120-1][0] = "flushingLayout";			//Theme Name	
	themeArray[120-1][1] = "/uploads/Cn/DB/CnDBx9QQkxbzjSCYZuls-w/flushing_bkgnd2.jpg";		//Background Image
	
	themeArray[121-1][0] = "identityLayout";			//Theme Name	
	themeArray[121-1][1] = "/uploads/Pb/Sn/PbSnID4IVy1wV8RK8DC7tQ/Identity_bkgd.jpg";		//Background Image
	
	themeArray[122-1][0] = "gonorthLayout";			//Theme Name	
	themeArray[122-1][1] = "/uploads/xr/Uq/xrUq5m6B5P43cOjPEL6JJw/go_north.jpg";		//Background Image
	
	themeArray[123-1][0] = "topuniversitiesLayout";			//Theme Name	
	themeArray[123-1][1] = "/uploads/Ky/4H/Ky4HidbPLK437SCZQOXv2Q/TopUniversity_bkgd.jpg";		//Background Image
	
	themeArray[124-1][0] = "pittsburghLayout";			//Theme Name	
	themeArray[124-1][1] = "/uploads/_-/U-/_-U-_o6anzxWWkvPaN2bqw/Campaign_rustbelt_bkgd.jpg";		//Background Image
	
	themeArray[125-1][0] = "nationalparksLayout";			//Theme Name	
	themeArray[125-1][1] = "/uploads/Aw/wW/AwwWfHvDMgh-W3EjSucYag/Campaign-passports-bkgd.jpg";		//Background Image
	
	themeArray[126-1][0] = "surveillanceLayout";			//Theme Name	
	themeArray[126-1][1] = "/uploads/PC/51/PC51wPTsINRFdIeOdIdnIQ/campaign-ids-bkgd2.jpg";		//Background Image
	
	themeArray[127-1][0] = "lincolnLayout";			//Theme Name	
	themeArray[127-1][1] = "/uploads/YK/zw/YKzwWg-QI5xdYBAhkaRfdg/abraham-lincoln-625.jpg";		//Background Image
	
	themeArray[128-1][0] = "oceansLayout";			//Theme Name	
	themeArray[128-1][1] = "/uploads/6h/2q/6h2qMpg1CiUZB6fspd7rSw/ocean-protecting2-bkgd.jpg";		//Background Image
	
	themeArray[129-1][0] = "aidsLayout";			//Theme Name	
	themeArray[129-1][1] = "/uploads/a2/Hp/a2Hp10Msz7t0PPtBZg2tVg/amgov_beating_aids_bg.jpg";		//Background Image
	
	themeArray[130-1][0] = "marsLayout";			//Theme Name	
	themeArray[130-1][1] = "/uploads/_G/6v/_G6vrjxPGEeCyQouz59miQ/campaign-mars-bkgd2.jpg";		//Background Image
	
	themeArray[131-1][0] = "tsunamiLayout";			//Theme Name	
	themeArray[131-1][1] = "/uploads/Oy/Bn/OyBnCHlEcWIbBMtfCnp0tQ/campaign-deploy-bkgd-new.jpg";		//Background Image
	
	themeArray[132-1][0] = "jazzLayout";			//Theme Name	
	themeArray[132-1][1] = "/uploads/PU/WN/PUWNTo1ESgzy0FeMMQ6WiA/Campaign-jazz-bkgd.jpg";		//Background Image
	
	themeArray[133-1][0] = "greensburgLayout";			//Theme Name	
	themeArray[133-1][1] = "/uploads/2k/j_/2kj_RXb6fUIIzfNBrz9Nsw/Campaign-gonerebuilt-bkgd.jpg";		//Background Image
	
	themeArray[134-1][0] = "childsoldiersLayout";			//Theme Name	
	themeArray[134-1][1] = "/uploads/w_/5N/w_5NP-8O7me_Ob9GpKIJuQ/Campaign-exploited-bkgd.jpg";		//Background Image
	
	themeArray[135-1][0] = "alternativeenergyLayout";			//Theme Name	
	themeArray[135-1][1] = "/uploads/NC/hq/NChqjDVrNlXCFU3tm0UXeA/Campaign-alt_energy_final.jpg";		//Background Image
	
	themeArray[136-1][0] = "dissentLayout";			//Theme Name	
	themeArray[136-1][1] = "/uploads/Gc/v0/Gcv0fIjCu3DYGODYHcWdTg/Campaign-dissent-bkgd.jpg";		//Background Image
	
	themeArray[137-1][0] = "baseballLayout";			//Theme Name	
	themeArray[137-1][1] = "/uploads/VU/-f/VU-fymCls7WjhEsuJStWuQ/Campaign-baseball-bkgd.jpg";		//Background Image
	
	themeArray[138-1][0] = "endangeredLayout";			//Theme Name	
	themeArray[138-1][1] = "/uploads/eM/s-/eMs-R0St758c_zPXdOYJ0g/vanishing-act_bkgd.jpg";		//Background Image
	
	themeArray[139-1][0] = "landingLayout";			//Theme Name	
	themeArray[139-1][1] = "";		//Background Image
	
	themeArray[140-1][0] = "exampleLayout";			//Theme Name	
	themeArray[140-1][1] = "/uploads/Wn/Ja/WnJaqnpywEgKXEgEB6dN2Q/25.png";		//Background Image
	
	
	
	for(i=0;i<counter;i++)		
		if(themeName == themeArray[i][0]) {			
			var bckImg = document.getElementById(elementId);
			var ifImage = bckImg.getElementsByTagName('img');
			if(ifImage.length > 0)
				bckImg.removeChild(ifImage[0])
			var newImg = document.createElement('img');
			newImg.setAttribute('src',themeArray[i][1]);
			newImg.setAttribute('style','z-index:0;position:relative;top:0px;left:0px;');
			newImg.setAttribute('width',bckImgWidth);
			//imgHeight = (bckImgWidth < 500) ? '33%' : '100%';	
			newImg.setAttribute('height','*');			
			bckImg.appendChild(newImg);
		}
}


//################################################################################
//#			NAME: 		expandParent
//#			CALLED BY: 	Page Layout Manager (Thread)
//#			PURPOSE:	Resizes the containing element to allow all of the
//#						absolutely positioned items to not overflow
//################################################################################
function expandParent(parentEl) {
	var parentEl = document.getElementById(parentEl);
	var childEl = parentEl.getElementsByTagName('div');  
	var childImg = parentEl.getElementsByTagName('img');
	var dynaCells = new Array();
	var counter = 1;
	var finalVal = 0;
	var isProduction = 0;
	
	for(i=0;i<childEl.length;i++) {
		if(childEl[i].id.indexOf('dyna') != -1) isProduction = 1;
		if(childEl[i].className.indexOf('Layout') != -1) parentEl = childEl[i];
	}
			
	
	if(isProduction) {
		counter = 0;
		for(i=0;i<childEl.length;i++) {
			dynaCells[counter] = childEl[i].offsetTop + childEl[i].offsetHeight;
			counter++
		}
		counter = 1;
		
		for(i=0;i<dynaCells.length;i++) {
			if(i==dynaCells.length-1)
				counter = 0;
			
			if(dynaCells[i] >= dynaCells[counter]) {
				if(dynaCells[i] > finalVal)
					finalVal = dynaCells[i]
				
				//alert(i + "- " + dynaCells[i] + " vs." + dynaCells[counter] + " = " + finalVal);
			}
		}	

	}
	else {
		for(i=0;i<childEl.length;i++) {
			if(i==childEl.length - 1)
				counter = 0;
	
			if(childEl[i].offsetTop + childEl[i].offsetHeight > childEl[counter].offsetTop + childEl[counter].offsetHeight)
				finalVal = childEl[i].offsetTop + childEl[i].offsetHeight;
				
			counter++;			
		}
	}


	if(!isProduction)
		for(i=0;i<childImg.length;i++) {
			if(i==childImg.length -1)
				counter = 0;
				
			if(childImg[i].offsetHeight > finalVal) {
				finalVal = childImg[i].offsetHeight;		
				
			}
		}

	/*parentEl.setAttribute("style", "min-height:" + (finalVal + 16) + "px;height:auto !important;height:" + (finalVal + 16) + "px");*/
}


//################################################################################
//#			NAME: 		macroLayout
//#			CALLED BY: 	Page Layout Manager (Thread)
//#			PURPOSE:	Positions the layout squares based on the info provided
//#						via the Post Form
//################################################################################
function macroLayout(posValues,itemId) {
	var itemId = document.getElementById(itemId);
	if(posValues != '') {
		var posArray = posValues.split(",");
		itemId.style.top = posArray[0] + "px";
		itemId.style.left = posArray[1] + "px";
		itemId.style.width = posArray[2] + "px";
		itemId.style.display = "block";	
	}	
}


//################################################################################
//#			NAME: 		initializeDelete
//#			CALLED BY: 	Page Layout Manager (Thread)
//#			PURPOSE:	Takes the 'confirmDelete' box from the template, clones it
//#						removes the original and then attaches the clone to the 
//#						body of the document. This allows the box to be centered
//#						on the page no matter what layout is used. It also creates
//#						the dropshadow div.
//################################################################################
function intializeDelete() {
	var newDiv = document.createElement('div');
	var confirmDelete = document.getElementById('confirmDelete');
	var confirmClone = confirmDelete.cloneNode(true);
	
	newDiv.setAttribute('id','overlay');
	newDiv.setAttribute('style','display:none');		
	document.body.appendChild(newDiv);	
	
	confirmDelete.parentNode.removeChild(confirmDelete);
	document.body.appendChild(confirmClone);
}



//################################################################################
//#			NAME: 		confirmDelete
//#			CALLED BY: 	Page Layout Manager (Thread)
//#			PURPOSE:	Handles the appearance of the confirmDelete box and its
//#						dropshadow
//################################################################################
function confirmDelete(titleVal) {
	var confirmDelete = document.getElementById('confirmDelete');
	var deleteMessage = document.getElementById('deleteMessage');
	var overlayDiv = document.getElementById('overlay');
	deleteMessage.innerHTML = "Are you sure you wish to delete " + titleVal + "?";
	
	overlayDiv.style.display = "block";
	confirmDelete.style.display = "block";
	
	overlayDiv.style.width = confirmDelete.offsetWidth + "px";
	overlayDiv.style.height = confirmDelete.offsetHeight + "px";
			
	confirmDelete.style.left = ((document.body.clientWidth / 2) - (confirmDelete.offsetWidth / 2)) + "px";
	confirmDelete.style.top = ((document.body.clientHeight / 2) - confirmDelete.offsetHeight) + "px";
	overlayDiv.style.left = eval(x=confirmDelete.style.left.split('p')[0]) + 5 + "px";
	overlayDiv.style.top = eval(x=confirmDelete.style.top.split('p')[0]) + 5 + "px";

}


function addLayoutLink() {
	var usedLayouts = new Array("obamaLayout","identityLayout","alternativeenergyLayout","communitycollegesLayout","climatechangeLayout","surveillanceLayout","money_transfersLayout","moneytransfersLayout","swinefluLayout","portraitsiranLayout","passportsLayout","contrastscapitalismLayout","constitutionLayout","graphicnovelLayout","financecorruptionLayout","womencourageLayout","waterusageLayout","aidlatinamericaLayout","oceansLayout","dissentLayout","africandevelopmentLayout","undeclarationLayout","pittsburghLayout","summitLayout","carbonLayout","anticorruptionLayout","cairoLayout","piracyLayout","revivetradeLayout","chinausLayout","slampoetryLayout","space_commercializationLayout","americanindiansLayout","baseballLayout","flushingLayout","landolakesLayout","nationalparksLayout","lincolnLayout","tsunamiLayout","childsoldiersLayout","womeningovtLayout","cabinetLayout","aidsLayout","topuniversitiesLayout","gonorthLayout","greensburgLayout","natoLayout","marsLayout","endangeredLayout","digitallibraryLayout","moscowLayout","moscowtrialLayout","obama_trialLayout","july4th2009Layout","michelleobamaLayout","g8_2009Layout","bikesworldLayout","obamaghanaLayout","russianartLayout","nanotechnologyLayout","usg_clickLayout","foiaLayout","anatomy_juryLayout","architect_greenLayout","agoa_2009_engLayout","nativeamerbizLayout","ramadanLayout","latinmusicLayout","carsshiftgreenLayout","cellphoneLayout","globalengineeringLayout","smartgridLayout","cap_and_tradeLayout","hiphopLayout","climate_healthLayout","consumer_layoutLayout","ungaLayout","conspiracyLayout","hispanicsusLayout","food_securityLayout","cybersecurityLayout","hispanic_purchaseLayout","search_rescueLayout","protestersaskLayout","adaptationLayout","anticorruptionbordersLayout","Eastern_BlocLayout","aceawards2009Layout","nativeamericanvoicesLayout","girls_educationLayout","teaching_toleranceLayout","cop15Layout","obama_nobelLayout","nuclearfreeworldLayout","eexchange1Layout","mitigationLayout","russian_coinsLayout","understanding_climate_changeLayout","eexchange_nuclearLayout","journalismundersiegeLayout","nonviolenceLayout","religious_freedomLayout","eexchange3_forumLayout","entrepreneursconnectLayout","notable_african_americansLayout","preserving_minority_cultureLayout","scienceenvoysLayout","youasked_febLayout","oprah_schoolLayout","talkingraceLayout","haitiLayout","govt_entrepreneurLayout","woc2010Layout","preserving_world_culturesLayout","climate_waterLayout","youasked_carsLayout","ag_edLayout","jazz_americaLayout","youasked_marchLayout","planting_treesLayout","michelle_mexicoLayout","cultural_preservation_scaLayout","earthday2010Layout","entrepreneurship_summitLayout","debate_internetLayout","cc_partnershipsLayout","nuclear_understandLayout","youasked_federalismLayout","huck_finnLayout","twain_abroadLayout","youasked_archivesLayout","hispbuyingpower2Layout","youasked_indiansLayout","seeyouLayout","soccerLayout");		//Supplies the populated usedLayouts array
	var themeNames = new Array("Theme ManagerLayout","exampleLayout","marsLayout","americanindiansLayout","flushingLayout","surveillanceLayout","tsunamiLayout","oceansLayout","lincolnLayout","chinausLayout","pittsburghLayout","alternativeenergyLayout","africandevelopmentLayout","dissentLayout","baseballLayout","gonorthLayout","greensburgLayout","jazzLayout","childsoldiersLayout","aidsLayout","nationalparksLayout","womeningovtLayout","undeclarationLayout","aidlatinamericaLayout","topuniversitiesLayout","identityLayout","cabinetLayout","endangeredLayout","obamaLayout","landingLayout","landolakesLayout","natoLayout","nonviolenceLayout","summitLayout","climatechangeLayout","journalismundersiegeLayout","communitycollegesLayout","moneytransfersLayout","swinefluLayout","portraitsiranLayout","passportsLayout","contrastscapitalismLayout","constitutionLayout","graphicnovelLayout","financecorruptionLayout","womencourageLayout","waterusageLayout","carbonLayout","anticorruptionLayout","cairoLayout","piracyLayout","revivetradeLayout","slampoetryLayout","space_commercializationLayout","digitallibraryLayout","moscowLayout","moscow_testLayout","moscowtrialLayout","obama_trialLayout","g8_2009Layout","july4th2009Layout","michelleobamaLayout","bikesworldLayout","obamaghanaLayout","russianartLayout","nanotechnologyLayout","usg_clickLayout","foiaLayout","anatomy_juryLayout","architect_greenLayout","agoa_2009_engLayout","nativeamerbizLayout","ramadanLayout","latinmusicLayout","carsshiftgreenLayout","hispanosartesLayout","cellphoneLayout","globalengineeringLayout","smartgridLayout","cap_and_tradeLayout","hiphopLayout","climate_healthLayout","consumer_layoutLayout","ungaLayout","conspiracyLayout","hispanicsusLayout","food_securityLayout","cybersecurityLayout","hispanic_purchaseLayout","search_rescueLayout","protestersaskLayout","adaptationLayout","anticorruptionbordersLayout","Eastern_BlocLayout","aceawards2009Layout","nativeamericanvoicesLayout","girls_educationLayout","teaching_toleranceLayout","cop15Layout","obama_nobelLayout","nuclearfreeworldLayout","eexchange1Layout","mitigationLayout","russian_coinsLayout","understanding_climate_changeLayout","eexchange_nuclearLayout","nukeguysLayout","religious_freedomLayout","eexchange3_forumLayout","entrepreneursconnectLayout","notable_african_americansLayout","preserving_minority_cultureLayout","scienceenvoysLayout","preserving_world_culturesLayout","youasked_febLayout","oprah_schoolLayout","talkingraceLayout","haitiLayout","govt_entrepreneurLayout","woc2010Layout","climate_waterLayout","youasked_carsLayout","ag_edLayout","jazz_americaLayout","youasked_marchLayout","planting_treesLayout","michelle_mexicoLayout","cultural_preservation_scaLayout","earthday2010Layout","entrepreneurship_summitLayout","debate_internetLayout","cc_partnershipsLayout","nuclear_understandLayout","youasked_federalismLayout","huck_finnLayout","twain_abroadLayout","youasked_archivesLayout","hispbuyingpower2Layout","youasked_indiansLayout","seeyouLayout","soccerLayout");		//Supplies the populated themeNames array
	
	var isUsed = 0;	
	
	for(i=1;i<themeNames.length;i++) {
		for(x=0;x<usedLayouts.length;x++)
			if(themeNames[i] == usedLayouts[x])	{	
				document.getElementById(usedLayouts[x] + 'Id').innerHTML = "<a href='/page-layout-manager/page-layout-manager/" + usedLayouts[x].toLowerCase() +".html?func=edit'  class='editLayout' target='_blank'>Edit Layout</a>";	
				isUsed = 1;
			}
		if(!isUsed)	
			document.getElementById(themeNames[i] + 'Id').innerHTML = "<a href='/page-layout-manager/page-layout-manager.html?func=add;class=WebGUI::Asset::Post::Thread' class='addLayout'>Add a Layout</a>";
			
		isUsed = 0;			
	}	
}









