var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

function CountDowndmn(yr,m,d){
	cdyear=yr;
	cdmonth=m;
	cdday=d;
	var today=new Date();
	var todayy=today.getYear();
	if (todayy < 1000)
	todayy+=1900;
	var todaym=today.getMonth();
	var todayd=today.getDate();
	var todayh=today.getHours();
	var todaymin=today.getMinutes();
	var todaysec=today.getSeconds();
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
	futurestring=montharray[m-1]+" "+d+", "+yr
	dd=Date.parse(futurestring)-Date.parse(todaystring);
	dday=Math.floor(dd/(60*60*1000*24)*1);
	dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
	dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
	dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
	if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1){
return 'end';
}
else {
	var lastchar = ""+dsec;	lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
	var dsecstr = "<small>ñåê.</small>";
	
	lastchar = ""+dmin;	lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
	var dminstr    = "<small>ì. </small>";

	lastchar = ""+dhour;	lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
	var dhourstr   = "<small>÷. </small>";

	lastchar = ""+dday;	lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
	var ddaystr = "<small>äí. </small>";

	//return ""+dday+ "" +ddaystr+""+dhour+""+dhourstr+""+dmin+""+dminstr+""+dsec+""+dsecstr;

        var res = new Array();

        if(dday<10) res[0] = '0'+dday; else res[0] = dday;
        if(dhour<10) res[1] = '0'+dhour; else res[1] = dhour;
        if(dmin<10) res[2] = '0'+dmin; else res[2] = dmin;
        if(dsec<10) res[3] = '0'+dsec; else res[3] = dsec;

        return res;  
}
}

jQuery(document).ready(function($){
   setTimeout("actionsUpdate()",100); 
});

function actionsUpdate() {
   jQuery('.action').each(
      function(){
         var obj=jQuery(this).find('.action-date');
         var year=jQuery(obj).attr('year');
         var month=jQuery(obj).attr('month');
         var day=jQuery(obj).attr('day');
         var textafter=jQuery(obj).attr('textafter');

         //var text = CountDowndmn(year,month,day); 
         //if(text=='end') {text=textafter; $(this).find('.act-txt').hide();}
         //$(obj).html(text);

         var res = CountDowndmn(year,month,day);
         jQuery('#actionday').html(res[0]);
         jQuery('#actionhour').html(res[1]);
         jQuery('#actionmin').html(res[2]);
         jQuery('#actionsec').html(res[3]);


      }
   )
   setTimeout("actionsUpdate()",1000);
}