function changeFontSize(val) {
	var oldFontSize = $('body').css('font-size');
	var newFontSize = parseInt(oldFontSize) + val;
	$('body').css('font-size', newFontSize+'px');
}

function focusSearchField(element) {
	if(element.value == 'Search the WSWS') {
		element.value = '';
	}
}

function blurSearchField(element) {
	if(element.value == '') {
		element.value = 'Search the WSWS';
	}
}

function openShareWindow(url,title) {
	var options = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=710,height=400';
	shareWindow = window.open(url,'shareWindow',options);
	shareWindow.focus();
}

function openPrintWindow(url) {
	var options = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=710,height=510';
	printWindow = window.open(url,'printWindow',options);
	printWindow.focus();
	// printWindow.print();
}

function initLanguages() {
	if ($('#language').length > 0) {
		$('#language').change(function(){
			var url = $('#language option:selected').attr('value');
			if (url != '#') {
				window.location.href = url;
			}
		});
	}
}

function initNavigation() {
	resetFirst = $('#navigation > ul > li > a.active');
	resetSecond = $('#navigation > ul > li > ul.active');
	resetThird = $('#navigation > ul > li > ul > li > a.active');
	$('#navigation > ul').hover(
		function(){
			void(0);
		},
		function(){
			$('#navigation > ul > li > a').removeClass('active');
			$('#navigation > ul > li > ul').removeClass('active');
			resetFirst.addClass('active');
			resetSecond.addClass('active');
			resetThird.addClass('active');
		}
	);
	$('#navigation > ul > li').hover(
		function(){
			$(this).siblings('li').children('a').removeClass('active');
			$(this).siblings('li').children('ul').removeClass('active');
			$(this).children('a').addClass('active');
			$(this).children('ul').addClass('active');
		},
		function(){
			$(this).children('a').removeClass('active');
			$(this).children('ul').removeClass('active');
			resetFirst.addClass('active');
			resetSecond.addClass('active');
			resetThird.addClass('active');
		}
	);
	$('#navigation > ul > li > ul > li').hover(
		function(){
			$(this).siblings('li').children('a').removeClass('active');
			$(this).siblings('li').children('ul').removeClass('active');
			$(this).children('a').addClass('active');
			$(this).children('ul').addClass('active');
		},
		function(){
			$(this).children('a').removeClass('active');
			$(this).children('ul').removeClass('active');
		}
	);
}

function initArticleTools() {
	if ($('#tools').length > 0) {
		if (!$('#content').is('.width72,.category')) {
	
		$('#tools > ul > li > a.print').attr('target','_blank');
		$('#tools > ul > li > a.print').attr('href',function(){
			var url = $(this).attr('href');
			url += '&amp;url='+encodeURIComponent(location.href);
			return url;
		});

		$('#tools > ul > li > a.print').parent().after('<li><a class="leaflet" href="http://intsse.com/wswspdf/">Leaflet</a></li>');
		$('#tools > ul > li > a.leaflet').attr('target','_blank');
		$('#tools > ul > li > a.leaflet').attr('href',function(){
			var url = location.href; 
			url = url.replace(/http(s)?:\/\/.*\articles\//i, 'articles/');
			url = url.replace(/.shtml/i, '.pdf');
			url = $(this).attr('href') + url;
			return url;
		});
		
		$('#tools > ul > li > a.email').attr('href',function(){
			var url = $(this).attr('href');
			url += '&url='+encodeURIComponent(window.location.href);
			url += '&title='+encodeURIComponent(document.title);
			return url;
		});
		
		$('#tools > ul > li > a.email').parent().remove();
		
		$('#tools > ul > li > a.feedback').attr('href',function(){
			var url = $(this).attr('href');
			url += '?url='+encodeURIComponent(window.location.href);
			url += '&title='+encodeURIComponent(document.title);
			return url;
		});
		
		$('#tools > ul > li > a.share').parent().remove();
		var newShareHtml = '<li>';
		newShareHtml += '<a class="share" href="#">Share &raquo;</a>';
		newShareHtml += '<ul>';
		newShareHtml += '<li class="noborder"><a class="share-facebook" rel="nofollow" href="http://facebook.com/" target="_blank">Facebook</a></li>';
		newShareHtml += '<li><a class="share-twitter" rel="nofollow" href="http://twitter.com/" target="_blank">Twitter</a></li>';
		newShareHtml += '<li><a class="share-digg" rel="nofollow" href="http://digg.com/" target="_blank">Digg</a></li>';
		newShareHtml += '<li><a class="share-reddit" rel="nofollow" href="http://reddit.com/" target="_blank">Reddit</a></li>';
		newShareHtml += '<li><a class="share-delicious" rel="nofollow" href="http://delicious.com/" target="_blank">Delicious</a></li>';
		newShareHtml += '<li><a class="share-stumble" rel="nofollow" href="http://stumbleupon.com/" target="_blank">StumbleUpon</a></li>';
		newShareHtml += '<li><a class="share-blogger" rel="nofollow" href="http://blogger.com/" target="_blank">Blogger</a></li>';
		newShareHtml += '<li><a class="share-email" rel="nofollow" href="/tools/index.php?page=sendlink" target="_blank">E-Mail</a></li>';
		newShareHtml += '</ul>';
		newShareHtml += '</li>';
		$(newShareHtml).insertAfter('#tools > ul > li:last');

		 $('#tools > ul > li > ul > li > a.share-facebook').attr('href',function(){
		 	var url = $(this).attr('href');
		 	url += 'sharer.php?u='+encodeURIComponent(location.href);
		 	url += '&amp;t='+encodeURIComponent(document.title);
		 	return url;
		 });
		 
		 $('#tools > ul > li > ul > li > a.share-twitter').attr('href',function(){
		 	var url = $(this).attr('href');
		 	/* old version (disabled on 7. June 2011 by FR)
		 	url += 'home?status='+encodeURIComponent(document.title)
		 	url += ': '+encodeURIComponent(location.href);
		 	*/
		 	/* new version (enabled on 7. June 2011 by FR) */
		 	url += 'share?original_referer='+encodeURIComponent(location.href);
		 	url += '&text='+encodeURIComponent(document.title);
		 	url += '&url='+encodeURIComponent(location.href);
		 	return url;
		 });
		 
		 $('#tools > ul > li > ul > li > a.share-digg').attr('href',function(){
		 	var url = $(this).attr('href');
		 	url += 'submit?phase=2&amp;bodytext=&amp;tags=';
		 	url += '&amp;url='+encodeURIComponent(location.href);
		 	url += '&amp;title='+encodeURIComponent(document.title);
		 	return url;
		 });
		 
		 $('#tools > ul > li > ul > li > a.share-reddit').attr('href',function(){
		 	var url = $(this).attr('href');
		 	url += 'submit?url='+encodeURIComponent(location.href);
		 	url += '&amp;title='+encodeURIComponent(document.title);
		 	return url;
		 });
		 
		 $('#tools > ul > li > ul > li > a.share-delicious').attr('href',function(){
		 	var url = $(this).attr('href');
		 	url += 'post?v=2&amp;notes=&amp;tags=';
		 	url += '&amp;url='+encodeURIComponent(location.href);
		 	url += '&amp;title='+encodeURIComponent(document.title);
		 	return url;
		 });
		 
		 $('#tools > ul > li > ul > li > a.share-stumble').attr('href',function(){
		 	var url = $(this).attr('href');
		 	url += 'submit?url='+location.href;
		 	url += '&title='+document.title;
		 	return url;
		 });
		 
		 $('#tools > ul > li > ul > li > a.share-blogger').attr('href',function(){
		 	var url = $(this).attr('href');
		 	url += 'blog_this.pyra?t';
		 	url += '&u='+encodeURIComponent(location.href);
		 	url += '&n='+encodeURIComponent(document.title);
		 	return url;
		 });
		 
		 $('#tools > ul > li > ul > li > a.share-email').attr('href',function(){
		 	var url = $(this).attr('href');
		 	url += '&url='+encodeURIComponent(window.location.href);
		 	url += '&title='+encodeURIComponent(document.title);
		 	return url;
		 });

		var newShareHtmlBottom = '';
		newShareHtmlBottom += '<div id="article-tools">';
		newShareHtmlBottom += '<p>Share this article:</p>';
		newShareHtmlBottom += '<ul>';
		newShareHtmlBottom += '<li><a class="facebook" rel="nofollow" href="http://facebook.com/" target="_blank">Facebook</a></li>';
		
		newShareHtmlBottom += '<li><a class="twitter" rel="nofollow" href="http://twitter.com/" target="_blank">Twitter</a></li>';
		newShareHtmlBottom += '<li><a class="digg" rel="nofollow" href="http://digg.com/" target="_blank">Digg</a></li>';
		newShareHtmlBottom += '<li><a class="reddit" rel="nofollow" href="http://reddit.com/" target="_blank">Reddit</a></li>';
		newShareHtmlBottom += '<li><a class="delicious" rel="nofollow" href="http://delicious.com/" target="_blank">Delicious</a></li>';
		newShareHtmlBottom += '<li><a class="stumble" rel="nofollow" href="http://stumbleupon.com/" target="_blank">StumbleUpon</a></li>';
		newShareHtmlBottom += '<li><a class="blogger" rel="nofollow" href="http://blogger.com/" target="_blank">Blogger</a></li>'
		newShareHtmlBottom += '<li><a class="email" rel="nofollow" href="/tools/index.php?page=sendlink" target="_blank">E-Mail</a></li>';
		newShareHtmlBottom += '</ul>';
		newShareHtmlBottom += '</div>';
		$(newShareHtmlBottom).appendTo('#content');

  	  	if ($('#article-tools').length > 0) {
  	  		
  	  		$('#article-tools > ul > li > a.facebook').attr('href',function(){
  	  			var url = $(this).attr('href');
  	  			url += 'sharer.php?u='+encodeURIComponent(location.href);
  	  			url += '&amp;t='+encodeURIComponent(document.title);
  	  			return url;
  	  		});
  	  		

  	  		$('#article-tools > ul > li > a.twitter').attr('href',function(){
  	  			var url = $(this).attr('href');
			 	/* old version (disabled on 7. June 2011 by FR)
			 	url += 'home?status='+encodeURIComponent(document.title)
			 	url += ': '+encodeURIComponent(location.href);
		 		*/
			 	/* new version (enabled on 7. June 2011 by FR) */
			 	url += 'share?original_referer='+encodeURIComponent(location.href);
			 	url += '&text='+encodeURIComponent(document.title);
		 		url += '&url='+encodeURIComponent(location.href);
  	  			return url;
  	  		});

		 	$('#article-tools > ul > li > a.digg').attr('href',function(){
		 		var url = $(this).attr('href');
		 		url += 'submit?phase=2&amp;bodytext=&amp;tags=';
		 		url += '&amp;url='+encodeURIComponent(location.href);
		 		url += '&amp;title='+encodeURIComponent(document.title);
		 		return url;
		 	});

  	  		$('#article-tools > ul > li > a.reddit').attr('href',function(){
  	  			var url = $(this).attr('href');
  	  			url += 'submit?url='+encodeURIComponent(location.href);
  	  			url += '&amp;title='+encodeURIComponent(document.title);
  	  			return url;
  	  		});
  	  	
  	  		$('#article-tools > ul > li > a.delicious').attr('href',function(){
  	  			var url = $(this).attr('href');
  	  			url += 'post?v=2&amp;notes=&amp;tags=';
  	  			url += '&amp;url='+encodeURIComponent(location.href);
  	  			url += '&amp;title='+encodeURIComponent(document.title);
  	  			return url;
  	  		});
  	  		
  	  		$('#article-tools > ul > li > a.stumble').attr('href',function(){
  	  			var url = $(this).attr('href');
  	  			url += 'submit?url='+location.href;
  	  			url += '&title='+document.title;
  	  			return url;
  	  		});
  	  		
  	  		$('#article-tools > ul > li > a.blogger').attr('href',function(){
  	  			var url = $(this).attr('href');
  	  			url += 'blog_this.pyra?t';
  	  			url += '&u='+encodeURIComponent(location.href);
  	  			url += '&n='+encodeURIComponent(document.title);
  	  			return url;
  	  		});
  	  		
  	  		$('#article-tools > ul > li > a.email').attr('href',function(){
			  var url = $(this).attr('href');
			  url += '&url='+encodeURIComponent(window.location.href);
			  url += '&title='+encodeURIComponent(document.title);
			  return url;
			});

		}

		}
		
		$('#tools > ul > li').hover(
			function(){
				if ($(this).children('ul').length > 0) {
					$(this).children('ul').addClass('active');
				}
			},
			function(){
				if ($(this).children('ul').length > 0) {
					$(this).children('ul').removeClass('active');
				}
			}
		);
		
	}
}

function initArchiveBox() {
	if ($('#archivebox').length > 0) {
		$('#archivebox').hover(
			function(){
				$(this).children('ul').addClass('active');
			},
			function(){
				$(this).children('ul').removeClass('active');
			}
		);
	}
}

function initMediaBox() {
	if ($('#mediabox').length > 0) {
		var mediaCount = $('#mediabox > div.stage > div.panel > a').length;
		var panelCount = Math.ceil(mediaCount/3);
		var panelWidth = $('#mediabox > div.stage > div.panel').width();
		$('#mediabox > div.stage').css('position','relative');
		$('#mediabox > div.stage').css('overflow','hidden');
		$('#mediabox > div.stage > div.panel').css('position','absolute');
		$('#mediabox > div.stage > div.panel').css('width',panelCount*panelWidth);
		// var panelHeight = $('#mediabox > div.stage > div.panel').height();
		// $('#mediabox > div.stage').height(panelHeight);
		
		$('#mediabox > div.pages > a').each(function(i){
			$(this).click(function(){
				var newLeft = -(i*panelWidth);
				$('#mediabox > div.stage > div.panel').animate({
					left: newLeft
				},500);
				$('#mediabox > div.pages > a').removeClass('active');
				$(this).addClass('active');
				return false;
			});
		});
	}
}

function initLangtabs() {
	if ($('#langtabs').length > 0) {
		$('#langtabs > ul.tabnav > li').hover(
			function(){
				if ($(this).attr('rel') != 'next' && $(this).attr('rel') != 'prev') {
					$(this).siblings('li').children('a').removeClass('active');
					$(this).siblings('li').children('ul').removeClass('active');
					$(this).children('a').addClass('active');
					$(this).children('ul').addClass('active');
				}
			},
			function(){
				void(0);
			}
		);
		$('#langtabs > ul.tabnav > li[rel=next] > a').click(function(){
			$(this).parent('li[rel=next]').parent('ul.tabnav').hide();
			$(this).parent('li[rel=next]').parent('ul.tabnav').next('ul.tabnav').show();
			return(false);
		});
		$('#langtabs > ul.tabnav > li[rel=prev] > a').click(function(){
			$(this).parent('li[rel=prev]').parent('ul.tabnav').hide();
			$(this).parent('li[rel=prev]').parent('ul.tabnav').prev('ul.tabnav').show();
			return(false);
		});
	}
}

function initLightbox() {
	if (!$('#content').is('.width72,.category')) {
		$('.lightbox').lightbox({fitToScreen: true});
	}
}

function initSidebarAccordion() {
	// contact us comment field
	$('#fm_comments.fmtextarea').focus(function(){
		if ($(this).val() == 'Enter your comments') {
	    	$(this).val('');
		}
	});
	$('.fmtextarea.sidebar').blur(function(){
		if ($(this).val() == '') {
	    	$(this).val('Enter your comments');
		}
	});
	
	// contact us email field	
	$('#fm_email.fmtext').focus(function(){
		if ($(this).val() == 'Email Address') {
	    	$(this).val('');
		}
	});
	$('#fm_email.fmtext').blur(function(){
		if ($(this).val() == '') {
	    	$(this).val('Email Address');
		}
	});
	
	// Newsletter email field	
	$('#newsletter_email').focus(function(){
		if ($(this).val() == 'Email Address') {
	    	$(this).val('');
		}
	});
	$('#newsletter_email.sidebar').blur(function(){
		if ($(this).val() == '') {
	    	$(this).val('Email Address');
		}
	});
	
}

function initBookAd() {
	if (!$('#content').is('.width72,.category')) {
		var category = $('meta[name=category]').attr('content');
		$.ajax({
			url: 'http://mehring.com/adpool/retrieve-ad.php?cats=' + category,
			dataType: 'jsonp',
			jsonp: 'jsonp',
			jsonpCallback: 'whatever',
			success: function(data) {
				var bookad = '';
				bookad += '<div id="bookad" class="infobox" style="display:none;">';
				bookad += '<h3>Mehring Books</h3>';
				bookad += '<p style="text-align:center; padding:0 5px; font-size:14px;">';
				bookad += '<a href="' + data.url_path + '"><strong>' + data.name + '</strong></a>';
				bookad += '</p>';
				bookad += '<p style="text-align:center; padding:0 5px;">';
				bookad += '<a href="' + data.url_path + '"><img src="' + data.image_url + '" alt="' + data.name + '" border="0" /></a>';
				bookad += '</p>';
				bookad += '<p style="text-align:center; padding:0 5px;">';
				bookad += 'By ' + data.author + '';
				bookad += '</p>';
				bookad += '</div>';
				$('#sidebar > .column:first').append(bookad);
				$('#bookad').fadeIn(500);
			}
		});
	}
}

function appendAppeal() {
	var html = '<p><b>The World Socialist Web Site needs your support!</b><br /><a href="/donate.shtml">Click here for a special message from US SEP Chairman David North &raquo;</a></p>';
	if (!$('#content').is('.width72,.category')) {
		$('#content').append('<div id="attention">' + html + '</div>');
	} else {
		if ($('#content').is('.width72')) {
			$('#content.width72').prepend('<div id="attention" style="margin:0 1em 2em 0; display:none;">' + html + '</div>');
			$('#attention').animate({opacity:1.0},1000).slideDown(1000);
		}
	}
}

function initFancybox() {
	$('head').append('<link rel="stylesheet" type="text/css" href="/js/fancybox-1.3.4/jquery.fancybox-1.3.4.css" media="screen" />');
	$.getScript('/js/fancybox-1.3.4/jquery.fancybox-1.3.4.pack.js', function(){
		$("a.fancybox").fancybox({'width': 550, 'height': 440, 'scrolling': 'no'});
    });
}

function switchStyles() {
	if (window.location.search != "") {
		var params = window.location.search;
		if (params.search(/style=white/) != -1) {
			$('head').append('<link rel="stylesheet" type="text/css" href="./css/sidebar_white.css" />');
		}
		if (params.search(/color=/) != -1) { 
			var color = '';
			if (params.search(/color=green/) != -1) {
				color = '#009900';
			} else if (params.search(/color=brown/) != -1) {
				color = '#AD532F';
			} else if (params.search(/color=pink/) != -1) {
				color = '#D1008B';
			} else if (params.search(/color=purple/) != -1) {
				color = '#8F1AB6';
			} else if (params.search(/color=orange/) != -1) {
				color = '#FF6600';
			}
			$('#content > .columnwidth34borderleft > .editorial').css('border-color',color);
			$('#content > .columnwidth34borderleft > .editorial > h3').css('background-color',color);
			$("#sidebar > .column > .special > h3[rel='color']").css('background-color',color);
		}
	}
}

$(document).ready(function(){
	initLanguages();
	initNavigation();
	initArticleTools();
	initArchiveBox();
	initMediaBox();
	initLangtabs();
	initLightbox();
	initFancybox();
	//appendAppeal();
	initSidebarAccordion();
	initBookAd();
});



/*Variable for opening random sidebar panels */  
	var rand_no = Math.floor((3+1)*Math.random()) + 0;


/*Script for Expanding 'more meetings' */
  $(document).ready(function(){
  	  $("#morelink").show()
	  $("#extrameetings").hide()
      $("#moremeetings").hover(function(){
      $("#morelink").hide();
      $("#extrameetings").show({ 
      } );
      return false;
      });
  });


/*Script for animating the sidebar */
  $(document).ready(function(){
    $("#accordion").accordion({
      event: 'click',
      active: rand_no,
      collapsible: true,
      autoHeight: false
    });
    $("#accordion > h3").focus(function () {
      $(this).blur();
    });
  });
  



/*Contact form active highlighting - currently disabled*/
/*
		$(document).ready(function()
		{
			$('input').focus(function(){
				$(this).parents('span').addClass("over");
			}).blur(function(){
				$(this).parents('span').removeClass("over");
			});
		});
*/



// Function for appending pdf generation to article tools

/*
  	$(document).ready(function(){
  		var template = $('meta[name=template]').attr("content")
  		if( template == "post.htm") {
  			var appendpdf = '<li id="pdfversion"><a id="pdfversion" class="PDF" href="#">PDF</a></li>'
			$("ul.tools").append(appendpdf);  	  	
  		}  	
  	});
*/


// Function for opening  new window with print version
$(function(){
	var curdocurl = window.location;
    $('a#pdfversion').click(function(){
        window.open("http://intsse.com/rss-to-pdf/makepdf_modded.php?url=" + curdocurl);
        return false;
    });
});


// Function for This Week in History tabs

  $(document).ready(function(){
    $("#thisweekinhistory").tabs({event: 'click', fx:{opacity: 'toggle'}})
    .tabs('select', rand_no);
  });
  


// Function for Mehring rotating sidebar ads
function rotating_sidebar_mehring(){
 var rotatingimages=new Array()



 rotatingimages[1]="/images/sidebar2/rotating/2011-holiday-sale.png"  
 rotatingimages[2]="/images/sidebar2/rotating/2011-holidaysalerotation-SecFI.png"  
 rotatingimages[3]="/images/sidebar2/rotating/2011-holidaysalerotation-SelLT.png"  
 rotatingimages[4]="/images/sidebar2/rotating/2011-holiday-sale.png"   
 
  var imagelinks=new Array()


 imagelinks[1]="/articles/2011/dec2011/mehr-d01.shtml" 
 imagelinks[2]="http://www.mehring.com/index.php/sale-bundle-security-and-the-fourth-international.html"  
 imagelinks[3]="http://www.mehring.com/index.php/bundle-trotsky-1.html?___SID=U"  
 imagelinks[4]="http://www.mehring.com"
 

// rotatingimages[1]="/images/sidebar2/rotating/Pers-TasksAd2.png"
// rotatingimages[2]="/images/sidebar2/rotating/Coup.png" 
// rotatingimages[3]="/images/sidebar2/rotating/RedStar.png" 
// rotatingimages[4]="/images/sidebar2/rotating/Bols-to-Power2.png"
// rotatingimages[5]="/images/sidebar2/rotating/VoronskyAd.png" 
// rotatingimages[6]="/images/sidebar2/rotating/IDLT-new.png"
// rotatingimages[7]="/images/sidebar2/rotating/IDLT-new.png"
// var imagelinks=new Array()

// imagelinks[1]="http://mehring.com/index.php/the-crisis-of-the-world-capitalist-system-the-perspectives-and-tasks-of-the-socialist-equality-party-2008-2010.html"
// imagelinks[2]="/articles/2010/aug2010/coup-a18.shtml"
// imagelinks[3]="http://mehring.com/index.php/red-star-over-russia.html" 
// imagelinks[4]="http://mehring.com/index.php/the-bolsheviks-come-to-power-the-revolution-of-1917-in-petrograd.html"  
// imagelinks[5]="http://mehring.com/index.php/art-as-the-cognition-of-life.html"   
// imagelinks[6]="http://mehring.com/index.php/in-defense-of-leon-trotsky.html"  
// imagelinks[7]="http://mehring.com/index.php/in-defense-of-leon-trotsky.html"  
 
 
 var ry=Math.floor(Math.random()*rotatingimages.length)
 if (ry==0)
    ry=1
    document.write('<h3 style="">Mehring Books</h3><div id="mehringad"><a href='+'"'+imagelinks[ry]+'"'+'><div id="mehringimage" style=""><img src="'+rotatingimages[ry]+'" border=0></div></a></div>')
}

// Function for SEP Announcements
function rotating_sidebar_announcements_party(){
 var rotatingimages2=new Array()
 rotatingimages2[1]="/images/2011feb/CAUS.png"
/*  rotatingimages2[3]="/images/sidebar/gulf_videos.jpg" */

 var imagelinks2=new Array()
 imagelinks2[1]="http://stopshutoffs.org" 
/*  imagelinks2[3]="/articles/2010/jun2010/vide-j29.shtml" */

 
 var ry=Math.floor(Math.random()*rotatingimages2.length)
 if (ry==0)
    ry=1
    document.write('<div id="mehringad"><a href='+'"'+imagelinks2[ry]+'"'+'><div id="mehringimage" style=""><img src="'+rotatingimages2[ry]+'" border=0></div></a></div>')
}




/*
function rotating_sidebar(){
 var rotatingimages=new Array()
 
 rotatingimages[1]="/images/sidebar2/rotating/SpringSaleExt.png"
 rotatingimages[2]="/images/sidebar2/rotating/AustHIFSEPad.png"
 rotatingimages[3]="/images/sidebar/caus_ad.jpg"
 rotatingimages[4]="/images/2010may/200pixel-ad.jpg"
  
 var imagelinks=new Array()
 imagelinks[1]="http://mehring.com/sale"
 imagelinks[2]="http://mehring.com/the-historical-and-international-foundations-of-the-sep-australia.html"
 imagelinks[3]="http://socialequality.com/caus"
 imagelinks[4]="http://wsws.org/articles/2010/may2010/conf-m21.shtml"
 
 var ry=Math.floor(Math.random()*rotatingimages.length)
 if (ry==0)
    ry=1
    document.write('<h3 style="">Announcements</h3><div id="mehringad"><a href='+'"'+imagelinks[ry]+'"'+'><div id="mehringimage" style=""><img src="'+rotatingimages[ry]+'" border=0></div></a></div>')
}
*/


  
$(document).ready(function(){
$("#isse_meetings").load("/inc/isse_meetings_auto.inc", null, function() {
   $("#extrameetings").hide()
     	  $("#morelink").show()
	  $("#extrameetings").hide()
	  $("#see_full_meetings_div").hide()
	  
	  
	  
      $("#moremeetings").hover(function(){
      $("#morelink").hide();
      $("#see_full_meetings_div").show()

      $("#extrameetings").show({ 
      } );
      return false;
      });
});
  });

  
/* Cookie script used in fund appeal */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


/* Fund Appeal Script */
  $(document).ready(function(){
	$("#fundingad").click(function () { 
    document.location.href = "/appeal/appeal.shtml"; 
    });
    });

  

/* Fund Appeal Sidebar Ad */
 $(document).ready(function() {
var title = document.title;
    $("#sidebar_fundappeal").click(function () { 
    document.location.href = "/appeal/appeal.shtml"; 
    });
 });

