//<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
date=new Date();
bgdays=Array("Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота");
var newcontent = document.createElement('table');  
newcontent.width = '310px';  
newcontent.cellspacing = '0';  
newcontent.cellpadding = '0';  
newcontent.border = '0';  
newcontent.style.padding = '3px 3px 3px 6px';
newcontent.style.borderBottom = '1px #000000 dashed';
newcontent.style.borderLeft = '1px #000000 dashed';  
tbody = document.createElement('tbody');
newcontent.appendChild(tbody);  
tr = document.createElement('tr');
tbody.appendChild(tr);  
		for(i=0;i<7;i++){
			daynum=date.getDay()-i;
			if(daynum<0){
				daynum=7-(i-date.getDay());
			}
			td = document.createElement('td');
			td.style.padding = '3px 1px 3px 0px';
			tr.appendChild(td);  
				if(i==chosenday || (chosenday==7 && i==0)){
					b = document.createElement('b');
					td.appendChild(b);  
					text_containing_element = document.createElement('font');
					text_containing_element.color = '#FF3300';
					b.appendChild(text_containing_element);  
				}else{
					if(i==0){
						text_containing_element = document.createElement('a');
						text_containing_element.href = 'index.php?day=7';
						td.appendChild(text_containing_element);  
					}else{
						text_containing_element = document.createElement('a');
						text_containing_element.href = 'index.php?day='+i;
						td.appendChild(text_containing_element);  
					}
				}
				if(i==0){
					text_containing_element.appendChild(document.createTextNode('Днес'));
				}else{
					text_containing_element.appendChild(document.createTextNode(bgdays[daynum]));
				}
			td2 = document.createElement('td');
			td2.style.padding = '3px 8px 3px 0px';
			tr.appendChild(td2);  
				if(i==chosenday || (chosenday==7 && i==0)){
					b2 = document.createElement('b');
					td2.appendChild(b2);  
					text_containing_element2 = document.createElement('font');
					text_containing_element2.color = '#FF3300';
					b2.appendChild(text_containing_element2);  
				}else{
					if(i==0){
						a2_href = 'index.php?day=7';
					}else{
						a2_href = 'index.php?day='+i;
					}
					a2 = document.createElement('a');
					a2.href = a2_href;
					td2.appendChild(a2);  
					text_containing_element2 = document.createElement('font');
					text_containing_element2.color = '#999999';
					a2.appendChild(text_containing_element2);  
				}
				text_containing_element2.appendChild(document.createTextNode("("+day[daynum]+")"));
			if(i==2){
				td3 = document.createElement('td');
				td3.appendChild(document.createTextNode(" "));
				tr.appendChild(td3);  

				td4 = document.createElement('td');
				td4.appendChild(document.createTextNode(" "));
				tr.appendChild(td4);
				
				tr = document.createElement('tr');
				tbody.appendChild(tr);  
			}
		}

var scr = document.getElementById('sites_per_weekday');  
scr.parentNode.insertBefore(newcontent, scr);
