


$(document).ready(function() {
// equlizes the heightts of the divs so they ware the same dispite the content. 
var $write14= $('<div id="RecordNum4" ><ul><li>1</li><li>to</li><li>3</li><li>of</li><li></li></ul></div>');
var $Xli= $('<li class="RSB_li">  </li>');
var $Xli2= $('<li class="RSB_li">  </li>');

var $write13= $('<div id="RecordNum3" ><ul><li>1</li><li>to</li><li>3</li><li>of</li><li></li></ul></div>');
var $X3li= $('<li class="RSB_li">  </li>');
var $X3li2= $('<li class="RSB_li">  </li>');

var $write12= $('<div id="RecordNum2" ><ul><li>1</li><li>to</li><li>3</li><li>of</li><li></li></ul></div>');
var $X2li= $('<li class="RSB_li">  </li>');
var $X2li2= $('<li class="RSB_li">  </li>');

var $write11= $('<div id="RecordNum" ><ul><li>1</li><li>to</li><li>3</li><li>of</li><li></li></ul></div>');
var $X1li= $('<li class="RSB_li">  </li>');
var $X1li2= $('<li class="RSB_li">  </li>');


// this gets the heights of the image ellmet fomr the first Image in and sets the heigt of the sournding div to be that height.  - because they are all suposd to be the same height
  // there is no need to get the others. 
//$(window).load(function() { 
  var RN1H=($('#RN1 >a >img').height());
//   alert('RN1H is '+RN1H);
        $('.RNImageSlides').height(RN1H);	
  
//});

// $("#signin a.pub_list").css('font-size','30px');


	$("#signin a.pub_list").fancybox({
			'hideOnContentClick': false, 
			'frameWidth':475,
			'frameHeight':300
			}); 	

// this wraps the first left navagation div with the correct wrapper no matter what cartridge is placed there
$("#Left_nav h2:first").wrap('<div id="firstH2" />');


// this starts the first set of checks for the recordscrool banner and setes the modulious


// this initiates the RotatingBanner Cartridge 
$('#slideshow').after('<div id="SliderNav" />').cycle({
	 fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	 random: 1,
	 speed: 4000,
	 pause: 1, 
         pager: '#SliderNav'
	});



// Start the block that drives the 4th record scrool banner 

// start the intal counts and set the varables for 
//var n_rsb4 = $("#mycarousel4 >li").size(); // Counts number of first child div in c1
var blockCount4 =(1);
// alert('blockCount is  '+blockCount4);
var ct4mod = $('#mycarousel4').children().size(); 

//alert('ct4mod is '+ct4mod);


if (ct4mod< 4){
//	alert('ct is less than 4');
	//var ct4a= (ct4 - 2)
//	 $('#RecordNum4 ul li').last().append(ct4mod);
	 
}else{

var mod4 =(ct4mod % 3);

switch (mod4)
{
case 0:
	  	  //	  	 do nothing 
  break;
case 1:// this writes 2 items to the ul to balance out the blocks in to groups of three 
//   	  alert('mod1 is '+ mod4);
 	  	 $('#mycarousel4 li').last().after($Xli);
	  	 $('#mycarousel4 li').last().after($Xli2);
	  	 var mod4Add =(2);
  break;
case 2: // this wirtes 1 item to the ul to balance out the blocks in to groups of three
//	alert('mod1 is '+ mod4);
	  	 $('#mycarousel4 li').last().after($Xli);
	  	 var mod4Add =(1);	
  break;  
default:// we dont know what this is 

}
};
// this calls the carrosell 

$('#mycarousel4').jcarousel({
        // Configuration goes here
});

//This writes the navagtion to the code
$('#RecordScrollBanner4 >div >div >div').before($write14);


// starts the second record scrool banner call r of first child div in c1
var ct4 = $('#mycarousel4').children().size(); 
var blocks4 =(ct4/3);
//alert('blocks4 is  '+blocks4);

if (ct4 > 3){
	var count4 = (3);

	//var ct4a= (ct4 - 2)
	 $('#RecordNum4 ul li').last().append(ct4mod);
	 
}else{ // if the record number is 2 then do this 

	switch(ct4)
		{
		case 1:
			$('#RecordScrollBanner4 >div').css('padding-left','214px');
			$('#RecordScrollBanner4 >div >div').css('width','300px');
		  break;
		case 2:
			$('#RecordScrollBanner4 >div').css('padding-left','135px');
			$('#RecordScrollBanner4 >div >div').css('width','300px'); 
		   break;
		default:

		}
	$('#RecordNum4').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner4 #rsbPrev').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner4 #rsbNext').css('position','absolute').css('left','-2000px');
};
	
	// increments the numbers up //
$('#RecordScrollBanner4 #rsbNext').click(function(){
			var count4 = parseFloat( $('#RecordNum4 ul li').first().html());
			var lastnum4 = parseFloat( $('#RecordNum4 ul li:nth-child(3)').html());
			
			blockCount4 ++; // incrments block count by 1 with every click
			
if (blockCount4 == blocks4){
// set max 1 to be 1 
var max4 =(1);

};

if (lastnum4 >= ct4){
// do nothing and set it so the switch is doing nothing  
var max4 =(0);
};
	
	switch(max4)
		{
	case 0:
	 break;
 	case 1:
			var count4d =(count4+3);
			
			$('#RecordNum4 ul li').first().replaceWith('<li></li>');
			$('#RecordNum4 ul li').first().append(count4d);

//			var count4d = parseFloat( $('#RecordNum4 ul li:nth-child(3)').html());
//			var count5d =(count4d+3);		

			$('#RecordNum4 ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum4 ul li:nth-child(3)').append(ct4mod);

		break;
     default:
			var count4d =(count4+3);

			$('#RecordNum4 ul li').first().replaceWith('<li></li>');
			$('#RecordNum4 ul li').first().append(count4d);

			var count4d = parseFloat( $('#RecordNum4 ul li:nth-child(3)').html());
			var count5d =(count4d+3);		

			$('#RecordNum4 ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum4 ul li:nth-child(3)').append(count5d);
		}
    
});

// incraements the numbers down //
$('#RecordScrollBanner4 #rsbPrev').click(function(){
// this resetes the call gloabal since the functions are not click independent. 			
if (blockCount4 == blocks4){
//  if these two gloabals are eq then we need max4 to be one for the switch  
var max4 =(1);
};

var countDownd = parseFloat( $('#RecordNum4 ul li').first().html());
	blockCount4 --; // incrments the block count down by 1 with every click
	
		if (blockCount4 == 0){
			// do nothing checks to make sure you dont get numbers going down in after you hit 0 
			var max4 =(0);
		};	
		
		
if (countDownd == 1){
var max4 =(0);
}else{
	
switch(max4)
		{
	case 0:
	break;
		
	case 1:	
		var count4d =(countDownd-3);

		$('#RecordNum4 ul li').first().replaceWith('<li></li>');
		$('#RecordNum4 ul li').first().append(count4d);
		
//		var countDown2d = parseFloat( $('#RecordNum4 ul li:nth-child(3)').html());
		
		var count5d =(ct4-3);		
		// replace the third number with the correct inncrment down in the loop
		$('#RecordNum4 ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum4 ul li:nth-child(3)').append(count5d);
			
	break;
	default:
		var count4d =(countDownd-3);
		
		$('#RecordNum4 ul li').first().replaceWith('<li></li>');
		$('#RecordNum4 ul li').first().append(count4d);
		
		var countDown2d = parseFloat( $('#RecordNum4 ul li:nth-child(3)').html());
		var count5d =(countDown2d-3);		
		
		$('#RecordNum4 ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum4 ul li:nth-child(3)').append(count5d);
					
		}
};

});

// end the block that drives the 4th reccord scrool banner 

// Start the block that drives the 3rd record scrool banner 

// start the intal counts and set the varables for 
//var n_rsb4 = $("#mycarousel4 >li").size(); // Counts number of first child div in c1
var blockCount3 =(1);
// alert('blockCount is  '+blockCount3);
var ct3mod = $('#mycarousel3').children().size(); 

//alert('ct3mod is '+ct3mod);


if (ct3mod< 4){
//	alert('ct is less than 4');
	//var ct4a= (ct4 - 2)
//	 $('#RecordNum3 ul li').last().append(ct3mod);
	 
}else{

var mod3 =(ct3mod % 3);

switch (mod3)
{
case 0:
	  	  //	  	 do nothing 
  break;
case 1:// this writes 2 items to the ul to balance out the blocks in to groups of three 
//   	  alert('mod1 is '+ mod3);
 	  	 $('#mycarousel3 li').last().after($X3li);
	  	 $('#mycarousel3 li').last().after($X3li2);
	  	 var mod3Add =(2);
  break;
case 2: // this wirtes 1 item to the ul to balance out the blocks in to groups of three
//	alert('mod1 is '+ mod3);
	  	 $('#mycarousel3 li').last().after($X3li);
	  	 var mod3Add =(1);	
  break;  
default:// we dont know what this is 

}
};
// this calls the carrosell 

$('#mycarousel3').jcarousel({
        // Configuration goes here
});

//This writes the navagtion to the code
$('#RecordScrollBanner3 >div >div >div').before($write13);


// starts the second record scrool banner call r of first child div in c1
var ct3 = $('#mycarousel3').children().size(); 
var blocks3 =(ct3/3);
//alert('blocks3 is  '+blocks3);

if (ct3 > 3){
	var count3 = (3);

	//var ct4a= (ct4 - 2)
	 $('#RecordNum3 ul li').last().append(ct3mod);
	 
}else{ // if the record number is 2 then do this 

	switch(ct3)
		{
		case 1:
			$('#RecordScrollBanner3 >div').css('padding-left','214px');
			$('#RecordScrollBanner3 >div >div').css('width','300px');
		  break;
		case 2:
			$('#RecordScrollBanner3 >div').css('padding-left','135px');
			$('#RecordScrollBanner3 >div >div').css('width','300px'); 
		   break;
		default:

		}
	$('#RecordNum3').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner3 #rsbPrev').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner3 #rsbNext').css('position','absolute').css('left','-2000px');
};
	
	// increments the numbers up //
$('#RecordScrollBanner3 #rsbNext').click(function(){
			var count3 = parseFloat( $('#RecordNum3 ul li').first().html());
			var lastnum3 = parseFloat( $('#RecordNum3 ul li:nth-child(3)').html());
			
			blockCount3 ++; // incrments block count by 1 with every click
			
if (blockCount3 == blocks3){
// set max 1 to be 1 
var max3 =(1);

};

if (lastnum3 >= ct3){
// do nothing and set it so the switch is doing nothing  
var max3 =(0);
};
	
	switch(max3)
		{
	case 0:
	 break;
 	case 1:
			var count4c =(count3+3);
			
			$('#RecordNum3 ul li').first().replaceWith('<li></li>');
			$('#RecordNum3 ul li').first().append(count4c);

//			var count3c = parseFloat( $('#RecordNum3 ul li:nth-child(3)').html());
//			var count5c =(count3c+3);		

			$('#RecordNum3 ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum3 ul li:nth-child(3)').append(ct3mod);

		break;
     default:
			var count4c =(count3+3);

			$('#RecordNum3 ul li').first().replaceWith('<li></li>');
			$('#RecordNum3 ul li').first().append(count4c);

			var count3c = parseFloat( $('#RecordNum3 ul li:nth-child(3)').html());
			var count5c =(count3c+3);		

			$('#RecordNum3 ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum3 ul li:nth-child(3)').append(count5c);
		}
    
});

// incraements the numbers down //
$('#RecordScrollBanner3 #rsbPrev').click(function(){
// this resetes the call gloabal since the functions are not click independent. 			
if (blockCount3 == blocks3){
//  if these two gloabals are eq then we need max3 to be one for the switch  
var max3 =(1);
};

var countDownc = parseFloat( $('#RecordNum3 ul li').first().html());
	blockCount3 --; // incrments the block count down by 1 with every click
	
		if (blockCount3 == 0){
			// do nothing checks to make sure you dont get numbers going down in after you hit 0 
			var max3 =(0);
		};	
		
		
if (countDownc == 1){
var max3 =(0);
}else{
	
switch(max3)
		{
	case 0:
	break;
		
	case 1:	
		var count4c =(countDownc-3);

		$('#RecordNum3 ul li').first().replaceWith('<li></li>');
		$('#RecordNum3 ul li').first().append(count4c);
		
//		var countDown2c = parseFloat( $('#RecordNum3 ul li:nth-child(3)').html());
		
		var count5c =(ct3-3);		
		// replace the third number with the correct inncrment down in the loop
		$('#RecordNum3 ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum3 ul li:nth-child(3)').append(count5c);
			
	break;
	default:
		var count4c =(countDownc-3);
		
		$('#RecordNum3 ul li').first().replaceWith('<li></li>');
		$('#RecordNum3 ul li').first().append(count4c);
		
		var countDown2c = parseFloat( $('#RecordNum3 ul li:nth-child(3)').html());
		var count5c =(countDown2c-3);		
		
		$('#RecordNum3 ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum3 ul li:nth-child(3)').append(count5c);
					
		}
};

});

// end the block that drives the 3rd reccord scrool banner 

// Start the block that drives the 2nd record scrool banner 

// start the intal counts and set the varables for 
//var n_rsb4 = $("#mycarousel4 >li").size(); // Counts number of first child div in c1
var blockCount2 =(1);
// alert('blockCount is  '+blockCount2);
var ct2mod = $('#mycarousel2').children().size(); 

//alert('ct2mod is '+ct2mod);


if (ct2mod< 4){
//	alert('ct is less than 4');
	//var ct4a= (ct4 - 2)
//	 $('#RecordNum2 ul li').last().append(ct2mod);
	 
}else{

var mod2 =(ct2mod % 3);

switch (mod2)
{
case 0:
  // var zeroItm =(0);
//	  	  alert('mod1 is '+ mod2);
//	  	  alert( 'there is an even block of li in RSB 1');
	  	  //	  	 do nothing 
  break;
case 1:// this writes 2 items to the ul to balance out the blocks in to groups of three 
//   	  alert('mod1 is '+ mod2);
 	  	 $('#mycarousel2 li').last().after($X2li);
	  	 $('#mycarousel2 li').last().after($X2li2);
	  	 var mod2Add =(2);
  break;
case 2: // this wirtes 1 item to the ul to balance out the blocks in to groups of three
//	alert('mod1 is '+ mod2);
	  	 $('#mycarousel2 li').last().after($X2li);
	  	 var mod2Add =(1);	
  break;  
default:// we dont know what this is 

}
};
// this calls the carrosell 

$('#mycarousel2').jcarousel({
        // Configuration goes here
});

//This writes the navagtion to the code
$('#RecordScrollBanner2 >div >div >div').before($write12);


// starts the second record scrool banner call r of first child div in c1
var ct2 = $('#mycarousel2').children().size(); 
var blocks2 =(ct2/3);
//alert('blocks2 is  '+blocks2);

if (ct2 > 3){
	var count2 = (3);
//	alert('first if stament');
	//var ct4a= (ct4 - 2)
	 $('#RecordNum2 ul li').last().append(ct2mod);
	 
}else{ // if the record number is 2 then do this 
//	alert('enting the switch ' +ct2);
	switch(ct2)
		{
		case 1:
			$('#RecordScrollBanner2 >div').css('padding-left','214px');
			$('#RecordScrollBanner2 >div >div').css('width','300px');
		  break;
		case 2:
			$('#RecordScrollBanner2 >div').css('padding-left','135px');
			$('#RecordScrollBanner2 >div >div').css('width','300px'); 
		   break;
		default:

		}
	$('#RecordNum2').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner2 #rsbPrev').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner2 #rsbNext').css('position','absolute').css('left','-2000px');
};
	
	// increments the numbers up //
$('#RecordScrollBanner2 #rsbNext').click(function(){
			var count2 = parseFloat( $('#RecordNum2 ul li').first().html());
			var lastnum2 = parseFloat( $('#RecordNum2 ul li:nth-child(3)').html());
			
			blockCount2 ++; // incrments block count by 1 with every click
			
if (blockCount2 == blocks2){
// set max 1 to be 1 
var max2 =(1);

};

if (lastnum2 >= ct2){
// do nothing and set it so the switch is doing nothing  
var max2 =(0);
};
	
	switch(max2)
		{
	case 0:
	 break;
 	case 1:
			var count4b =(count2+3);
			
			$('#RecordNum2 ul li').first().replaceWith('<li></li>');
			$('#RecordNum2 ul li').first().append(count4b);

//			var count3b = parseFloat( $('#RecordNum2 ul li:nth-child(3)').html());
//			var count5b =(count3b+3);		

			$('#RecordNum2 ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum2 ul li:nth-child(3)').append(ct2mod);

		break;
     default:
			var count4b =(count2+3);

			$('#RecordNum2 ul li').first().replaceWith('<li></li>');
			$('#RecordNum2 ul li').first().append(count4b);

			var count3b = parseFloat( $('#RecordNum2 ul li:nth-child(3)').html());
			var count5b =(count3b+3);		

			$('#RecordNum2 ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum2 ul li:nth-child(3)').append(count5b);
		}
    
});

// incraements the numbers down //
$('#RecordScrollBanner2 #rsbPrev').click(function(){
// this resetes the call gloabal since the functions are not click independent. 			
if (blockCount2 == blocks2){
//  if these two gloabals are eq then we need max2 to be one for the switch  
var max2 =(1);
};

var countDownb = parseFloat( $('#RecordNum2 ul li').first().html());
	blockCount2 --; // incrments the block count down by 1 with every click
	
		if (blockCount2 == 0){
			// do nothing checks to make sure you dont get numbers going down in after you hit 0 
			var max2 =(0);
		};	
		
		
if (countDownb == 1){
var max2 =(0);
}else{
	
switch(max2)
		{
	case 0:
	break;
		
	case 1:	
		var count4b =(countDownb-3);

		$('#RecordNum2 ul li').first().replaceWith('<li></li>');
		$('#RecordNum2 ul li').first().append(count4b);
		
//		var countDown2b = parseFloat( $('#RecordNum2 ul li:nth-child(3)').html());
		
		var count5b =(ct2-3);		
		// replace the third number with the correct inncrment down in the loop
		$('#RecordNum2 ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum2 ul li:nth-child(3)').append(count5b);
			
	break;
	default:
		var count4b =(countDownb-3);
		
		$('#RecordNum2 ul li').first().replaceWith('<li></li>');
		$('#RecordNum2 ul li').first().append(count4b);
		
		var countDown2b = parseFloat( $('#RecordNum2 ul li:nth-child(3)').html());
		var count5b =(countDown2b-3);		
		
		$('#RecordNum2 ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum2 ul li:nth-child(3)').append(count5b);
					
		}
};

});

// end the block that drives the 2nd reccord scrool banner 

// Start the block that drives the 1st record scrool banner 

// start the intal counts and set the varables for 
//var n_rsb4 = $("#mycarousel4 >li").size(); // Counts number of first child div in c1
var blockCount1 =(1);
// alert('blockCount is  '+blockCount1);
var ct1mod = $('#mycarousel1').children().size(); 

//alert('ct1mod is '+ct1mod);


if (ct1mod< 4){
//	alert('ct is less than 4');
	//var ct4a= (ct4 - 2)
//	 $('#RecordNum ul li').last().append(ct1mod);
	 
}else{

var mod1 =(ct1mod % 3);

switch (mod1)
{
case 0:
  // var zeroItm =(0);
//	  	  alert('mod1 is '+ mod1);
//	  	  alert( 'there is an even block of li in RSB 1');
	  	  //	  	 do nothing 
  break;
case 1:// this writes 2 items to the ul to balance out the blocks in to groups of three 
//   	  alert('mod1 is '+ mod1);
 	  	 $('#mycarousel1 li').last().after($X1li);
	  	 $('#mycarousel1 li').last().after($X1li2);
	  	 var modAdd =(2);
  break;
case 2: // this wirtes 1 item to the ul to balance out the blocks in to groups of three
//	alert('mod1 is '+ mod1);
	  	 $('#mycarousel1 li').last().after($X1li);
	  	 var modAdd =(1);	
  break;  
default:// we dont know what this is 

}
};
// this calls the carrosell 

$('#mycarousel1').jcarousel({
        // Configuration goes here
});

//This writes the navagtion to the code
$('#RecordScrollBanner1 >div >div >div').before($write11);


// starts the second record scrool banner call r of first child div in c1
var ct1 = $('#mycarousel1').children().size(); 
var blocks1 =(ct1/3);
//alert('blocks1 is  '+blocks1);

if (ct1 > 3){
	var count1 = (3);
//	alert('first if stament');
	//var ct4a= (ct4 - 2)
	 $('#RecordNum ul li').last().append(ct1mod);
	 
}else{ // if the record number is 2 then do this 
//	alert('enting the switch ' +ct1);
	switch(ct1)
		{
		case 1:
			$('#RecordScrollBanner1 >div').css('padding-left','214px');
			$('#RecordScrollBanner1 >div >div').css('width','300px');
		  break;
		case 2:
			$('#RecordScrollBanner1 >div').css('padding-left','135px');
			$('#RecordScrollBanner1 >div >div').css('width','300px'); 
		   break;
		default:
//		 
		}
	$('#RecordNum').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner1 #rsbPrev').css('position','absolute').css('left','-2000px');
	$('#RecordScrollBanner1 #rsbNext').css('position','absolute').css('left','-2000px');
};
	
	// increments the numbers up //
$('#RecordScrollBanner1 #rsbNext').click(function(){
			var count1 = parseFloat( $('#RecordNum ul li').first().html());
			var lastnum1 = parseFloat( $('#RecordNum ul li:nth-child(3)').html());
			
			blockCount1 ++; // incrments block count by 1 with every click
			
if (blockCount1 == blocks1){
// set max 1 to be 1 
var max1 =(1);

};

if (lastnum1 >= ct1){
// do nothing and set it so the switch is doing nothing  
var max1 =(0);
};
	
	switch(max1)
		{
	case 0:
	 break;
 	case 1:
			var count4a =(count1+3);
			
			$('#RecordNum ul li').first().replaceWith('<li></li>');
			$('#RecordNum ul li').first().append(count4a);

//			var count3a = parseFloat( $('#RecordNum ul li:nth-child(3)').html());
//			var count5a =(count3a+3);		

			$('#RecordNum ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum ul li:nth-child(3)').append(ct1mod);

		break;
     default:
			var count4a =(count1+3);

			$('#RecordNum ul li').first().replaceWith('<li></li>');
			$('#RecordNum ul li').first().append(count4a);

			var count3a = parseFloat( $('#RecordNum ul li:nth-child(3)').html());
			var count5a =(count3a+3);		

			$('#RecordNum ul li:nth-child(3)').replaceWith('<li></li>');
			$('#RecordNum ul li:nth-child(3)').append(count5a);
		}
    
});

// incraements the numbers down //
$('#RecordScrollBanner1 #rsbPrev').click(function(){
// this resetes the call gloabal since the functions are not click independent. 			
if (blockCount1 == blocks1){
//  if these two gloabals are eq then we need max1 to be one for the switch  
var max1 =(1);
};

var countDowna = parseFloat( $('#RecordNum ul li').first().html());
	blockCount1 --; // incrments the block count down by 1 with every click
	
		if (blockCount1 == 0){
			// do nothing checks to make sure you dont get numbers going down in after you hit 0 
			var max1 =(0);
		};	
		
		
if (countDowna == 1){
var max1 =(0);
}else{
	
switch(max1)
		{
	case 0:
	break;
		
	case 1:	
		var count4a =(countDowna-3);

		$('#RecordNum ul li').first().replaceWith('<li></li>');
		$('#RecordNum ul li').first().append(count4a);
		
//		var countDown2a = parseFloat( $('#RecordNum ul li:nth-child(3)').html());
		
		var count5a =(ct1-3);		
		// replace the third number with the correct inncrment down in the loop
		$('#RecordNum ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum ul li:nth-child(3)').append(count5a);
			
	break;
	default:
		var count4a =(countDowna-3);
		
		$('#RecordNum ul li').first().replaceWith('<li></li>');
		$('#RecordNum ul li').first().append(count4a);
		
		var countDown2a = parseFloat( $('#RecordNum ul li:nth-child(3)').html());
		var count5a =(countDown2a-3);		
		
		$('#RecordNum ul li:nth-child(3)').replaceWith('<li></li>');
		$('#RecordNum ul li:nth-child(3)').append(count5a);
					
		}
};

});

// end the block that drives the 1st reccord scrool banner 

// this controols the specif focus for each of teh potetial adds


//	$('#f1 a').focus(function(){ this needs to be replaced when the link is placed back in to the image 
	$('#f1 a').focus(function(){
			$('#slideshow').cycle(0); 
			return false; 
    });
    		
    	$('#f2 a').focus(function(){
			$('#slideshow').cycle(1); 
			return false; 
    });
    	
    	$('#f3 a').focus(function(){
			$('#slideshow').cycle(2); 
			return false; 
    });
    	
    	$('#f4 a').focus(function(){
			$('#slideshow').cycle(3); 
			return false; 
    });
    	$('#f5 a').focus(function(){
			$('#slideshow').cycle(4); 
			return false; 
    });
    	$('#f6 a').focus(function(){
			$('#slideshow').cycle(5); 
			return false; 
});
 
 	$('#f7 a').focus(function(){
			$('#slideshow').cycle(6); 
			return false; 
    });

    
  // this gets the heights of the image ellmet fomr the first Image in and sets the heigt of the sournding div to be that height.  - because they are all suposd to be the same height
  // there is no need to get the others. 

 // var RN1H=($('#RN1 >a >img').height());
//   alert('RN1H is '+RN1H);
   //     $('.RNImageSlides').height(RN1H);	
	
        
  // fixes the hard coded image height in the search cartidge    
$('#rightTopAdCar >a >img').height(188);	
      
    	
// this initiates the RotatingImage Cartidge in the right Nav - has no navagtion under it. 

$('.RNImageSlides').cycle({
	 fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	 random: 1,
	 speed: 4000,
	 pause: 1 
      
	});

// sets the focus for tab ontrool - has no aria 

$('#RN1 a').focus(function(){
			$('#RNImageSlides').cycle(0); 
			return false; 
    });

$('#RN2 a').focus(function(){
			$('#RNImageSlides').cycle(0); 
			return false; 
    });

$('#RN3 a').focus(function(){
			$('#RNImageSlides').cycle(0); 
			return false; 
    });



// these set the links to report to Sprops in the Omniture code
		
$("#rightTopAdCar a").click(function(){
			var ObId = $(this).get(0).id;
	
			s=s_gi('cengagesearch');
			s.linkTrackVars='prop2,prop4,eVar4,events'; 
			s.linkTrackEvents='event4';
			s.prop4=ObId;
			s.eVar4=ObId;
			s.events='event4';
			s.tl(this,'o','ObId');
		});

$(".Rnav_content a").click(function(){
			var ObId = $(this).get(0).id;
			s=s_gi('cengagesearch');
			s.linkTrackVars='prop2,prop4,eVar4,events'; 
			s.linkTrackEvents='event4';
			s.prop4=ObId;
			s.eVar4=ObId;
			s.events='event4';
			s.tl(this,'o','ObId');
	
	});
	
	$(".Rnav_content_html a").click(function(){
			var ObId = $(this).get(0).id;
			s=s_gi('cengagesearch');
			s.linkTrackVars='prop2,prop4,eVar4,events'; 
			s.linkTrackEvents='event4';
			s.prop4=ObId;
			s.eVar4=ObId;
			s.events='event4';
			s.tl(this,'o','ObId');
	
	});
	
// this one set the search box inthe middel still needs to capture the value of the submit and pass that to an sprop.
	$("#submit_search_learning_products_button").click(function(){
			
			var ObId = $(this).get(0).id;	
//			alert(ObId);
			s=s_gi('cengagesearch');
			s.linkTrackVars='prop2,prop4,eVar4,events'; 
			s.linkTrackEvents='event4';
			s.prop4=ObId;
			s.eVar4=ObId;
			s.events='event4';
			s.tl(this,'o','ObId');
	
	});
	
	
	
	$('#FooterWrap').wrap('<div id="footer" />');
	// fixes the missing footer div in the code

	
	
//RSS feeds appears that we can move these intot the functions - 
// test on all browsers before comitting possable issue with code not beeing used causing the JS to brake code not eeing uses causs this to brake for example, if there are three rss in top and 3 in the narrow . if only two are used intop all thre below brake. can be verrified by reversing the code.  
	$('#rssFeed1').rssfeed(rssFeed_1, {
    limit: rssFeed_1_limit
  });	
	$('#rssFeed2').rssfeed(rssFeed_2, {
    limit: rssFeed_2_limit
  });
	$('#rssFeed3').rssfeed(rssFeed_3, {
    limit: rssFeed_3_limit
  });
	$('#rssFeed4').rssfeed(rssFeed_4, {
    limit: rssFeed_4_limit
  });
 	$('#rssFeed5').rssfeed(rssFeed_5, {
    limit: rssFeed_5_limit
  });	
  	
  	 
//	/*form submit behavior*/
	$("#submit_search_learning_products_button").click(function(){
			var n = validateISBN2($('#search_all').val());
			if (n[0]==true){$('#search_all').val(n[1]);}
	});

	$("#search_all").keyup(function(event){
		  if(event.keyCode == 13){
		    $("#submit_search_learning_products_button").click();
		  }
		});
	

});
// end document.ready 

// functions from the java script files 
//this is the search results page code for the submit form   
function submitRefineSearchForm(url,formObject) {
	//debugger;
	 var form = formObject;
	 
	 var nttparam =getUrlParam(url,"Ntt");
	 var ntkparam = getUrlParam(url,"Ntk");
	 cleanupUrl(form);
	var isbn = form.newSearchTerm.value;
	var n = validateISBN2(isbn);
	if (n[0]==true){
	  form.newSearchTerm.value = n[1];
	}
	
	if(nttparam!="" && form.newSearchTerm.value!="" && form.newSearchTerm.value!=null){
	   nttparam = nttparam +"||" + form.newSearchTerm.value;
	   url = replaceUrlParam(url,"Ntt",nttparam);
	   
	   if(ntkparam!="" && ntkparam!=null){
	   	ntkvalue = ntkparam.split('||'); 
	   	ntkparam = ntkvalue[0] +"||" + ntkparam;
	   	url = replaceUrlParam(url,"Ntk",ntkparam);
	   	}
	   }
	 if(nttparam == "" && form.newSearchTerm.value!="" && form.newSearchTerm.value!=null){ 
	        url = url +"&Ntt="+ form.newSearchTerm.value;
	 }
	 if(ntkparam == "" || ntkparam ==null){ 
	        url = url +"&Ntk=all";
	 }
	//var pageSize= form.maxRecordsPerPage.value;
	form.action=form.action+"?"+url;
	form.submit();
	/*}*/
}

function submitRefineSearchSAndTForm(url) {
	var form= document.getElementsByName('globalSearchForm')[0];
	cleanupUrl(form);
	var isbn = form.newSearchTerm.value;
	var n = validateISBN2(isbn);
	if (n[0]==true){
	  form.newSearchTerm.value = n[1];
	}
	//var pageSize= form.maxRecordsPerPage.value;
	form.action=form.action+"?urlQueryString="+escape(url);

	form.submit();
}


function getUrlParam(url,name)
{
  //var url = "&pageSize=10&N=+16&Ntt=test||micro&Ntk=all||all";
  if(url.substr(0,1)!="&") url="&"+url;
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec(url);
  if( results == null )
   	return "";
  else
    return results[1];	
}


function replaceUrlParam(url,name, newValue){
  var replacedUrl='';
  //var url = "pageSize=10&N=+16&Ntt=test||micro&Ntk=all||all";
  var pairs = url.split('&');
   for(var i=0;i<pairs.length;i++){
         var nameVal = pairs[i].split('=');
		//alert(nameVal[0]+"*****"+nameVal[1]);

         if(nameVal[0] == name){
		    if(replacedUrl!='' && replacedUrl!="undefined"){
		 	replacedUrl = replacedUrl +"&"+ nameVal[0]+"="+newValue;
	     	}	
	     	else{
			replacedUrl = nameVal[0]+"="+newValue;                 
		    }	
	    }else{
            if(replacedUrl!='' && replacedUrl!="undefined"){
				replacedUrl = replacedUrl +"&"+ pairs[i];	
	    	}else{
				replacedUrl = pairs[i];	
	    	}			
	   }
   } 
return replacedUrl;
}



function submitRFByType(url,formObject,event)
{
	if((event.keyCode==13))
	{
		submitRefineSearchForm(url,formObject);
	}
}

function submitBrowseFilterForm(url,formObject)
{
  for(var i=0;i<formObject.length;i++)
  {
  	if(formObject.elements[i].type == "checkbox")
  	{
  		if(formObject.elements[i].checked)
  		{ 	
  				url=url+"+"+formObject.elements[i].value;  					
  		} 
  	}  
  }
 
 //var pageSize= formObject.maxRecordsPerPage.value;
 formObject.action=formObject.action+"?"+url;
 formObject.submit();
}

// Page drop down code from Search results page 

function submitSearchByPageSize(pageDropdown)
{
	var url=null;
	var form= document.getElementsByName('globalSearchForm')[0];
	form.maxRecordsPerPage.value = pageDropdown.options[pageDropdown.selectedIndex].value;
	var urlQueryString = getQueryString();
	submitSearchStatusForm(urlQueryString,null); 
}


function getQueryString()
{
    var search = unescape(location.search);
    search = search.substr(1);
    return search;
}

function submitGlobalSearchForm(suggestedTerm)
{
			var form= document.getElementsByName('globalSearchForm')[0];
			// cleanupUrl(form);
			form.globalSearchTerm.value = suggestedTerm;
			form.submit();
			return false;
}

function submitServiceTrainingForm()
{
	var form= document.getElementsByName('serviceTrainingForm')[0];
	cleanupUrl(form);	
	var url='N=+16+4294922239';
	//var pageSize= form.maxRecordsPerPage.value;
	form.action=form.action+"?"+url;
	form.submit();
	return false;
}

function cleanupUrl(form){

		var actionUrl = form.action;
		if( actionUrl.indexOf('?') > -1){
			 actionUrl=actionUrl.substr(0,actionUrl.indexOf('?'));
		}  
		form.action=actionUrl

	}
	
	
		function submitBreadCrumbForm(url)
		{
			var form= document.getElementsByName('breadCrumbForm')[0];
			//var pageSize= form.maxRecordsPerPage.value;
			form.action=form.action+"?"+url;
			form.submit();
		}
		function submitSearchStatusForm(url,activityFlag)
		{
			var form= document.getElementsByName('globalSearchForm')[0];
			//var pageSize= form.maxRecordsPerPage.value;
			form.action=form.action+"?"+url;
			form.submit();
		}	

