/*
Replace Function

By: Tim Giegel - Dick's Sporting Goods
Created: 8-17-09

Desc: Use this function to display elements based on a time frame verses manualy changing elements out.  This function degrades to non js browsers by not running.  Keep this in mind in case somthing must be taken down, this may not be approprate.

Function Desc:
replaceElement([year]str, [month]str, [day]str, [parent by id element]str, [element by id to remove]str, [html]str)
*/

function replaceElementByDate(year,month,day,parent,child,html) {
	//setup variables
	var flipDate = new Date();
	var today = new Date();
	
	//manipulate variables
	month = month - 1;
	flipDate.setFullYear(year,month,day);
	
	//if date is set run swap function
	if (flipDate <= today) {
			swapElement(parent,child,html);
	}
}

function removeElementByDate(year,month,day,parent,child,html) {
	//setup variables
	var flipDate = new Date();
	var today = new Date();
	
	//manipulate variables
	month = month - 1;
	flipDate.setFullYear(year,month,day);
	
	//if date is set run swap function
	if (flipDate >= today) {
			swapElement(parent,child,html);
	}
}


function swapElement(parent,child,html) {
	//remove the first element
	var a = document.getElementById(child);
	var c = document.getElementById(parent);
	c.removeChild(a);
	//add new element
	var newdiv = document.createElement('div');
	var divIdName = child+'_replaced';
	newdiv.setAttribute('id',divIdName);
	newdiv.innerHTML = html;
	c.appendChild(newdiv);
}