function showimagename(racenum,raceimagenum)
{
	
	    testvalue(racenum);
	
	    var filevalue=document.getElementById("imagerace"+parseInt(racenum)+"_"+parseInt(raceimagenum)).value;
	    var filearray=filevalue.split(".");
 
	    if(filearray[1]=="gif" || filearray[1]=="GIF")
		var imagevalue="<img src=\"../images/new/gif.gif\" border=\"0\" alt=\"gifimage\" />";
		else if(filearray[1]=="png" || filearray[1]=="PNG")
		var imagevalue="<img src=\"../images/new/png.gif\" border=\"0\" alt=\"gifimage\" />";
		else if(filearray[1]=="jpg" || filearray[1]=="JPG" || filearray[1]=="jpeg" || filearray[1]=="JPEG")
		var imagevalue="<img src=\"../images/new/jpg.gif\" border=\"0\" alt=\"gifimage\" />";
		else if(filearray[1]=="bmp" || filearray[1]=="BMP")
		var imagevalue="<img src=\"../images/new/bmp.gif\" border=\"0\" alt=\"gifimage\" />";
	  
	   var presentimage=document.getElementById("presentimage").value;
	   var imagefilecount=document.getElementById("filecount"+presentimage).value;
	   var filecount=document.getElementById("totalfilecount"+presentimage).value;
	   var replacefilesection="spacefilesection"+parseInt(presentimage)+"_"+(parseInt(filecount)+1);//alert(replacefilesection);
	   var replacespacefilesectiondiv="spacefilesectiondiv"+parseInt(presentimage)+"_"+(parseInt(filecount)+1);//alert(replacespacefilesectiondiv);
	   var showimageval="files"+parseInt(presentimage)+"_"+parseInt(filecount);//alert("showimageval=="+showimageval);
	   var showimgaevaldivplace="nextfilediv"+parseInt(presentimage)+"_"+(parseInt(filecount)+1);//alert("showimgaevaldivplace"+showimgaevaldivplace);
	   var showimagevaldiv="<div id='files"+parseInt(presentimage)+"_"+(parseInt(filecount)+1)+"' ></div><div id='nextfilediv"+presentimage+"_"+(parseInt(filecount)+2)+"' ></div>";//alert(showimagevaldiv);
	   var replacefilevalue="<input type='file' size='60' name='imagerace"+parseInt(presentimage)+"_"+(parseInt(filecount)+1)+"' id='imagerace"+parseInt(presentimage)+"_"+(parseInt(filecount)+1)+"' onchange='showimagename("+parseInt(presentimage)+","+(parseInt(filecount)+1)+")'  class='filetypeclass' />";
	   var replacedivvalue="<div id='spacefilesection"+parseInt(presentimage)+"_"+(parseInt(filecount)+2)+"'></div><div id='spacefilesectiondiv"+parseInt(presentimage)+"_"+(parseInt(filecount)+2)+"'></div>";
	   document.getElementById(showimageval).innerHTML='<table cellpadding="0" cellspacing="0"  class="removed" ><tr><td >'+imagevalue+'&nbsp;&nbsp;'+filevalue+'&nbsp;&nbsp;<a onclick="removeimagemanage('+presentimage+','+filecount+')" class="removed">Radera</a></td></tr></table>';
	   document.getElementById(showimgaevaldivplace).innerHTML=showimagevaldiv;
		if(parseInt(imagefilecount)!=4)
		{
			  document.getElementById(replacefilesection).innerHTML=replacefilevalue;
		}
		document.getElementById(replacespacefilesectiondiv).innerHTML=replacedivvalue;	
		document.getElementById("spacefilesection"+parseInt(presentimage)+"_"+(parseInt(filecount))).style.display="none";
		document.getElementById("filecount"+presentimage).value=parseInt(imagefilecount)+1;
		document.getElementById("totalfilecount"+presentimage).value=parseInt(filecount)+1;		
	  
	  
	  
}


function removeimagemanage(presentimage,filecount)
{
	
	var showimageval="files"+parseInt(presentimage)+"_"+parseInt(filecount);	
	document.getElementById(showimageval).innerHTML="";
	var hidehtml="spacefilesection"+parseInt(presentimage)+"_"+(parseInt(filecount));
	document.getElementById(hidehtml).innerHTML="";
	 var showfilecount=document.getElementById("totalfilecount"+presentimage).value;
	var nextshowhtmlplace="spacefilesection"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+1);
	var nextshowhtml="<input type='file' size='60' name='imagerace"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+1)+"' id='imagerace"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+1)+"' onchange='showimagename("+parseInt(presentimage)+","+(parseInt(showfilecount)+1)+")'  class='filetypeclass' />";//alert(nextshowhtml);
	var nextdivreplace="<div id='spacefilesection"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+2)+"'></div><div id='spacefilesectiondiv"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+2)+"'></div>";
	var nextdivplace="spacefilesectiondiv"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+1);
	document.getElementById(nextshowhtmlplace).innerHTML=nextshowhtml;
	document.getElementById(nextdivplace).innerHTML=nextdivreplace;	
			document.getElementById("filecount"+presentimage).value=parseInt(document.getElementById("filecount"+presentimage).value)-1;
		document.getElementById("totalfilecount"+presentimage).value=parseInt(showfilecount)+1;	
		
		var showimgaevaldivplace="nextfilediv"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+1);//alert("showimgaevaldivplace"+showimgaevaldivplace);
	   var showimagevaldiv="<div id='files"+parseInt(presentimage)+"_"+(parseInt(showfilecount)+1)+"' ></div><div id='nextfilediv"+presentimage+"_"+(parseInt(showfilecount)+2)+"' ></div>";
	   document.getElementById(showimgaevaldivplace).innerHTML=showimagevaldiv;
	//   alert("sfsf");alert
	   if(parseInt(document.getElementById("filecount"+presentimage).value)<=4)
	   {
		     document.getElementById("spacefilesection"+parseInt(presentimage)+"_"+(parseInt(showfilecount))).innerHTML="";
	   }

	
}


