var shopObj = {
  init : function(){
    if( sessionObj.loggedOn ) return;
    this.loggedOn  = getCookie('cookiesVar_loggedOn');
    this.loggedOut = getCookie('cookiesVar_loggedOut');
    this.debitorNo = getCookie('cookiesVar_debitorNo');
    this.SomeThing = getCookie('cookiesVar_SomeThing');
    if( this.debitorNo && ( this.now - this.loggedOut > 300000 ) ){
      document.location.href = "/logon.ms";
      return;
    }

    if( !isUndefined( document.login ) && isGuest ){
      if( this.debitorNo ){
        document.login.deb.value = this.debitorNo;
        document.login.rememberMe.checked = true;
      }
      if( this.SomeThing ){
        document.login.passwd.value = this.SomeThing;
        document.login.rememberMe.checked = true;
      }
      this.today = new Date();
      this.now = this.today.setTime( this.today.getTime() );
      if( this.debitorNo && this.SomeThing ){
        document.login.remembered.value = 1;
        if( !autoLogonDisabled && this.now - this.loggedOut > 300000 ) document.login.submit();
      }
    }
  },
  rememberMeCheck : function(obj){
    if( !obj.checked && confirm('Dear customer\n If you uncheck this box the automatic sign in will be disabled. Do you wish to coninue?') ){
      obj.checked=false;
      deleteCookie( 'cookiesVar_debitorNo', '/' , SERVER_NAME );
      deleteCookie( 'cookiesVar_SomeThing', '/' , SERVER_NAME );
      layout.hideRememberMe();
      return;
    }else{
      obj.checked=true;
    }
  },
  rememberMe : function(){
    this.debitorNo = getCookie( 'cookiesVar_debitorNo' );
    if( this.debitorNo ){
      document.out.rememberMe.checked=true;
    }else if($('#rememberMeHolder').length){
      layout.hideRememberMe();
      document.out.rememberMe.disabled=true;
    }
  },
  submitLogoutForm : function(obj){
    document.location.href= "/Debitor/log_out.ms" + ( document.out.rememberMe.checked ? "?rememberMe=1" : "" );
  },
  submitLoginForm : function(event,obj){
    if( event && event.keyCode == 13 && !empty( obj.form.passwd.value ) ){
      obj.form.submit();
      return false;
    }else if( empty( obj.form.passwd.value ) ){
      setFocus(obj);
      return true;
    }
  },
  backToFrontPage : function(){
    document.location.href = "/index.ms";
  },
  customerGuide : function( alternativeLocation ){
    this.allowedCustomers = [];

    //if( sessionObj.debitorNo.length < 6 ){
    if( in_array(sessionObj.debitorNo,this.allowedCustomers ) ){
      document.location.href = '/shop/search.ms?shopType=personnel';
    }else{
      document.location.href = alternativeLocation;
    }
  },
  setBackgroundImage : function(){
    $('#NAVIGATION_DIV').css({backgroundImage:"url('/graphics/fp/star.jpg')"});
    $('#menuPlaceHolder').css({backgroundImage:"url('/graphics/fp/star.jpg')"});
    $(document.body).css({backgroundImage:"url('/graphics/fp/star.jpg')"});
  },
  QuickShoppingSubmit:function(e){
    if(!isUndefined(e.keyCode) && isObject(e)){
      var key = e.keyCode;
      if(key==13){
        $("#QuickShoppingItemNumber").attr('value', parseInt($("#QuickShoppingItemNumber").attr('value')) );

        if( $("#QuickShoppingItemNumber").attr('value') == "NaN" ){
          $("#QuickShoppingItemNumber").attr('value','');
          return;
        }
        addToTrolley($("#QuickShoppingItemNumber").attr('value'),"QuickShoppingQuantity");
        $("#QuickShoppingItemNumber").focus();
        $("#QuickShoppingItemNumber").attr('value','');
        $("#QuickShoppingQuantity").attr('value',1);
        this.controlLocation();
      }
      return;
    }
  },
  controlLocation:function(){
    if( document.location.href.indexOf("trolley.ms") == -1 ) document.location.href = "/shop/trolley.ms";
  },
  showThumbnail:function(imagebanknr){
    var pic= new Image();
    pic.src="http://" + document.domain + "/img/142X142/" + imagebanknr + ".jpg";
    overlib("<img src='/img/142X142/" + imagebanknr + ".jpg' border=0>" , WIDTH, pic.width , HEIGHT, pic.height , BGCOLOR , '#A0CE67', FGCOLOR , '#A0CE67');
  },
  hideThumbnail:function(imagebanknr){
    nd();
  }
//end of Object
}
