/* 给对比按钮加事件
*/
function addEventToComparisonBtn() {
  $('input[name=comparison_switch]').each( function(i,n) {
      var product_id = $(n).attr('product_id');
      $(n).click( function() {
          var par = {
            _rn: Math.random(),
            product_id: product_id,
            act: $(this).attr('checked') ? 'add' : 'del'
          };
          $.post('act.php?comparison_switch', par, function() {
              if(par.act == 'add') {
                $(n).next('label:eq(0)').html('Remove from Comparison')
                  .next('span.tips:eq(0)').html('<a href="comparison.shtml"><img src="/webbase/img/bigger.gif" /></a>');
              } else {
                $(n).next('label:eq(0)').html('Add to Product Comparison')
                  .next('span.tips:eq(0)').html('');
              }
            });
        } );
    } );
}

/* 导航菜单*/
function menuFix() {
  var sfEls = document.getElementById("headnav").getElementsByTagName("li");
  for(var i=0;i<sfEls.length;i++) {
		var ulss=sfEls[i].getElementsByTagName("ul");	
	}
  for (var i=0; i<sfEls.length; i++) {
    sfEls[i].onmouseover=function() {
      this.className+=(this.className.length>0? " ": "") + "show";
    }
    sfEls[i].onmouseout=function() {
      this.className=this.className.replace(new RegExp("( ?|^)show\\b"), "");
    }
  }
}
window.onload=menuFix;



/* faq */
function MenuToggle(e)
{
   aTags = new Array('ul','div');
   oTargetArray = new Array();
   oParent = e.parentNode ;
     for(i = 0 ; i < aTags.length; i++) 
	 {
	    oTargetArray.push(oParent.getElementsByTagName(aTags[i]));
	}
   for (i = 0 ; i < oTargetArray.length;i++)
   {
     oTarget = oTargetArray[i];
     // alert(oTarget[0].tagName);
    if(typeof oTarget[0] != 'undefined')
   {
  if(oTarget[0].style.display != 'block'  ){
   oTarget[0].style.display = 'block';
	 oTarget[0].parentNode.className = "list";
	 }
   else{
   oTarget[0].style.display = 'none';
	 oTarget[0].parentNode.className = "";
   return false;}
   }
}  
return true;
}




function dump(o) {
  var name = '__dump_message_container__';
  var s;
  if(typeof o == 'object') {
    s = dumpExec(o, 1);
  } else if(typeof o == 'undefined') {
    s = 'UNDEFINED';
  } else {
    s = o.toString();
  }
  if(document.getElementById(name)) {
    var obj = document.getElementById(name);
  } else {
    var obj = document.createElement('div');
    obj.id = name;
    obj.style.backgroundColor = '#FFFFFF';
    obj.style.border = 'solid 2px #F00';
    obj.style.margin = '1em';
    obj.style.padding = '.5em';
    obj.style.fontSize = '1.2em';
    obj.style.lineHeight = '160%';
    document.body.appendChild(obj);
  }
  obj.innerHTML = s;
}
function dumpExec(o, depth) {
  var s = '';
  var indent = new Array(depth).join('&nbsp;&nbsp;&nbsp;&nbsp;');
  for(a in o) {
    if(typeof o[a] == 'object') {
      s += indent + a + ': {<br />' + dumpExec(o[a], (depth+1)) + indent + '}<br />';
    } else {
      s += indent + a + ': ' + o[a].toString() + '<br />';
    }
  }
  return s;
}

String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }


