/*==========================================================================================*/
function addLoadEvent(func) {
	var oldonload=window.onload;
	if (typeof window.onload!="function") {
		window.onload=func;
	} else {
		window.onload=function() {
			oldonload();
			func();
		}//end function
	}//end if (typeof window.onload!="function")
}//end function
/*==========================================================================================*/
function setHighlights() {
	xInputs=document.getElementsByTagName("input");
	for (i=0;i<xInputs.length;i++) {
		if (xInputs[i].type=="text") {
			xInputs[i].onfocus=function() {
					if (this.defaultValue==this.value) {
						this.select();
					}//end if ()
				}//end function
			xInputs[i].onmouseup=function(){return false};//because safari is special
		}//end if (xInputs[i].type=="text")
	}//next i<xInputs.length
	xTextAreas=document.getElementsByTagName("textarea");
	for (i=0;i<xTextAreas.length;i++) {
		xTextAreas[i].onfocus=function() {
				if (this.defaultValue==this.value) {
					this.select();
				}//end if ()
			}//end function
		xTextAreas[i].onmouseup=function(){return false};//because safari is special
	}//next i<xTextAreas.length
}//end function
/*==========================================================================================*/
function bcMoveLeft() {
	xBc=document.getElementById("blendercontrol");
	if (xBc) {
		xNumImages=xBc.getElementsByTagName("img").length;
			if (xNumImages>0) {
			xMinMargin=0;
			xBcUL=xBc.getElementsByTagName("ul")[0];
			if (xBcUL) {
				xMarginLeft=xBcUL.style.marginLeft.replace("px", "");
				if (xMarginLeft=="") {xMarginLeft=0};
				xNewMargin=0;
				if (xMarginLeft<xMinMargin) {
					while (xNewMargin<110) {
						xNewMargin=xNewMargin+1;
						xMarginLeft=parseInt(xMarginLeft)+1;
						setTimeout("SetMarginLeft("+xMarginLeft+")",2*xNewMargin);
					}//wend
				}//end if (xMarginRight<xMaxMargin)
			}//end if (xBcUL)
		}//end if (xNumImages>0)
	}//end if (xBc)
}//end function
/*==========================================================================================*/
function bcMoveRight() {
	xBc=document.getElementById("blendercontrol");
	if (xBc) {
		xNumImages=xBc.getElementsByTagName("img").length;
			if (xNumImages>0) {
			xMaxMargin=0-(110*(xNumImages-6));
			xBcUL=xBc.getElementsByTagName("ul")[0];
			if (xBcUL) {
				xMarginLeft=xBcUL.style.marginLeft.replace("px", "");
				if (xMarginLeft=="") {xMarginLeft=0};
				xNewMargin=0;
				if (xMarginLeft>xMaxMargin) {
					while (xNewMargin<110) {
						xNewMargin=xNewMargin+1;
						xMarginLeft=xMarginLeft-1;
						setTimeout("SetMarginLeft("+xMarginLeft+")",2*xNewMargin);
					}//wend
				}//end if (xMarginRight<xMaxMargin)
			}//end if (xBcUL)
		}//end if (xNumImages>0)
	}//end if (xBc)
}//end function
/*==========================================================================================*/
function SetMarginLeft(theMarginLeft) {
	xBc=document.getElementById("blendercontrol");
	if (xBc) {
		xBcUL=xBc.getElementsByTagName("ul")[0];
		if (xBcUL) {
			xBcUL.style.marginLeft=theMarginLeft+"px";
			ShowHideGalleryButtons()
		}//end if (xBcUL)
	}//end if (xBc)
}//end function
/*==========================================================================================*/
function ShowHideGalleryButtons() {
	xBc=document.getElementById("blendercontrol");
	if (xBc) {
		xLeftButton=document.getElementById("bcMoveLeft");
		xRightButton=document.getElementById("bcMoveRight");
		if (xLeftButton&&xRightButton) {
			xNumImages=xBc.getElementsByTagName("img").length;
				if (xNumImages>0) {
				xMaxMargin=0-(110*(xNumImages-6));
				xMinMargin=0;
				xBcUL=xBc.getElementsByTagName("ul")[0];
				if (xBcUL) {
					xMarginLeft=xBcUL.style.marginLeft.replace("px", "");
					if (xMarginLeft=="") {xMarginLeft=0};
					if (xMarginLeft==0) {
						xLeftButton.style.display="none";
					} else {
						xLeftButton.style.display="block";
					}//end if (xMarginLeft==0) 
					if (xMarginLeft==xMaxMargin) {
						xRightButton.style.display="none";
					} else {
						xRightButton.style.display="block";
					}//end if (xMarginLeft==xMaxMargin)
				}//end if (xBcUL)
			}//end if (xLeftButton&&xRightButton)
		}//end if (xNumImages>0)
	}//end if (xBc)
}//end function
/*======================================================================================================*/
function setOpacity(xDiv, xOpac, xDirection) {
	xDiv=document.getElementById(xDiv)
    xDiv.style.opacity=(xOpac/100);
    xDiv.style.MozOpacity=(xOpac/100);
    xDiv.style.KhtmlOpacity=(xOpac/100);
    xDiv.style.filter='alpha(opacity='+xOpac+')';
	//document.getElementById("xopacdiv").value=xOpac;
	if (xDirection=="down") {
		if (xOpac==0) {
			xDiv.innerHTML='';
		}//end if (xOpac=="0")
	}//end if (xDirection=="down")
}//end function
/*======================================================================================================*/
var zindex=100;
/*==========================================================================================*/
function ShowGalleryImage(divnum) {
	zindex=zindex+100;
	xDiv=document.getElementById("bigimgdiv"+divnum);
	if (xDiv) {
		xDiv.style.opacity=0;
		xDiv.style.MozOpacity=0;
		xDiv.style.KhtmlOpacity=0;
		xDiv.style.filter='alpha(opacity=0)';
		xDiv.style.zIndex=zindex;
		for (o=0;o<=100;o++) {
			ot=o*10;
			op=o;
			setTimeout("setOpacity(\"bigimgdiv"+divnum+"\", "+op+", \"up\")", ot);
		}//next
	}//end if (xDiv)
	xDivs=document.getElementById("gallerydescs").getElementsByTagName("div");
	for (d=0;d<xDivs.length;d++) {
		xDivs[d].style.display="none";
	}//next d<xDivs.lenght
//	xDiv2=document.getElementById("bigimgdesc"+divnum);
	xDivs[divnum].style.display="block";
}//end function
/*==========================================================================================*/
addLoadEvent(setHighlights);
addLoadEvent(ShowHideGalleryButtons);
/*==========================================================================================*/

