/*----------------------------------------
CPHA Javascript
Last Updated By: Mitch Dunaway
Last Updated: June 2, 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
----------------------------------------*/


<!--
	/*
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
	
	function adjustModule() {
		if (!document.getElementById("maincontenttable")) return false;
		if (document.getElementById("maincontentsubcell")) return false;
		
		mainContent = document.getElementById("maincontenttable");
		mainContent.className = "module";
		
	}
	*/
	
	function changeCal() {
		if (!document.getElementsByTagName) return false;
		if (!document.getElementById) return false;
		
		var currentUrl = window.location.href;
		var eventUrl = "calendar.cfm";
		
		if (currentUrl.indexOf(eventUrl) != -1) {
			var contentMain = document.getElementById("maincontentcell");
			var calTables = contentMain.getElementsByTagName("table");    
			
			for (var i=0; i<calTables.length; i++) {
				if (calTables[i].getAttribute("border") == 1) {
						calTables[i].setAttribute("bordercolor","#fff");
						calTables[i].setAttribute("cellspacing","0");
						calTables[i].className = "calTable";
				}
			}
		}
		
	}
	
	//addLoadEvent(adjustModule);
	//addLoadEvent(changeCal);
//-->




var j = jQuery.noConflict();
j(document).ready(function($){
	
	
	
	
	
	// Adjust Calendar Styles
	changeCal();
	
	// Photoboxes
	$('#photobox ul').incMarketingBanner({
		showButtons: true,
		time: 9,
		showCaptions: true,
		captionEvent: 'change',
		captionEffect: 'slideIn' 
	});
	
	// Setup Region Map
    $('#region-map .region').addClass('active');
    $('#region-map .chapter').addClass('active');
    $('#region-map area').tooltip({
        effect:     "slide",
        position:   "top center",
        predelay:   500
    });
    
    // Search Widget
    $('body').append('<div id="search-widget"></div>');
    
    $('#search-widget').incSearchWidget({
    	buttonImage: "/associations/7884/imgs/btn-search.png",
    	hoverImage: "/associations/7884/imgs/btn-search-hover.png"
    }); 
    
    // Login Widget
	$('#login-widget').incLoginWidget({
		showLabels: false,
		showAutoLogout: false,
		showForgotUser: false,
		showForgotPass: false,
		buttonImage: "/associations/7884/imgs/btn-login.png",
    	hoverImage: "/associations/7884/imgs/btn-login-hover.png"
	});
	
	// Sponsor Box
    $('.sponsors').incSponsorBox({
        time: 6
    }); 
    
    // Header Banner
    $('#header-banner').incHeaderBanner({
        time: 6
    }); 

	// 360 Events Widget
    $('#events-widget').new360events({
        url: 'https://m360.cpha.com/calendar.aspx',
        items: 4,
        style: 'compact'
    }); 

	// Movin' Stuff Around (AKA DOM manipulation)
	$("#footertable").wrap("<div id='footerDiv' />");
	$("#structuraltable").after($("#footerDiv"));
	$("#search-form").append($("#search-field"));
	$("#footerDiv").append($("#powered_by"));

	// Clickable Logo
    $('body').addClickableLogo({
        name: 'California Pharmacists Association',
        url: 'http://www.cpha.com'
    });
    
    // Sliding Flyouts
    $('#navtop1, #navtop2').addSlidingFlyouts({ 
			speedDown: 0,
			speedUp: 0, 
			delay: 0
		});

	/*var time = 250;
	$(".chapter").css('opacity',0).addClass('active');
	$("area[shape='circle']").mouseover(
		function(){
			$('.chapter').hide();
			var d = $(this).attr('href');
			$(d).show().animate({ opacity: 1 }, time);
		}
	);
	$(".chapter").mouseout(
		function(){
			$(this).animate({ opacity: 0 }, time).hide();
		}
	);*/

});


