//maked all added functions work onload. at the end of each function you want to work onload add addLoadEvent(function); to the end of the function.
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// The following two functions make it possible to have web standard popups
window.onload = function() {
  if (!document.getElementsByTagName) return false;
  var lnks = document.getElementsByTagName("a");
  for (var i=0; i<lnks.length; i++) {
    if (lnks[i].className == "popupfrom") {
      lnks[i].onclick = function() {
        popUp(this.getAttribute("href"));
        return false;
      }
    }
    if (lnks[i].className == "popupGallery") {
      lnks[i].onclick = function() {
        popUpGallery(this.getAttribute("href"));
        return false;
      }
    }
  }
}

function popUp(winURL) {
  window.open(winURL,"popupfrom");
}
function popUpGallery(winURL) {
  window.open(winURL,"popupfrom","width=710,height=480");
}

//css background replacement method
function rplcImg() {
	var number = 17
	var random_number=""
	var number = Math.random()*number
	var random_number = Math.ceil(number)
	var hmlnk = document.getElementById('hmlnk')
	if(hmlnk){
	  var bgs = ['',
  		'url(/images/2010summer/hdr-logo1.jpg)',
  		'url(/images/2010summer/hdr-logo2.jpg)',
  		'url(/images/2010summer/hdr-logo3.jpg)',
  		'url(/images/2010summer/hdr-logo4.jpg)',
  		'url(/images/2010summer/hdr-logo5.jpg)',
  		'url(/images/2010summer/hdr-logo6.jpg)',
  		'url(/images/2010summer/hdr-logo7.jpg)',
  		'url(/images/2010summer/hdr-logo8.jpg)',
  		'url(/images/2010summer/hdr-logo9.jpg)',
  		'url(/images/2010summer/hdr-logo10.jpg)',
  		'url(/images/2010summer/hdr-logo11.jpg)',
  		'url(/images/2010summer/hdr-logo12.jpg)',
  		'url(/images/2010summer/hdr-logo13.jpg)',
  		'url(/images/2010summer/hdr-logo14.jpg)',
  		'url(/images/2010summer/hdr-logo15.jpg)',
  		'url(/images/2010summer/hdr-logo16.jpg)',
  		'url(/images/2010summer/hdr-logo17.jpg)'
  	]
  	hmlnk.style.backgroundImage = bgs[random_number]
	}
}
addLoadEvent(rplcImg);

//Show correct tab
function rplcTab() {
	if (document.getElementById('floral') != null) {
		document.getElementById('fmlnk').style.backgroundPosition = "bottom left";
		//document.getElementById('fmlnk').style.backgroundImage = "url(../images/mnav-flrlmrkt2.gif)";
	}
	if (document.getElementById('resources') != null) {
		document.getElementById('rclnk').style.backgroundPosition = "bottom left";
		//document.getElementById('rclnk').style.backgroundImage = "url(../images/mnav-rsrccntr2.gif)";
	}
	if (document.getElementById('education') != null) {
		document.getElementById('edlnk').style.backgroundPosition = "bottom left";
		//document.getElementById('edlnk').style.backgroundImage = "url(../images/mnav-edctn2.gif)";
	}
	if (document.getElementById('news') != null) {
		document.getElementById('nelnk').style.backgroundPosition = "bottom left";
		//document.getElementById('nelnk').style.backgroundImage = "url(../images/mnav-nwsevnts2.gif)";
	}
	if (document.getElementById('about') != null) {
		document.getElementById('aulnk').style.backgroundPosition = "bottom left";
		//document.getElementById('aulnk').style.backgroundImage = "url(../images/mnav-abtus2.gif)";
	}
	if (document.getElementById('industry') != null) {
		document.getElementById('iflnk').style.backgroundPosition = "bottom left";
		//document.getElementById('iflnk').style.backgroundImage = "url(../images/mnav-indstryfcs2.gif)";
	}
	if (document.getElementById('designer') != null) {
		document.getElementById('dslnk').style.backgroundPosition = "bottom left";
		//document.getElementById('dslnk').style.backgroundImage = "url(../images/mnav-dsgnrshwcs2.gif)";
	}
	if (document.getElementById('locations') != null) {
		document.getElementById('lclnk').style.backgroundPosition = "bottom left";
		//document.getElementById('lclnk').style.backgroundImage = "url(../images/mnav-lctns2.gif)";
	}
	if(document.getElementById('txtSearch')){
		document.getElementById('txtSearch').onfocus = function(){document.getElementById('txtSearch').value = ''}
	}
}
addLoadEvent(rplcTab);

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

//scrolling on interior pages
function hideScrollBar() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById('cntntcpy')) return false;
	var cpyHght = document.getElementById("cntntcpy").offsetHeight;
	if (cpyHght > 127) {
		document.getElementById("scrollbar").style.display = 'block';
	}
}
addLoadEvent(hideScrollBar);
addLoadEvent(function(){
  var lis = document.getElementsByTagName('li')
  for(var i=0;i<lis.length;i++){
    if(lis[i].className.indexOf('galleryGallery') != -1){
      var a = lis[i].getElementsByTagName('a')
      a[0].onclick = function(){ launchGallery(this); return false }
    }
  }
})
function launchGallery(link){
  window.open(link.href, 'gallery', 'width=700,height=470,resizable=yes,scrollbars=no')
}

var timerID = null;
var pos = 0;
function sliderUp() {
	if ((pos * -1) > 0) {
		pos = eval(pos + 14);
	}
	if (document.getElementById) {
		document.getElementById("cntntcpy").style.top =	pos+"px";
	}
	timerID = window.setTimeout('sliderUp()',100);
}

function sliderDn() {
	if ((pos * -1) < (document.getElementById("cntntcpy").offsetHeight - 80)) {
		pos = eval(pos - 14);
	}
	if (document.getElementById) {
		document.getElementById("cntntcpy").style.top = pos+"px";
	}
	timerID = window.setTimeout('sliderDn()',100);
}

//scrolling on slideshow
function hideSlideshow() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById('slideshowouter')) return false;
	if (!document.getElementById('slideshow')) return false;
	var sldCount = document.getElementById('slideshow').getElementsByTagName('li').length;
	document.getElementById('slideshow').style.width = ((144 * sldCount) + 'px');
	var sldWdth = document.getElementById("slideshow").offsetWidth;
	if (sldWdth > 432) {
		document.getElementById('slideshowbar').style.display = 'block';
	}
}
addLoadEvent(hideSlideshow);

var posSldr = 0;
function sliderLt() {
	if ((posSldr * -1) > 0) {
		posSldr = eval(posSldr + 24);
	}
	if (document.getElementById) {
		document.getElementById("slideshow").style.left =	posSldr+"px";
	}
	timerID = window.setTimeout('sliderLt()',100);
}

function sliderRt() {
	if ((posSldr * -1) < (document.getElementById("slideshow").offsetWidth - 432)) {
		posSldr = eval(posSldr - 24);
	}
	if (document.getElementById) {
		document.getElementById("slideshow").style.left = posSldr+"px";
	}
	timerID = window.setTimeout('sliderRt()',100);
}

function terminateTimer() {
    window.clearTimeout(timerID);
}