﻿var slideImages;

var profile =
{  
  addBrandToProfile: function(brandId, type, el) {
    Tools.post("post", "/_/AddBrandToProfile", function(obj){
      profile.markFunction(el,"disabled");
      profile.restoreClassName(document.getElementById("actionDelete-"+type));
    }, {brandId:brandId,relationType:type});
    return false;
  },
  
  removeBrandFromProfile: function(brandId, type, el) {
    Tools.post("post", "/_/RemoveBrandFromProfile", function(obj){
      profile.restoreClassName(document.getElementById("profileAction-"+type));
      profile.hideElement(el);
    }, {brandId:brandId,relationType:type});
    return false;
  },
  
  markFunction: function(el, markType)
  {
    Spif.ClassNameAbstraction.add(el, markType);
  },  
  
  restoreClassName:function(el)
  {
    el.className = "";
  },
  
  hideElement:function(el)
  {
    Spif.ClassNameAbstraction.add(el, "hide");
  },
  
  BrandSwitchBox:function(elId)
  {    
    if(document.getElementById(elId) != null)
    {
      var slideImages = document.getElementById(elId).getElementsByTagName('div');
      if (slideImages.length > 0)
      {
        Spif.Utils.setIntervalHandler(function()
        {
          var randNummer = Math.floor(Math.random() * slideImages.length * 0.99 );                 
          Spif.ClassNameAbstraction.replace(slideImages[randNummer],"collapsed", "expanded");
          
          var _img = slideImages[randNummer].getElementsByTagName("img");
          if(_img.length == 1)
          {
            var imageRelation = document.getElementById("imageRelation");
            if(imageRelation != null)
              imageRelation.innerHTML = _img[0].getAttribute("relation");
          }
        }, 4000);
      }
    }
  }
  
}
