function generateDOD( dodxmlfile ){
	$.ajax({			
		type:       'GET',
		url:        dodxmlfile,
		dataType: 	'xml',
		success: function(xml) {	
			$(xml).find('Worksheet').each(function(Wi) {
				$(this).find('Row').each(function(Ri) {
					if (Ri!=0) { 
						// todays date
						var today = new Date();
						var xmlStartDate = $(this).find('Cell').eq(6).text();
						
						xmlStartDate = dateString(xmlStartDate);
						
						if( isDateEqual( today, xmlStartDate ) ){
							
							var dodItemDesc1 = $(this).find('Cell').eq(0).text();
							var dodItemDesc2 = $(this).find('Cell').eq(1).text();
							var dodPrice = $(this).find('Cell').eq(2).text();
							var dodSavings = $(this).find('Cell').eq(3).text();
							var dodRegularPrice= $(this).find('Cell').eq(4).text();
							var dodLink = $(this).find('Cell').eq(7).text();
							var dodImage = $(this).find('Cell').eq(5).text().replace(/(p|b$){1}/i, '');
							var dodImgSrcSplit = dodImage.split('.');
							var dodImgSrc = (dodImgSrcSplit[1]) ? "<img id='mainPromo' src='http://content.sears.com/ue/home/"+ dodImage + "' border='0' />":"<img id='mainPromo' src='http://s.sears.com/is/image/Sears/"+ dodImage+ "?op_sharpen=1&qlt=75'  border='0' />";
							
							$('#dodItemDesc1').html((dodItemDesc1=='-')?'':dodItemDesc1);
							$('#dodItemDesc2').html((dodItemDesc2=='-')?'':dodItemDesc2);
							$('#dodPrice').html((dodPrice=='-')?'':dodPrice);
							$('#dodSavings').html((dodSavings=='-')?'':dodSavings);
							$('#dodRegularPrice').html((dodRegularPrice=='-')?'':dodRegularPrice);
							$('#dodLink').attr( (dodLink=='-')?'':'href', 'http://www.sears.com/shc/s'+dodLink );
							$('#dodImage').attr( (dodLink=='-')?'':'href', 'http://www.sears.com/shc/s'+dodLink );
							$('#dodImage').html((dodImgSrc=='-')?'':dodImgSrc);
							

							
							// Resize Product Images
					$('#mainPromo').load(function () {$(this).resizeImage(300);});
							
						}
					}
				});
			});
			
			}
		});		
	}

		/****/					
		$.fn.resizeImage = function(imgSize){
			$(this).each(function(){
				var imgWidth = $(this).width();
				var imgHeight = $(this).height();
				if (imgHeight>=imgSize) {
					var imgScale = imgSize/imgHeight;
					imgHeight = imgSize;
					imgWidth = imgWidth*imgScale;
				} 
				if (imgHeight < 300) {
				var marginTop = (300 - imgHeight) / 2;
				$(this).css('margin-top', marginTop );
				}

				$(this).width(imgWidth);
				$(this).height(imgHeight);
			});
		};
		/****/	

//creating a new date object from the xml file
function dateString(date){
	var dateSplit = date.split('.');
	dateSplit[0] = parseFloat(dateSplit[0])-1;
	date = new Date(20+dateSplit[2],dateSplit[0],dateSplit[1]);
	return date;
}	

//comparing the two dates
function isDateEqual( today, xmlDate ){
	if( today.getMonth() == xmlDate.getMonth() 
	&& today.getDate() == xmlDate.getDate()
	&& today.getYear() == xmlDate.getYear() ){
	return true;
	} else {
	return false;
	}
}

//count down timer code
var present;   
var future;    
var tseconds;  
var seconds;   
var minutes;
var hours;
var days;
ID=setTimeout("countdown();", 1000);

function countdown(){
	present = new Date();
	//setting curent date to end of day time
	future = new Date();
	future.setHours(23);
	future.setMinutes(59);
	future.setSeconds(59);
	
	tseconds = (future - present) / 1000;
	
	hours = tseconds /60/60;
	hours = Math.floor(hours);//all this for an even number, ie no decimals
	tseconds = tseconds - (hours * 60 * 60);
	
	
	minutes = tseconds /60;
	minutes = Math.floor(minutes);//all this for an even number, ie no decimals
	tseconds = tseconds - (minutes * 60);
	
	seconds = tseconds;
	seconds = Math.floor(seconds);//all this for an even number, ie no decimals
	
	if ( hours < 10 ){ 
	document.getElementById('hours').innerHTML = "0" + hours + " :";
	}else{
	document.getElementById('hours').innerHTML = hours + ":";
	}
	if ( minutes < 10 ){
	document.getElementById('minutes').innerHTML = "0" + minutes + " :";
	}else{
	document.getElementById('minutes').innerHTML = minutes + " :";
	}
	if ( seconds < 10 ){
	document.getElementById('seconds').innerHTML = "0" + seconds;
	}else{
	document.getElementById('seconds').innerHTML = seconds;
	}
	
	ID=setTimeout("countdown();", 1000);
}
