//browser depreciation warning
if (!$buoop) {
	var $buoop = {
		vs:{i:10,f:15,o:12.1,s:4.1},
		c:2,
		reminder: 0,
		onshow: function(infos){
			//console.log('show');
			
			el = '<div id="outdated_browser" class="centertext can_embed_outdated_browser">'
				+ '<div id="outdated_browser_message">'
		        + '<h2 class="entry-title js-entry-title">It\'s Time For A Better Browser</h2>'
		        + '<p>We don\'t want to alarm you, but it looks like you\'re using an old browser. This page, along with much of the web, is optimized for the latest browsers. If you continue, this page may not work as expected.</p>'
		        + '<h3 class="outdated-title mt20">Upgrade or Try A New Browser</h2>'
		        + '<div id="browser_box_wrap" class="clearfix">'
		        + '<div class="browser_box chrome">'
		        + '<strong>Google Chrome</strong>'
		        + '<a href="http://google.com/chrome" class="outdated_link" target="_blank">Learn More</a>'
		        + '</div>'
		        + '<div class="browser_box firefox">'
		        + '<strong>Firefox</strong>'
		        + '<a href="http://firefox.com" class="outdated_link" target="_blank">Learn More</a>'
		        + '</div>'
		        + '<div class="browser_box ie">'
		        + '<strong>Internet Explorer</strong>'
		        + '<a href="http://windows.microsoft.com/ie" class="outdated_link" target="_blank">Learn More</a>'
		        + '</div>'
		        + '<div style="clear: both;"></div>'
		        + '</div>'
				+ '</div>'
				+ '</div>';
			
			tempdiv = document.createElement('div');
			tempdiv.innerHTML = el;
		
			document.getElementById("can-fundraising-area-adjunct-faculty-association-dues-donations").insertAdjacentHTML('beforebegin', el);
		},
		test: false
	};
	function $buo_f(){ 
	 var e = document.createElement("script"); 
	 e.src = "//browser-update.org/update.min.js"; 
	 document.body.appendChild(e);
	};
	try {document.addEventListener("DOMContentLoaded", $buo_f,false)}
	catch(e){window.attachEvent("onload", $buo_f)}
}

window.CANjs_fundraising_adjunct_faculty_association_dues_donations = {
	create_form: function () {
		var place = document.getElementById("can-fundraising-area-adjunct-faculty-association-dues-donations");
		if (place == null){
			var place = document.getElementById("can-fundraising-area");
		}
		
		function getURLParameter(name) {
		    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
		}
		
		var css = '';
		var referrer = 'robin-sowards';

		if (getURLParameter('source') != null) {
			var source = getURLParameter('source');
		} else {
			var source = 'widget';
		}

		if (getURLParameter('email_referrer') != null) {
			var email_referrer = getURLParameter('email_referrer');
		}
		
		if (getURLParameter('amount') != null) {
			var amount = getURLParameter('amount');
		}
		
		if (getURLParameter('recurring') != null) {
			var recurring = getURLParameter('recurring');
		}
		
		if (getURLParameter('period') != null) {
			var period = getURLParameter('period');
		}
		
		if (referrer) {
			place.innerHTML = "\n  <iframe src=\"https://actionnetwork.org/widgets/fundraising/adjunct-faculty-association-dues-donations\?css=" + css + "&referrer=" + referrer + "&source=" + source + "&email_referrer=" + email_referrer + "&amount=" + amount + "&recurring=" + recurring + "&period=" + period + '&redirect_url=' + encodeURIComponent(window.location.href) + "\" id=\"can_embed_iframe\" frameborder=\"0\" width=\"100%\" scrolling=\"no\"></iframe>";
		} else {
			place.innerHTML = "\n  <iframe src=\"https://actionnetwork.org/widgets/fundraising/adjunct-faculty-association-dues-donations\?css=" + css + "&source=" + source  + "&email_referrer=" + email_referrer + "&amount=" + amount + "&recurring=" + recurring + "&period=" + period + '&redirect_url=' + encodeURIComponent(window.location.href) + "\" id=\"can_embed_iframe\" frameborder=\"0\" width=\"100%\" scrolling=\"no\"></iframe>";
		}
		
		    
	}    
}

var canEmbedLoad_fundraising_adjunct_faculty_association_dues_donations = function() {
	CANjs_fundraising_adjunct_faculty_association_dues_donations.create_form();
	//jq_can.event.trigger('can_embed_loaded', [ '#can-fundraising-area-adjunct-faculty-association-dues-donations' ]);
	
	if (typeof CustomEvent === 'function') {
		  var event_id = new CustomEvent('can-fundraising-area-adjunct-faculty-association-dues-donations_loaded');
		  var event_generic = new CustomEvent('can_embed_loaded');
		} else {
		  var event_id = document.createEvent('CustomEvent');
		  var event_generic = document.createEvent('CustomEvent');
		  
		  event_id.initCustomEvent('can-fundraising-area-adjunct-faculty-association-dues-donations_loaded', true, true, {some: 'data'});
		  event_generic.initCustomEvent('can_embed_loaded', true, true, {some: 'data'});
		}
		
		document.getElementById('can-fundraising-area-adjunct-faculty-association-dues-donations').dispatchEvent(event_id);
		document.getElementById('can-fundraising-area-adjunct-faculty-association-dues-donations').dispatchEvent(event_generic);
	
	jq_can(document).ready(function($){
    	//canEmbed($);
    	
    	var iframe_message_received = false;
 	
     	//cross domain post message listener
     	function parent_event_listener(event){
     		//console.log(event.data);
     		
     		event_data = JSON.parse(event.data);
     		
     		//console.log(event_data);
     		
     		//change iframe height based on message from iframe
     		if (typeof(event_data.height) !== 'undefined') {
     			//console.log(event_data.height);
     			iframe_message_received = true;
         		$('#can_embed_iframe').height(parseInt(event_data.height));
     		}
		}
		
		if (window.addEventListener){
		  	addEventListener("message", parent_event_listener, false);
		} else {
		  	attachEvent("onmessage", parent_event_listener);
		}
		
		//console.log('change');
		//define cross domain messaging iframe
		var iframe = document.getElementById('can_embed_iframe').contentWindow;
		
		//poll the iframe until it's ready to send us back messages
		var iframe_poll = self.setInterval(function() {
			//get the iframe's height
			iframe.postMessage('get_height', $('#can_embed_iframe').attr('src'));
			
			if (iframe_message_received == true) {
				window.clearInterval(iframe_poll);
				
				//send parent css in stringified arrays
			 	parent_css_files = [];
			 	//console.log(document.styleSheets);
			 	/*
$('link[rel="stylesheet"]').each(function(i) {
			 		if ($(this).context.sheet.cssRules) {
						$.each($(this).context.sheet.cssRules, function(i, e) {
							parent_css_files.push(e.cssText);
		 				});
					} else if ($(this).context.sheet.rules) {
						$.each($(this).context.sheet.rules, function(i, e) {
							parent_css_files.push(e.cssText);
						});
					}
			 	});
*/
				
				$.each(document.styleSheets, function() {			
					//don't load stylesheets that are cross domain, because it breaks FF
					if (this.href) {
						var pathArray = this.href.split( '/' );
						var protocol = pathArray[0];
						var host = pathArray[2];
						var url = protocol + '//' + host;
					} else {
						var url = window.location.origin
					}
					
					//console.log(url);
					//console.log(window.location.origin);
					
					if ((url == window.location.origin) && (this.cssRules)) {
						//console.log('after each');
						$.each(this.cssRules, function(i, e) {
							parent_css_files.push(e.cssText);
		 				});
					} else if ((url == window.location.origin) && (this.rules)) {
						//console.log('after each');
						$.each(this.rules, function(i, e) {
							parent_css_files.push(e.cssText);
						});
					}
					//console.log('end each');
				});
				
				//console.log(parent_css_files);
			 	
			 	parent_css_files_message = {
			 		"css_files": parent_css_files.join(' ')
			 		//"css_files": "h2 { color:expression(alert('hello'), 0)"
			 	}
			 	
			 	//console.log(parent_css_files_message);
			 	
			 	/*
parent_css_tags = [];
			 	$('style').each(function() {
			 		parent_css_tags.push($(this).html());
			 	});
			 	
			 	var parent_css_tags_message = {
			 		"css_tags": parent_css_tags.join(' ')
			 		//css_tags: '</style><script>console.log("uhoh");</script>'
			 	}
*/
			 	
			 	//iframe.postMessage(JSON.stringify(parent_css_tags_message), $('#can_embed_iframe').attr('src'));
			 	iframe.postMessage(JSON.stringify(parent_css_files_message), $('#can_embed_iframe').attr('src'));
				
			}
		}, 500);
    });
}

if (typeof(can_embed_count) == 'undefined') {
	can_embed_count = 1;
	yepnope({
		load: ["https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"],
		complete: function() {
	    	yepnope({
		    	load: ["https://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js","https://actionnetwork.org/includes/js/jquery.placeholder.min.js","https://actionnetwork.org/includes/js/jquery.customSelect.min.js","https://actionnetwork.org/includes/js/can-embed.js?v=6"],
		    	complete: function() {
	             	jq_can = jQuery.noConflict( true ); //remove this and image load fails
	             	
	             	canEmbedLoad_fundraising_adjunct_faculty_association_dues_donations();
				}  
	    	});
		}    
	});
} else {
	can_jq_poll_fundraising_adjunct_faculty_association_dues_donations = self.setInterval(function() {
		if (typeof(jq_can) !== 'undefined') {
			canEmbedLoad_fundraising_adjunct_faculty_association_dues_donations();
		    
		    window.clearInterval(can_jq_poll_fundraising_adjunct_faculty_association_dues_donations);
		}
	}, 500);
}