//
// "Choose Your Pregnancy Stage" FORM (webfx version)
//
function changeAction(ServerName) {
//first trimester
if (document.stage.week.selectedIndex == 1) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-1.php";
if (document.stage.week.selectedIndex == 2) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-2.php";
if (document.stage.week.selectedIndex == 3) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-3.php";
if (document.stage.week.selectedIndex == 4) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-4.php";
if (document.stage.week.selectedIndex == 5) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-5.php";
if (document.stage.week.selectedIndex == 6) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-6.php";
if (document.stage.week.selectedIndex == 7) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-7.php";
if (document.stage.week.selectedIndex == 8) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-8.php";
if (document.stage.week.selectedIndex == 9) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-9.php";
if (document.stage.week.selectedIndex == 10) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-10.php";
if (document.stage.week.selectedIndex == 11) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-11.php";
if (document.stage.week.selectedIndex == 12) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-12.php";
//second trimester
if (document.stage.week.selectedIndex == 13) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-13.php";
if (document.stage.week.selectedIndex == 14) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-14.php";
if (document.stage.week.selectedIndex == 15) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-15.php";
if (document.stage.week.selectedIndex == 16) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-16.php";
if (document.stage.week.selectedIndex == 17) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-17.php";
if (document.stage.week.selectedIndex == 18) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-18.php";
if (document.stage.week.selectedIndex == 19) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-19.php";
if (document.stage.week.selectedIndex == 20) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-20.php";
if (document.stage.week.selectedIndex == 21) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-21.php";
if (document.stage.week.selectedIndex == 22) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-22.php";
if (document.stage.week.selectedIndex == 23) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-23.php";
if (document.stage.week.selectedIndex == 24) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-24.php";
if (document.stage.week.selectedIndex == 25) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-25.php";
if (document.stage.week.selectedIndex == 26) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-26.php";
if (document.stage.week.selectedIndex == 27) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-27.php";
//third trimester
if (document.stage.week.selectedIndex == 28) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-28.php";
if (document.stage.week.selectedIndex == 29) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-29.php";
if (document.stage.week.selectedIndex == 30) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-30.php";
if (document.stage.week.selectedIndex == 31) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-31.php";
if (document.stage.week.selectedIndex == 32) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-32.php";
if (document.stage.week.selectedIndex == 33) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-33.php";
if (document.stage.week.selectedIndex == 34) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-34.php";
if (document.stage.week.selectedIndex == 35) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-35.php";
if (document.stage.week.selectedIndex == 36) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-36.php";
if (document.stage.week.selectedIndex == 37) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-37.php";
if (document.stage.week.selectedIndex == 38) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-38.php";
if (document.stage.week.selectedIndex == 39) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-39.php";
if (document.stage.week.selectedIndex == 40) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-40.php";
}

// "Choose Your Pregnancy Stage" FORM (php site version)
//
function changeActionPregStage(ServerName) {
//first trimester
if (document.stage.week.selectedIndex == 1) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-1.php";
if (document.stage.week.selectedIndex == 2) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-2.php";
if (document.stage.week.selectedIndex == 3) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-3.php";
if (document.stage.week.selectedIndex == 4) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-4.php";
if (document.stage.week.selectedIndex == 5) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-5.php";
if (document.stage.week.selectedIndex == 6) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-6.php";
if (document.stage.week.selectedIndex == 7) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-7.php";
if (document.stage.week.selectedIndex == 8) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-8.php";
if (document.stage.week.selectedIndex == 9) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-9.php";
if (document.stage.week.selectedIndex == 10) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-10.php";
if (document.stage.week.selectedIndex == 11) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-11.php";
if (document.stage.week.selectedIndex == 12) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-12.php";
//second trimester
if (document.stage.week.selectedIndex == 13) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-13.php";
if (document.stage.week.selectedIndex == 14) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-14.php";
if (document.stage.week.selectedIndex == 15) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-15.php";
if (document.stage.week.selectedIndex == 16) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-16.php";
if (document.stage.week.selectedIndex == 17) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-17.php";
if (document.stage.week.selectedIndex == 18) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-18.php";
if (document.stage.week.selectedIndex == 19) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-19.php";
if (document.stage.week.selectedIndex == 20) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-20.php";
if (document.stage.week.selectedIndex == 21) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-21.php";
if (document.stage.week.selectedIndex == 22) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-22.php";
if (document.stage.week.selectedIndex == 23) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-23.php";
if (document.stage.week.selectedIndex == 24) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-24.php";
if (document.stage.week.selectedIndex == 25) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-25.php";
if (document.stage.week.selectedIndex == 26) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-26.php";
if (document.stage.week.selectedIndex == 27) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-27.php";
//third trimester
if (document.stage.week.selectedIndex == 28) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-28.php";
if (document.stage.week.selectedIndex == 29) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-29.php";
if (document.stage.week.selectedIndex == 30) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-30.php";
if (document.stage.week.selectedIndex == 31) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-31.php";
if (document.stage.week.selectedIndex == 32) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-32.php";
if (document.stage.week.selectedIndex == 33) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-33.php";
if (document.stage.week.selectedIndex == 34) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-34.php";
if (document.stage.week.selectedIndex == 35) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-35.php";
if (document.stage.week.selectedIndex == 36) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-36.php";
if (document.stage.week.selectedIndex == 37) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-37.php";
if (document.stage.week.selectedIndex == 38) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-38.php";
if (document.stage.week.selectedIndex == 39) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-39.php";
if (document.stage.week.selectedIndex == 40) window.location = "/pregnancy-and-birth/week-by-week/pregnancy-week-40.php";
}

// "DUE DATE CLUBS" FORM (webfx site)
//
function changeAction2(ClubName) {	
	$.ajax({
		url: "http://www.surebaby.com/includes/duedateclub-list.php",
		dataType: 'json',
		success: function(result) {
			window.location = result.months[ document.clubs.month.selectedIndex - 1].url;
		},
		error:function (xhr, ajaxOptions, thrownError){
                    alert(xhr.status);
                    alert(thrownError);
                }
	});
}
/*
function changeAction2(ClubName) {
if (document.clubs.month.selectedIndex == 1) window.location = "http://www.surebaby.com/community/forum/tid_33-january-2012-due-date-club";
if (document.clubs.month.selectedIndex == 2) window.location = "http://www.surebaby.com/community/forum/tid_37-february-2012-due-date-club";
if (document.clubs.month.selectedIndex == 3) window.location = "http://www.surebaby.com/community/forum/tid_38-march-2012-due-date-club";
if (document.clubs.month.selectedIndex == 4) window.location = "http://www.surebaby.com/community/forum/tid_39-april-2012-due-date-club";
if (document.clubs.month.selectedIndex == 5) window.location = "http://www.surebaby.com/community/forum/tid_40-may-2012-due-date-club";
if (document.clubs.month.selectedIndex == 6) window.location = "http://www.surebaby.com/community/forum/tid_41-june-2012-due-date-club";
if (document.clubs.month.selectedIndex == 7) window.location = "http://www.surebaby.com/community/forum/tid_26-july-2011-due-date-club";
if (document.clubs.month.selectedIndex == 8) window.location = "http://www.surebaby.com/community/forum/tid_27-august-2011-due-date-club";
if (document.clubs.month.selectedIndex == 9) window.location = "http://www.surebaby.com/community/forum/tid_28-september-2011-due-date-club";
if (document.clubs.month.selectedIndex == 10) window.location = "http://www.surebaby.com/community/forum/tid_29-october-2011-due-date-club";
if (document.clubs.month.selectedIndex == 11) window.location = "http://www.surebaby.com/community/forum/tid_30-november-2011-due-date-club";
if (document.clubs.month.selectedIndex == 12) window.location = "http://www.surebaby.com/community/forum/tid_31-december-2011-due-date-club";
}*/


var monthscallout = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function weekYouAreOn() {
    var wkpath = location.pathname;
    var wk = wkpath.split("pregnancy-week-")[1];
    var patt = /\d{1,2}/;
    var i = wk.match(patt);
    return i;
}

function addWeeks(weeks) {
    // 1 week: 7 days, 24 hours each, 60 min per hour, 60 seconds per minute, 1000 ms per second
    // x weeks: 1 week * x
    date = new Date();
    return new Date(date.getTime() + 7 * 24 * 60 * 60 * 1000 * weeks);
}

function weekCallout(mediaPath) {    
    var createSpacerA = document.createElement("a");
    var createSpacerImg = document.createElement("img");
    
    var i = weekYouAreOn();
    var wksRemaining = 40 - i;
    //get due month
    var due_mth = monthscallout[addWeeks(wksRemaining).getMonth()].toLowerCase();
    //get due year
    var due_yr = addWeeks(wksRemaining).getFullYear();
    //get forum id (tid)
    var y2011 = { 'july': '26', 'august': '27', 'september': '28', 'october': '29', 'november': '30', 'december': '31' }; //object for year 2011 TID's
    var y2012 = { 'january': '33', 'february': '37', 'march': '38', 'april': '39', 'may': '40', 'june': '41' }; //object for year 2012 TID's
    var tid = '';
    if (due_yr == '2011') { tid = y2011[due_mth]; }
    if (due_yr == '2012') { tid = y2012[due_mth]; }
    var bgpath = mediaPath + "/i/mth-callouts/callout-mth-" + due_mth + ".jpg";
    document.getElementById("week-callout").style.background = 'url(' + bgpath + ') no-repeat';
    
    //create callout
    createSpacerA.setAttribute("href", "http://www.surebaby.com/community/forum/tid_" + tid + "-" + due_mth + "-" + due_yr + "-due-date-club");

    createSpacerImg.setAttribute("id", "week-link");
    createSpacerImg.setAttribute("src", mediaPath + "/i/spacer.gif");
    createSpacerImg.setAttribute("height", "300");
    createSpacerImg.setAttribute("width", "212");

    createSpacerA.appendChild(createSpacerImg);
    document.getElementById("week-callout").insertBefore(createSpacerA,document.getElementById("week-callout").lastChild);
}

