// This script is for use with Cafepress ad banners. This particular script defaults to the
// large CP banner, but you can easily make changes to it in the "adtext" field below.
// Jim Lord, Teesed.com for questions or suggestions, please post on CP message board
// http://forums.cafepress.com/groupee/forums?a=tpc&s=810104&f=793104&m=80810172&r=25210272

function checkSaleDate(shopid,firstdate,lastdate,adchoice,alttext)
{

// Ad banner text to display between firstdate and lastdate

	if (adchoice == 1) 
	{
    	adtext = '<a href="http://www.cafepress.com/' + shopid + '"><img src="http://www.cafepress.com/content/banners/promo_468x60_01.gif" width="468" height="60" alt="Store Sale Banner" border="0"></a>';
	} 
	else if (adchoice == 2) {
    	adtext = '<a href="http://www.cafepress.com/' + shopid + '"><img src="http://www.cafepress.com/content/banners/promo_125x125_01.gif" width="125" height="125" alt="Store Sale Banner" border="0"></a>';
	}
	else if (adchoice == 3) {
    	adtext = '<a href="http://www.cafepress.com/' + shopid + '"><img src="http://www.cafepress.com/content/banners/promo_120x60_01.gif" width="120" height="60" alt="Store Sale Banner" border="0"></a>';
	}
	else if (adchoice == 4) {
		adtext = '<a href="http://www.cafepress.com/' + shopid + '"><img src="http://www.hecticstudios.com/salebanner.gif" width="750" height="40" alt="Store Sale Banner" border="0"></a>';
	
	}
	else { // just in case an ad choice hasn't been made, or it is something other than 1 - 4
    	adtext = '<a href="http://www.cafepress.com/' + shopid + '"><img src="http://www.cafepress.com/content/banners/promo_468x60_01.gif" width="468" height="60" alt="Store Sale Banner" border="0"></a>';
	}
	
	
    var startdate = new Date(firstdate);
    var enddate = new Date(lastdate);
    var today = new Date();
    
    if ((today >= startdate) && (today <= enddate))
        {
        document.write (adtext);
        }
    else
        {
        document.write (alttext);
        }

} //function checkSaleDate()
