can any one tell me whats the wrong with code
<pre><code>function MoveAddToCartAccordingly()
{
  var elems = document.getElementsByClassName('box-collateral box-related');
  var av = document.getElementsByClassName('availability in-stock');
  var sp = document.getElementsByClassName('product-options');
  var ac = document.getElementsByClassName('add-to-cart');
  var first = document.getElementsByClassName('item first');
  var second = document.getElementsByClassName('item');
  for(var k = 0; k &lt; sp.length; k++){
   if (getComputedStyle(sp[k]).visibility == "visible")
   {  
     for (var i = 0; i &lt; elems.length; i++) {
      if (getComputedStyle(elems[i]).visibility == 'visible') {
       for (var j = 0; j &lt; av.length; j++) {
        av[j].style.visibility = 'visible';
        av[j].id = "someID";
        elems[i].appendChild(av[j]);
       }     
      }
      else
      {  
        for (var s = 0; s &lt; av.length; s++) {
         av[s].style.visibility = 'hidden';
        }
        for (var l = 0; l &lt; ac.length; l++) {
         ac[l].style.marginTop = "-500px";
         ac[l].style.marginLeft = "-20px";
        }
      }
     }

   }
   return;
  }
  for (var p = 0; p &lt; elems.length; p++) {
   if (getComputedStyle(elems[p]).visibility == 'visible') {
     for (var q = 0; q &lt; av.length; q++) {
        av[q].style.visibility = 'visible';
        av[q].id = "someID";
        elems[p].appendChild(av[q]);
     }     
     if(elems[p].style.marginTop == "-610px")
     { 
        elems[p].style.marginTop = "-640px";
     }
     for(var r = 0; r &lt; first.length; r++)
     {
       if(getComputedStyle(first[r]).visiblity == 'visible'){
        for(var m = 0; m &lt; ac.length; m++)
        { 
          if(ac[m].style.marginTop == "-120px")
          {
            ac[m].style.marginTop ="-140px";
          }   
        } 
       }
       else if(getComputedStyle(first[r]).visiblity == 'visible' &amp;&amp; getComputedStyle(second[r]).visiblity == 'visible' )
       {
         for(var n = 0; n &lt; ac.length; n++)
         { 
           if(ac[n].style.marginTop == "-120px")
          {
            ac[n].style.marginTop ="-140px";
          }
         }
       } 
     }
   }
 }
}
window.onload = MoveAddToCartAccordingly;
</code></pre>

<p>can any one whats the wrong with code here actually i am checking if div product option is visible then again i am checking if div with class "box-colatral box-related" if visible if it is not then i am hidding other tag p with class Availability-in-stock and moving add-to- cart div to top position but that one is not working </p>
