window.addEvent('domready', function() {
	var myMenu = new UvumiDropdown('Categories_Menu_0', {
		duration: 250, // Default is 250
		transition: Fx.Transitions.linear // Default is Fx.Transitions.linear
	});
	
	if ($('searchform')) {
		$('SearchSubmitButton').addEvent('click', function() {
			$('searchform').submit();
		});
	}
});

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/* Open XML connection */
function createXMLHttpRequest() {
	try{return new XMLHttpRequest();}
	catch(e){
		try { return new ActiveXObject('Msxml2.XMLHTTP'); }
		catch(e){
			try { return new ActiveXObject('Microsoft.XMLHTTP'); }
			catch(e){}
		}	
	}
	
	return null;
}

function ChangeMenuGraphics(strChange, strGraphic) {
	document.getElementById(strChange).src = strGraphic;
}

/* Use XML to contact the email page */
function SendEmail() {
	var xmlHttp = createXMLHttpRequest();
	xmlHttp.open('GET', '/contact/sendmail.asp?Name=' + document.getElementById('Name').value + '&Email=' + document.getElementById('Email').value + '&Message=' + document.getElementById('Message').value.replace(/\n/g, '<br />').replace(/\?/g,'*qu*').replace(/\&/g,'*am*').replace(/\=/g,'*eq*').replace(/\+/g,'*pl*'), false);
	xmlHttp.send(null);
	
	var myFunction = function(){
		var divFx = new Fx.Style('loadBar', 'opacity', {
			duration: 400, 
			transition: Fx.Transitions.quartInOut
		});
		
		divFx.start(0,1); // fade it in
	}
	
	document.getElementById('spaceHolder').style.display = 'none';
	
	myFunction(); // Fade the "Sending" text in and out
	
	if (xmlHttp.status == 200) {
		var myFunction2 = function(){
			var divFx = new Fx.Style('loadBar', 'opacity', {
				duration: 50, 
				transition: Fx.Transitions.quartInOut
			});
			
			var divFx2 = new Fx.Style('emailSuccess', 'opacity', {
				duration: 500, 
				transition: Fx.Transitions.quartInOut
			});
			
			divFx.start.pass([1,0], divFx).delay(0);
			
			document.getElementById('loadBar').style.display = 'none';
			document.getElementById('emailSuccess').style.display = '';
			
			divFx2.start(0,1); // fade it in
			divFx2.start.pass([1,0], divFx2).delay(5000); // and back out
		}
		
		myFunction2(); // Fade the "Success" text in and out
	} else {
		var myFunction2 = function(){
			var divFx = new Fx.Style('loadBar', 'opacity', {
				duration: 50, 
				transition: Fx.Transitions.quartInOut
			});
			
			var divFx2 = new Fx.Style('emailFailed', 'opacity', {
				duration: 500, 
				transition: Fx.Transitions.quartInOut
			});
			
			divFx.start.pass([1,0], divFx).delay(0);
			
			document.getElementById('loadBar').style.display = 'none';
			document.getElementById('emailFailed').style.display = '';
			
			divFx2.start(0,1); // fade it in
			divFx2.start.pass([1,0], divFx2).delay(5000); // and back out
		}
		
		myFunction2(); // Fade the "Failure" text in and out
	}
	
	return xmlHttp.responseText;
}

function DeleteConfirmation(varURL, varText) {
	var conf = confirm('Are you sure you wish to permanently delete this ' + varText + '?');
	
	if (conf) {
		location.replace(varURL);
	}
}
