window.onerror = function(){return true;};

window.onload = function(){
	updateScrollInterface(DocWindowList);
	updateScrollInterface(FRWindowList);
	updateScrollInterface(TBWindowList);
	updateScrollInterface(VWindowList);
	updateScrollInterface(MVWindowList);
	updateScrollInterface(IMGWindowList);
	};

var intItemWidth = 145;
var intControlOffset = 42;

Effect.Combo = function(element) {
	element = $(element);
	if(element.style.display == 'none') { 
		new Effect.Appear(element, arguments[1] || {}); 
	}else { 
		new Effect.BlindUp(element, arguments[1] || {}); 
	}
	if (DocWindowBase && element.id == DocWindowBase+"_detail1") {//_detail1 is left over frome home_panels not used here, watch this for errors
		setButton(DocWindowBase+"_tabControl");
	} else {
		setButton(FRWindowBase+"_tabControl");
	}
}

function findPosX(obj) {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

function setButton(whichButtonID) {
	if ($(whichButtonID).className == "down") {
		$(whichButtonID).className = "up";
	} else {
		$(whichButtonID).className = "down";
	}
}

function toggleFeatureVideoContent() {
	summaryElement = $("featureVideoTextSummaryContent");
	remainingContentElement = $("featureVideoTextRemainingContent");
	if(remainingContentElement){
		if ($(remainingContentElement).style.display == "none") {
			$("featureVideoTextSummaryContent").style.display = "none";
			new Effect.Appear(remainingContentElement);
			setButton("featureVideoContainerVisibleToggle");
		} else {
			new Effect.Fade(remainingContentElement, {duration:0.5});
			new Effect.Appear(summaryElement, {duration:1.5});
			//new Effect.Parallel([new Effect.Fade(remainingContentElement), new Effect.Appear(summaryElement)], {duration:0.5});
			setButton("featureVideoContainerVisibleToggle");
		}
	}
}

var intCurrentDocumentariesScrollerItem = 1;
var intCurrentFieldReportsScrollerItem = 1;
var intCurrentTravellersBlogsScrollerItem = 1;
var intCurrentVideosScrollerItem = 1;
var intCurrentMoreVideosScrollerItem = 1;
var intCurrentImagesScrollerItem = 1;

var DocWindowBase = '';
var DocWindowList = '';
var DocWindowNext = '';
var DocWindowPrev = '';

var FRWindowBase = '';
var FRWindowList = '';
var FRWindowNext = '';
var FRWindowPrev = '';

var TBWindowBase = '';
var TBWindowList = '';
var TBWindowNext = '';
var TBWindowPrev = '';

var VWindowBase = '';
var VWindowList = '';
var VWindowNext = '';
var VWindowPrev = '';
var VWindowCar = '';
var VWindowItem = '';

var MVWindowBase = '';
var MVWindowList = '';
var MVWindowNext = '';
var MVWindowPrev = '';

var IMGWindowBase = '';
var IMGWindowList = '';
var IMGWindowNext = '';
var IMGWindowPrev = '';

function initializeDocumentariesScrollerWindow(baseName) {
	//intCurrentDocumentariesScrollerItem = 1;
	DocWindowBase = baseName;
	DocWindowList = baseName+'_vidWindowList';
	DocWindowNext = baseName+'_vidWindowNext';
	DocWindowPrev = baseName+'_vidWindowPrevious';	
	DocWindowCar = baseName+'_vidWindowCarouselContainer';
	DocWindowItem = baseName+'_vidWindowItem_';
	updateScrollInterface(DocWindowList);
	/*var currimage = $(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage=currimage;
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).className = "active";*/
}

function initializeFieldReportsScrollerWindow(baseName) {
	//intCurrentFieldReportsScrollerItem = 1;
	FRWindowBase = baseName;
	FRWindowList = baseName+'_vidWindowList';
	FRWindowNext = baseName+'_vidWindowNext';
	FRWindowPrev = baseName+'_vidWindowPrevious';
	FRWindowCar = baseName+'_vidWindowCarouselContainer';	
	FRWindowItem = baseName+'_vidWindowItem_';
	updateScrollInterface(FRWindowList);
	/*var currimage = $(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage=currimage;
	$(FRWindowItem + intCurrentFieldReportsScrollerItem).className = "active";*/
}

function initializeTravellersBlogsScrollerWindow(baseName) {
	//intCurrentTravellersBlogsScrollerItem = 1;
	TBWindowBase = baseName;
	TBWindowList = baseName+'_vidWindowList';
	TBWindowNext = baseName+'_vidWindowNext';
	TBWindowPrev = baseName+'_vidWindowPrevious';
	TBWindowCar = baseName+'_vidWindowCarouselContainer';	
	TBWindowItem = baseName+'_vidWindowItem_';
	updateScrollInterface(TBWindowList);
	/*var currimage = $(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage=currimage;
	$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).className = "active";*/
}

function initializeVideosScrollerWindow(baseName) {

	//intCurrentDocumentariesScrollerItem = 1;
	
	VWindowBase = baseName;
	VWindowList = baseName+'_vidWindowList';
	VWindowNext = baseName+'_vidWindowNext';
	VWindowPrev = baseName+'_vidWindowPrevious';	
	VWindowCar = baseName+'_vidWindowCarouselContainer';
	VWindowItem = baseName+'_vidWindowItem_';
	updateScrollInterface(VWindowList);
	/*var currimage = $(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage=currimage;
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).className = "active";*/
}

function initializeMoreVideosScrollerWindow(baseName) {
	//intCurrentDocumentariesScrollerItem = 1;
	MVWindowBase = baseName;
	MVWindowList = baseName+'_vidWindowList';
	MVWindowNext = baseName+'_vidWindowNext';
	MVWindowPrev = baseName+'_vidWindowPrevious';	
	MVWindowCar = baseName+'_vidWindowCarouselContainer';
	MVWindowItem = baseName+'_vidWindowItem_';
	updateScrollInterface(MVWindowList);
	/*var currimage = $(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage=currimage;
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).className = "active";*/
}

function initializeImagesScrollerWindow(baseName) {
	//intCurrentDocumentariesScrollerItem = 1;

	IMGWindowBase = baseName;
	IMGWindowList = baseName+'_vidWindowList';
	IMGWindowNext = baseName+'_vidWindowNext';
	IMGWindowPrev = baseName+'_vidWindowPrevious';	
	IMGWindowCar = baseName+'_vidWindowCarouselContainer';
	IMGWindowItem = baseName+'_vidWindowItem_';
	updateScrollInterface(IMGWindowList);
	/*var currimage = $(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage=currimage;
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).className = "active";*/
}

function clearSelectedItem(baseName){
    
	var currimage = '';
	
	if (DocWindowBase && baseName == DocWindowBase) {
		currimage = $(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage;
		currimage = currimage.replace("blue", "white");
		$(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage=currimage;
		$(DocWindowItem + intCurrentDocumentariesScrollerItem).className = "inactive";
	} else if (FRWindowBase && baseName == FRWindowBase) {
	
		currimage = $(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage;
		if(currimage)
			currimage = currimage.replace("blue", "white");
		$(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage=currimage;
		$(FRWindowItem + intCurrentFieldReportsScrollerItem).className = "inactive";
	} else if (TBWindowBase && baseName == TBWindowBase) {
	
		currimage = $(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage;
		if(currimage)
			currimage = currimage.replace("blue", "white");
		$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage=currimage;
		$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).className = "inactive";
	} else if (VWindowBase && baseName == VWindowBase) {
		currimage = $(VWindowItem + intCurrentVideosScrollerItem).style.backgroundImage;
		if(currimage)
			currimage = currimage.replace("blue", "white");
		$(VWindowItem + intCurrentVideosScrollerItem).style.backgroundImage=currimage;
		$(VWindowItem + intCurrentVideosScrollerItem).className = "inactive";
	} else if (MVWindowBase && baseName == MVWindowBase) {
		
		currimage = $(MVWindowItem + intCurrentMoreVideosScrollerItem).style.backgroundImage;
		if(currimage)
			currimage = currimage.replace("blue", "white");
		$(MVWindowItem + intCurrentMoreVideosScrollerItem).style.backgroundImage=currimage;
		$(MVWindowItem + intCurrentMoreVideosScrollerItem).className = "inactive";
	} else if (IMGWindowBase && baseName == IMGWindowBase) {
		
		currimage = $(IMGWindowItem + intCurrentImagesScrollerItem).style.backgroundImage;
		if(currimage)
			currimage = currimage.replace("blue", "white");
		$(IMGWindowItem + intCurrentImagesScrollerItem).style.backgroundImage=currimage;
		$(IMGWindowItem + intCurrentImagesScrollerItem).className = "inactive";
	}
	
}

function setItem(baseName, whichItem) {

	clearSelectedItem(baseName);
	if(DocWindowBase && baseName == DocWindowBase)
		setDocItem(whichItem);
	else if (FRWindowBase && baseName == FRWindowBase)
		setFRItem(whichItem);
	else if (TBWindowBase && baseName == TBWindowBase)
		setTBItem(whichItem);
	else if (VWindowBase && baseName == VWindowBase)
		setVItem(whichItem);
	else if (MVWindowBase && baseName == MVWindowBase)
		setMVItem(whichItem);
	else if (IMGWindowBase && baseName == IMGWindowBase)
		setIMGItem(whichItem);
		
	//when switching items we want to reset these things 
	remainingContentElement = $("featureVideoTextRemainingContent");
	if(remainingContentElement)	$(remainingContentElement).style.display == "none"
	$("featureVideoContainerVisibleToggle").className = "down";
	$("featureVideoContainerVisibleToggle").style.display = "none";	//this is switched on in functions.js
}

function setDocItem(whichItem) {
	var currimage = $(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("blue", "white");
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage=currimage;
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).className = "";
	intCurrentDocumentariesScrollerItem = whichItem;
	// reload contents of 'detail1' container via AJAX
	
	currimage = $(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).style.backgroundImage=currimage;
	$(DocWindowItem + intCurrentDocumentariesScrollerItem).className = "active";
	
	//check if the selected item is fully visible; if not, then scroll the view over to show the item
	intCurrentWindowWidth = $(DocWindowCar).offsetWidth - intControlOffset;
	intThisListItemRightXPosition = $(DocWindowList).offsetLeft + (intCurrentDocumentariesScrollerItem * intItemWidth);
	intThisListItemLeftXPosition = $(DocWindowList).offsetLeft + ((intCurrentDocumentariesScrollerItem - 1) * intItemWidth);
	if (intThisListItemRightXPosition > intCurrentWindowWidth) {
		new Effect.Move(DocWindowList, {x:(intCurrentWindowWidth - intThisListItemRightXPosition), duration: 0.5});
	} else if (intThisListItemLeftXPosition < 0) {
		new Effect.Move(DocWindowList, {x:(-1 * intThisListItemLeftXPosition), duration: 0.5});
	}
	updateScrollInterface(DocWindowList);
}

function setFRItem(whichItem) {
	var currimage = $(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage;
	currimage = currimage.replace("blue", "white");
	$(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage=currimage;
	$(FRWindowItem + intCurrentFieldReportsScrollerItem).className = "";
	intCurrentFieldReportsScrollerItem = whichItem;
	// reload contents of 'detail2' container via AJAX
	
	currimage = $(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(FRWindowItem + intCurrentFieldReportsScrollerItem).style.backgroundImage=currimage;
	$(FRWindowItem + intCurrentFieldReportsScrollerItem).className = "active";
	
	//check if the selected item is fully visible; if not, then scroll the view over to show the item
	intCurrentWindowWidth = $(FRWindowCar).offsetWidth - intControlOffset;
	intThisListItemRightXPosition = $(FRWindowList).offsetLeft + (intCurrentFieldReportsScrollerItem * intItemWidth);
	intThisListItemLeftXPosition = $(FRWindowList).offsetLeft + ((intCurrentFieldReportsScrollerItem - 1) * intItemWidth);
	if (intThisListItemRightXPosition > intCurrentWindowWidth) {
		new Effect.Move(FRWindowList, {x:(intCurrentWindowWidth - intThisListItemRightXPosition), duration: 0.5});
	} else if (intThisListItemLeftXPosition < 0) {
		new Effect.Move(FRWindowList, {x:(-1 * intThisListItemLeftXPosition), duration: 0.5});
	}
	updateScrollInterface(FRWindowList);
}

function setTBItem(whichItem) {
	var currimage = $(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage;
	currimage = currimage.replace("blue", "white");
	$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage=currimage;
	$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).className = "";
	intCurrentTravellersBlogsScrollerItem = whichItem;
	// reload contents of 'detail2' container via AJAX
	
	currimage = $(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).style.backgroundImage=currimage;
	$(TBWindowItem + intCurrentTravellersBlogsScrollerItem).className = "active";
	
	//check if the selected item is fully visible; if not, then scroll the view over to show the item
	intCurrentWindowWidth = $(TBWindowCar).offsetWidth - intControlOffset;
	intThisListItemRightXPosition = $(TBWindowList).offsetLeft + (intCurrentTravellersBlogsScrollerItem * intItemWidth);
	intThisListItemLeftXPosition = $(TBWindowList).offsetLeft + ((intCurrentTravellersBlogsScrollerItem - 1) * intItemWidth);
	if (intThisListItemRightXPosition > intCurrentWindowWidth) {
		new Effect.Move(TBWindowList, {x:(intCurrentWindowWidth - intThisListItemRightXPosition), duration: 0.5});
	} else if (intThisListItemLeftXPosition < 0) {
		new Effect.Move(TBWindowList, {x:(-1 * intThisListItemLeftXPosition), duration: 0.5});
	}
	updateScrollInterface(TBWindowList);
}

function setVItem(whichItem) {

	var currimage = $(VWindowItem + intCurrentVideosScrollerItem).style.backgroundImage;
	currimage = currimage.replace("blue", "white");
	$(VWindowItem + intCurrentVideosScrollerItem).style.backgroundImage=currimage;
	$(VWindowItem + intCurrentVideosScrollerItem).className = "";
	intCurrentVideosScrollerItem = whichItem;
	// reload contents of 'detail2' container via AJAX
	
	currimage = $(VWindowItem + intCurrentVideosScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(VWindowItem + intCurrentVideosScrollerItem).style.backgroundImage=currimage;
	$(VWindowItem + intCurrentVideosScrollerItem).className = "active";
	
	//check if the selected item is fully visible; if not, then scroll the view over to show the item
	intCurrentWindowWidth = $(VWindowCar).offsetWidth - intControlOffset;
	intThisListItemRightXPosition = $(VWindowList).offsetLeft + (intCurrentVideosScrollerItem * intItemWidth);
	intThisListItemLeftXPosition = $(VWindowList).offsetLeft + ((intCurrentVideosScrollerItem - 1) * intItemWidth);
	if (intThisListItemRightXPosition > intCurrentWindowWidth) {
		new Effect.Move(VWindowList, {x:(intCurrentWindowWidth - intThisListItemRightXPosition), duration: 0.5});
	} else if (intThisListItemLeftXPosition < 0) {
		new Effect.Move(VWindowList, {x:(-1 * intThisListItemLeftXPosition), duration: 0.5});
	}
	updateScrollInterface(VWindowList);
}

function setMVItem(whichItem) {
	var currimage = $(MVWindowItem + intCurrentMoreVideosScrollerItem).style.backgroundImage;
	currimage = currimage.replace("blue", "white");
	$(MVWindowItem + intCurrentMoreVideosScrollerItem).style.backgroundImage=currimage;
	$(MVWindowItem + intCurrentMoreVideosScrollerItem).className = "";
	intCurrentMoreVideosScrollerItem = whichItem;
	// reload contents of 'detail2' container via AJAX
	
	currimage = $(MVWindowItem + intCurrentMoreVideosScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(MVWindowItem + intCurrentMoreVideosScrollerItem).style.backgroundImage=currimage;
	$(MVWindowItem + intCurrentMoreVideosScrollerItem).className = "active";
	
	//check if the selected item is fully visible; if not, then scroll the view over to show the item
	intCurrentWindowWidth = $(MVWindowCar).offsetWidth - intControlOffset;
	intThisListItemRightXPosition = $(MVWindowList).offsetLeft + (intCurrentMoreVideosScrollerItem * intItemWidth);
	intThisListItemLeftXPosition = $(MVWindowList).offsetLeft + ((intCurrentMoreVideosScrollerItem - 1) * intItemWidth);
	if (intThisListItemRightXPosition > intCurrentWindowWidth) {
		new Effect.Move(MVWindowList, {x:(intCurrentWindowWidth - intThisListItemRightXPosition), duration: 0.5});
	} else if (intThisListItemLeftXPosition < 0) {
		new Effect.Move(MVWindowList, {x:(-1 * intThisListItemLeftXPosition), duration: 0.5});
	}
	updateScrollInterface(MVWindowList);
}

function setIMGItem(whichItem) {
	var currimage = $(IMGWindowItem + intCurrentImagesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("blue", "white");
	$(IMGWindowItem + intCurrentImagesScrollerItem).style.backgroundImage=currimage;
	$(IMGWindowItem + intCurrentImagesScrollerItem).className = "";
	intCurrentImagesScrollerItem = whichItem;
	// reload contents of 'detail2' container via AJAX
	
	currimage = $(IMGWindowItem + intCurrentImagesScrollerItem).style.backgroundImage;
	currimage = currimage.replace("white", "blue");
	$(IMGWindowItem + intCurrentImagesScrollerItem).style.backgroundImage=currimage;
	$(IMGWindowItem + intCurrentImagesScrollerItem).className = "active";
	
	//check if the selected item is fully visible; if not, then scroll the view over to show the item
	intCurrentWindowWidth = $(IMGWindowCar).offsetWidth - intControlOffset;
	intThisListItemRightXPosition = $(IMGWindowList).offsetLeft + (intCurrentImagesScrollerItem * intItemWidth);
	intThisListItemLeftXPosition = $(IMGWindowList).offsetLeft + ((intCurrentImagesScrollerItem - 1) * intItemWidth);
	if (intThisListItemRightXPosition > intCurrentWindowWidth) {
		new Effect.Move(IMGWindowList, {x:(intCurrentWindowWidth - intThisListItemRightXPosition), duration: 0.5});
	} else if (intThisListItemLeftXPosition < 0) {
		new Effect.Move(IMGWindowList, {x:(-1 * intThisListItemLeftXPosition), duration: 0.5});
	}
	updateScrollInterface(IMGWindowList);
}



function updateScrollInterface(whichControl) {
	
	if (DocWindowList && whichControl == DocWindowList) {
		intThisWindowListRightXPosition = $(DocWindowList).offsetLeft + (intDocumentariesWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(DocWindowCar).offsetWidth - intControlOffset;
		if ($(DocWindowList).offsetLeft < 0) {
			$(DocWindowPrev).className = "";
			$(DocWindowPrev).className = "prevControl";
		} else {
			$(DocWindowPrev).className = "";
			$(DocWindowPrev).className = "prevControl inactive";
		}
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			$(DocWindowNext).className = "";
			$(DocWindowNext).className = "nextControl";
		} else {
			$(DocWindowNext).className = "";
			$(DocWindowNext).className = "nextControl inactive";
		}
	} else if (FRWindowList && whichControl == FRWindowList) {
		intThisWindowListRightXPosition = $(FRWindowList).offsetLeft + (intFieldReportsWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(FRWindowCar).offsetWidth - intControlOffset;
		if ($(FRWindowList).offsetLeft < 0) {
			$(FRWindowPrev).className = "prevControl";
		} else {
			$(FRWindowPrev).className = "prevControl inactive";
		}
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			$(FRWindowNext).className = "nextControl";
		} else {
			$(FRWindowNext).className = "nextControl inactive";
		}
	} else if (TBWindowList && whichControl == TBWindowList){
		intThisWindowListRightXPosition = $(TBWindowList).offsetLeft + (intTravellersBlogsWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(TBWindowCar).offsetWidth - intControlOffset;
		if ($(TBWindowList).offsetLeft < 0) {
			$(TBWindowPrev).className = "prevControl";
		} else {
			$(TBWindowPrev).className = "prevControl inactive";
		}
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			$(TBWindowNext).className = "nextControl";
		} else {
			$(TBWindowNext).className = "nextControl inactive";
		}
	} else if (VWindowList && whichControl == VWindowList){
		intThisWindowListRightXPosition = $(VWindowList).offsetLeft + (intVideosWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(VWindowCar).offsetWidth - intControlOffset;
		if ($(VWindowList).offsetLeft < 0) {
			$(VWindowPrev).className = "prevControl";
		} else {
			$(VWindowPrev).className = "prevControl inactive";
		}
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			$(VWindowNext).className = "nextControl";
		} else {
			$(VWindowNext).className = "nextControl inactive";
		}
	} else if (MVWindowList && whichControl == MVWindowList){
		intThisWindowListRightXPosition = $(MVWindowList).offsetLeft + (intMoreVideosWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(MVWindowCar).offsetWidth - intControlOffset;
		if ($(MVWindowList).offsetLeft < 0) {
			$(MVWindowPrev).className = "prevControl";
		} else {
			$(MVWindowPrev).className = "prevControl inactive";
		}
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			$(MVWindowNext).className = "nextControl";
		} else {
			$(MVWindowNext).className = "nextControl inactive";
		}
	} else if (IMGWindowList && whichControl == IMGWindowList){
		intThisWindowListRightXPosition = $(IMGWindowList).offsetLeft + (intImagesWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(IMGWindowCar).offsetWidth - intControlOffset;
		if ($(IMGWindowList).offsetLeft < 0) {
			$(IMGWindowPrev).className = "prevControl";
		} else {
			$(IMGWindowPrev).className = "prevControl inactive";
		}
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			$(IMGWindowNext).className = "nextControl";
		} else {
			$(IMGWindowNext).className = "nextControl inactive";
		}
	}
}

function scrollWindowLeft(whichElement) {
	if (DocWindowList && whichElement == DocWindowList) {
		intThisWindowListRightXPosition = $(DocWindowList).offsetLeft + (intDocumentariesWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(DocWindowCar).offsetWidth - intControlOffset;
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			if ((intThisWindowListRightXPosition - intCurrentWindowWidth) > intItemWidth) {
				new Effect.Move(whichElement, {x:-intItemWidth, duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(DocWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(intCurrentWindowWidth - intThisWindowListRightXPosition), duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(DocWindowList);}});
			}
		}
	} else if (FRWindowList && whichElement == FRWindowList) {
		intThisWindowListRightXPosition = $(FRWindowList).offsetLeft + (intFieldReportsWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(FRWindowCar).offsetWidth - intControlOffset;
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			if ((intThisWindowListRightXPosition - intCurrentWindowWidth) > intItemWidth) {
				new Effect.Move(whichElement, {x:-intItemWidth, duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(FRWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(intCurrentWindowWidth - intThisWindowListRightXPosition), duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(FRWindowList);}});
			}
		}
	} else if (TBWindowList && whichElement == TBWindowList) {
		intThisWindowListRightXPosition = $(TBWindowList).offsetLeft + (intTravellersBlogsWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(TBWindowCar).offsetWidth - intControlOffset;
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			if ((intThisWindowListRightXPosition - intCurrentWindowWidth) > intItemWidth) {
				new Effect.Move(whichElement, {x:-intItemWidth, duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(TBWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(intCurrentWindowWidth - intThisWindowListRightXPosition), duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(TBWindowList);}});
			}
		}
	} else if (VWindowList && whichElement == VWindowList) {
		intThisWindowListRightXPosition = $(VWindowList).offsetLeft + (intVideosWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(VWindowCar).offsetWidth - intControlOffset;
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			if ((intThisWindowListRightXPosition - intCurrentWindowWidth) > intItemWidth) {
				new Effect.Move(whichElement, {x:-intItemWidth, duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(VWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(intCurrentWindowWidth - intThisWindowListRightXPosition), duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(VWindowList);}});
			}
		}
	} else if (MVWindowList && whichElement == MVWindowList) {
		intThisWindowListRightXPosition = $(MVWindowList).offsetLeft + (intMoreVideosWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(MVWindowCar).offsetWidth - intControlOffset;
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			if ((intThisWindowListRightXPosition - intCurrentWindowWidth) > intItemWidth) {
				new Effect.Move(whichElement, {x:-intItemWidth, duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(MVWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(intCurrentWindowWidth - intThisWindowListRightXPosition), duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(MVWindowList);}});
			}
		}
	} else if (IMGWindowList && whichElement == IMGWindowList) {
		intThisWindowListRightXPosition = $(IMGWindowList).offsetLeft + (intImagesWindowListCount * intItemWidth);
		intCurrentWindowWidth = $(IMGWindowCar).offsetWidth - intControlOffset;
		if (intThisWindowListRightXPosition > intCurrentWindowWidth) {
			if ((intThisWindowListRightXPosition - intCurrentWindowWidth) > intItemWidth) {
				new Effect.Move(whichElement, {x:-intItemWidth, duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(IMGWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(intCurrentWindowWidth - intThisWindowListRightXPosition), duration: 0.5, afterFinish:function callback(obj){updateScrollInterface(IMGWindowList);}});
			}
		}
	}
}

function scrollWindowRight(whichElement) {
	if (whichElement == DocWindowList) {
		intThisWindowListLeftXPosition = $(DocWindowList).offsetLeft;
		if (intThisWindowListLeftXPosition < 0) {
			if (intThisWindowListLeftXPosition < -intItemWidth) {
				new Effect.Move(whichElement, {x:intItemWidth, duration: 0.5,  afterFinish: function callback(obj){updateScrollInterface(DocWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(-1 * intThisWindowListLeftXPosition), duration: 0.5, afterFinish: function callback(obj){updateScrollInterface(DocWindowList);}});
			}
		}
	} else if (whichElement == FRWindowList) {
		intThisWindowListLeftXPosition = $(FRWindowList).offsetLeft;
		if (intThisWindowListLeftXPosition < 0) {
			if (intThisWindowListLeftXPosition < -intItemWidth) {
				new Effect.Move(whichElement, {x:intItemWidth, duration: 0.5,  afterFinish: function callback(obj){updateScrollInterface(FRWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(-1 * intThisWindowListLeftXPosition), duration: 0.5, afterFinish: function callback(obj){updateScrollInterface(FRWindowList);}});
			}
		}
	} else if (whichElement == TBWindowList){
		intThisWindowListLeftXPosition = $(TBWindowList).offsetLeft;
		if (intThisWindowListLeftXPosition < 0) {
			if (intThisWindowListLeftXPosition < -intItemWidth) {
				new Effect.Move(whichElement, {x:intItemWidth, duration: 0.5,  afterFinish: function callback(obj){updateScrollInterface(TBWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(-1 * intThisWindowListLeftXPosition), duration: 0.5, afterFinish: function callback(obj){updateScrollInterface(TBWindowList);}});
			}
		}
	} else if (whichElement == VWindowList){
		intThisWindowListLeftXPosition = $(VWindowList).offsetLeft;
		if (intThisWindowListLeftXPosition < 0) {
			if (intThisWindowListLeftXPosition < -intItemWidth) {
				new Effect.Move(whichElement, {x:intItemWidth, duration: 0.5,  afterFinish: function callback(obj){updateScrollInterface(VWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(-1 * intThisWindowListLeftXPosition), duration: 0.5, afterFinish: function callback(obj){updateScrollInterface(VWindowList);}});
			}
		}
	} else if (whichElement == MVWindowList){
		intThisWindowListLeftXPosition = $(MVWindowList).offsetLeft;
		if (intThisWindowListLeftXPosition < 0) {
			if (intThisWindowListLeftXPosition < -intItemWidth) {
				new Effect.Move(whichElement, {x:intItemWidth, duration: 0.5,  afterFinish: function callback(obj){updateScrollInterface(MVWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(-1 * intThisWindowListLeftXPosition), duration: 0.5, afterFinish: function callback(obj){updateScrollInterface(MVWindowList);}});
			}
		}
	} else if (whichElement == IMGWindowList){
		intThisWindowListLeftXPosition = $(IMGWindowList).offsetLeft;
		if (intThisWindowListLeftXPosition < 0) {
			if (intThisWindowListLeftXPosition < -intItemWidth) {
				new Effect.Move(whichElement, {x:intItemWidth, duration: 0.5,  afterFinish: function callback(obj){updateScrollInterface(IMGWindowList);}});
			} else {
				new Effect.Move(whichElement, {x:(-1 * intThisWindowListLeftXPosition), duration: 0.5, afterFinish: function callback(obj){updateScrollInterface(IMGWindowList);}});
			}
		}
	}
}


Event.observe(window, 'resize', function() {
	updateScrollInterface(DocWindowList);
	updateScrollInterface(FRWindowList);
	updateScrollInterface(TBWindowList);
	updateScrollInterface(VWindowList);
	updateScrollInterface(MVWindowList);
	updateScrollInterface(IMGWindowList);
});
