function ValidateFields(form)
{
	for (var i=0; i < form.elements.length; i++)
	{
		var element = form.elements[i];
		if (element.name[0] == "*" && element.value == "")
		{
			alert("Please fill in all the items marked with an *");
			return false;
		}
	}	
	return true;
}

function EmbedFlashObject(movie, width, height)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" height="'+height+'" width="'+width+'">');
	document.write('<param name="movie" value="'+movie+'"><param name="quality" value="high"><param name="BGCOLOR" value="#FFFFFF">');
	document.write('<embed src="'+movie+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#FFFFFF" height="'+height+'" width="'+width+'">');
	document.write('</object>');
}

function BrowserDetect()
{
	var ua = navigator.userAgent.toLowerCase(); 
	this.isGecko   = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
	this.isSafari  = (ua.indexOf('safari') != - 1);
	this.isOpera   = (ua.indexOf('opera') != -1); 
	this.isIE      = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
	this.isMozilla = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
	this.isNS      = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
	this.isFirefox = (ua.indexOf('firefox') != - 1);
}

var browser = new BrowserDetect();
var slideshow_id = 0;

function SlideShow(width, height, images)
{
	this.current_image = 0;
	this.images = images;
	this.ie_anim1 = "ie_anim1"+slideshow_id;
	this.anim1 = "anim1"+slideshow_id;
	this.anim2 = "anim2"+slideshow_id;
	slideshow_id++;
	this.speed = 5000;
	
	for (var i=0; i<images.length; i++)
		document.write('<img src="'+images[i]+'" alt="" style="display:none;" />');

	document.write('<div class="slideshow" id="'+this.anim1+'" style="display:none;width:'+width+'px; height:'+height+'px; background-image: url('+images[0]+');"><div id="'+this.anim2+'" style="width:'+width+'px; height:'+height+'px;"></div></div>');
	document.write('<img id="'+this.ie_anim1+'" src="'+images[0]+'" style="display:none; filter:progid:DXImageTransform.Microsoft.Fade(Duration=1); width:'+width+'px; height:'+height+'px;" alt="" />');
		
	if (browser.isIE)
		document.getElementById(this.ie_anim1).style.display = "block";
	else
		document.getElementById(this.anim1).style.display = "block";
	
	var thisObject = this;
	window.setTimeout(function() { thisObject.nextImage() }, this.speed);
}

SlideShow.prototype.nextImage = function()
{

	var img1 = this.images[this.current_image];
	this.current_image ++;
	if (this.current_image >= this.images.length)
		this.current_image = 0;
	var img2 = this.images[this.current_image];
	if (browser.isIE)
	{
		var o = document.getElementById(this.ie_anim1);
		o.filters[0].apply();
		o.src = img2;
		o.filters[0].play();
		var thisObject = this;
		window.setTimeout(function() { thisObject.nextImage() }, this.speed);
	}
	else
	{
		var o1 = document.getElementById(this.anim1);
		var o2 = document.getElementById(this.anim2);
		o1.style.background = "url('"+img1+"')";
		o2.style.background = "url('"+img2+"')";
		this.fadeIn(this.anim2, 0);
	}
}

SlideShow.prototype.fadeIn = function(id, opacity)
{
	var thisObject = this;
	var o = document.getElementById(id);
	if (opacity <= 100)
	{
		setOpacity(o, opacity);
	}
	if (opacity < 100)
		window.setTimeout(function() { thisObject.fadeIn(id,opacity+4) }, 50);
	else
		window.setTimeout(function() { thisObject.nextImage() }, this.speed);
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	obj.style.KHTMLOpacity = opacity/100; // Safari<1.2, Konqueror
	obj.style.MozOpacity = opacity/100; // Older Mozilla and Firefox
	obj.style.opacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3
}

function showMovie(name) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="fullscreen" align="middle" height="255" width="320">');
	document.write('<param name="allowScriptAccess" value="sameDomain">');
	document.write('<param name="movie" value="movieplayer.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="salign" value="tl">');
	document.write('<param name="bgcolor" value="#000000">');
	document.write('<param name="FlashVars" value="vidpath='+name+'">');
	document.write('<embed src="movieplayer.swf" flashvars="vidpath='+name+'" quality="high" salign="tl" name="fullscreen" bgcolor="#000000" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" height="255" width="320">');
	document.write('</object>');
}


