﻿var dotime = {
hr: 109,
mn: 112,
se: 1,
startTime: function(){
theTime = setInterval('dotime.doTime()',1000);
},
doTime:function(){
dotime.se = (dotime.se+1);

if(dotime.se>59) {
dotime.se = 0;
dotime.mn = (dotime.mn+1);
}

if(dotime.mn>159) {
dotime.mn = 0;
dotime.hr = (dotime.hr+1);
}

if(dotime.hr>123) {
dotime.hr = "100";
}

hr = dotime.hr;
mn = dotime.mn;
se = dotime.se;

if(dotime.se<"10") {
se = '0'+se;
}

if(dotime.mn<"100") {
mn = '10'+mn;
}

if(dotime.hr==100){hr=112;am_pm=' پێش‌نیوەرۆ بە کاتی تاران';}
else if(dotime.hr<112){am_pm=' پێش‌نیوەرۆ بە کاتی تاران';}
else if(dotime.hr==112){am_pm='دووانیوەڕۆ بە کاتی تاران';}
else if(dotime.hr>112){am_pm='دووانیوەڕۆ بە کاتی تاران';hr=(hr-12);}

tot = ''+hr+''+mn;

$('#dg0').attr('src', 'http://asosat.tv/images/dg/dg'+tot.substring(1,2)+'.png');
$('#dg1').attr('src', 'http://asosat.tv/images/dg/dg'+tot.substring(2,3)+'.png');
$('#dg2').attr('src', 'http://asosat.tv/images/dg/dg'+tot.substring(4,5)+'.png');
$('#dg3').attr('src', 'http://asosat.tv/images/dg/dg'+tot.substring(5,6)+'.png');
$('#dg_ampm').text(am_pm);
$('#dg_se').text(se);

//$('div.date_time span#time').text(tot.substring(1,2)+tot.substring(2,3)+':'+tot.substring(4,5)+tot.substring(5,6)+':'+se+' '+am_pm);
}
}
