/* Dynamic Addition of Celebration Corner Style Sheet to Select Pages */

// Array of Select Pages and whether to use Wide Format Style Sheet
// ccPages.push(["<URL STRING MATCH>", <USE WIDE>]);
var ccPages = new Array();
ccPages.push(["/celebrationcorner/", false]);
ccPages.push(["/specialoffers/wonkagummies/", true]);

// Return ccPages Item if Current Page is Found
function findCCPage(theURL){
	if (theURL == null){
		theURL = location.pathname;
	}
	theURL = theURL.toLowerCase();
	for (var i = 0; i < ccPages.length; i++){
		if (theURL.indexOf(ccPages[i][0].toLowerCase()) != -1){
			return ccPages[i];
		}
	}
	return null;
}

// Insert DOM Node After Another
function insertAfter(refNode, newNode){
	refNode.parentNode.insertBefore(newNode, refNode.nextSibling);
}

// If Current Page is a CC Page then add Style Sheet reference after global.css
var currentCCPage = findCCPage();
if (currentCCPage != null){
	var globalSS = document.getElementsByTagName("link")[0];
	var ccSS = document.createElement("link");
	ccSS.type ="text/css";
	ccSS.rel= "stylesheet";
	ccSS.href = "/css/section_easter_2010";
	if (currentCCPage[1]){
		ccSS.href += "_wide";
	}
	ccSS.href += ".css";
	insertAfter(globalSS, ccSS);
}
