$(document).ready(function(){ /// the DOM-ready thing covers the first four snippets

//================== manually and automatically designated internal and external links with icons
$(function(){
$('a[href^="http://"]').addClass('external').attr('target','_blank');
$('a[href^="https://"]').addClass('external').attr('target','_blank');
$('.external').attr('target','_blank');
$('a[href$=pdf]').addClass('pdfLink').attr('target','_blank');
$('a[href$=doc]').addClass('wordLink').attr('target','_blank');
});

// ================= Last list items of simple list within the text area to add a class of lastBullet
// Engage
//$(function(){
//$("ul.simple_list li:last").addClass("lastBullet");
//});








// http://andylangton.co.uk/jquery-show-hide
		var showText='More';
		var hideText='Less';
		// initialise the visibility check
		var is_visible = false;
		// append show/hide links to the element directly preceding the element with a class of "toggle"
		$('.toggle').prev().append(' <a href="#" class="toggleLink">'+showText+'<\/a>');
		$('.toggle').hide(); // hide all of the elements with a class of 'toggle'
		// capture clicks on the toggle links
		$('a.toggleLink').click(function() {
		// switch visibility
		is_visible = !is_visible;
		
		// change the link text depending on whether the element is shown or hidden
		if ($(this).text()==showText) {
		$(this).text(hideText);
		$(this).parent().next('.toggle').slideDown(1200);
		}
		else {
		$(this).text(showText);
		$(this).parent().next('.toggle').slideUp(700);
		//$('.toggle').css({'margin-Top':'230px','border':'1px solid green'});
		}
		return false;
		});
// ================= MULTI-CLASS FAQ Professional with up and down arrow but problem with p tag
// http://www.webdesignerwall.com/demo/jquery/accordion2.html
	$(".FAQContainer h3").eq(3).addClass("active");
	//$(".accordion2 p").eq(3).show();
	$(".FAQContainer h3").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
});
	
// ================= NICE SIMPLE FAQ MVJ adapted for DL list format
// http://www.learningjquery.com/2007/02/more-showing-more-hiding
//$(document).ready(function() {
	$('dl.faq:eq(0)> dd').hide();  
	$('dl.faq:eq(0)> dt').click(function() {
    $(this).next().slideToggle('slow');
	//$(this).next().slideToggle(800);  //make it really slow and easy!
	});
//  });

// ====================  Popupwindow plugin for jQuery by Tony Petruzzi
// homepage: http://rip747.wordpress.com
// plugin download: http://rip747.wordpress.com/2007/03/02/the-return-of-popupwindow-jquery-plugin
jQuery.fn.popupwindow = function(p)
{
	var profiles = p || {};
	return this.each(function(index){
		var settings, parameters, mysettings, b, a;
		// for overrideing the default settings
		mysettings = (jQuery(this).attr("rel") || "").split(",");
		settings = {
			height:600, // sets the height in pixels of the window.
			width:600, // sets the width in pixels of the window.
			toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			left:0, // left position when the window appears.
			top:0, // top position when the window appears.
			center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
			createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
		};

		// if mysettings length is 1 and not a value pair then assume it is a profile declaration
		// and see if the profile settings exists

		// if(mysettings.length == 1 && mysettings[0].split(":").length == 1)
//		{
//			a = mysettings[0];
//			// see if a profile has been defined
//			if(typeof profiles[a] != "undefined")
//			{
//				settings = jQuery.extend(settings, profiles[a]);
//			}
//		}
//		else
		{
			// overrides the settings with parameter passed in using the rel tag.
			for(var i=0; i < mysettings.length; i++)
			{
				b = mysettings[i].split(":");
				if(typeof settings[b[0]] != "undefined" && b.length == 2)
				{
					settings[b[0]] = b[1];
				}
			}
		}
		// center the window if the REL parameters aren't qualified
		if (settings.center == 1)
		{
			settings.top = (screen.height-(settings.height + 110))/2;
			settings.left = (screen.width-settings.width)/2;
		}
		
		parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
		
		jQuery(this).bind("click", function(){
			var name = settings.createnew ? "PopUpWindow" + index : "PopUpWindow";
			window.open(this.href, name, parameters).focus();
			return false;
		});
	});

};

//================= jQuery Scroll to Top Control SIMPLE, NO ABSOLUTELY POSITIONED GRAPHIC BUTTON BOTTOM RIGHT
//================= This also counts the paragraphs and assigns links as defined by eq(n)
//** http://www.electrictoolbox.com/jquery-scroll-top/ with add links to certain paragraphs added bits by MVJ
//** define the HTML string to insert	
//	$('<div class="BacktoTopCont"><a href="#top">Top</a></div>')
//	.insertAfter('div#contentTextArea p:eq(5), div#contentTextArea p:eq(6), div#contentTextArea p:eq(8)');
//** and now add the click function
	$('a[href*=#top]').click(function(){
	$('html, body').animate({scrollTop:0}, 1500);
	return false;
});
	
//================= jQuery Striped Tables, SIMPLE, NO SORT
//** http://15daysofjquery.com/examples/zebra/ AND http://15daysofjquery.com/examples/zebra/code/demoFinal.php
//** requires: stripeMeTables.css and lines 124-128 on global.js unremed.
	//$(".stripeMe tr:even").addClass("alt");
	//$(".stripeMe tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
	//$(".stripeMe th:first-child").addClass("FirstColumnHeader");
	//$(".stripeMe th:last-child").addClass("LastColumnHeader");
	//$(".stripeMe td:first-child").addClass("FirstColumnCell");




}); /// the DOM ready thing thats covers all the above snippets

<!--
function bookMark() {
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)){
window.external.AddFavorite (window.location,document.title);
}
else {
var msg = "Bookmark this page";
if(navigator.appName == "Netscape") msg += " (CTRL-D)";
alert(msg);
}
}
//End hiding from old browsers -->
