
//edited by Avnish
// ---  VARIABLES  ---
n2ColCurrentItem = 0; 
n2ColCurrentItem1 = 0;
// Holds the current LEFT most item on the carousel

// -----------------------
// FUNCTION: fWrite2ColTeasers
// DESCRIPTION: Write the teaser HTML into a div
// ARGUMENTS: sTeaserID - Div to write into; sLinkURL,sHdrSection,sImgURL,sImgAlt,sTitle,sTeaser
// RETURN: True
// -----------------------
function fWrite2ColTeasers(sTeaserID,sLinkURL,sHdrSection,sImgURL,sImgAlt,sTitle,sTitleLinkURL,sTeaser,sShowTeaserText,sShowSectionTitle) {

	var sHTML = '';
	if(sShowSectionTitle){
	sHTML += '<h3 class="section-heading"><a href="'+sLinkURL+'" class="link-333 padding-right-10">'+sHdrSection+'</a><span class="double-chevron-right">&nbsp;</span></h3>';
	}
	if(!sImgURL==""){
	sHTML += '<div class="float-left"><img src="'+sImgURL+'" width="165" height="70"  alt="'+sImgAlt+'" /></div>';
	}
	sHTML += '<div class="float-left padding-top-5">';
	sHTML += '<a class="reg-bold" href="'+sTitleLinkURL+'">'+sTitle+'</a>';
	sHTML += '<div class="clear-simple padding-top-3"></div>';
	if(sShowTeaserText){
	sHTML += '<p class="small">'+sTeaser+'</p>';
	}
	sHTML += '</div>';
	var sTeaserIDName = 'Carousel2Col'+sTeaserID;
	//Known error with IE
	try {
		document.getElementById(sTeaserIDName).innerHTML = sHTML;
	}
	catch(e) {
	}
}
function fWrite2ColTeasers1(sTeaserID,sLinkURL,sHdrSection,sImgURL,sImgAlt,sTitle,sTitleLinkURL,sTeaser,sShowTeaserText,sShowSectionTitle) {

	var sHTML = '';
	if(sShowSectionTitle){
	sHTML += '<h3 class="section-heading"><a href="'+sLinkURL+'" class="link-333 padding-right-10">'+sHdrSection+'</a><span class="double-chevron-right">&nbsp;</span></h3>';
	}
	if(!sImgURL==""){
	sHTML += '<div class="float-left"><img src="'+sImgURL+'" width="165" height="70"  alt="'+sImgAlt+'" /></div>';
	}
	sHTML += '<div class="float-left padding-top-5">';
	sHTML += '<a class="reg-bold" href="'+sTitleLinkURL+'">'+sTitle+'</a>';
	sHTML += '<div class="clear-simple padding-top-3"></div>';
	if(sShowTeaserText){
	sHTML += '<p class="small">'+sTeaser+'</p>';
	}
	sHTML += '</div>';
	var sTeaserIDName = 'Carousel2Coll'+sTeaserID;
	//Known error with IE
	try {
		document.getElementById(sTeaserIDName).innerHTML = sHTML;
	}
	catch(e) {
	}
}
// -----------------------
// FUNCTION: fMoveCarousel2Col
// DESCRIPTION: Moves the 2 Column Carousel one item at a time.
// ARGUMENTS: nDirection - 0 = backwards, 1 = forwards
// RETURN: True
// -----------------------
function fMoveCarousel2Col(nDirection,sShowTeaserText,sShowSectionTitle) {

	if(nDirection == 1) {
		// BEGIN: Forwards
		// Set current item to be the new current item
		if (n2ColCurrentItem == n2ColTotalCarouselItems-1) {
			n2ColCurrentItem=0;
		} else {
			n2ColCurrentItem++;
		}
		var i = n2ColCurrentItem; // allows us to loop through the items in the array and leave the current item correct
		//  Loop through changing div content
		for (var x = 1; x < 3; x++)  {
			fWrite2ColTeasers(x,aTeaser2Col[i][0],aTeaser2Col[i][1],aTeaser2Col[i][2],aTeaser2Col[i][3],aTeaser2Col[i][4],aTeaser2Col[i][5],aTeaser2Col[i][6],sShowTeaserText,sShowSectionTitle);
			//  check for circular looping
			if (i == n2ColTotalCarouselItems-1) {
				i=0;
			} else {
				i++;
			}
		}
		// END: Forwards
	} else {
		// BEGIN: Backwards
		if (n2ColCurrentItem == 0) {
			n2ColCurrentItem=n2ColTotalCarouselItems-1;
		} else {
			n2ColCurrentItem--;
		}
		var i = n2ColCurrentItem;
		//  Loop through changing div content
		for (var x = 1; x < 3; x++)  {
			fWrite2ColTeasers(x,aTeaser2Col[i][0],aTeaser2Col[i][1],aTeaser2Col[i][2],aTeaser2Col[i][3],aTeaser2Col[i][4],aTeaser2Col[i][5],aTeaser2Col[i][6],sShowTeaserText,sShowSectionTitle);
			if (i == n2ColTotalCarouselItems-1) {
				i=0;
			} else {
				i++;
			}
		}
		// END: Backwards
	}
	return true;
}

function fMoveCarousel2Col1(nDirection,sShowTeaserText,sShowSectionTitle) {

	if(nDirection == 1) {
		// BEGIN: Forwards
		// Set current item to be the new current item
		if (n2ColCurrentItem1 == n2ColTotalCarouselItems1-1) {
			n2ColCurrentItem1=0;
		} else {
			n2ColCurrentItem1++;
		}
		var i = n2ColCurrentItem1; // allows us to loop through the items in the array and leave the current item correct
		//  Loop through changing div content
		for (var x = 1; x < 3; x++)  {
			fWrite2ColTeasers1(x,aTeaser2Col1[i][0],aTeaser2Col1[i][1],aTeaser2Col1[i][2],aTeaser2Col1[i][3],aTeaser2Col1[i][4],aTeaser2Col1[i][5],aTeaser2Col1[i][6],sShowTeaserText,sShowSectionTitle);
			
			//  check for circular looping
			if (i == n2ColTotalCarouselItems1-1) {
				i=0;
			} else {
				i++;
			}
		}
		// END: Forwards
	} else {

		// BEGIN: Backwards
		if (n2ColCurrentItem1 == 0) {
			n2ColCurrentItem1=n2ColTotalCarouselItems1-1;
		} else {
			n2ColCurrentItem1--;
		}
		var i = n2ColCurrentItem1;
		//  Loop through changing div content
		for (var x = 1; x < 3; x++)  {
			fWrite2ColTeasers1(x,aTeaser2Col1[i][0],aTeaser2Col1[i][1],aTeaser2Col1[i][2],aTeaser2Col1[i][3],aTeaser2Col1[i][4],aTeaser2Col1[i][5],aTeaser2Col1[i][6],sShowTeaserText,sShowSectionTitle);
			if (i == n2ColTotalCarouselItems1-1) {
				i=0;
			} else {
				i++;
			}
		}
		// END: Backwards
	}
	return true;
}



