/* Path for this file: /content/dam/nissan/codepack/nissan/components/pages/layout/mainlayout.js/jcr:content/renditions/original */
// these were pulled from main JS file into mainlayout.js
/*
jQuery(document).ready(function() {
    if(jQuery("#frameBg").size()>0){
        //jQuery("#frameBg").height(jQuery("#frameContent").height()+20);
    }
    jQuery("#frameContent").click(function(){
        //jQuery("#frameContent").html(jQuery("#frameContent").html()+"<br /><br />");
        //resizeMe(jQuery("#frameContent").height());
    });    
});
function resizeMe(hgt){
    if(jQuery("#frameBg").size()>0){
        jQuery("#frameBg").height(hgt+20);
        if(jQuery("#frameContent").height() + 50 > jQuery("#pageBg").height()){
            //jQuery("#pageBg").height(jQuery("#pageBg").height()+20);
        }
    }
}
*/

jQuery(document).ready(function() {
    if(jQuery.browser.msie && parseInt(jQuery.browser.version) === 6) jQuery('#frameBg + #frameContent').addClass('frameContentHasBg');
 
    if(jQuery("#frameContent").height() + 50 > jQuery("#pageBg").height()){         
            jQuery("#pageBg").css("margin-bottom","50px");
        }
    
});


jQuery(document).ready(function() { 

// This is included at the bottom of a tabSoa page in order to adjust the heights 
// of the tabSoaPageBgResize and tabSoaFrameBg to match the main page's variable frame height.
var h = 0;
var minPageHeight = 730;
var frameH = 0;
var pageH = 0;

// we must have a tabSoaFrameContent element to proceed
if (document.getElementById("tabSoaFrameContent")) {
  h = document.getElementById("tabSoaFrameContent").clientHeight;
  frameH = (h+10);

  // expand frame height if necessary
  // if current frame height < new frame height
    if(document.getElementById("tabSoaFrameBg").clientHeight < frameH) {
    document.getElementById("tabSoaFrameBg").style.height = frameH + "px";
  }
  
  // expand page height if necessary
  if (document.getElementById("tabSoaFrameBg")) {
    pageH = (document.getElementById("tabSoaFrameBg").clientHeight + 50);
    if (document.getElementById("tabSoaPageBgResize")) {
      
      // if the new page height is > min height AND current page height < new page height
      if ((pageH > minPageHeight) && (document.getElementById("tabSoaPageBgResize").clientHeight < pageH)) {
        document.getElementById("tabSoaPageBgResize").style.height = pageH + "px";
      }
    }
  }
}

});

