/*----------------------------------------
HHCAM Javascript
Author: Marcus Ellis
Last Updated: October 28, 2011
(c) 2011 Affiniscape, Inc.
All Rights Reserved. This JavaScript file must not be reproduced without the express written permission of Affiniscape, Inc.
For questions regarding licensing or setup please contact Affiniscape, projects @ affiniscape dot com
----------------------------------------*/

var j = jQuery.noConflict();
j(document).ready(function($){
	
	// Vendor Search
	var vendor = '<table width="100%"><tbody><tr><td width="50%"><h1>Allied &amp; Preferred Vendors</h1></td><td align="right"><a href="http://www.thinkhomecare.org/">Home</a>&nbsp;&gt; Join the Alliance</td></tr></tbody></table><table width="100%" cols="5" border="0"><tbody><tr><td width="133" align="center"><a href="https://m360.thinkhomecare.org/frontend/search.aspx?cs=66" onMouseOver="document.consulting.src=\'/associations/1892/files/Allied-Consulting-Rollover.png\'" onMouseOut="document.consulting.src=\'/associations/1892/files/Allied-Consulting.png\'"><img width="125" height="125" alt="" border="0" src="/associations/1892/files/Allied-Consulting.png" name="consulting" /></a></td><td width="133" align="center"><a href="https://m360.thinkhomecare.org/frontend/search.aspx?cs=68" onMouseOver="document.finance.src=\'/associations/1892/files/Allied-Financial-Insurance-Rollover.png\'" onMouseOut="document.finance.src=\'/associations/1892/files/Allied-Financial-Insurance.png\'"><img width="125" height="125" alt="" border="0" src="/associations/1892/files/Allied-Financial-Insurance.png" name="finance" /></a></td><td width="133" align="center"><a href="https://m360.thinkhomecare.org/frontend/search.aspx?cs=69" onMouseOver="document.legal.src=\'/associations/1892/files/Allied-Legal-Rollover.png\'" onMouseOut="document.legal.src=\'/associations/1892/files/Allied-Legal.png\'"><img width="125" height="125" alt="" border="0" src="/associations/1892/files/Allied-Legal.png" name="legal" /></a></td><td width="133" align="center"><a href="https://m360.thinkhomecare.org/frontend/search.aspx?cs=70" onMouseOver="document.supplies.src=\'/associations/1892/files/Allied-Office-Med-Rollover.png\'" onMouseOut="document.supplies.src=\'/associations/1892/files/Allied-Office-Med.png\'"><img width="125" height="125" alt="" border="0" src="/associations/1892/files/Allied-Office-Med.png" name="supplies" /></a></td><td width="133" align="center"><a href="https://m360.thinkhomecare.org/frontend/search.aspx?cs=71" onMouseOver="document.telecomm.src=\'/associations/1892/files/Allied-Telecommun-Rollover.png\'" onMouseOut="document.telecomm.src=\'/associations/1892/files/Allied-Telecommun.png\'"><img width="125" height="125" alt="" border="0" src="/associations/1892/files/Allied-Telecommun.png" name="telecomm" /></a></td></tr></tbody></table><p>One of the best benefits of Alliance membership is access to our Allied members &amp; Preferred Vendor programs.&nbsp; Select one of the categories above to narrow your seach for companies that support the Alliance and/or offer special programs to our members.</p>';
	$('#aspnetForm[action*="cs=66"], #aspnetForm[action*="cs=68"], #aspnetForm[action*="cs=69"], #aspnetForm[action*="cs=70"], #aspnetForm[action*="cs=71"], #aspnetForm[action*="cs=2594"]').prepend(vendor);

	// Accreditation Search
	var accred = '<table width="100%" border="0"><tbody><tr><td>&nbsp;</td><td align="right"><a href="http://www.thinkhomecare.org/">Home</a>&nbsp;&gt; <a href="http://www.thinkhomecare.org/accreditation/">Agency Accreditation</a> &gt; List of Accred. Agencies</td></tr></tbody></table><table cellspacing="0" cellpadding="0" border="0" id="accreditation"><tbody><tr><td colspan="5"><a href="http://www.thinkhomecare.org/accreditation/"><img height="159" border="0" width="770" src="/associations/1892/files/Accreditation-Logo-3_01.png" alt="" /></a></td></tr><tr><td rowspan="2"><a href="http://www.thinkhomecare.org/accreditation"><img height="41" border="0" width="217" src="/associations/1892/files/Accreditation-Logo-3_02.png" alt="" /></a></td><td><a class="button" href="http://www.thinkhomecare.org/displaycommon.cfm?an=1&amp;subarticlenbr=168" id="accredQandA" style="background-image: url(/associations/1892/files/Accred-Q-and-A-over.png);"><img height="30" border="0" width="159" src="/associations/1892/files/Accred-Q-and-A.png" alt="" /></a></td><td><a class="button" href="https://m360.thinkhomecare.org/frontend/search.aspx?cs=1400" id="listofAccredAgencies" style="background-image: url(/associations/1892/files/List-of-Accred-Agencies-over.png);"><img height="30" border="0" width="210" src="/associations/1892/files/List-of-Accred-Agencies.png" alt="" /></a></td><td><a class="button" href="http://www.thinkhomecare.org/displaycommon.cfm?an=1&amp;subarticlenbr=169" id="accredApplication" style="background-image: url(/associations/1892/files/Accred-Application-over.png);"><img height="30" border="0" width="176" src="/associations/1892/files/Accred-Application.png" alt="" /></a></td><td rowspan="2"><img height="41" width="8" src="/associations/1892/files/Accreditation-Logo-3_06.png" alt="" /></td></tr><tr><td colspan="3"><img height="11" width="545" src="/associations/1892/files/Accreditation-Logo-3_07.png" alt="" /></td></tr></tbody></table><p>&nbsp;</p>';
	$('#aspnetForm[action*="cs=1400"]').prepend(accred);
	
	// Accreditation Hovers
	$('#accreditation .button').hover(function(){
		$('img',this).css('visibility','hidden');
	},function(){
		$('img',this).css('visibility','visible');
	});

	// Tabbed Content
	var a = $('.selected').attr('href');	
	$(a).show();	
	$('#tab-menu a').click(function(e){
		e.preventDefault();	
		$('#tabs-widget > div').hide();
		$('.selected').removeClass('selected');
		$(this).addClass('selected');
		var tabID = $(this).attr('href');
		$(tabID).show();		
	});
	
	
	// Find an Agency Map
	if ($('#areaMap').length) {
		var mapHovers = new Array();
			mapHovers[0] = "/associations/1892/files/images/Areamap-Barnstable.png";
			mapHovers[1] = "/associations/1892/files/images/Areamap-Dukes.png";
			mapHovers[2] = "/associations/1892/files/images/Areamap-Nantucket.png";
			mapHovers[3] = "/associations/1892/files/images/Areamap-Bristol.png";
			mapHovers[4] = "/associations/1892/files/images/Areamap-Plymouth.png";
			mapHovers[5] = "/associations/1892/files/images/Areamap-Norfolk.png";
			mapHovers[6] = "/associations/1892/files/images/Areamap-Suffolk.png";
			mapHovers[7] = "/associations/1892/files/images/Areamap-Middlesex.png";
			mapHovers[8] = "/associations/1892/files/images/Areamap-Essex.png";
			mapHovers[9] = "/associations/1892/files/images/Areamap-Worcester.png";
			mapHovers[10] = "/associations/1892/files/images/Areamap-Hampden.png";
			mapHovers[11] = "/associations/1892/files/images/Areamap-Hampshire.png";
			mapHovers[12] = "/associations/1892/files/images/Areamap-Franklin.png";
			mapHovers[13] = "/associations/1892/files/images/Areamap-Berkshire.png";
		preloadImages(mapHovers);
	}
	$('#areaMap area').hover(function(){
		$('#areamapImage').attr('src','/associations/1892/files/images/Areamap-'+ $(this).attr('alt') +'.png');
	},function(){
		$('#areamapImage').attr('src','/associations/1892/files/images/Areamap.png');
	});

	// Featured Jobs
	$('#jobs-widget').incFeaturedJobs({
		url: 'hcare.ma.associationcareernetwork.com',
		ccID: 'HCARE.MA',
		items: 7,
		showDescription: true
	});
	
	// 360 Events
	$('#events-widget').new360events({
		url: 'https://m360.thinkhomecare.org/calendar.aspx',
		style: 'compact',
		showDesc: true
	
	});
	
	// Preload Home Page Buttons 
	if ($('#landing').length > 0) {
		var btnHovers = [ '/associations/1892/imgs/imgbtn-accred-h.jpg',
			'/associations/1892/imgs/imgbtn-advo-h.jpg',
			'/associations/1892/imgs/imgbtn-careers-h.jpg',
			'/associations/1892/imgs/imgbtn-develop-h.jpg',
			'/associations/1892/imgs/imgbtn-map-h.png',
			'/associations/1892/imgs/imgbtn-regulatory-h.jpg'];
		preloadImages(btnHovers);
	}
	
	// Feed Widgets
	$('#feed-widget-home').incFeedWidget({
		url: 'http://thinkhomecare.wordpress.com/feed/',
		items: 7,
		showDate: true,
		showTime: true,
		dateFormat: 'full'
	});
	$('#feed-widget-advocacy').incFeedWidget({
		url: 'http://thinkhomecare.wordpress.com/feed/?cat=5967',
		items: 7,
		showDate: true,
		showTime: true,
		dateFormat: 'full'
	});
	$('#feed-widget-medicare').incFeedWidget({
		url: 'http://thinkhomecare.wordpress.com/tag/medicare/feed/',
		items: 7,
		showDate: true,
		showTime: true,
		dateFormat: 'full'
	});

	// Flyouts
	$('#navtop1,#navtop2').addSlidingFlyouts({
		speedDown: 200,
		speedUp: 100
	});
	
	// Clickable Logo
	$('body').addClickableLogo({
		name: 'Home Care Alliance of Massachusetts, Inc.',
		url: 'http://www.thinkhomecare.org/'
	});
	
});


// Simple Image Preload Function
function preloadImages(preload){
	var imgs = [];
	for (var i=0; i<preload.length;i++){
		imgs[i] = new Image();
		imgs[i].src = preload[i];
	}
}

// Load Flash Sponsor Box
function incSponsor() {
   var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="840" height="112">';
      str += '<param name="movie" value="/associations/1892/swfs/HHCAM-ads.swf" />';
      str += '<param name="quality" value="high" />';
      str += '<param name="wmode" value="transparent" />';
      str += '<embed src="/associations/1892/swfs/HHCAM-ads.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="840" height="112" wmode="transparent"></embed>';
      str += '</object>';
   
   document.write(str);
}

