jQuery(document).ready(function(){
	//ie menu hover fix
	if (window.attachEvent) {jQuery("#nav li").hover(
		function(){jQuery(this).addClass("iehover");},
		function(){jQuery(this).removeClass("iehover");}
	);};
	//email functions
	jQuery("span.sendmail").each(function(iuy) {
		//	username+domain+com+[display}
		var aetr = jQuery(this).text().split("+");
		aetr[3] = aetr[3] || aetr[0]+"@"+aetr[1]+"."+aetr[2];
		jQuery(this).text("").html('<a href="mailto:'+aetr[0]+'@'+aetr[1]+'.'+aetr[2]+'">'+aetr[3]+'</a>');
	});
	//show hide div
	jQuery("div[id^='shd']").each(function(i) {jQuery(this).hide();});
	jQuery("a[id^='shd']").click(function(){
		var id = jQuery(this).attr("id");
		id = id + "d";
		jQuery("div[id^='shd']").not("#"+id).hide("fast");
		jQuery("#"+id).show("fast");
		return false;
	});
	//toggle div
	jQuery("div[id^='tog']").each(function(i) {jQuery(this).hide();});
	jQuery("a[id^='tog']").click(function(){
		var id = jQuery(this).attr("id");
		id = id + "d";
		jQuery("#"+id).toggle("fast");
		return false;
	});
	//flash movies
	jQuery("div.flashmov").each(function(i){
		// url+w+h
		var a = jQuery(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>';
		jQuery(this).html(str);
	});
	// FLV+SWF+SKIN+w+h+ID
	jQuery("div.flashvid").each(function(i){
		var a = jQuery(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>';
		jQuery(this).html(str);
	});
	jQuery("img.flashvidpic").click(function(){
		var id = "#" + jQuery(this).attr("id") + "d";
		jQuery(this).addClass("hide");
		jQuery(id).removeClass("hide");
	});
	// no label forms, with minimal no label validation
	jQuery("form.nolabel label").each(function(i){
		if (jQuery(this).attr("type") !== "radio" && jQuery(this).attr("type") !== "checkbox") {
			if (jQuery("#"+jQuery(this).attr("for")).val() !== null) {jQuery(this).css({'top':'-1000px','left':'-1000px'});}
			var that = jQuery(this).hide().css("cursor","text");
			var pos = jQuery("#"+jQuery(this).attr("for")).offset();
			pos.left += 5;
			jQuery(this).css({'position':'absolute','z-index':'30','top':pos.top+'px','left':pos.left+'px','color':'#000000;'}).show();
			jQuery("#"+jQuery(this).attr("for")).focus(function(){
				jQuery(that).css({'top':'-1000px','left':'-1000px'});
			}).blur(function(){
				if (jQuery(this).val() === "") {jQuery(that).css({'top':pos.top+'px','left':pos.left+'px'});}
			});
		}
	});
	//clear & replace text
	jQuery("input.crt").each(function(){
		if (jQuery(this).val()==="") {jQuery(this).val(jQuery(this).attr("title"));}
	}).focus(function(){
		if (jQuery(this).attr("title")===jQuery(this).val()) {jQuery(this).val("");}
		else {jQuery(this).val(jQuery(this).attr("title"));}
	}).blur(function(){
		if (jQuery(this).val()==="") {jQuery(this).val(jQuery(this).attr("title"));}
	});
	jQuery("a[href^=#]").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var jQuerytarget = jQuery(this.hash);
			jQuerytarget = jQuerytarget.length && jQuerytarget || jQuery('[name=' + this.hash.slice(1) +']');
			if (jQuerytarget.length) {
				var targetOffset = jQuerytarget.offset().top;
				var distance = Math.abs(jQuery(this).offset().top - targetOffset);
				jQuery('html,body').animate({scrollTop: targetOffset}, 1000 + (distance / 5));
				return false;
			}
		} 
	}); 
	jQuery("a[hrefjQuery='.pdf'],a[hrefjQuery='.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;}
};
