function zk(f,evt) { if(evt.keyCode==13) { top.location = '/index.php?view=page&page=zoeken&pattern=' + f.value; } }

$(document).ready(function() {
  $("body").fixPng();

  $("#search").focus(function() { $(this).removeClass("sActive"); if($(this).attr("value") == $(this).attr("defaultValue")) { $(this).attr("value", "");} });
  $("#search").blur(function() { $(this).addClass("sActive"); if($(this).attr("value") == "") { $(this).attr("value", $(this).attr("defaultValue"));} });

  $('img.tip').qtip({
      //style: { border: { width: 2, radius: 8, color: '#6699CC' }, width: 200 },
      style: { border: { width: 1, color:'#003099'}, background: '#e2e7ff',  width: 400, tip: true },
      position: { corner: { taget: 'rightTop', tooltip: 'leftTop' }, adjust: { y: -10  } },
      hide: { delay: 1000 },

      content:{
         text:'Loading' 
         //title:{ text:'Loading...', }
      },
      api:{
         onRender: function(){
            var me = this;
            var url = '/php/tooltip.php';
            var entity_id = jQuery(this.elements['target']).attr('id').split('_')[1];
            var entity_type = jQuery(this.elements['target']).attr('id').split('_')[0];
            jQuery.post(
               url,
               {'id':entity_id,'entity_type':entity_type,'ajax_action':'test1'},
               function(theResponse){   // Callback after the ajax request is complete
                  try { responseJSON = eval("(" + theResponse +")"); } catch(e) { responseJSON=false; }
                  me.updateContent(responseJSON.content,false);   // Replace current content
                  //me.updateTitle(responseJSON.title,false);   // Replace current title
                  return true;
               }
            );
         }
      }
   }).show();

  $('img.tip2').qtip({
      style: { border: { width: 1, color:'#003099'}, background: '#e2e7ff',  width: 200, tip: true },
      position: { corner: { taget: 'rightTop', tooltip: 'leftTop' }, adjust: { y: -10  } },
      hide: { delay: 1000 }, content:{ text:'Loading' },
      api:{
         onRender: function(){
            var me = this;
            var url = '/php/tooltip.php';
            var entity_id = jQuery(this.elements['target']).attr('id').split('_')[1];
            var entity_type = jQuery(this.elements['target']).attr('id').split('_')[0];
            jQuery.post(
               url,
               {'id':entity_id,'entity_type':entity_type,'ajax_action':'test1'},
               function(theResponse){   // Callback after the ajax request is complete
                  try { responseJSON = eval("(" + theResponse +")"); } catch(e) { responseJSON=false; }
                  me.updateContent(responseJSON.content,false);   // Replace current content
                  //me.updateTitle(responseJSON.title,false);   // Replace current title
                  return true;
               }
            );
         }
      }
   }).show();

 
 
  //
  // FancyBox
  //
  $(".fancy01").fancybox({'transitionIn':'linear', 'transitionOut' : 'swing', 'speedIn': 600, 'speedOut' : 200, 'titlePosition' : 'over',
     'hideOnContentClick': true,
     onStart   : function() { $('object').hide(); },
     onClosed  : function() { $('object').show(); },
       'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
       return '<span id="fancybox-title-over"><b>' + title + '<\/b><br \/>Afbeelding ' +  (currentIndex + 1) + ' / ' + currentArray.length + '<\/span>';
     }
  });
  $("a.ifrPerc").fancybox({'width':'95%','height':'95%','autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe','scrolling':'auto'});
  $("a.ifr800").fancybox({'width':800,'height':'80%','autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe'});
  $("a.ifr640").fancybox({'width':640,'height':'80%','autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe','scrolling':'none'});
  $("a.ifr400").fancybox({'width':400,'height':300,'autoScale':false,'transitionIn':'none','transitionOut':'none','type':'iframe','scrolling':'none'});
  $(".combo_images a").fancybox({'hideOnContentClick':true, 'autoScale':true, 'transitionIn':'elastic', 'transitionOut':'elastic',
    'titlePosition':'over','showNavArrows':false});

  //
  // Menu
  //
  $(".cNode1").click(function() {
    $(".cNode2Sub").slideUp(300); 
    $(".cNode1Sub").slideUp(300); 
    if($("#" + this.id + "Sub").is(':hidden')) { 
      $("#" + this.id + "Sub").slideDown(300); } else { $("#" + this.id + "Sub").slideUp(300); 
    }
  });

  $(".cNode2").click(function() {
    $(".cNode2Sub").slideUp(300); 
    if($("#" + this.id + "Sub").is(':hidden')) { 
      $("#" + this.id + "Sub").slideDown(300); } else { $("#" + this.id + "Sub").slideUp(300); 
    } 
  });
});

str='(marco)';
 
function setCartAmount(v) {
  if(v=='+') {
     var str = $('#cartAmount').html(); 
     v = eval (str.replace(/[()]/ig, ""));
     if(!v) { v=0; } v++;
  }
  if(v>0) { 
    $('#cartAmount').html('(' + v + ')'); 
  } else { 
    $('#cartAmount').html(''); 
  }
}

function imageChange(img) {
  var i = document.getElementById('bigimg');
  i.src = 'http://www.cameranu.nl/upload/thumb_160/' + img;
  i.parentNode.href = 'http://www.cameranu.nl/upload/' + img;
}

function opVerlanglijstje(id) {
  ajaxWL = new asack;
  ajaxWL.AARead('/php/json_opVerlanglijstje.php?artikel_id=' + id, opVerlanglijstje2);
}

function opVerlanglijstje2() {
  if(ajaxWL.responseJSON.status=='OK') { 
    alert('Artikel aan verlanglijstje toegevoegd!');
  } else {
    alert(ajaxWL.responseJSON.msg);
  }
}
