/*
	This javascript(jquery plugin) is created by iindev.com (http://www.iindev.com)
	This is not a free software. Please do not resell or redistribute this code
	without prior permission of iindev.com
	
	This plugin is tested using with jquery version 1.3.2
-------------------------------------------------------------------------------
*/

(function($) {
$.fn.pngFix = function(settings) {

	// Settings
	settings = $.extend({
		blankgif: 'images/blank.gif'
	}, settings);

		//fix images with png-source
		$(this).find("img[src$=.png]").each(function() {

			$(this).attr('width',$(this).width());
			$(this).attr('height',$(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = ($(this).attr('id')) ? 'id="' + $(this).attr('id') + '" ' : '';
			var imgClass = ($(this).attr('class')) ? 'class="' + $(this).attr('class') + '" ' : '';
			var imgTitle = ($(this).attr('title')) ? 'title="' + $(this).attr('title') + '" ' : '';
			var imgAlt = ($(this).attr('alt')) ? 'alt="' + $(this).attr('alt') + '" ' : '';
			var imgAlign = ($(this).attr('align')) ? 'float:' + $(this).attr('align') + ';' : '';
			var imgHand = ($(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + $(this).width() + 'px;' + 'height:' + $(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + $(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + $(this).width() + 'px;' + 'height:' + $(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			$(this).hide();
			$(this).after(strNewHTML);

		});

		// fix css background pngs
		$(this).find("*").each(function(){
			var bgIMG = $(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				$(this).css('background-image', 'none');
				$(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});

		//fix input with png-source
		$(this).find("input[src$=.png]").each(function() {
			var bgIMG = $(this).attr('src');
			$(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		$(this).attr('src', settings.blankgif)
		});
	return $;
};
})($);

var aSpeed = 500;

$(function(){
	if ($.browser.msie && $.browser.version == 6) {
		var bottomVal;
		if($("#mainWrap").height() % 2 == 0) bottomVal = '-18px'
		else bottomVal = '-19px'
		$("#mainWrap > div.btmX").css({background:"url(images/ie6onlyImages/mWrapBtmX_4_IE6.png) repeat-x",bottom:bottomVal}).prependTo("#ie6")
		$("#mainWrap > div.rb").css({background:"url(images/ie6onlyImages/mWrapRB_4_IE6.png) repeat-x",bottom:bottomVal}).prependTo("#ie6")
		$("#mainWrap > div.lb").css({background:"url(images/ie6onlyImages/mWrapLB_4_IE6.png) repeat-x",bottom:bottomVal}).prependTo("#ie6")

		$(document).pngFix()
	}
	
	//if($("#eWpParty").find()) alert('political party h3 found')
	
	$("#filterByParty").css({opacity:0})
	$("#filterByFigure").css({opacity:0})
	
	$("#eWpParty").click(function(){
		
		if($("#filterByFigure").css("opacity") == 1){
			$("#filterByFigure").animate({opacity:0},aSpeed,function(){
				$(this).css({zIndex:1});
				$(this).css('visibility', 'hidden');
			})
			$("#eWpFigure").css({height:34})
		}
		if($("#filterByParty").css("opacity") == 1){
			$("#filterByParty").animate({opacity:0},aSpeed,function(){
				$(this).css({zIndex:1});
				$(this).css('visibility', 'hidden');
			})
			$("#eWpParty").css({height:34})
		}
		else{
			$("#filterByParty").css({zIndex:99})
			$("#filterByParty").css('visibility', 'visible');
			$("#filterByParty").animate({opacity:1},aSpeed);			
			$("#eWpParty").css({height:35})
		}
		
	})
		
	$("#eWpFigure").click(function(){
		
		if($("#filterByParty").css("opacity") == 1){
			$("#filterByParty").animate({opacity:0},aSpeed,function(){
				$(this).css({zIndex:1});
				$(this).css('visibility', 'hidden');
			})
			$("#eWpParty").css({height:34})
		}
		
		if($("#filterByFigure").css("opacity") == 1){
			$("#filterByFigure").animate({opacity:0},aSpeed,function(){
				$(this).css({zIndex:1});
				$(this).css('visibility', 'hidden');
			})
			$("#eWpFigure").css({height:34})
		}
		else{
			$("#filterByFigure").css({zIndex:99})
			$("#filterByFigure").css('visibility', 'visible');
			$("#filterByFigure").animate({opacity:1},aSpeed)
			
			$("#eWpFigure").css({height:35})
		}
		
	})
	
	$(".InfoDetails").hover(
		function(){ $(this).addClass("InfoD_hover")},
		function(){ $(this).removeClass("InfoD_hover")}
	)
})