function $(id) {
	return document.getElementById(id);
}

function openCalendar(FormElement) {
	var calendarwindow;
	var calendarFile = document.form1.LanguageID.value == "1" ? "calendar_1.html" : "calendar_2.html";
	url = calendarFile + "?formname=form1&formelement=" + FormElement; 
	calendarwindow = window.open(url,"thewindow","toolbar=no,left=300,top=250,width=170, height=140,status=no,scrollbars=no,resize=no,menubar=no");
	calendarwindow.focus();
}

function StripFirstLeftBorderFromListItems(idUl) {
	var nOffsetTop = -100; // impossible value
	var aLi = $(idUl).getElementsByTagName('li');
	var i;
	for(i = 0; i < aLi.length; i++) {
		if(aLi[i].offsetTop > nOffsetTop) {
			if(i == 1) {
				// Something goes wrong, break and call it again in a few milisec
				setTimeout("StripFirstLeftBorderFromListItems('"+idUl+"')", 100);
				break;
			}
			aLi[i].getElementsByTagName('span')[0].style.borderLeft = 'none';
			nOffsetTop = aLi[i].offsetTop;
		}
	}
}

function Pager(sDivParent) {
	 this.divParent = null;
	 this.sDivChild = null;
	 this.divPrev = null;
	 this.divNext = null;
	 this.divPrevNext = null;
	 this.nPages = 0;
	 this.nCurrentPage = 0;
	 
	 this.Pager = function(sDivParent) {
		 var divChild;
		 this.divParent = $(sDivParent);
		 this.divPrevNext = $(sDivParent + "PrevNext");
		 this.divPrev = $(sDivParent + "Prev");
		 this.divNext = $(sDivParent + "Next");
		 this.sDivChild = sDivParent + "Page";
		 while((divChild = $(this.sDivChild + this.nPages)) && this.nPages < 1000) {
			 this.nPages++;
		 }
		 if(this.nPages > 1) {
		 	this.Show(0);
			this.divPrevNext.style.display = "block";
		 }
	 }
	 
	 this.Next = function() {
		 if(this.nCurrentPage < this.nPages - 1) {
			 this.Show(this.nCurrentPage + 1);
		 }
	 }
	 
	 this.Prev = function() {
		 if(this.nCurrentPage > 0) {
			 this.Show(this.nCurrentPage - 1);
		 }
	 }
	 
	 this.Show = function(nPage) {
		var i, divChild;
	 	this.nCurrentPage = nPage;
		for(i = 0; i < this.nPages; i++) {
			divChild = $(this.sDivChild + i);
			divChild.style.display = (i == this.nCurrentPage) ? "block" : "none";
		}
		this.divPrev.style.display = this.nCurrentPage > 0 ? "block" : "none";
		this.divNext.style.display = this.nCurrentPage < this.nPages - 1 ? "block" : "none";
	 }
	 
	 this.Pager(sDivParent);
}

function BgImage(sInstanceName, sDivImage, sDivThumbs) {
	
	this.divImage = $(sDivImage);
	this.divThumbs = $(sDivThumbs);
	
	var i, img;
	var aA = this.divThumbs.getElementsByTagName("a");
	for(i=0;i<aA.length;i++) {
		aA[i].href = "javascript:" + sInstanceName + ".Swap('" + aA[i].href + "')";
	}
	
	this.Swap = function(sImgPath) {
		this.divImage.style.backgroundImage = "url("+sImgPath+")";
	}
	
	if(aA.length < 2) $(sDivThumbs+'Container').style.display = "none";
	
}

function ToggleDisplayBlockNone(sElement) {
	element = $(sElement);
	if(element.style.display != "none") element.style.display = "none";
	else element.style.display = "block";
}

function MinimizeRestoreContent(sElement) {
	this.sElement = sElement;
	this.toggle = function() {
		ToggleDisplayBlockNone(this.sElement);
	}
}
