<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -257,35 +257,22 @@ function enableAutoAdd(){
     },300)
 }
 
-function toggleEmbedStyle(check){
-    var styled = check.get('checked')
-    var embed_field = $('quoteURL-embed-field')
-    if (embed_styles == null){
-        //first-time, store the style info
-        embed_styles = embed_field.value.match(/&lt;.*?style=&quot;[^&quot;]*&quot;/g)
-    }
-    var lastindex = 0;
-    var embed_string = embed_field.value
-    if (!styled) {
-        //remove style
-        for (var i=0; i&lt;embed_styles.length; i++){
-            lastindex = embed_string.indexOf(embed_styles[i],lastindex)
-            embed_string =  embed_string.substring(0,lastindex) +
-                                embed_styles[i].substring(0, embed_styles[i].indexOf('style=&quot;')-1) +
-                                embed_string.substring(lastindex+embed_styles[i].length, embed_string.length)
-        }
-        embed_field.value = embed_string.replace('QuoteURL styled embed start','QuoteURL no-style embed start')
-    } else {
-        //put styles back
-        for (var i=0; i&lt;embed_styles.length; i++){
-            var searchfor = embed_styles[i].substring(0, embed_styles[i].indexOf('style=&quot;')-1)
-            lastindex = embed_string.indexOf(searchfor,lastindex)
-            embed_string =  embed_string.substring(0,lastindex) +
-                                embed_styles[i] +
-                                embed_string.substring(lastindex+searchfor.length, embed_string.length)
-        }
-        embed_field.value = embed_string.replace('QuoteURL no-style embed start','QuoteURL styled embed start')
-    }
+function toggleEmbedStyle(check) {
+   var styled = check.get('checked');
+   var embed_field = $('quoteURL-embed-field')
+   if (embed_styles == null){
+       //first-time, store the style info
+       embed_styles = embed_field.value.match(/(style=&quot;[^&quot;]+&quot;)/gi);
+   }
+   var embed_string = embed_field.value
+   if (!styled) {
+       embed_string = embed_string.replace(/(style=&quot;[^&quot;]+&quot;)/gi, 'style=&quot;&quot;');
+       embed_field.value = embed_string.replace('QuoteURL styled embed start','QuoteURL no-style embed start')
+   } else {
+       for(var i = 0, len = embed_styles.length; i &lt; len; i++)
+         embed_string = embed_string.replace(/(style=&quot;&quot;)/, embed_styles[i]);
+       embed_field.value = embed_string.replace('QuoteURL no-style embed start','QuoteURL styled embed start')
+   }
 }
 //--- Errors and Warnings ---
 </diff>
      <filename>js/main.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d98b5504d22a4dc7d07584d0ce04f70cf59e9c3b</id>
    </parent>
  </parents>
  <author>
    <name>Fabricio Zuardi</name>
    <email>fabricio@gmail.com</email>
  </author>
  <url>http://github.com/fczuardi/quoteurl/commit/7a0040e389cbd373669cb1bc211c46956e0c7479</url>
  <id>7a0040e389cbd373669cb1bc211c46956e0c7479</id>
  <committed-date>2009-06-03T13:33:25-07:00</committed-date>
  <authored-date>2009-06-03T13:33:25-07:00</authored-date>
  <message>A new fix for [#45 state:resolved]</message>
  <tree>d5b1733eb603f4c81922f1ed6409eeb10faffad0</tree>
  <committer>
    <name>Fabricio Zuardi</name>
    <email>fabricio@gmail.com</email>
  </committer>
</commit>
