$(document).ready(function(){
	myInit();
});

function myInit() {
  var padTop = (jQuery('#mainrightbox').height() - jQuery('#mainrightinner').height()) / 2;
  if (padTop > 0) {
    jQuery('#mainrightinnerwrap').css('padding-top',padTop + 'px');
  } else {
    jQuery('#mainrightinner').addClass('scroll-pane');
    jQuery('.scroll-pane').jScrollPane({scrollbarWidth:34, scrollbarMargin:0, dragMinHeight:21, dragMaxHeight:21});
  }
}

function contentloader($cat ,$off) {
  if ($off==null) {
	  $off=0;
  }
  jQuery('#mainleft').removeClass('bgimgleft');
  jQuery('#mainleft').load("products_aj.php",{l: 1,cat: $cat, off: $off});
  jQuery('#footer').load("footer_aj.php",{cat: $cat, off: $off});
  jQuery('#arrowleft').load("arrow_aj.php",{cat: $cat, off: $off, type: 's'});
  jQuery('#arrowright').load("arrow_aj.php",{cat: $cat, off: $off, type: 's', r: 'r'});
  jQuery('#mainrightinner').empty();
  jQuery('#mainrightinnerwrap').css('padding-top','0');
  jQuery('#mainrightinner').removeClass('scroll-pane');
  jQuery('#mainrightinner').jScrollPaneRemove();
  jQuery('#mainrightinner').load("products_aj.php",{r: 1,cat: $cat, off: $off},function(){myInit();});
}

function contentloader_mid($cat, $off, $prodId, $fromLarge) {
	  if ($off==null) {
		  $off=0;
	  }
	  jQuery('#mainleft').removeClass('bgimgleft');
	  jQuery('#mainleft').load("products_mid_aj.php",{l: 1,cat: $cat, off: $off, prodId: $prodId});
	  if ($fromLarge) {
		  jQuery('#arrowleft').load("arrow_aj.php",{cat: $cat, off: $off, type: 'm', prodId: $prodId});
		  jQuery('#arrowright').load("arrow_aj.php",{cat: $cat, off: $off, type: 'm', r: 'r', prodId: $prodId});
	  } else {
		  jQuery('#footer').load("footer_aj.php",{cat: $cat, off: $off});
		  jQuery('#arrowleft').load("arrow_aj.php",{cat: $cat, off: $off, type: 'm', prodId: $prodId});
		  jQuery('#arrowright').load("arrow_aj.php",{cat: $cat, off: $off, type: 'm', r: 'r', prodId: $prodId});
		  jQuery('#mainrightinner').empty();
		  jQuery('#mainrightinnerwrap').css('padding-top','0');
		  jQuery('#mainrightinner').removeClass('scroll-pane');
		  jQuery('#mainrightinner').jScrollPaneRemove();
		  jQuery('#mainrightinner').load("products_mid_aj.php",{r: 1,cat: $cat, off: $off, prodId: $prodId},function(){myInit();});
	  }
}

function contentloader_large($cat, $off, $prodId, $ind, $fromSmall) {
	  if ($off==null) {
		  $off=0;
	  }
	  jQuery('#mainleft').addClass('bgimgleft');
	  jQuery('#mainleft').load("products_large_aj.php",{l: 1,cat: $cat, off: $off, prodId: $prodId, ind: $ind, fromsmall: $fromSmall});
	  if ($fromSmall) {
		  jQuery('#footer').load("footer_aj.php",{cat: $cat, off: $off});
		  jQuery('#arrowleft').load("arrow_aj.php",{cat: $cat, off: $off, type: 'm', prodId: $prodId});
		  jQuery('#arrowright').load("arrow_aj.php",{cat: $cat, off: $off, type: 'm', r: 'r', prodId: $prodId});
		  jQuery('#mainrightinner').empty();
		  jQuery('#mainrightinnerwrap').css('padding-top','0');
		  jQuery('#mainrightinner').removeClass('scroll-pane');
		  jQuery('#mainrightinner').jScrollPaneRemove();
		  jQuery('#mainrightinner').load("products_large_aj.php",{r: 1,cat: $cat, off: $off, prodId: $prodId, ind: $ind},function(){myInit();});
	  } else {
		  jQuery('#arrowleft').load("arrow_aj.php",{cat: $cat, off: $off, type: 'l', prodId: $prodId});
		  jQuery('#arrowright').load("arrow_aj.php",{cat: $cat, off: $off, type: 'l', r: 'r', prodId: $prodId});
	  }
}

