// START Dynamic Product Images on Radio Buttons
var current = '';
var scaledown;
var colcount;
var colpos;
var textunder;
var buttonunder;
function radioimage(radiohtml, choicename){
   var result = choicename.match(/(.*)\{(.*)\}(.*)/);   		// see if HTML for Name contains {.....}
   if ( result != null )
     {
     var textsep = textunder ? '<br>' : ''; 				// do we want text under button
     scaledown = scaledown - 0;
     var twidth = Math.floor(100 / colcount);
     colpos++;
     if ( isNaN(scaledown) || scaledown < 1 ) scaledown = 4;    	// set a default if bad scaledown
     var cpath = '';
     var curbits = current.match(/(.*\/)(.*)/);				// if we're previewing 
     if ( curbits != null ) cpath = curbits[1];				//  then get path to main image
     var thisimage = result[2];      					// the text within { }
     // add in image substitution code
     radiohtml += ' onClick="document.getElementById(\'' + current + '\').src=\'' + cpath + thisimage + '\'">';
     var thiswidth = Math.floor(iwidth.replace(/WIDTH=(.*)/,"$1") / scaledown);	// the width
     var thisheight = Math.floor(iheight.replace(/HEIGHT=(.*)/,"$1") / scaledown);	// the height
     document.write('<table width="' + twidth + '%" align=left>');		// start a table if appropriate width
     document.write('<tr><td><img src="' + cpath + thisimage 			// first cell with image
                  + '" width=' + thiswidth + ' height=' + thisheight + '>');
     if ( buttonunder )							// where do we want the button text 
       {
       document.write('<br>' + radiohtml + textsep + result[1] + result[3]);	// button under image
       }
     else
       {
       document.write('</td><td width="100%" valign=top>');		// new cell next to image
       document.write(radiohtml + textsep + result[1] + result[3]);     // then radio button and description
       }
     document.write('</td></tr></table>');				// finally end table
     if ( colpos >= colcount ) 
       {
       document.write('<br clear=all>');
       colpos = 0;
       }
     }
   else  
     {
     result = choicename.match(/(.*)\[(.*)\](.*)/);   			// see if HTML for Name contains [.....]
     if ( result != null )
       {
       var textsep = textunder ? '<br>' : ''; 				// do we want text under button
       var twidth = Math.floor(100 / colcount);
       colpos++;
       var cpath = '';
       var curbits = current.match(/(.*\/)(.*)/);			// if we're previewing 
       if ( curbits != null ) cpath = curbits[1];			//  then get path to main image
       var thisimage = result[2];      					// the text within [ ]
       radiohtml += '>';
       document.write('<table width="' + twidth + '%" align=left>');	// start a table if appropriate width
       document.write('<tr><td><img src="' + cpath + thisimage + '">');	// first cell with image
       if ( buttonunder )						// where do we want the button text 
         {
         document.write('<br>' + radiohtml + textsep + result[1] + result[3]);	// button under image
         }
       else
         {
         document.write('</td><td width="100%" valign=top>');		// new cell next to image
         document.write(radiohtml + textsep + result[1] + result[3]);  	// then radio button and description
         }
       document.write('</td></tr></table>');				// finally end table
       if ( colpos >= colcount ) 
         {
         document.write('<br clear=all>');
         colpos = 0;
         }
       }
     else								// no brackets of any kind
       {
       document.write(radiohtml + '>' + choicename);  			// so write the unaltered choice text
       }
    }
}
// END Dynamic Product Images on Radio Buttons

