//------------------------------------
//	SCRIPTS.JS
//	Author: 	IterMedia
//	Requires:	jquery 1.3.2
//------------------------------------

$(document).ready(function() {
	
	((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? (ie6=true) : (ie6=false);
	
	$('#cnt-press .content, #cnt-campaign-press .content').jScrollPane({scrollbarWidth: 15});
	
	setLayout();
	
	$(window).resize(function(){
		setLayout();
		$('.prod').resizeProduct();
	});
	
	$('#store a').hover(function() {
		$('.on', $(this)).fadeIn('fast');
	}, function() {
		$('.on', $(this)).fadeOut('fast');
	});
	
	$('#press-close a').click(function(e) {
		press.close('hp');
	});
	
	$('#campaign-press-close a').click(function(e) {
		cmp_press.close('hp');
	});
	
	if($.browser.webkit) {
		$('img.bg').each(function() {
			$(this).parent().append('<div class="over"></div>'); //avoid selecting and dragging of background images in Safari
		});
	}
	
	loadXML();
});


function setLayout(){
	h_wp=$(window).height()-29;
	w_wp=$(window).width();
	var bg_left = 0;
	
	$('#layout').height(h_wp);

	//resize bg image
	if( (w_wp / bg_imgratio) < h_wp ) {
		var bg_height = h_wp;
		var bg_width = bg_height * bg_imgratio;
		var bg_left = -(bg_width - w_wp) / 2;
	}
	else {
		var bg_width = w_wp;
		var bg_height = ( w_wp / bg_imgratio );
	}
	
	//position press content
	var press_lft = ( w_wp - 410 ) / 2;
	var press_top = ( h_wp - 400 ) / 2;
	
	//position campaign press content
	var cmppress_lft = ( w_wp - 890 ) / 2;
	
	//resize campaign image, if exists
	if($('.imgHolder img').length) {
		type = $('.imgHolder img').attr('class');
		imgPos = campaign.getImagePosition(type);
		$('.imgHolder img').css({height: imgPos['img_h'], width:imgPos['img_w'], left:imgPos['img_l'], top:imgPos['img_t']});
	}
	
	//position video
	$('.videoWrapper:visible').css({top: (h_wp - $('.videoWrapper:visible').height()) / 2, left: (w_wp - $('.videoWrapper:visible').width()) / 2})
			
	$('.bg').css({width: bg_width, height: bg_height, left: bg_left });
	$('#cnt-press .outWrapper').css({left: press_lft, top: press_top });
	$('#cnt-campaign-press .container').css({left: cmppress_lft, top: press_top });
	$('#panel').css({ width: w_wp - (97*2), height: h_wp });
	$('#footer').css({top:h_wp, visibility:'visible'});
};

function MM_showHideLayers() { 
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

var menu = {
	listen : function() {
		$('#menu li a').not('#campaign').click(function(e) {
			
			if($(this).attr('class') == curPage) return;
			
			if(!$(this).parent().hasClass('selected')) {
				e.preventDefault();
				$('#menu li').removeClass('selected');
				$(this).parent().addClass('selected');
				
				//add selected class to 1st level li
				if($(this).parent().parent().parent().is('li')) {
					$(this).parent().parent().parent().addClass('selected');
					$(this).parent().parent().fadeOut('fast');
				}
				
				var goTo = $(this).attr('class'); 
				switch(curPage) {
					case('hp'):
						hp.close(goTo);
						break;
					case('campaign'):
						campaign.close(goTo);
						break;
					case('press'):
						press.close(goTo);
						break;
					case('backstage'):
						backstage.close(goTo);
						break;
					case('video'):
						video.close(goTo);
						break;
					case('cmp_press'):
						cmp_press.close(goTo);
						break;
					case('products'):
						products.close(goTo);
						break;
					}
				}
		});
		$('#logo').click(function(e) {
			if(curPage != 'hp') {
				e.preventDefault();
				$('#menu li').removeClass('active');
				switch(curPage) {
					case('campaign'):
						campaign.close('hp');
						break;
					case('press'):
						press.close('hp');
						break;
					case('video'):
						video.close('hp');
						break;
					case('backstage'):
						backstage.close('hp');
						break;
					case('cmp_press'):
						cmp_press.close('hp');
						break;
					case('products'):
						products.close('hp');
						break;
					}
				}
		});
		
		$('#menu>ul>li').hover(function() {
			if(!$(this).hasClass('active')) {
				$('#menu li').removeClass('active');
				$(this).addClass('active');
				$('#submenu', $(this)).fadeIn('fast');
				}
		}, function() {
			$(this).removeClass('active');
			$('#submenu', $(this)).fadeOut('fast');
		});
	}
}

var hp = {
	open : function() {
		((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? (ie6=true) : (ie6=false);
		curPage = 'hp';
		$('#menu li').removeClass('selected');
		if(ie6) DD_belatedPNG.fix('.png, #submenu');
			$('#hp .bg').fadeIn('slow', function() {
				$('#shape1').fadeIn('slow', function() {
					$('#shape2').fadeIn('slow', function() {
						//$('#store').fadeIn('slow');
						$('#logo').fadeIn('slow', function() {
							$('#menu>ul>li').eq(0).fadeIn('slow', function() {
									$('#menu>ul>li').eq(1).fadeIn('slow', function() {
										$('#menu>ul>li').eq(2).fadeIn('slow', function() {
											$('.outWrapper').css({visibility:'visible', display: 'none' })
											menu.listen();
										});
									});
								});
							});
						});
					});
				});
	},	
	close : function(goTo) {
		$('#hp .bg').fadeOut('slow', function() {
			changePage(goTo);
			});
		}
}

var campaign = {
	init : function() {
		campaign.images = $(xmlFile).find('campaign image');
	},
	open : function() {
		campaign.currItem = 1;
		curPage = 'campaign';
		$('#cnt-campaign .bg').fadeIn('slow', function() {
			campaign.openImg(campaign.currItem);
			if(ie6) DD_belatedPNG.fix('#cp_prev, #cp_next');
			$('#cp_prev, #cp_next').fadeIn('slow');
			campaign.browse()
		});
	},
	openImg : function(n) {
		campaign.currItem = n = (n == 0) ? campaign.images.length : (n > campaign.images.length) ? 1 : n;
		var pic = new Image();
		picSrc = $(campaign.images).eq(campaign.currItem-1).attr('src');
		imgPos = campaign.getImagePosition($(campaign.images).eq(campaign.currItem-1).attr('type'));
		$(pic).load(function(){
			$('#cp_imgHolder img').remove();
			$('#cp_imgHolder')
				.append(pic)
				.find('img')
				.fadeIn('slow', function() {
					if($('#cp_imgHolder img').length > 1) {  //remove first image from DOM
						$('#cp_imgHolder img:first').remove();
						}
					});
				});
		$(pic)
			.attr({src:cp_imgPath + picSrc})
			.css({height: imgPos['img_h'], width:imgPos['img_w'], left:imgPos['img_l'], top:imgPos['img_t']})
			.addClass($(campaign.images).eq(campaign.currItem-1).attr('type'));
	},
	getImagePosition : function(type) {
		//resize campaign (horizontal)
		if(type=='hor') {
			campaign.h = h_wp * 0.8;
			campaign.w = campaign.h * cp_hor_ratio;
			campaign.lft = ( w_wp - campaign.w ) / 2;
			campaign.top = ( h_wp - campaign.h ) / 2;
		}
		if(type=='ver') {
			campaign.h = h_wp;
			campaign.w = campaign.h * cp_ver_ratio;
			campaign.lft = ( w_wp - campaign.w ) / 2;
			campaign.top = 0;
		}
		return {img_h:campaign.h, img_w:campaign.w, img_l:campaign.lft, img_t:campaign.top};
	},
	browse : function() {
		$('a#cp_prev').
			bind('click', function() {
				$('#cp_imgHolder img').fadeOut('slow', function() {
					campaign.openImg(campaign.currItem - 1);
				});
			});
		
		$('a#cp_next').
			bind('click', function() {
				$('#cp_imgHolder img').fadeOut('slow', function() {
					campaign.openImg(campaign.currItem + 1);
				});
			});
	},
	close : function(goTo) {
		$('#cp_imgHolder img').fadeOut('slow', function() {
			$('#cp_prev, #cp_next')
				.unbind()
				.fadeOut('slow');
			$('#cnt-campaign .bg').fadeOut('slow', function() {
				changePage(goTo);
				});
			});
		}
}

var backstage = {
	init : function() {
		backstage.images = $(xmlFile).find('backstage image');
	},
	open : function() {
		backstage.currItem = 1;
		curPage = 'backstage';
		$('#cnt-backstage .bg').fadeIn('slow', function() {
			backstage.openImg(backstage.currItem);
			if(ie6) DD_belatedPNG.fix('#bs_prev, #bs_next');
			$('#bs_prev, #bs_next').fadeIn('slow');
			backstage.browse();
		});
	},
	openImg : function(n) {
		backstage.currItem = n = (n == 0) ? backstage.images.length : (n > backstage.images.length) ? 1 : n;
		var pic = new Image();
		picSrc = $(backstage.images).eq(backstage.currItem-1).attr('src');
		imgPos = backstage.getImagePosition($(backstage.images).eq(backstage.currItem-1).attr('type'));
		$(pic).load(function(){
			$('#bs_imgHolder img').remove();
			$('#bs_imgHolder')
				.append(pic)
				.find('img')
				.fadeIn('slow', function() {
					if($('#bs_imgHolder img').length > 1) {  //remove first image from DOM
						$('#bs_imgHolder img:first').remove();
						}
					});
				});
		$(pic)
			.attr({src:bs_imgPath + picSrc})
			.css({height: imgPos['img_h'], width:imgPos['img_w'], left:imgPos['img_l'], top:imgPos['img_t']})
			.addClass($(backstage.images).eq(backstage.currItem-1).attr('type'));
	},
	getImagePosition : function(type) {
		//resize campaign (horizontal)
		if(type=='hor') {
			backstage.h = h_wp * 0.8;
			backstage.w = backstage.h * cp_hor_ratio;
			backstage.lft = ( w_wp - backstage.w ) / 2;
			backstage.top = ( h_wp - backstage.h ) / 2;
		}
		if(type=='ver') {
			backstage.h = h_wp;
			backstage.w = backstage.h * cp_ver_ratio;
			backstage.lft = ( w_wp - backstage.w ) / 2;
			backstage.top = 0;
		}
		return {img_h:backstage.h, img_w:backstage.w, img_l:backstage.lft, img_t:backstage.top};
	},
	browse : function() {
		$('a#bs_prev').
			bind('click', function() {
				$('#bs_imgHolder img').fadeOut('slow', function() {
					backstage.openImg(backstage.currItem - 1);
				});
			});
		
		$('a#bs_next').
			bind('click', function() {
				$('#bs_imgHolder img').fadeOut('slow', function() {
					backstage.openImg(backstage.currItem + 1);
				});
			});
	},
	close : function(goTo) {
		$('#bs_imgHolder img').fadeOut('slow', function() {
			$('#bs_prev, #bs_next')
				.unbind()
				.fadeOut('slow');
			$('#cnt-backstage .bg').fadeOut('slow', function() {
				changePage(goTo);
				});
			});
		}
}


var press = {
	open : function() {
		curPage = 'press';
		$('#cnt-press .bg').fadeIn('slow', function() {
			if(ie6) DD_belatedPNG.fix('#press-close');
			$('#cnt-press .outWrapper').fadeIn('slow');
		});
	},
	close : function(goTo) {
		$('#cnt-press .outWrapper').fadeOut('slow', function() {
			$('#cnt-press .bg').fadeOut('slow', function() {
				changePage(goTo);
			});
		});
	}
}


var cmp_press = {
	open : function() {
		curPage = 'cmp_press';
		$('#cnt-campaign-press .bg').fadeIn('slow', function() {
			$('#cnt-campaign-press .outWrapper, #cnt-campaign-press img.campaign').fadeIn('slow');
		});
	},
	close : function(goTo) {
		$('#cnt-campaign-press .outWrapper').fadeOut('slow', function() {
			$('#cnt-campaign-press .bg').fadeOut('slow', function() {
				changePage(goTo);
			});
		});
		$('#cnt-campaign-press img.campaign').fadeOut('slow');
	}
}


var video = {
	curRes : null,
	open : function() {
		curPage = 'video';
		$('#cnt-video .bg').fadeIn('slow', function() {
			if(h_wp < 650) {
				video.openMedres();
			}
			else {
				video.openHires();
			}
		});
	},
	openHires : function() {
		video.curRes = 'hr';
		$('.hr')
			.css({top: (h_wp - $('.hr').height()) / 2, left: (w_wp - $('.hr').width()) / 2})
			.fadeIn('slow');
		$('#hr-video').media({
				width: 1024,
		        height: 596,
				bgColor: 'transparent',
				autoplay:  true,
				params:    {wmode : 'transparent',scale:'noscale', allowfullscreen:'true'},
				attrs :	{ id : 'player', wmode : 'transparent',scale:'noscale', allowfullscreen:'true' },
				src:       'swf/player.swf',
				flashvars:  {file: 'voddolcegabbana/dg/underwear/Underwear_grande.flv', streamer: 'rtmp://cp70242.edgefcs.net/ondemand', skin: 'swf/skin/sfilata_skin.xml', autostart: true, frontcolor :"5b4c3c", backcolor: "000000", lightcolor : "FFFFFF", overstretch : false,bufferlength : 5, usefullscreen : true},
				caption:   false
			});
	},
	openMedres : function() {
		video.curRes = 'md';
		$('.md')
			.css({top: (h_wp - $('.md').height()) / 2, left: (w_wp - $('.md').width()) / 2})
			.fadeIn('slow');
		$('#md-video').media({
				width: 900,
		        height: 526,
				bgColor: 'transparent',
				autoplay:  true,
				params:    {wmode : 'transparent',scale:'noscale', allowfullscreen:'true'},
				attrs :	{ id : 'player', wmode : 'transparent',scale:'noscale', allowfullscreen:'true' },
				src:       'swf/player.swf',
				flashvars:  {file: 'voddolcegabbana/dg/underwear/Underwear_medio.flv', streamer: 'rtmp://cp70242.edgefcs.net/ondemand', skin: 'swf/skin/sfilata_skin.xml', autostart: true, frontcolor :"5b4c3c", backcolor: "000000", lightcolor : "FFFFFF", overstretch : false,bufferlength : 5, usefullscreen : true},
				caption:   false
			});
	},
	openLowres : function() {
		video.curRes = 'lo';
		$('.lo')
			.css({top: (h_wp - $('.lo').height()) / 2, left: (w_wp - $('.lo').width()) / 2})
			.fadeIn('slow');
		$('#lo-video').media({
				width: 700,
		        height: 410,
				bgColor: 'transparent',
				autoplay:  true,
				params:    {wmode : 'transparent',scale:'noscale', allowfullscreen:'true'},
				attrs :	{ id : 'player', wmode : 'transparent',scale:'noscale', allowfullscreen:'true' },
				src:       'swf/player.swf',
				flashvars:  {file: 'voddolcegabbana/dg/underwear/Underwear_piccolo.flv', streamer: 'rtmp://cp70242.edgefcs.net/ondemand', skin: 'swf/skin/sfilata_skin.xml', autostart: true, frontcolor :"5b4c3c", backcolor: "000000", lightcolor : "FFFFFF", overstretch : false,bufferlength : 5, usefullscreen : true},
				caption:   false
			});
	},
	changeRes : function(goTo) {
		$('#cnt-video .'+video.curRes).fadeOut('fast', function() {
			$('div', this).html('');
			switch(goTo) {
				case 'hr':
				video.openHires();
				break;
				
				case 'md':
				video.openMedres();
				break;
				
				case 'lo':
				video.openLowres();
				break
			}
		});
	},
	close : function(goTo) {
		$('#cnt-video .'+video.curRes).fadeOut('fast', function() {
			$('#cnt-video .bg').fadeOut('slow', function() {
				$('div', this).html('');
				changePage(goTo);
			});
		});
	}
}


var products = {
	dataset : null,
	firstinit : true,
	counter: 0,
	elstoshow: 3,
	infopanel: '<div class="info"><div class="line"></div><span class="code"></span><span class="desc"></span></div>',
	start: function() {
		products.counter = 0;
		products.elstoshow = 3;
		curPage = 'products';
		$('#layout').addClass('products');
		$('#products-wrapper').fadeIn('slow', function() {
			$('#menu').fadeIn('slow', function() {
				$('#logo').fadeIn('slow', function() {
					$('#menu>ul>li').eq(0).fadeIn('slow', function() {
							$('#menu>ul>li').eq(1).fadeIn('slow', function() {
								$('#menu>ul>li').eq(2).fadeIn('slow', function() {
									if(ie6) DD_belatedPNG.fix('#prod_sx, #prod_dx');
									$('#prod_sx, #prod_dx').fadeIn('slow');
									products.init();
									products.listenEvs();
							});
						});
					});
				});
			});
		});
	},
	init: function() {
		var loaded = 0;
		products.panel = $('#panel');
		products.dataset.each(function(i){
			if(i<products.elstoshow&&i>products.counter-1){
				//get item data
				lineProd=products.dataset.eq(i).find('Linea>textblock').filter("[language="+currlang+"]").text();
				descProd=products.dataset.eq(i).find('lang').filter("[language="+currlang+"]").find('dictionary').text();
				codeProd=products.dataset.eq(i).find('code').attr('value');
				
				elId=$(this).attr('id');
				products.panel.append('<div class="prod" id="'+elId+'"><img src="'+abspath+'/img/products/prod-background.jpg" /><a href="#" class="info"></a></div>');
				var thumbP=new Image();
				
				$('#'+elId)
					.css({zIndex: (110 - i)})
					.append((thumbP))
					.append(products.infopanel)
					.find('.line').html(lineProd)
					.end()
					.find('.code').html(codeProd)
					.end()
					.find('.desc').html(descProd)
					.end()
					.find('a.info')
					.hover(function() {
						$('div.info', $(this).parent()).fadeIn('fast');
						}, function() {
						$('div.info', $(this).parent()).fadeOut('fast');
						})
					.end();	
	
				$(thumbP).load(function(){
						loaded++;
						elstoLoad = (products.elstoshow > products.dataset.length) ? ( products.dataset.length  - products.counter ) : ( products.elstoshow - products.counter );
						if(loaded == elstoLoad) {
							$('#loading').remove();
							if(ie6) DD_belatedPNG.fix('.prod img, a.info, div.info');
							$('.prod')
								.fadeIn('slow')
								.resizeProduct();
						}
					});
				
				$(thumbP).attr({src:abspath+$(this).find('Prodotto').eq(0).text()});
			}
		});
	},
	listenEvs : function() {
		$('#prod_dx').click(function(){
			if(products.elstoshow>=products.dataset.length) return;
			products.counter=products.counter+3;
			products.elstoshow=products.elstoshow+3;
			products.removeProds();
		});
		$('#prod_sx').click(function(){
			if(products.counter<=0) return;
			products.counter=products.counter-3;
			products.elstoshow=products.elstoshow-3;
			products.removeProds();
		});
	},
	removeProds: function(){
		$('#panel').html('<div id="loading"></div>');
		products.init();
	},
	close : function(goTo) {
		$('#prod_sx, #prod_dx').fadeOut('fast').unbind();
		$('.prod').fadeOut('slow');
		$('#menu').fadeOut('slow', function() {
			$('#products-wrapper').fadeOut('slow', function() {
				$('#panel').empty();
				$('#layout').removeClass('products');
				switchToMain(goTo);
			});
		})
		$('#logo').fadeOut('slow');
	}
}



$.fn.resizeProduct = function() {
    return this.each(function() {
        $panel = $(this);
        
        m_left = 97;
        products_w = w_wp - (97*2);
        panel_w = Math.floor(products_w / 3);
        panel_h = Math.floor(h_wp - 113);
        
        prd_h = (panel_w / prd_imgratio);
        if(prd_h > panel_h) {
        	prd_h = panel_h;
        	panel_w = prd_h * prd_imgratio;
        	m_left = 97 + (products_w - (panel_w *3)) / 2;
        	$('#panel').css({ left: m_left });
        };
        
        $panel.css({width: panel_w, height: prd_h  });
        $('img', $panel).css({width: panel_w, height: prd_h });
        
        var position = $('a.info', $panel).position();
        $('div.info', $panel).css({top: position.top - 110, left: position.left - 55 });
        
        //center products
        if(prd_h < panel_h) $panel.css({ marginTop: (panel_h - prd_h)/2 });
                        
    });
}

function changePage(page) {
	switch(page) {
		case('hp'):
			hp.open();
			break;
		case('campaign'):
			campaign.open();
			break;
		case('press'):
			press.open();
			break;
		case('video'):
			video.open();
			break;
		case('backstage'):
			backstage.open();
			break;
		case('cmp-press'):
			cmp_press.open();
			break;
		case('products'):
			switchToProducts();
			break;
		}
}

//switch to products page
function switchToProducts() {
	$('#menu').fadeOut('slow', function() {
		$('#shape1, #shape2, #logo').hide();
		products.start();
	});
}


//switch to main page
function switchToMain(goTo) {
	$('#menu, #shape1, #shape2, #logo').fadeIn('slow');
	changePage(goTo);
}


function loadXML() {
	//load galleries xml
	$.ajax({
        type: "GET",
        url: "data.xml",
        dataType: "xml",
        success: function(xmlData) {
			xmlFile = xmlData;
			},
		complete : function(xmlData) {
			campaign.init();
			backstage.init();
			},
		error:function(){
			alert('Error loading xml data1. Please, reload this page and try again.')
			}	
	});
	
	//load products xml
	$.ajax({
	    type: "GET",
	    url: "XML/mondiali/data.xml",
	    dataType: "xml",
	    success: function(xmlData) {
			products.dataset =  $("Item", xmlData);
			},
		error:function(){
			alert('Error loading xml data2. Please, reload this page and try again.')
			}	
	});
	
}

bg_imgratio = 1.64705882;
prd_imgratio = 0.65793781;
min_width = 1200;
min_heigth = 728;
cp_hor_ratio = 1.4749
cp_ver_ratio = 0.766;
var cp_imgPath = 'img/campaign/';
var bs_imgPath = 'img/backstage/gallery/';
var ie6 = null;

/** UTILS **/
/* Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * $Id: jScrollPane.js 87 2009-10-12 10:44:17Z kelvin.luck $
 */

(function($) {

$.jScrollPane = {
	active : []
};
$.fn.jScrollPane = function(settings)
{
	settings = $.extend({}, $.fn.jScrollPane.defaults, settings);

	var rf = function() { return false; };
	
	return this.each(
		function()
		{
			var $this = $(this);
			var paneEle = this;
			var currentScrollPosition = 0;
			var paneWidth;
			var paneHeight;
			var trackHeight;
			var trackOffset = settings.topCapHeight;
			
			if ($(this).parent().is('.jScrollPaneContainer')) {
				currentScrollPosition = settings.maintainPosition ? $this.position().top : 0;
				var $c = $(this).parent();
				paneWidth = $c.innerWidth();
				paneHeight = $c.outerHeight();
				$('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap', $c).remove();
				$this.css({'top':0});
			} else {
				$this.data('originalStyleTag', $this.attr('style'));
				// Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
				$this.css('overflow', 'hidden');
				this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
				this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
				paneWidth = $this.innerWidth();
				paneHeight = $this.innerHeight();
				var $container = $('<div></div>')
					.attr({'className':'jScrollPaneContainer'})
					.css(
						{
							'height':paneHeight+'px', 
							'width':paneWidth+'px'
						}
					);
				if (settings.enableKeyboardNavigation) {
					$container.attr(
						'tabindex', 
						settings.tabIndex
					);
				}
				$this.wrap($container);
				// deal with text size changes (if the jquery.em plugin is included)
				// and re-initialise the scrollPane so the track maintains the
				// correct size
				$(document).bind(
					'emchange', 
					function(e, cur, prev)
					{
						$this.jScrollPane(settings);
					}
				);
				
			}
			trackHeight = paneHeight;
			
			if (settings.reinitialiseOnImageLoad) {
				// code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
				// except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
				// TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
				var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this);
				var loadedImages = [];
				
				if ($imagesToLoad.length) {
					$imagesToLoad.each(function(i, val)	{
						$(this).bind('load readystatechange', function() {
							if($.inArray(i, loadedImages) == -1){ //don't double count images
								loadedImages.push(val); //keep a record of images we've seen
								$imagesToLoad = $.grep($imagesToLoad, function(n, i) {
									return n != val;
								});
								$.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad);
								var s2 = $.extend(settings, {reinitialiseOnImageLoad:false});
								$this.jScrollPane(s2); // re-initialise
							}
						}).each(function(i, val) {
							if(this.complete || this.complete===undefined) { 
								//needed for potential cached images
								this.src = this.src; 
							} 
						});
					});
				};
			}

			var p = this.originalSidePaddingTotal;
			var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;

			var cssToApply = {
				'height':'auto',
				'width': realPaneWidth + 'px'
			}

			if(settings.scrollbarOnLeft) {
				cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
			} else {
				cssToApply.paddingRight = settings.scrollbarMargin + 'px';
			}

			$this.css(cssToApply);

			var contentHeight = $this.outerHeight();
			var percentInView = paneHeight / contentHeight;

			if (percentInView < .99) {
				var $container = $this.parent();
				$container.append(
					$('<div></div>').addClass('jScrollCap jScrollCapTop').css({height:settings.topCapHeight}),
					$('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append(
						$('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append(
							$('<div></div>').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}),
							$('<div></div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'})
						)
					),
					$('<div></div>').addClass('jScrollCap jScrollCapBottom').css({height:settings.bottomCapHeight})
				);
				
				var $track = $('>.jScrollPaneTrack', $container);
				var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);
				
				
				var currentArrowDirection;
				var currentArrowTimerArr = [];// Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug.
				var currentArrowInc;
				var whileArrowButtonDown = function() 
				{
					if (currentArrowInc > 4 || currentArrowInc % 4 == 0) {
						positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
					}
					currentArrowInc++;
				};

				if (settings.enableKeyboardNavigation) {
					$container.bind(
						'keydown.jscrollpane',
						function(e) 
						{
							switch (e.keyCode) {
								case 38: //up
									currentArrowDirection = -1;
									currentArrowInc = 0;
									whileArrowButtonDown();
									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
									return false;
								case 40: //down
									currentArrowDirection = 1;
									currentArrowInc = 0;
									whileArrowButtonDown();
									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
									return false;
								case 33: // page up
								case 34: // page down
									// TODO
									return false;
								default:
							}
						}
					).bind(
						'keyup.jscrollpane',
						function(e) 
						{
							if (e.keyCode == 38 || e.keyCode == 40) {
								for (var i = 0; i < currentArrowTimerArr.length; i++) {
									clearInterval(currentArrowTimerArr[i]);
								}
								return false;
							}
						}
					);
				}

				if (settings.showArrows) {
					
					var currentArrowButton;
					var currentArrowInterval;

					var onArrowMouseUp = function(event)
					{
						$('html').unbind('mouseup', onArrowMouseUp);
						currentArrowButton.removeClass('jScrollActiveArrowButton');
						clearInterval(currentArrowInterval);
					};
					var onArrowMouseDown = function() {
						$('html').bind('mouseup', onArrowMouseUp);
						currentArrowButton.addClass('jScrollActiveArrowButton');
						currentArrowInc = 0;
						whileArrowButtonDown();
						currentArrowInterval = setInterval(whileArrowButtonDown, 100);
					};
					$container
						.append(
							$('<a></a>')
								.attr(
									{
										'href':'javascript:;', 
										'className':'jScrollArrowUp', 
										'tabindex':-1
									}
								)
								.css(
									{
										'width':settings.scrollbarWidth+'px',
										'top':settings.topCapHeight + 'px'
									}
								)
								.html('Scroll up')
								.bind('mousedown', function()
								{
									currentArrowButton = $(this);
									currentArrowDirection = -1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
								.bind('click', rf),
							$('<a></a>')
								.attr(
									{
										'href':'javascript:;', 
										'className':'jScrollArrowDown', 
										'tabindex':-1
									}
								)
								.css(
									{
										'width':settings.scrollbarWidth+'px',
										'bottom':settings.bottomCapHeight + 'px'
									}
								)
								.html('Scroll down')
								.bind('mousedown', function()
								{
									currentArrowButton = $(this);
									currentArrowDirection = 1;
									onArrowMouseDown();
									this.blur();
									return false;
								})
								.bind('click', rf)
						);
					var $upArrow = $('>.jScrollArrowUp', $container);
					var $downArrow = $('>.jScrollArrowDown', $container);
				}
				
				if (settings.arrowSize) {
					trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
					trackOffset += settings.arrowSize;
				} else if ($upArrow) {
					var topArrowHeight = $upArrow.height();
					settings.arrowSize = topArrowHeight;
					trackHeight = paneHeight - topArrowHeight - $downArrow.height();
					trackOffset += topArrowHeight;
				}
				trackHeight -= settings.topCapHeight + settings.bottomCapHeight;
				$track.css({'height': trackHeight+'px', top:trackOffset+'px'})
				
				var $pane = $(this).css({'position':'absolute', 'overflow':'visible'});
				
				var currentOffset;
				var maxY;
				var mouseWheelMultiplier;
				// store this in a seperate variable so we can keep track more accurately than just updating the css property..
				var dragPosition = 0;
				var dragMiddle = percentInView*paneHeight/2;
				
				// pos function borrowed from tooltip plugin and adapted...
				var getPos = function (event, c) {
					var p = c == 'X' ? 'Left' : 'Top';
					return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
				};
				
				var ignoreNativeDrag = function() {	return false; };
				
				var initDrag = function()
				{
					ceaseAnimation();
					currentOffset = $drag.offset(false);
					currentOffset.top -= dragPosition;
					maxY = trackHeight - $drag[0].offsetHeight;
					mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
				};
				
				var onStartDrag = function(event)
				{
					initDrag();
					dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
					$('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
					if ($.browser.msie) {
						$('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
					}
					return false;
				};
				var onStopDrag = function()
				{
					$('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
					dragMiddle = percentInView*paneHeight/2;
					if ($.browser.msie) {
						$('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
					}
				};
				var positionDrag = function(destY)
				{
					$container.scrollTop(0);
					destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
					dragPosition = destY;
					$drag.css({'top':destY+'px'});
					var p = destY / maxY;
					$this.data('jScrollPanePosition', (paneHeight-contentHeight)*-p);
					$pane.css({'top':((paneHeight-contentHeight)*p) + 'px'});
					$this.trigger('scroll');
					if (settings.showArrows) {
						$upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
						$downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
					}
				};
				var updateScroll = function(e)
				{
					positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
				};
				
				var dragH = Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2), settings.dragMaxHeight), settings.dragMinHeight);
				
				$drag.css(
					{'height':dragH+'px'}
				).bind('mousedown', onStartDrag);
				
				var trackScrollInterval;
				var trackScrollInc;
				var trackScrollMousePos;
				var doTrackScroll = function()
				{
					if (trackScrollInc > 8 || trackScrollInc%4==0) {
						positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
					}
					trackScrollInc ++;
				};
				var onStopTrackClick = function()
				{
					clearInterval(trackScrollInterval);
					$('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
				};
				var onTrackMouseMove = function(event)
				{
					trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
				};
				var onTrackClick = function(event)
				{
					initDrag();
					onTrackMouseMove(event);
					trackScrollInc = 0;
					$('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
					trackScrollInterval = setInterval(doTrackScroll, 100);
					doTrackScroll();
					return false;
				};
				
				$track.bind('mousedown', onTrackClick);
				
				$container.bind(
					'mousewheel',
					function (event, delta) {
						delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ?
-event.detail/3 : 0);
						initDrag();
						ceaseAnimation();
						var d = dragPosition;
						positionDrag(dragPosition - delta * mouseWheelMultiplier);
						var dragOccured = d != dragPosition;
						return !dragOccured;
					}
				);

				var _animateToPosition;
				var _animateToInterval;
				function animateToPosition()
				{
					var diff = (_animateToPosition - dragPosition) / settings.animateStep;
					if (diff > 1 || diff < -1) {
						positionDrag(dragPosition + diff);
					} else {
						positionDrag(_animateToPosition);
						ceaseAnimation();
					}
				}
				var ceaseAnimation = function()
				{
					if (_animateToInterval) {
						clearInterval(_animateToInterval);
						delete _animateToPosition;
					}
				};
				var scrollTo = function(pos, preventAni)
				{
					if (typeof pos == "string") {
						$e = $(pos, $this);
						if (!$e.length) return;
						pos = $e.offset().top - $this.offset().top;
					}
					ceaseAnimation();
					var maxScroll = contentHeight - paneHeight;
					pos = pos > maxScroll ? maxScroll : pos;
					$this.data('jScrollPaneMaxScroll', maxScroll);
					var destDragPosition = pos/maxScroll * maxY;
					if (preventAni || !settings.animateTo) {
						positionDrag(destDragPosition);
					} else {
						$container.scrollTop(0);
						_animateToPosition = destDragPosition;
						_animateToInterval = setInterval(animateToPosition, settings.animateInterval);
					}
				};
				$this[0].scrollTo = scrollTo;
				
				$this[0].scrollBy = function(delta)
				{
					var currentPos = -parseInt($pane.css('top')) || 0;
					scrollTo(currentPos + delta);
				};
				
				initDrag();
				
				scrollTo(-currentScrollPosition, true);
			
				// Deal with it when the user tabs to a link or form element within this scrollpane
				$('*', this).bind(
					'focus',
					function(event)
					{
						var $e = $(this);
						
						// loop through parents adding the offset top of any elements that are relatively positioned between
						// the focused element and the jScrollPaneContainer so we can get the true distance from the top
						// of the focused element to the top of the scrollpane...
						var eleTop = 0;
						
						while ($e[0] != $this[0]) {
							eleTop += $e.position().top;
							$e = $e.offsetParent();
						}
						
						var viewportTop = -parseInt($pane.css('top')) || 0;
						var maxVisibleEleTop = viewportTop + paneHeight;
						var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
						if (!eleInView) {
							var destPos = eleTop - settings.scrollbarMargin;
							if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom.
								destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight;
							}
							scrollTo(destPos);
						}
					}
				)
				
				
				if (location.hash && location.hash.length > 1) {
					setTimeout(function() {scrollTo(location.hash);}, $.browser.safari ? 100 : 0);
				}
				
				// use event delegation to listen for all clicks on links and hijack them if they are links to
				// anchors within our content...
				$(document).bind(
					'click',
					function(e)
					{
						$target = $(e.target);
						if ($target.is('a')) {
							var h = $target.attr('href');
							if (h && h.substr(0, 1) == '#' && h.length > 1) {
								setTimeout(function() {scrollTo(h, !settings.animateToInternalLinks);}, $.browser.safari ? 100 : 0);
							}
						}
					}
				); 
				
				// Deal with dragging and selecting text to make the scrollpane scroll...
				function onSelectScrollMouseDown(e)
				{
				   $(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove);
				   $(document).bind('mouseup.jScrollPaneDragging',   onSelectScrollMouseUp);
				  
				}
				
				var textDragDistanceAway;
				var textSelectionInterval;
				
				function onTextSelectionInterval()
				{
					direction = textDragDistanceAway < 0 ? -1 : 1;
					$this[0].scrollBy(textDragDistanceAway / 2);
				}

				function clearTextSelectionInterval()
				{
					if (textSelectionInterval) {
						clearInterval(textSelectionInterval);
						textSelectionInterval = undefined;
					}
				}
				
				function onTextSelectionScrollMouseMove(e)
				{
					var offset = $this.parent().offset().top;
					var maxOffset = offset + paneHeight;
					var mouseOffset = getPos(e, 'Y');
					textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
					if (textDragDistanceAway == 0) {
						clearTextSelectionInterval();
					} else {
						if (!textSelectionInterval) {
							textSelectionInterval  = setInterval(onTextSelectionInterval, 100);
						}
					}
				}

				function onSelectScrollMouseUp(e)
				{
				   $(document)
					  .unbind('mousemove.jScrollPaneDragging')
					  .unbind('mouseup.jScrollPaneDragging');
				   clearTextSelectionInterval();
				}

				$container.bind('mousedown.jScrollPane', onSelectScrollMouseDown);

				
				$.jScrollPane.active.push($this[0]);
				
			} else {
				$this.css(
					{
						'height':paneHeight+'px',
						'width':paneWidth-this.originalSidePaddingTotal+'px',
						'padding':this.originalPadding
					}
				);
				$this[0].scrollTo = $this[0].scrollBy = function() {};
				// clean up listeners
				$this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane');
			}
			
		}
	)
};

$.fn.jScrollPaneRemove = function()
{
	$(this).each(function()
	{
		$this = $(this);
		var $c = $this.parent();
		if ($c.is('.jScrollPaneContainer')) {
			$this.css(
				{
					'top':'',
					'height':'',
					'width':'',
					'padding':'',
					'overflow':'',
					'position':''
				}
			);
			$this.attr('style', $this.data('originalStyleTag'));
			$c.after($this).remove();
		}
	});
}

$.fn.jScrollPane.defaults = {
	scrollbarWidth : 10,
	scrollbarMargin : 5,
	wheelSpeed : 18,
	showArrows : false,
	arrowSize : 0,
	animateTo : false,
	dragMinHeight : 1,
	dragMaxHeight : 99999,
	animateInterval : 100,
	animateStep: 3,
	maintainPosition: true,
	scrollbarOnLeft: false,
	reinitialiseOnImageLoad: false,
	tabIndex : 0,
	enableKeyboardNavigation: true,
	animateToInternalLinks: false,
	topCapHeight: 0,
	bottomCapHeight: 0
};

// clean up the scrollTo expandos
$(window)
	.bind('unload', function() {
		var els = $.jScrollPane.active; 
		for (var i=0; i<els.length; i++) {
			els[i].scrollTo = els[i].scrollBy = null;
		}
	}
);

})(jQuery);
//media
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.3.4=6(d,e,f){s X.1o(6(){5(10 d==\'6\'){f=e;e=d;d={}}2 o=22(X,d);5(10 e==\'6\')e(X,o);2 r=28();2 m=r.3C(o.8)||[\'\'];o.L?m[0]=o.L:m.37();v(2 i=0;i<m.11;i++){3=m[i].1F();5(1a(3[0]))3=\'3\'+3;5(!$.3.4[3])2x;2 a=$.3.4[3+\'1v\'];5(!o.u)o.u={};5(a){2 b=a.12==\'1b\';o.u[a.12||\'18\']=b?(o.18?1:0):o.18?19:1Y}2 c=$.3.4[3](X,o);c.1V(\'1S\',o.G).y(o.y);5(10 f==\'6\')f(X,c[0],o,a.H);36}})};$.3.4.2Z=6(a,b){5(!a||!b||!$.3.4.t.F[b])s;a=a.1F();5(1a(a[0]))a=\'3\'+a;$.3.4[a]=$.3.4[b];$.3.4[a+\'1v\']=$.3.4.t.F[b]};$.3.4.t={y:1J,z:1J,1H:1,18:0,G:\'#2K\',u:{},P:{},D:{},1i:\'7\',1p:Z,25:\'1B.Y\',26:\'1B.Y\',A:{1w:\'19\',1z:\'19\',1x:\'24\',13:\'0.9\',1A:Z,1s:Z,1c:Z,1q:Z}};$.3.4.t.F={S:{H:\'S\',J:\'20,1e,Y\',N:{17:\'16:3q-3n-1T-3i-3g\',L:\'T/x-1P\',1O:\'Q://35.32.R/2X/1M/2V/S/2U.1K#13=\'+$.3.4.t.1i},M:{L:\'T/x-1M-S\',15:\'Q://U.2O.R/2M/2L\'}},1k:{H:\'1k\',J:\'2J,2I,2G,2F,2D,2C,2B,2A,2y,2w,2u,2t,2s,2r,2p,2n,2l,2k,2h,2g,2e,4l,4e,4b\',N:{17:\'16:4a-49-46-45-41\',1O:\'Q://U.27.R/3Y/3U.1K\'},M:{15:\'Q://U.27.R/1k/3S/\'}},3R:{H:\'23\',J:\'3Q,3P,3O,3N,3L,3J,3G\',12:\'1b\',N:{17:\'16:3F-3E-1T-3D-3B\'},M:{L:\'3A/x-3z-3y-3x\',15:\'Q://U.23.R/3v/\'}},1X:{H:\'1X\',J:\'3u,3t,3s,3r\',12:\'1b\',1W:\'3p\',N:{17:\'16:3o-3m-3l-3k-3j\',L:\'T/x-1P\'},M:{L:$.1j.3h&&1Q()?\'T/x-3f-3e\':\'T/x-3d\',15:\'Q://U.3c.R/3b/3a/\'}},W:{H:\'W\',J:\'V,39\'},A:{H:\'A\',J:\'14\'}};6 1Q(){2 a=38.34;v(i=0;i<a.11;i++){2 b=a[i];5(b[\'33\']==\'31-30.2Y\')s 19}s 1Y}2 l=1;v(2 n C $.3.4.t.F){2 q=$.3.4.t.F[n].J;$.1o(q.2W(\',\'),6(i,o){5(1a(o[0]))o=\'3\'+o;$.3.4[o]=$.3.4[n]=1L(n);$.3.4[o+\'1v\']=$.3.4.t.F[n]})};6 28(){2 a=\'\';v(2 b C $.3.4.t.F){5(a.11)a+=\',\';a+=$.3.4.t.F[b].J};s 1N 2T(\'\\\\.(\'+a.2S(/,/g,\'|\')+\')\\\\b\')};6 1L(c){s 6(a,b){s 1l(a,b,c)}};6 1a(c){s\'2R\'.2Q(c)>-1};6 22(d,e){e=e||{};2 f=$(d);2 g=d.2P||\'\';2 j=$.1m?f.1m():$.1I?f.2N():{};j=j||{};2 w=j.y||1G(((g.1R(/w:(\\d+)/)||[])[1]||0));2 h=j.z||1G(((g.1R(/h:(\\d+)/)||[])[1]||0));5(w)j.y=w;5(h)j.z=h;5(g)j.K=g;2 a=$.3.4.t;2 b=(($.1I||$.1m)&&$.3.4.t.1H)?e:j;2 c=b==e?j:e;2 p={u:{G:e.G||$.3.4.t.G}};2 k=$.1n({},a,b,c);$.1o([\'P\',\'u\',\'D\',\'A\'],6(i,o){k[o]=$.1n({},p[o]||{},a[o]||{},b[o]||{},c[o]||{})});5(10 k.I==\'1U\')k.I=f.2H();k.8=k.8||f.1u(\'3w\')||f.1u(\'8\')||\'2E\';s k};$.3.4.Y=6(b,c){5(10 1Z==\'1U\'){5(c.D){2 a=[];v(2 f C c.D)a.E(f+\'=\'+c.D[f]);5(!c.u)c.u={};c.u.D=a.1f(\'&\')}s 1l(b,c,\'S\')}2 d=b.B?(\' B="\'+b.B+\'"\'):\'\';2 e=c.K?(\' 1h="\'+c.K+\'"\'):\'\';2 g=$(\'<O\'+d+e+\'>\');$(b).1g(g).1t();2 h=1N 1Z(c.8,\'2z\'+l++,c.y,c.z,c.1i,c.G);5(c.1p)h.3H(c.1p);v(2 p C c.u)5(p!=\'G\')h.3I(p,c.u[p]);v(2 f C c.D)h.2v(f,c.D[f]);h.3K(g[0]);5(c.I)$(\'<O>\').1d(g).V(c.I);s g};$.3.4.20=$.3.4.1e=6(a,b){2 c=b.8;2 d=/\\.1e\\b/i.3M(c)?$.3.4.t.26:$.3.4.t.25;b.8=d;b.8=b.8+\'?1E=\'+c;b.D=$.1n({},{1E:c},b.D);s $.3.4.Y(a,b)};$.3.4.14=6(a,b){5(!21.1r||!21.1r.1y){5($.3.4.14.1C)s;$.3.4.14.1C=1;2q(\'2o 3T 2m 3V 1y.3W 3X.\');s}2 c={y:b.y,z:b.z,2j:b.G,1w:b.A.1w,1z:b.A.1z,1x:b.A.1x,13:b.A.13};2 d={1A:b.A.1A,1s:b.A.1s};2 e=a.B?(\' B="\'+a.B+\'"\'):\'\';2 f=b.B||\'2i\'+l++;2 g=b.K?(\' 1h="\'+b.K+\'"\'):\'\';2 h=$(\'<O\'+e+g+\'>\');$(a).1g(h).1t();1r.1y.3Z({40:b.8,1c:b.A.1c,1q:b.A.1q,B:f,2f:h[0],42:c,43:d});5(b.I)$(\'<O>\').1d(h).V(b.I);s h};6 1l(b,c,d){2 e=$(b);2 o=$.3.4.t.F[d];5(d==\'W\'){2 o=$(\'<W\'+\' y="\'+c.y+\'" z="\'+c.z+\'" >\');o.1u(\'8\',c.8);o.1V(\'1S\',o.G)}1D 5($.1j.2d){2 a=[\'<4h y="\'+c.y+\'" z="\'+c.z+\'" \'];v(2 f C c.P)a.E(f+\'="\'+c.P[f]+\'" \');v(2 f C o.N||{})a.E(f+\'="\'+o.N[f]+\'" \');a.E(\'></4d\'+\'4c\'+\'>\');2 p=[\'<2c H="\'+(o.1W||\'8\')+\'" 2b="\'+c.8+\'">\'];v(2 f C c.u)p.E(\'<2c H="\'+f+\'" 2b="\'+c.u[f]+\'">\');2 o=2a.29(a.1f(\'\'));v(2 i=0;i<p.11;i++)o.48(2a.29(p[i]))}1D{2 a=[\'<47 y="\'+c.y+\'" z="\'+c.z+\'" 4f="4g:44"\'];5(c.8)a.E(\' 8="\'+c.8+\'" \');v(2 f C c.P)a.E(f+\'="\'+c.P[f]+\'" \');v(2 f C o.M||{})a.E(f+\'="\'+o.M[f]+\'" \');v(2 f C c.u)a.E(f+\'="\'+c.u[f]+\'" \');a.E(\'></4i\'+\'4j\'+\'>\')}2 g=b.B?(\' B="\'+b.B+\'"\'):\'\';2 h=c.K?(\' 1h="\'+c.K+\'"\'):\'\';2 j=$(\'<O\'+g+h+\'>\');e.1g(j).1t();($.1j.2d||d==\'W\')?j.4k(o):j.V(a.1f(\'\'));5(c.I)$(\'<O>\').1d(j).V(c.I);s j}})(4m);',62,271,'||var|fn|media|if|function||src||||||||||||||||||||return|defaults|params|for|||width|height|silverlight|id|in|flashvars|push|players|bgColor|name|caption|types|cls|type|eAttrs|oAttrs|div|attrs|http|com|flash|application|www|html|iframe|this|swf|null|typeof|length|autoplayAttr|version|xaml|pluginspage|clsid|classid|autoplay|true|isDigit|autostart|initParams|appendTo|mp3|join|after|class|flashVersion|browser|quicktime|generate|metadata|extend|each|expressInstaller|userContext|Sys|onLoad|remove|attr|_player|inplaceInstallPrompt|framerate|Silverlight|isWindowless|onError|mediaplayer|warning|else|file|toLowerCase|parseInt|preferMeta|meta|400|cab|getGenerator|shockwave|new|codebase|oleobject|isFirefoxWMPPluginInstalled|match|backgroundColor|11cf|undefined|css|oUrl|winmedia|false|SWFObject|flv|window|getSettings|real||flvPlayer|mp3Player|apple|getTypesRegExp|createElement|document|value|param|msie|tiff|parentElement|tif|snd|AG|background|qti|qif|include|qtif|You|qt|alert|psd|m4a|mp4|mpeg|addVariable|mpg|continue|midi|movie_player_|mid|mov|gsm|bmp|unknown|au|aac|text|aiff|aif|ffffff|getflashplayer|go|data|adobe|className|indexOf|0123456789|replace|RegExp|swflash|cabs|split|pub|dll|mapFormat|mswmp|np|macromedia|filename|plugins|fpdownload|break|shift|navigator|pdf|MediaPlayer|Windows|microsoft|mplayer2|wmp|ms|444553540000|mozilla|96b8|00C04F79FAA6|B153|11d3|394A|ae6d|6BF52A52|url|d27cdb6e|wmv|wma|avi|asf|player|href|plugin|realaudio|pn|audio|0020AFBBCCFA|exec|B84B|8BE4|CFCDAA03|smil|useExpressInstall|addParam|smi|write|rv|test|rpm|rm|ram|ra|realplayer|download|must|qtplugin|the|js|script|qtactivex|createObjectEx|source|D3488ABDDC6B|properties|events|block|BC80|4B23|embed|appendChild|8C17|02BF25D5|3gp|ject|ob|3g2|style|display|object|em|bed|append|wav|jQuery'.split('|'),0,{}));


/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/
var DD_belatedPNG={ns:"DD_belatedPNG",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")}},createVmlStyleSheet:function(){var b,a;b=document.createElement("style");b.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);if(b.styleSheet){b=b.styleSheet;b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");b.addRule(this.ns+"\\:shape","position:absolute;");b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=b;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}},readPropertyChange:function(){var b,c,a;b=event.srcElement;if(!b.vmlInitiated){return}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1){DD_belatedPNG.applyVML(b)}if(event.propertyName=="style.display"){c=(b.currentStyle.display=="none")?"none":"block";for(a in b.vml){if(b.vml.hasOwnProperty(a)){b.vml[a].shape.style.display=c}}}if(event.propertyName.search("filter")!=-1){DD_belatedPNG.vmlOpacity(b)}},vmlOpacity:function(b){if(b.currentStyle.filter.search("lpha")!=-1){var a=b.currentStyle.filter;a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;b.vml.color.shape.style.filter=b.currentStyle.filter;b.vml.image.fill.opacity=a}},handlePseudoHover:function(a){setTimeout(function(){DD_belatedPNG.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c,b;c=a.split(",");for(b=0;b<c.length;b++){this.screenStyleSheet.addRule(c[b],"behavior:expression(DD_belatedPNG.fixPng(this))")}}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a);if(a.isImg){this.copyImageBorders(a)}},attachHandlers:function(i){var d,c,g,e,b,f;d=this;c={resize:"vmlOffsets",move:"vmlOffsets"};if(i.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(b in e){if(e.hasOwnProperty(b)){c[b]=e[b]}}}for(f in c){if(c.hasOwnProperty(f)){g=function(){d[c[f]](i)};i.attachEvent("on"+f,g)}}i.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position=="static"){a.style.position="relative"}},copyImageBorders:function(b){var c,a;c={borderStyle:true,borderWidth:true,borderColor:true};for(a in c){if(c.hasOwnProperty(a)){b.vml.color.shape.style[a]=b.currentStyle[a]}}},vmlFill:function(e){if(!e.currentStyle){return}else{var d,f,g,b,a,c;d=e.currentStyle}for(b in e.vml){if(e.vml.hasOwnProperty(b)){e.vml[b].shape.style.zIndex=d.zIndex}}e.runtimeStyle.backgroundColor="";e.runtimeStyle.backgroundImage="";f=true;if(d.backgroundImage!="none"||e.isImg){if(!e.isImg){e.vmlBg=d.backgroundImage;e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)}else{e.vmlBg=e.src}g=this;if(!g.imgSize[e.vmlBg]){a=document.createElement("img");g.imgSize[e.vmlBg]=a;a.className=g.ns+"_sizeFinder";a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";c=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;g.vmlOffsets(e)};a.attachEvent("onload",c);a.src=e.vmlBg;a.removeAttribute("width");a.removeAttribute("height");document.body.insertBefore(a,document.body.firstChild)}e.vml.image.fill.src=e.vmlBg;f=false}e.vml.image.fill.on=!f;e.vml.image.fill.color="none";e.vml.color.shape.style.backgroundColor=d.backgroundColor;e.runtimeStyle.backgroundImage="none";e.runtimeStyle.backgroundColor="transparent"},vmlOffsets:function(d){var h,n,a,e,g,m,f,l,j,i,k;h=d.currentStyle;n={W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop};a=(n.L+n.bLW==1)?1:0;e=function(b,p,q,c,s,u){b.coordsize=c+","+s;b.coordorigin=u+","+u;b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";b.style.width=c+"px";b.style.height=s+"px";b.style.left=p+"px";b.style.top=q+"px"};e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);g={X:0,Y:0};if(d.isImg){g.X=parseInt(h.paddingLeft,10)+1;g.Y=parseInt(h.paddingTop,10)+1}else{for(j in g){if(g.hasOwnProperty(j)){this.figurePercentage(g,n,j,h["backgroundPosition"+j])}}}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);m=h.backgroundRepeat;f={T:1,R:n.W+a,B:n.H,L:1+a};l={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(m!="repeat"||d.isImg){i={T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)};if(m.search("repeat-")!=-1){k=m.split("repeat-")[1].toUpperCase();i[l[k].b1]=1;i[l[k].b2]=n[l[k].d]}if(i.B>n.H){i.B=n.H}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"}else{d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"}},figurePercentage:function(d,c,f,a){var b,e;e=true;b=(f=="X");switch(a){case"left":case"top":d[f]=0;break;case"center":d[f]=0.5;break;case"right":case"bottom":d[f]=1;break;default:if(a.search("%")!=-1){d[f]=parseInt(a,10)/100}else{e=false}}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));if(d[f]%2===0){d[f]++}return d[f]},fixPng:function(c){c.style.behavior="none";var g,b,f,a,d;if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR"){return}c.isImg=false;if(c.nodeName=="IMG"){if(c.src.toLowerCase().search(/\.png$/)!=-1){c.isImg=true;c.style.visibility="hidden"}else{return}}else{if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1){return}}g=DD_belatedPNG;c.vml={color:{},image:{}};b={shape:{},fill:{}};for(a in c.vml){if(c.vml.hasOwnProperty(a)){for(d in b){if(b.hasOwnProperty(d)){f=g.ns+":"+d;c.vml[a][d]=document.createElement(f)}}c.vml[a].shape.stroked=false;c.vml[a].shape.appendChild(c.vml[a].fill);c.parentNode.insertBefore(c.vml[a].shape,c)}}c.vml.image.shape.fillcolor="none";c.vml.image.fill.type="tile";c.vml.color.fill.on=false;g.attachHandlers(c);g.giveLayout(c);g.giveLayout(c.offsetParent);c.vmlInitiated=true;g.applyVML(c)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet()
