//  SETUP DAY MATH

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var today=new Date();
var todayy=today.getYear();
if (todayy < 1000)
todayy+=1900;
var todaym=today.getMonth();
var todaymPlus1 = todaym+1;
var todayd=today.getDate();
var todaystring=montharray[todaym]+" "+todayd+", "+todayy;

// END DAY MATH

// SETUP COUPON CLASS

function COUPONCLASS(title,sub_title,description,disclaimer,expire) {
	this.title=title;
	this.sub_title=sub_title;
	this.description=description;
	this.disclaimer=disclaimer;
	}

// END COUPON CLASS

// SETUP TOP COUPONS
coupontop = new Array();

coupontop[1] = new COUPONCLASS('Mercedes-Benz \'A\' Service','$160.00','Why pay $65 more at the dealer?  This is what we do.<li>Change your vehicle\'s engine oil and filter <li>Replace the dust filter in all SLK, CLK, C-Class and E-Class models <li>Ensure the warning and indicator lamps, horn, windshield/headlamp wiper and washer systems, and seat belts are functioning correctly <li>Inspect tires and check tire pressure (including spare) <li>Inspect brake pad thickness and disc condition <li>Check and correct all fluid levels <li>Reset your vehicle\'s FSS counter <br>*Model year 1998 through 2006 vehicles are equipped with the Flexible Service System (FSS)','Saving based on dealership cost at $225 for all models');
coupontop[2] = new COUPONCLASS('Mercedes-Benz \'B\' Service','$350.00','Why pay $155 more at the dealer?  This is what we do.<li>Change your vehicle\'s engine oil and filter <li>Replace the dust filter in all SLK, CLK, C-Class and E-Class models, and in S-Class and SL-Class models without the active charcoal filter <li>Replace windshield wiper inserts <li>Inspect and rotate tires <li>Lubricate and inspect throttle linkage <li>Ensure the parking brake, steering play, headlamps and exterior lamps, warning and indicator lamps, horn, windshield/headlamp wiper and washer systems, seat belts, and backrest lock (S-Class only) are functioning correctly <li>Inspect tires and check tire pressure (including spare) <li>Inspect brake pad thickness and disc condition <li>Inspect front axle ball joints and Poly-V-belt <li>Check and correct all fluid levels <li>Reset your vehicle\'s FSS counter <br>*Model year 1998 through 2006 vehicles are equipped with the Flexible Service System (FSS)','Saving based on dealership cost at $470 for S, SL, CL models');
coupontop[3] = new COUPONCLASS('$50 Off Labor','On any repair or Service','Let us take the sting out of a big repair with this discount','Cost of labor must be over $350 prior to discount. Only one discount per service.  Coupon must be presented at time of payment.');
coupontop[4] = new COUPONCLASS('Free One Day Rental','during car repair','We understand some repairs are complex and require more than one day service.  We offer the convenience of a car rental service on site for those who don\'t have alternate transportation.  To further pamper you, we will cover the first day free.','Estimated repair must be at least 24hrs');

// END TOP COUPONS

// SETUP TOP  HTML

teasetophtml = new Array();
coupontophtml = new Array();

for(var i = 1;i<coupontop.length;i++) {
	teasetophtml[i]="<span class='cpn_title'>"+coupontop[i].title+"</span><span class='cpn_subtitle'>"+coupontop[i].sub_title+"</span><br><span class='cpn_detail'><a class='link' href='javascript:LeftWindow(\"coupon1.htm\",\"coupon1\");'>Clink to print coupon and view details</a><br><a href='javascript:LeftWindow(\"coupon1.htm\",\"coupon1\")'><img src='images/print.gif' border=0></a></span><br><hr><span class='cpn_expire'>";
	coupontophtml[i]="<span class='cpn_title'>"+coupontop[i].title+"</span><br><span class='cpn_subtitle'>"+coupontop[i].sub_title+"</span><br><span class='cpn_detail'>"+coupontop[i].description+"<br><a href='javascript:window.print();'><img src='images/print.gif' border=0></a> <a class='link' href='javascript:window.print();'>Print to redeem</a></span><br><hr><span class='cpn_expire'>"+coupontop[i].disclaimer+"<br><u>";
}

// END TOP  HTML
 

// TOP COUPON DATE MATH

coupontopnbr= coupontop.length-1;
	//document.write(coupontopnbr);document.write(" nbr of top coupons<br>");
coupontopdelay = 25;
	//document.write(coupontopdelay);document.write(" days each top coupon runs<br>");
coupontoploop = coupontopnbr*coupontopdelay;
	//document.write(coupontoploop);document.write(" number of days to show all coupons<br>");
startcoupontopday = 01;  //DAYS IN DBL DIGIT
startcoupontopmonth = 10;   //MONTHS IN DBL DIGIT
startcoupontopyear = 2006;  //YEARS IN 4 DIGIT
startcoupontopdisplay = montharray[startcoupontopmonth-1]+" "+startcoupontopday+", "+startcoupontopyear;
	//document.write(startcoupontopdisplay);document.write(" Start Date<br>");
	//document.write(todaystring);document.write(" Today's Date<br>");
passedcoupontop=1+(Math.round((Date.parse(todaystring)-Date.parse(startcoupontopdisplay))/(24*60*60*1000))*1);
	//document.write(passedcoupontop);document.write(" Days passed since start date<br>");
coupontoploop_number = Math.ceil(passedcoupontop/coupontoploop);
	//document.write(coupontoploop_number);document.write(" top coupon on loop number<br>");
coupontoploopposition = passedcoupontop%coupontoploop;
if(coupontoploopposition==0) {
	coupontoploopposition = coupontoploop;
	}
coupontoprun=coupontoploopposition%coupontopdelay;
if(coupontoprun==0) {
	coupontoprun = coupontopdelay;
	}
coupontopremain=coupontopdelay-coupontoprun;
	//document.write(coupontoploopposition);document.write(" days within loop # "+coupontoploop_number+"<br>");
	//document.write(coupontoprun);document.write(" days running<br>");
	//document.write(coupontopremain);document.write(" days remaining<br>");
coupontopdisplayed = Math.ceil(coupontoploopposition/coupontopdelay);
	//document.write(coupontopdisplayed);document.write(" coupon Nbr to be displayed<br>");
coupontopexpire=(Math.round((Date.parse(todaystring)+Date.parse(startcoupontopdisplay))/(24*60*60*1000))*1);

// ENDTOP COUPON DATE MATH

// TOP COUPON AND TEASER FUNCTIONS

function teasertop_call() {
	if(coupontopremain>1){
		teasetophtml[coupontopdisplayed]=teasetophtml[coupontopdisplayed]+" Coupon rotates out in <u>"+coupontopremain+"</u> days</span>";
		}
	else if (coupontopremain==1) {
		teasetophtml[coupontopdisplayed]=teasetophtml[coupontopdisplayed]+" Coupon rotates out in <u>"+coupontopremain+"</u> day</span>";
		}
	else {
		teasetophtml[coupontopdisplayed]=teasetophtml[coupontopdisplayed]+" Coupon rotates out after today!</span>";
		}
	document.write(teasetophtml[coupontopdisplayed]);
	}

function coupontop_call() {
	if(coupontopremain>1){
		coupontophtml[coupontopdisplayed]=coupontophtml[coupontopdisplayed]+" Coupon expires in <u>"+coupontopremain+"</u> days after "+todaystring+"</span>";
		}
	else if (coupontopremain==1) {
		coupontophtml[coupontopdisplayed]=coupontophtml[coupontopdisplayed]+" Coupon expires in <u>"+coupontopremain+"</u> day after "+todaystring+"</span>";
		}
	else {
		coupontophtml[coupontopdisplayed]=coupontophtml[coupontopdisplayed]+" Coupon expires after today!, "+todaystring+"</span>";
		}
	document.write(coupontophtml[coupontopdisplayed]);
	}

// END TOP COUPON AND TEASER FUNCTIONS

// SETUP BOTTOM COUPONS
couponbottom = new Array();

couponbottom[1] = new COUPONCLASS('Free A/C Check','','Get you’re Air Conditioner checked early before the Texas heat causes problems','Capacity and Condition check are free.  Recharge or repair are charged if needed.  Coupon must be presented at time of payment.');
couponbottom[2] = new COUPONCLASS('Free Check Engine Light Code Check','$75 to diagnose problem','We will assist those Do-It-Yourselfers who would like to diagnose the problem on their own at home, but don\'t have the expensive equipment to determine the error code.  We will connect and give you the code for free.  If you\'d like us to troubleshoot and diagnose then we charge a small fee of $75 ($80-$100 at dealerships)','Coupon must be presented prior to service');
couponbottom[3] = new COUPONCLASS('Wheel Alignment','$49','','');
couponbottom[4] = new COUPONCLASS('20% Off Labor','First Time Discount','We are so confident of your repeat business that we want you to try us for the first time at a significant savings for yourself','No other discount can be applied.  Must provide valid email or mailing address to have coupon emailed or mailed to you to verify eligibility.  Discount can not exceed $100');
//couponbottom[3] = new COUPONCLASS('State Inspection','$28','We are fully licensed by the state and own all of the latest metrology equipment to perform this necessary service','');

// END BOTTOM COUPONS

// SETUP BOTTOM  HTML

teasebottomhtml = new Array();
couponbottomhtml = new Array();

for(var j = 1;j<couponbottom.length;j++) {
	teasebottomhtml[j]="<span class='cpn_title'>"+couponbottom[j].title+"</span><span class='cpn_subtitle'>"+couponbottom[j].sub_title+"</span><br><span class='cpn_detail'><a class='link' href='javascript:LeftWindow(\"coupon2.htm\",\"coupon2\");'>Clink to print coupon and view details</a><br><a href='javascript:LeftWindow(\"coupon2.htm\",\"coupon2\")'><img src='images/print.gif' border=0></a></span><br><hr><span class='cpn_expire'>";
	couponbottomhtml[j]="<span class='cpn_title'>"+couponbottom[j].title+"</span><br><span class='cpn_subtitle'>"+couponbottom[j].sub_title+"</span><br><span class='cpn_detail'>"+couponbottom[j].description+"<br><a href='javascript:window.print();'><img src='images/print.gif' border=0></a> <a class='link' href='javascript:window.print();'>Print to redeem</a></span><br><hr><span class='cpn_expire'>"+couponbottom[j].disclaimer+"<br><u>";
}

// END BOTTOM  HTML
 

// BOTTOM COUPON DATE MATH

couponbottomnbr= couponbottom.length-1;
	//document.write(couponbottomnbr);document.write(" nbr of bottom coupons<br>");
couponbottomdelay = 16;
	//document.write(couponbottomdelay);document.write(" days each bottom coupon runs<br>");
couponbottomloop = couponbottomnbr*couponbottomdelay;
	//document.write(couponbottomloop);document.write(" number of days to show all coupons<br>");
startcouponbottomday = 01;  //DAYS IN DBL DIGIT
startcouponbottommonth = 10;   //MONTHS IN DBL DIGIT
startcouponbottomyear = 2006;  //YEARS IN 4 DIGIT
startcouponbottomdisplay = montharray[startcouponbottommonth-1]+" "+startcouponbottomday+", "+startcouponbottomyear;
	//document.write(startcouponbottomdisplay);document.write(" Start Date<br>");
	//document.write(todaystring);document.write(" Today's Date<br>");
passedcouponbottom=1+(Math.round((Date.parse(todaystring)-Date.parse(startcouponbottomdisplay))/(24*60*60*1000))*1);
	//document.write(passedcouponbottom);document.write(" Days passed since start date<br>");
couponbottomloop_number = Math.ceil(passedcouponbottom/couponbottomloop);
	//document.write(couponbottomloop_number);document.write(" bottom coupon on loop number<br>");
couponbottomloopposition = passedcouponbottom%couponbottomloop;
if(couponbottomloopposition==0) {
	couponbottomloopposition = couponbottomloop;
	}
couponbottomrun=couponbottomloopposition%couponbottomdelay;
if(couponbottomrun==0) {
	couponbottomrun = couponbottomdelay;
	}
couponbottomremain=couponbottomdelay-couponbottomrun;
	//document.write(couponbottomloopposition);document.write(" days within loop # "+couponbottomloop_number+"<br>");
	//document.write(couponbottomrun);document.write(" days running<br>");
	//document.write(couponbottomremain);document.write(" days remaining<br>");
couponbottomdisplayed = Math.ceil(couponbottomloopposition/couponbottomdelay);
	//document.write(couponbottomdisplayed);document.write(" coupon Nbr to be displayed<br>");
couponbottomexpire=(Math.round((Date.parse(todaystring)+Date.parse(startcouponbottomdisplay))/(24*60*60*1000))*1);

// ENDBOTTOM COUPON DATE MATH

// BOTTOM COUPON AND TEASER FUNCTIONS

function teaserbottom_call() {
	if(couponbottomremain>1){
		teasebottomhtml[couponbottomdisplayed]=teasebottomhtml[couponbottomdisplayed]+" Coupon rotates out in <u>"+couponbottomremain+"</u> days</span>";
		}
	else if (couponbottomremain==1) {
		teasebottomhtml[couponbottomdisplayed]=teasebottomhtml[couponbottomdisplayed]+" Coupon rotates out in <u>"+couponbottomremain+"</u> day</span>";
		}
	else {
		teasebottomhtml[couponbottomdisplayed]=teasebottomhtml[couponbottomdisplayed]+" Coupon rotates out after today!</span>";
		}
	document.write(teasebottomhtml[couponbottomdisplayed]);
	}

function couponbottom_call() {
	if(couponbottomremain>1){
		couponbottomhtml[couponbottomdisplayed]=couponbottomhtml[couponbottomdisplayed]+" Coupon expires in <u>"+couponbottomremain+"</u> days after "+todaystring+"</span>";
		}
	else if (couponbottomremain==1) {
		couponbottomhtml[couponbottomdisplayed]=couponbottomhtml[couponbottomdisplayed]+" Coupon expires in <u>"+couponbottomremain+"</u> day after "+todaystring+"</span>";
		}
	else {
		couponbottomhtml[couponbottomdisplayed]=couponbottomhtml[couponbottomdisplayed]+" Coupon expires after today!, "+todaystring+"</span>";
		}
	document.write(couponbottomhtml[couponbottomdisplayed]);
	}

// END BOTTOM COUPON AND TEASER FUNCTIONS



/*

function countdown(eyr,em,ed,yr,m,d,ele){
var divid = document.getElementById(ele);
var poststring=montharray[m-1]+" "+d+", "+yr;
var expirestring=montharray[em-1]+" "+ed+", "+eyr;
var remaintime=(Math.round((Date.parse(expirestring)-Date.parse(todaystring))/(24*60*60*1000))*1);
var spantime=(Math.round((Date.parse(expirestring)-Date.parse(poststring))/(24*60*60*1000))*1);
var percentage=(Math.round(((spantime-remaintime)/spantime)*100));
if(remaintime == 1){
	//document.write("There is "+remaintime+" day until expiration. ");
	}
else {
	//document.write("There are "+remaintime+" days until expiration. ");
	}
document.write(" This content is "+percentage+"% into its viewable length of "+spantime+" days");
if(remaintime <= 0){
	divid.style.display='none';
	}
}
*/



