$(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);
	});
	// FLV+SWF+SKIN+w+h+ID
	$("div.flashvid").each(function(i){
		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=8,0,0,0" width="'+a[3]+'" height="'+a[4]+'" id="'+a[5]+'"><param name="movie" value="'+a[1]+'" /><param name="salign" value="lt" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="FlashVars" value="&MM_ComponentVersion=1&skinName='+a[2]+'&streamName='+a[0]+'&autoPlay=true&autoRewind=false" /><embed src="'+a[1]+'" flashvars="&MM_ComponentVersion=1&skinName='+a[2]+'&streamName='+a[0]+'&autoPlay=true&autoRewind=false" quality="high" scale="noscale" width="'+a[3]+'" height="'+a[4]+'" name="'+a[5]+'" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" /></object>';
		$(this).html(str);
	});
	$("img.flashvidpic").click(function(){
		var id = "#" + $(this).attr("id") + "d";
		$(this).addClass("hide");
		$(id).removeClass("hide");
	});
	// 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").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"));}
	});
	$("a[href^=#]").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				var distance = Math.abs($(this).offset().top - targetOffset);
				$('html,body').animate({scrollTop: targetOffset}, 1000 + (distance / 5));
				return false;
			}
		} 
	}); 
	$("a[href$='.pdf'],a[href$='.doc']").attr('target','_blank');
});

var AdminDelete = function(id,title,folder) {
	var msg = "Are you sure you wish do delete the item named '"+title+"'? This action cannot be undone.";
	if (confirm(msg)) {window.location = "/admin/"+folder+"/Delete.asp?ID="+id;}
};
