if (Gateway.siteHost != Gateway.secureHost && window.location.hostname == Gateway.secureHost) {
	jQuery(document).ready(function () {
		jQuery("a").each(function () {
			var	newhref = '',
				jqLink = jQuery(this);
			if (this.href != null && this.hostname == window.location.hostname && jqLink.attr('href').indexOf('#') != 0) {
				newhref = 'http://' + Gateway.siteHost + this.pathname + (this.search && this.search.length ? this.search : '');
				jqLink.attr('href', newhref);
			}
		});
	});
}

function popup(url, width, height) {
	window.open(url, 'newwindow', 'toolbar=0,width=' + width + ',height=' + height + ',directories=0,status=0,resizable=0,scrollbars=1,menubar=1,alwaysRaised');
	return false;
}
function popup_nomenu(url, width, height) {
	window.open(url, '_blank', 'toolbar=0,width=' + width + ',height=' + height + ',directories=0,status=0,resizable=0,scrollbars=1,menubar=0,alwaysRaised');
	return false;
}

function formvalidate (inputtext,inputid) {
	if (inputtext.value.length == 0) {
		document.getElementById(inputid).innerHTML = ' required';
		inputtext.focus();
		return false;
	} else {
		document.getElementById(inputid).innerHTML = '';
	}
	return true;
}

function emailvalidate (inputtext,inputid) {
	if (!(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/.test(inputtext.value))) {
		document.getElementById(inputid).innerHTML = ' invalid';
		inputtext.focus();
		return false;
	} else {
		document.getElementById(inputid).innerHTML = '';
	}
	return true;
}

function checkboxvalidate (inputtext,inputid) {
	var x = 0;
	for (z=0; z < inputtext.length; z++) {
		if (inputtext[z].checked) {
			x = 1;
			z = inputtext.length;
		}
	}
	if (x == 0) {
		document.getElementById(inputid).innerHTML = ' required';
		return false;
	} else {
		document.getElementById(inputid).innerHTML = '';
		return true;
	}
}

function biggerimage(url,width,height) {
	window.open('/sections/viewimage.cfm?image=' + url, '_blank', 'toolbar=0,width=' + width + ',height=' + height + ',directories=0,status=0,resizable=0,scrollbars=0,menubar=0,alwaysRaised');
}

function checkOnOff(thischeck,target) {
	if (thischeck.checked == false) target.disabled = false;
	else target.disabled = true;
}

function expandCollapse(itemid) {
	if (document.getElementById(itemid).style.display == 'block') document.getElementById(itemid).style.display = 'none';
	else document.getElementById(itemid).style.display = 'block';
}

var ie4=document.all
var dom=document.getElementById

var SlideShow = function (mycanvas0, mycanvas1, fadeimages, myid) {
	this.canvas0 = mycanvas0;
	this.canvas1 = mycanvas1;
	this.myimages = fadeimages;
	this.curcanvas = this.canvas0;
	this.nextcanvas = this.canvas1;
	this.id = myid;
	this.dropslide;
	
	this.curpos=10
	this.degree=10
	this.curimageindex=0
	this.nextimageindex=1
	
	this.fadepic = function (indx, tempobj){
		var myslide = window.slideshow_arr[indx];
		if (myslide.curpos<100){
			myslide.curpos+=10	
			if (tempobj.filters)
				tempobj.filters.alpha.opacity=myslide.curpos
			else if (tempobj.style.MozOpacity)
				tempobj.style.MozOpacity=myslide.curpos/101
		}
		else{
			clearInterval(myslide.dropslide)
			myslide.nextcanvas=(myslide.curcanvas==myslide.canvas0)? myslide.canvas0 : myslide.canvas1
			tempobj=document.getElementById(myslide.nextcanvas)
			tempobj.innerHTML=myslide.insertimage(myslide.nextimageindex)
			myslide.nextimageindex=(myslide.nextimageindex<myslide.myimages.length-1)? myslide.nextimageindex+1 : 0
			var tempobj2 = document.getElementById(myslide.nextcanvas)
			tempobj.style.visibility = "visible"
			tempobj2.style.visibility="hidden"
			setTimeout(function () { var s = window.slideshow_arr[indx ];  s.rotateimage(indx)},pause)
		}
	}

	this.rotateimage = function  (indx){	
		var myself = window.slideshow_arr[indx];
		if (ie4||dom){
			myself.resetit(myself.curcanvas)
			var crossobj =  document.getElementById(myself.curcanvas);
			var tempobj = crossobj;
			crossobj.style.zIndex++
			tempobj.style.visibility="visible"
			myself.dropslide = setInterval(function () { var myslide = window.slideshow_arr[myself.id]; myslide.fadepic(myself.id ,tempobj );} , 50);
			myself.curcanvas=(myself.curcanvas==myself.canvas0)? myself.canvas1 : myself.canvas0
		}else
			document.images.defaultslide.src=myself.myimages[myself.curimageindex][0]
		myself.curimageindex=(myself.curimageindex<myself.myimages.length-1)? myself.curimageindex+1 : 0
	}

	this.startit = function  (){
		var crossobj=document.getElementById(this.curcanvas)
		crossobj.innerHTML=this.insertimage(this.curimageindex)
		this.rotateimage(this.id)
	}
	
	this.resetit = function (what){
		this.curpos=10
		var crossobj=document.getElementById(what)
		if (crossobj.filters) {
			crossobj.filters.alpha.opacity=this.curpos
		}
		else if (crossobj.style.MozOpacity) {
			crossobj.style.MozOpacity=this.curpos/101
		}
	}
	
	this.insertimage = function (i){
		var tempcontainer=this.myimages[i][1]!=""? '<div class="photoHeadline">'+this.myimages[i][1]+'</div>' : ""
		tempcontainer+='<img src="'+this.myimages[i][0]+'" border="0" />'		
		tempcontainer=this.myimages[i][2]!=""? tempcontainer+'<div class="photoDescrp">'+this.myimages[i][2]+'</div>' : tempcontainer
		return tempcontainer
	}
}

function refreshCaptcha() {
	document.images["captchaImage"].src = "/common/captcha/captcha.cfm?" + Math.random();
}

