$(document).ready(function(){
	//ie menu hover fix
	if (window.attachEvent) {$("#nav li").hover(
		function(){$(this).addClass("iehover");},
		function(){$(this).removeClass("iehover");}
	);};
	//email functions
	$("span.sendmail").each(function(i) {
		//	username+domain+com+[display}
		var a = $(this).text().split("+");
		a[3] = a[3] || a[0]+"@"+a[1]+"."+a[2];
		$(this).text("").html('<a href="mailto:'+a[0]+'@'+a[1]+'.'+a[2]+'">'+a[3]+'</a>');
	});
	//show hide div
	$("div[id^='shd']").each(function(i) {$(this).hide();});
	$("a[id^='shd']").click(function(){
		var id = $(this).attr("id");
		id = id + "d";
		$("div[id^='shd']").not("#"+id).hide("fast");
		$("#"+id).show("fast");
		return false;
	});
	//toggle div
	$("div[id^='tog']").each(function(i) {$(this).hide();});
	$("a[id^='tog']").click(function(){
		var id = $(this).attr("id");
		id = id + "d";
		$("#"+id).toggle("fast");
		return false;
	});
	//flash movies
	$("div.flashmov").each(function(i){
		// url+w+h
		var a = $(this).text().split("+"); 
		var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+a[1]+'" height="'+a[2]+'"><param name="movie" value="'+a[0]+'"> <param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+a[0]+'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+a[1]+'" height="'+a[2]+'"></embed></object>';
		$(this).html(str);
	});
	// no label forms, with minimal no label validation
	$("form.nolabel label").each(function(i){
		if ($(this).attr("type") !== "radio" && $(this).attr("type") !== "checkbox") {
			if ($("#"+$(this).attr("for")).val() !== null) {$(this).css({'top':'-1000px','left':'-1000px'});}
			var that = $(this).hide().css("cursor","text");
			var pos = $("#"+$(this).attr("for")).offset();
			pos.left += 5;
			$(this).css({'position':'absolute','z-index':'30','top':pos.top+'px','left':pos.left+'px','color':'#000000;'}).show();
			$("#"+$(this).attr("for")).focus(function(){
				$(that).css({'top':'-1000px','left':'-1000px'});
			}).blur(function(){
				if ($(this).val() === "") {$(that).css({'top':pos.top+'px','left':pos.left+'px'});}
			});
		}
	});
	//clear & replace text
	$("input.crt, textarea.crt").each(function(){
		if ($(this).val()==="") {$(this).val($(this).attr("title"));}
	}).focus(function(){
		if ($(this).attr("title")===$(this).val()) {$(this).val("");}
		else {$(this).val($(this).attr("title"));}
	}).blur(function(){
		if ($(this).val()==="") {$(this).val($(this).attr("title"));}
	});
	//form validation
	$("form.validation input[type='submit']").click(function(){
		$("#validationmessage").html("");
		if (formFields && formFields.length && formFields.length > 0) {
			var isValid = true;
			for (var i=0; i<formFields.length; i+=1){
				if (formFields[i]) {if (!validate(formFields[i])) {isValid = false;}}
			}
			return (isValid ? isValid : false);
		} else {return true;}
	});
});