	var sourceHTML, sourceTitle;
	
	function displayTwitter(id,src){
		var obj = document.getElementById(id);
		var src = document.getElementById(src);
		if (obj && src){
			if (obj.style.visibility=='hidden'){
				obj.style.visibility='visible';
				obj.style.display='';
				src.innerHTML ='hide twitter'
			}else{
				obj.style.display='none';
				obj.style.visibility='hidden';
				src.innerHTML ='show twitter'
			}
		}
	}
	
	function showHide(id, targetId){
		var obj = document.getElementById(id);
		var target = document.getElementById(targetId);
		if (obj && target){
			if (target.style.visibility=='hidden' && (sourceHTML==undefined || sourceHTML=='')){
				sourceHTML = obj.innerHTML;
				sourceTitle = obj.title;
				target.style.display='';
				target.style.visibility='visible';
				obj.innerHTML = 'Hide comments';
				obj.title = 'Hide comments';
			}else{
				obj.innerHTML = sourceHTML;
				obj.title = sourceTitle;
				target.style.display='none';
				target.style.visibility='hidden';
				sourceHTML = '';
				sourceTitle = '';
			}
		}
	}

	function loadingDots(id){
		var element;
		element = id;
      	var o = document.getElementById(id);
      	if(o){
        	if(o.innerHTML==''){
          		o.innerHTML=' ·';
        	}else if(o.innerHTML==' ·'){
          		o.innerHTML=' · ·';
        	}else if(o.innerHTML==' · ·'){
          		o.innerHTML=' · · ·';
       	 	}else{
          		o.innerHTML='';
        	}
      	}
      	
      	var t,functionName;
      	functionName = 'loadingDots(\'' + element + '\')';
     	t=setTimeout(functionName,1000);
    }
    
    function redirect(path){
			document.location=path;
		}
		
		function showObject(id)
		{
			var o = document.getElementById(id);
			if(o)
			{
				o.style.visibility='visible';
			}
		}

		function hideObject(id)
		{
			var o = document.getElementById(id);
			if(o)
			{
				o.style.visibility='hidden';
			}
		}
		
		function Toggle(id)
		{
			var o = document.getElementById(id);
			if(o)
			{
				if(o.style.display=='none' && o.style.visibility=='hidden')
				{
					o.style.visibility='visible';
					o.style.display='block';
				}
				else{
					o.style.visibility='hidden';
					o.style.display='none';
				}
			}
		}
		
		function changeFocus(id,hide1,hide2,focusID)
		{
			var o = document.getElementById(id);
			var x = document.getElementById(focusID);
			if(x)
			{
				if(o.value =='')
				{
					alert('should be hidding');
					hideInput(hide1,hide2);
					//x.focus();
				}
			}
		}	
		
		function makeFocus(id)
		{
			var o = document.getElementById(id);
			if(o)
			{
				o.focus();
			}
		}	
		
		function hoverButton(id)
		{
			var o = document.getElementById(id);
			
			if(o)
			{
				o.style.cursor='pointer';
				if(o.className=='button ')
				{
					o.className='button button_over';
				}
				else if(o.className=='button')
				{
					o.className='button button_over';
				}
				else if(o.className=='first_button ')
				{
					o.className='first_button button_over';
				}
				else if(o.className=='first_button')
				{
					o.className='first_button button_over';
				}	
			}
		}
		
		function buttonOut(id)
		{
			var o = document.getElementById(id);
			if(o)
			{
				if(o.className=='button button_over')
				{
					o.className='button ';
				}	
				else if(o.className=='first_button button_over')
				{
					o.className='first_button ';
				}
			}
		}
				
		function sortColumn(path,page)
		{
			var o = location.search;
			if((o.match('sort')==null) || (o.match('sort=1')))
			{
				document.location=path + page + '.php?sort=2';
			}
			
			if(o.match('sort=2')){
				document.location=path + page + '.php?sort=1';
			}
			
		}
	
	function populateCalendar(new_month){
		
		if(isNaN(new_month)){
			var new_month = 0;
		}
		var one_day,date1,date2,rows,balance,Tdays,FirstDay,i,x,count,datescount,today,cells;
	  balance=0;
	  one_day = 1000*60*60*24;
	  today = new Date();
	  dates = new Array(48);
	  date1 = new Date();
	 	date2 = new Date();
	 	date1.setFullYear(today.getFullYear(),today.getMonth()+new_month,1);
	  date2.setFullYear(today.getFullYear(),(today.getMonth()+new_month)+1,1);
	  count=0;
	  datescount=1;
	  Tdays = Math.round((date2-date1)/one_day);
	
	  FirstDay = date1.getDay();
	  if(FirstDay > 4){
			balance=0.5;
		}
	  cells = 49;
	  
	  // blank all table cells before putting new dates in each time
	  clearCalendar(cells);
		
		//write current calendar month and year view
		var title = document.getElementById('title');
		if(title){
			title.innerHTML=getMonthName(date1.getMonth()) + ' ' + date1.getFullYear();
		}

		for(i=0;i<cells;i++){
			var o = document.getElementById(i);
			if(o){
				
				if(i>=FirstDay && datescount<=Tdays){
					
							//Highlight current day - very buggy at the mo!
					if((i==0) || (i==6) || (i==7) || (i==13) || (i==14) || (i==20) || (i==21) || (i==27) || (i==28) || (i==34) || (i==35) || (i==41)){
						if((datescount == today.getDate()) && (date1.getMonth() == today.getMonth())){
							o.className='calendar-weekend-highlight';
						}
					}
					else{
						if((datescount == today.getDate()) && (date1.getMonth() == today.getMonth())){
							o.className='calendar-weekday-highlight';
						}
					}
					
				o.innerHTML=datescount++;
				}
			}
		}
	  
	}
	
	function clearCalendar(cells){
		for(var i=0;i<=cells;i++){
			var o = document.getElementById(i);
			if(o){
				o.innerHTML='&nbsp;'
				if((i==0) || (i==6) || (i==7) || (i==13) || (i==14) || (i==20) || (i==21) || (i==27) || (i==28) || (i==34) || (i==35) || (i==41)){
					o.className='calendar-weekend';
				}
				else{
					o.className='calendar-weekday';
				}
			}
		}
	}
	
	function calendar(){
	  
	  var one_day,date1,date2,rows,balance,Tdays,FirstDay,i,x,count,datescount,today;
	  one_day = 1000*60*60*24;
	  today = new Date();
	  dates = new Array(48);
	  date1 = new Date();
	 	date2 = new Date();
	 	date1.setFullYear(today.getFullYear(),today.getMonth(),today.getDate());
	  date2.setFullYear(today.getFullYear(),today.getMonth()+1,today.getDate());
	  count=0;
	  Tdays = Math.round((date2-date1)/one_day);
	  FirstDay = date1.getDay(); 	  
	  rows = 6;
	  document.write('<table width=\"300px;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">');
	  document.write('<tr>');
	  document.write('<td><span onmouseover=\"this.style.cursor=\'pointer\'\" onclick=\"new_month--;populateCalendar(new_month);\"><-</span></td>');
	  document.write('<td id=\"title\" colspan=\"5\" align=\"center\">&nbsp;</td>');
	  document.write('<td align=\"right\"><span onmouseover=\"this.style.cursor=\'pointer\'\" onclick=\"new_month++;populateCalendar(new_month);\">-></span></td>');
	  document.write('</tr>');
	  document.write('<tr>');
	  document.write('<td style=\"text-align:center; font-size:7pt; width:20px; height:20px; background-color:rgb(255,255,255); border:0px; border-color:rgb(0,0,0); border-style:solid;\">S</td>');
	  document.write('<td style=\"text-align:center; font-size:7pt; width:20px; height:20px; background-color:rgb(255,255,255); border:0px; border-color:rgb(0,0,0); border-style:solid;\">M</td>');
	  document.write('<td style=\"text-align:center; font-size:7pt; width:20px; height:20px; background-color:rgb(255,255,255); border:0px; border-color:rgb(0,0,0); border-style:solid;\">T</td>');
	  document.write('<td style=\"text-align:center; font-size:7pt; width:20px; height:20px; background-color:rgb(255,255,255); border:0px; border-color:rgb(0,0,0); border-style:solid;\">W</td>');
	  document.write('<td style=\"text-align:center; font-size:7pt; width:20px; height:20px; background-color:rgb(255,255,255); border:0px; border-color:rgb(0,0,0); border-style:solid;\">T</td>');
	  document.write('<td style=\"text-align:center; font-size:7pt; width:20px; height:20px; background-color:rgb(255,255,255); border:0px; border-color:rgb(0,0,0); border-style:solid;\">F</td>');
	  document.write('<td style=\"text-align:center; font-size:7pt; width:20px; height:20px; background-color:rgb(255,255,255); border:0px; border-color:rgb(0,0,0); border-style:solid;\">S</td>');
	  document.write('</tr>');
	  
	  for(i=1;i<=Tdays;i++){
	    dates[i]=i;
	  }  
	 
	  for(i=0;i<rows;i++){
	 
	    document.write('<tr>');
	    for(x=0;x<7;x++){
	    	if((count==0) || (count==6) || (count==7) || (count==13) || (count==14) || (count==20) || (count==21) || (count==27) || (count==28) || (count==34) || (count==35) || (count==41)){
	      	document.write('<td id=\"' + count + '\" title=\"' + count +'\" class=\"calendar-weekend\">&nbsp;</td>');
	      }else{
	      	document.write('<td id=\"' + count + '\" title=\"' + count +'\" class=\"calendar-weekday\">&nbsp;</td>')
	      }
	      count++;
	    }
	    document.write('</tr>');
	  }
	  document.write('</table>');
	}	
	
	function getMonthName(value){
		if(value==12){
			value=valu-1;
		}
		var month=new Array(12)
			month[0]="January"	
			month[1]="February"
			month[2]="March"
			month[3]="April"
			month[4]="May"
			month[5]="June"
			month[6]="July"
			month[7]="August"
			month[8]="September"
			month[9]="October"
			month[10]="November"
			month[11]="December"
		
		return month[value];
	}
