/*



Custom Functions

*/
window.onload = function(){
	init();
};
/*
	


This is the function that attached the Javascript functions to the page
*/
function init(){


	/*
	
	
	
	Makes Internet Explorer 6 render 32 bit PNGs properly
	*/
	IE_PNG_Hack("#head h1 img");
	/*
	
	
	
	Clear the email input on the Newsletter form
	*/
	$$("form.newsletter input[name=member_email]").each(function(node, i){

		node = $(node);

		AlreadyReset = false;
		
		node.onclick = function(){

			if (AlreadyReset != true){
				node.value = "";
				AlreadyReset = true;
			}

		};

	});




	/*
	
	
	
	Forms
	*/
		/*
		
		
		
		Focus on an input
		*/
		$$("form input").each(function(node, i){
			node = $(node);
			node.onfocus = node.onblur = function(){

				ToggleClassName(node, "focus");

			};
	
		});

	
}



/*

This function makes 32 bit PNG's with transparency work
*/	
function IE_PNG_Hack(selector){

	if (navigator.userAgent.indexOf("MSIE ") == -1){
		
		return false;
		
	} else {

		$$(selector).each(function(node, i){
					
			var node = $(node);
			
			if (node.src.indexOf("png") == -1) {
				
				/*node.runtimeStyle.filter = "";*/
				
				return;
			}
			
			var oldSrc = node.src;
			
			node.src = "interface/images/transparent.gif";
			
			node.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + oldSrc + "',sizingMethod='scale')";
			
		});
		
	}
	
}


function ToggleClassName(TCN_element, TCN_ClassName){
	node = $(TCN_element);
	if (node.hasClassName(TCN_ClassName)) {
		node.removeClassName(TCN_ClassName);
	} else {
		node.addClassName(TCN_ClassName);
	}
}
