function formFocus(theForm, theCurrent, theDesired) {
	if (theForm.value == theCurrent) {
		theForm.value = theDesired;
	}
}


//change the opacity for different browsers
function setOpacity(opacity, id) {
	opacity = (opacity == 100)?99.999:opacity;
	opacity = (opacity == 0)?0.999:opacity;
	var obj = document.getElementById(id);
	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function runSlideShow() {
	blendimage('home-content-topimage', 'top-image-slide', preLoad[j].src, 2000)
	j = j + 1
	if (j > (images.length - 1)) j = 0
	t = setTimeout('runSlideShow()', slideShowSpeed)
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + " no-repeat )";
	
	//make image transparent
	setOpacity(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("setOpacity(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

var t; slideShowSpeed = 6000; j = 0; preLoad = new Array(); images = new Array()
function loadSlideShow(theSite) {
	switch(theSite) {
	case 'SAA':
		images[0] = 'http://stopaidsalliance.synkronvia.com/files/SAA/design/images/home-content-image.gif';
		images[1] = 'http://stopaidsalliance.synkronvia.com/files/SAA/design/images/home-content-image1.gif';
		images[2] = 'http://stopaidsalliance.synkronvia.com/files/SAA/design/images/home-content-image2.gif';
		images[3] = 'http://stopaidsalliance.synkronvia.com/files/SAA/design/images/home-content-image3.gif';
		images[4] = 'http://stopaidsalliance.synkronvia.com/files/SAA/design/images/home-content-image4.gif';
		images[5] = 'http://stopaidsalliance.synkronvia.com/files/SAA/design/images/home-content-image5.gif';
		break;
	
	}
	
	for (var i = 0; i < images.length; i++) {
		preLoad[i] = new Image()
		preLoad[i].src = images[i]
	}

	runSlideShow();
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}