var flag = 1
var discountAmt=0;
function discount()
{
	
//	alert(00)
	  discountAmt=0;
	
	
	var NowDate =new Date()
	var startdate =new Date("4 jun 2006 UTC") 
	var enddate = new Date("9 jun 2006 23:59:59") ;

    var monthlong = new Array()
    monthlong[1]='January'
	monthlong[2]='Febuary'
	monthlong[3]='March'
	monthlong[4]='April'
	monthlong[5]='May'
	monthlong[6]='June'
	monthlong[7]='July'
	monthlong[8]='August'
	monthlong[9]='September'
	monthlong[10]='October'
	monthlong[11]='November'
	monthlong[12]='December'
	if ((NowDate > startdate) && (NowDate < enddate) && (discountAmt > 0))
		{
			if (flag==1)
			{
			document.write('            <font face="Arial, Helvetica, sans-serif" size="5" color="#3333cc">');
			document.write('<strong><i> ' + discountAmt.toString()+ '% Discount through ');
			//document.write(((startdate.toString()).substring(4,10)) +', '+ (startdate.getYear().toString())+' - ' );
			//document.write(((enddate.toString()).substring(4,10)) +', '+ (enddate.getYear().toString()) );
			//alert(enddate.getDay())
			
			 document.write(monthlong[enddate.getMonth()+1]+' ' +enddate.getDate() +', '+ (enddate.getYear().toString()) );
			 document.write('    </i></strong>        </font> ');
			 return discountAmt
			}
			else
			{ 
				return ('Buy now and save '+discountAmt.toString()+'%  on all pictures through ' +' '+monthlong[enddate.getMonth()+1]+' ' +enddate.getDate() +', '+ (enddate.getYear().toString()) )
			}


			
		}
		else
		{

				//var cook =getCookie('mondphotodiscount5')
				//alert(cook)
			discount24 = returnDiscountCookie();
//				 alert('xx='+returnDiscountCookie())
			if (discount24=='')
			{

				discountAmt=0;
			}
			else
			{
				if (flag==1)
				{
				document.write('            <font face="Arial, Helvetica, sans-serif" size="4" color="#3333cc">');
				document.write('<strong><i> ' + discount24);
              document.write('    </i></strong>        </font> ');
				}
				else
				{
					
					return(discount24 )
				}
			}
			
		}
		//alert(discountAmt)
	return discountAmt
}

function discountNoText()
{

	flag=0
	    //var today2 = new Date()
		//var ser2=today2.getTime()
		//ser2 = ser2 + (1000*60*5 )
		//var cookie2 = ''
		 //cook2 =getCookie('mondphotodiscount52')
	//alert(cook2)
		 //if  ( cook2 ==null)  
		 //{
		 //var today22 = new Date(ser2)
		 //document.cookie ='mondphotodiscount52=' + new Date(ser2) + ';' +'expires='+  today22.toGMTString() + ';'
		 //cook2 =getCookie('mondphotodiscount52')
		 //alert(cook2)
		 //}
		 //else
		//{
		//	 alert(cook2)
		////		return('') //dont show alert messgae
		//}
	
	
	
	discountMsg = discount()
	return discountMsg
}

 
function returnDiscountCookie()
{
		var cook =getCookie('mondphotodiscount5')
		//var cook2 =getCookie('mondphotodiscount52')

//		alert('cook='+cook)

		

		rtnvalue =''

		
		if (cook == null)
		{
			//alert('hi')
			return('')
		}

		else
		{
			cook = cook.replace('+',' ')
			cook = cook.replace('+',' ')
			var mytool_array=cook.split("-");
			//alert('discount='+mytool_array[0])
			var mytool_time=mytool_array[1].split(" ");
				
			var mmddyyyy = mytool_time[0].split('/')
			 
			var hhmmss = mytool_time[1].split(':')
			 
			hh = +hhmmss[0]

			//			mm = +hhmmss[1]
			ss = +hhmmss[2]
			
		//alert('x='+hhmmss[0] + ' ' + hhmmss[1] + ' '+hhmmss[2] + ' ' +mytool_time[2])


			if ( mytool_time[2] == 'PM')
			{
				//alert(hh)
				hh = (+hh) + 12
				//alert('hh='+hh)
			}
			else
			{
				if (hh==12) hh = 0
			}
			//alert('new hh=' + ( hh + 12) )
			today = new Date()
			
			cookieexp = new Date(mmddyyyy[2], (mmddyyyy[0]-1), mmddyyyy[1], hh, hhmmss[1], hhmmss[2])
			//alert('hh='+hh)
			//alert('c='+cookieexp)

			cookser = cookieexp.getTime()
			todayser = today.getTime()
			hhser = Math.floor((((cookser - todayser)/60)/60/1000)) 
			mmser = Math.floor((cookser - todayser)%(60*60*1000) /(60 *1000))
			ssser = Math.floor(((cookser - todayser)%(60*60*1000) %(60 *1000)) / 1000)
			
//			document.write('<br>time left=' + hhser + ' '+ mmser + ' '+ ssser + ' ')

			//alert(mmser)
			//document.write('<br>date expire='+new Date(mmddyyyy[2], (mmddyyyy[0]-1), mmddyyyy[1], hh, hhmmss[1], hhmmss[2])+'<br>')
			//document.write('<br>todays date='+today)
			//alert('hh='+hh)
			
			if (hhser != 0 )
			{
				//alert(mm)
				if (flag==1)
				{
					rtnvalue ='Your ' +mytool_array[0] +'% discount expires in ' + hhser + ' hour(s) ' + ' & ' + mmser + ' min<br>All orders over $13.49 receive free shipping'
				}
				else // this msg isused on index.htm page
				{
					if (hhser==23 && mmser ==59 && ssser>1)
					{
						rtnvalue ='Special limited time offer\n\n' +mytool_array[0]  + '% discount off all orders made in the next 24 hours\n\nAll orders over $13.49 receive free shipping'
					}
					else
					{
						rtnvalue ='Your ' +mytool_array[0] +'% discount expires in ' + hhser + ' hour(s) ' + ' & ' + mmser + ' minutes\n\nAll orders over $13.49 receive free shipping'
					}
				}
				discountAmt=mytool_array[0]
				
			//alert(discountAmt)	
			}

			else //less then 1 hour
			{

				//alert(mm)
				if (flag==1)
				{
					rtnvalue = 'Your ' +mytool_array[0] +'% discount expires in ' + mmser + ' minute(s)' + ' & ' + ssser + ' sec<br>All orders over $13.49 receive free shipping'
				}
				else
					 // this msg isused on index.htm page
				{
					 
					
						rtnvalue ='Your ' +mytool_array[0] +'% discount expires in ' + mmser + ' minute(s)' + ' & ' + ssser + ' sec\n\nAll orders over $13.49 receive free shipping'
					
				}
				discountAmt=(+mytool_array[0])
				//alert(discountAmt)
			}
		}
return(rtnvalue )
}
//			
//
//			}

//return(rtnvalue )
//}


//document.write(cook);
//document.write('<br>' + today)


function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


 


