var myHeight = 0;
var docHeight = 702;
var minTopMargin =20;
var longSpeed =1500;
var intervalSpeeds =6000;

function sizeMe() {

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    //myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    //myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    //myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  setTopMargin();
 // sizeViewingArea();
}


function setTopMargin(){
    //Math.round((mapHeight*1.779));
    if( myHeight > (docHeight + (minTopMargin*2))){
        var margin = Math.round(((myHeight - docHeight)/2)-2);
        $("#container").css({"margin-top":margin+'px','margin-bottom':margin+'px'});
    }else{
        $("#container").css({"margin-top":minTopMargin+'px','margin-bottom':minTopMargin+'px'});
    }


}

$(document).ready(function(){
sizeMe();
window.onresize=sizeMe;
    document.onresize=sizeMe;
$(".catalogue").live("click",function () {
    var target = baseURL+"home/index/"+$(this).attr("id").substring(11);
$('#menu').animate({
    left: '-224px'
  }, {
    duration: 500,
    specialEasing: {
      width: 'easeOutBounce'
    },
    complete: function() {
      window.location = target;
    }
  });
return false;
});


$(".vimeo").live("click",function () {
    var target = baseURL+"home/video/"+$(this).attr("id").substring(11);
$('#menu').animate({
    left: '-224px'
  }, {
    duration: 500,
    specialEasing: {
      width: 'easeOutBounce'
    },
    complete: function() {
      window.location = target;
    }
  });
return false;
});



$("#menuToggle").live("click",function () {

  if( $(this).hasClass("menuOpen") ){
      //close
      $(this).removeClass("menuOpen")
      $('#menu').animate({
            left: '-224px'
            }, {
            duration: 500,
            specialEasing: {
            width: 'easeOutBounce'
            },
            complete: function() {

            }
        });
  }else{
      //open
      $(this).addClass("menuOpen")
      $('#menu').animate({
            left: '0'
            }, {
            duration: 500,
            specialEasing: {
            width: 'easeOutBounce'
            },
            complete: function() {

            }
        });

   }
  

});


$(".menulinks").live("mouseover",function () {
        if(! $(this).hasClass("black")){
            $(this).css("color","#555555");
        }
});
$(".menulinks").live("mouseout",function () {
        if(! $(this).hasClass("black")){
            $(this).css("color","#7F7F7F");
        }

});



$(".menuMainLink").live("click",function () {
var target = baseURL+$(this).children().attr("href");

$('#menu').animate({
    left: '-224px'
  }, {
    duration: 500,
    specialEasing: {
      width: 'easeOutBounce'
    },
    complete: function() {
      window.location = target;
    }
  });
return false;

});

$(".prodThumb").live("click",function () {
    
    if( $(this).hasClass("locked") || $(this).hasClass("thumbActive") ){return false}
    
    $(".prodThumb").addClass("locked")

    var activeId = $(".thumbActive").attr("id").substring(10);
    var newActiveId = $(this).attr("id").substring(10);
    var time1 =750;
    var time2 =1500;
    if (activeId ==1 && newActiveId == 2){
        var marginTop = "-454px";
        var time = time1;
    }else
    if (activeId ==1 && newActiveId == 3){
        var marginTop = "-908px";
        var time = time2;
    }else
    if (activeId ==2 && newActiveId == 1){
        var marginTop = "0px";
        var time = time1;
    }else
    if (activeId ==2 && newActiveId == 3){
        var marginTop = "-908px";
        var time = time1;
    }else
    if (activeId ==3 && newActiveId == 1){
        var marginTop = "0px";
        var time = time2;
    }else
    if (activeId ==3 && newActiveId == 2){
        var marginTop = "-454px";
        var time = time1;
    }

    $(".prodThumb").removeClass("thumbActive");
    $(this).addClass("thumbActive");


$('#prodLgImageInnerContainer').animate({
    marginTop: marginTop
  }, {
    duration: time,
    
    complete: function() {
      $(".prodThumb").removeClass("locked")
    }
  });
return false;

});


$("#basketLogo,#checkoutLogo").live("mouseover",function () {
    $(this).css("background-position","0 -30px");

});
$("#basketLogo,#checkoutLogo").live("mouseout",function () {
    $(this).css("background-position","0 0");

});

$("#basketLogo").live("click",function () {
    window.location = "basket/";

});

$("#checkoutLogo").live("click",function () {
    window.location = "basket/checkout/";

});


$("#addToBasket").live("click",function () {


if ($('#onesizeQuantity').length == 0){
    var onesizeQ = 0;
}else{
    var onesizeQ=$('#onesizeQuantity').getSetSSValue();
}

if ($('#smallQuantity').length == 0){
    var smallQ = 0;
}else{
    var smallQ= $('#smallQuantity').getSetSSValue();
}

if ($('#mediumQuantity').length == 0){
    var mediumQ = 0;
}else{
    var mediumQ= $('#mediumQuantity').getSetSSValue();
}

if ($('#largeQuantity').length == 0){
    var largeQ = 0;
}else{
    var largeQ=$('#largeQuantity').getSetSSValue();
}


$.post("basket/addto/",
        { id: $("#productId").attr("value"),
          smallQ: smallQ,
          mediumQ: mediumQ,
          largeQ: largeQ,
          onesizeQ: onesizeQ
        },
          function(data){
             //alert(data);
             $("#subTotal").html(data);
          });
});



});


function resetPrev(){
$('#prev').animate({
            left: '-43'
            }, {
            duration: 250,
            specialEasing: {
              width: 'easeOutBounce'
            },
            complete: function() {
                $("#hidePrev, #showPrev").removeClass("prevActive").removeClass("prevOpen");
            }
         });
}

function resetNext(){
$('#next').animate({
                right: '-43'
                }, {
                duration: 250,
                specialEasing: {
                  width: 'easeOutBounce'
                },
                complete: function() {
                    $("#hideNext, #showNext").removeClass("nextActive").removeClass("nextOpen");
                }
         });
}

function resetTab(){
$('#tabs').animate({
                left: '-1024'
                }, {
                duration: 250,
                specialEasing: {
                  width: 'easeOutBounce'
                },
                complete: function() {
                    $("#tabToggle").removeClass("tabActive").removeClass("tabOpen");
                }
         });
}



function collection(){
    $("#container").animate({backgroundPosition: '981px 0px'}, {duration:2800, specialEasing: {width: 'easeOutBounce'}});

}