var images_arr = new Array();
var previous_img = null;



$(document).ready(function(){
	var images_count = $('div.top-image img').length;
	if(images_count>0)
	{
	    for(var i = 0;i < images_count; i++){
		    images_arr[i] = $('div.top-image img')[i];
		    if(i!=0)
			    $(images_arr[i]).css('opacity',0);
	    }
	    initTopImages(0);
	}	
	TownHallSurvey();
});

/**
 *	show next image, and hide previous
 */ 

function initTopImages(numb){
	var images_count = $('div.top-image img').length;	
	var this_image = $('div.top-image img')[numb];
	
	if(previous_img!=null){
		//$(previous_img).hide();
		$(previous_img).animate({opacity: 0}, 800);
		//$(previous_img).css('display', 'none');
	}	
	//$(this_image).show();	
	$(this_image).css('display','block');
	$(this_image).animate({opacity: 1}, 800);	
	numb++;
	if(numb >= images_count)
		numb = 0;
	previous_img = this_image;
	setTimeout('initTopImages(' + numb + ')', 8000);	
}

function TownHallSurvey()
{
    
    var formID = jQuery.url.param('ID');
    if(formID == '451')
    {
        //$('input#ctl00_ctl00_ctl16_MyText').css('background','red');
        $('input#ctl00_ctl00_ctl16_MyText').after('<textarea class="inputText" id="ctl00_ctl00_ctl16_MyText" name="ctl00$ctl00$ctl16$MyText" style="width:400px;" rows="10">'+$('input#ctl00_ctl00_ctl16_MyText').val()+'</textarea>');
        $('input#ctl00_ctl00_ctl16_MyText').remove();
        
        $('.formRadio label').css('display','inline');
        $('table.formRadio').each(function(i){
            var checkList = "<br/>";
            $(this).find('td').each(function(j){
                checkList+=$(this).html();
            });
            checkList+='<br/><br/>';
            $(this).before(checkList);
            $(this).remove();
        });
    }
}
