// jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php * Copyright (c) 2007 George Smith * Licensed under the MIT License: *   http://www.opensource.org/licenses/mit-license.php */
// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d);},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b;},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b;},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b;},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b;},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b;},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b;},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b;},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b;},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b;},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b;},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b;},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b;},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b;},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b;},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b;}});

//jqModal - Minimalist Modaling with jQuery (http://dev.iceburg.net/jquery/jqModal/) * Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>* Dual licensed under the MIT and GPL licenses: *   http://www.opensource.org/licenses/mit-license.php *   http://www.gnu.org/licenses/gpl.html * $Version: 03/01/2009 +r14 */
(function($){$.fn.jqm=function(o){var _o={zIndex:3000,overlay:50,overlayClass:'jqmOverlay',closeClass:'jqmClose',trigger:'.jqModal',ajax:false,target:false,modal:false,toTop:false,onShow:false,onHide:false,onLoad:false};return this.each(function(){if(this._jqm)return;s++;this._jqm=s;H[s]={c:$.extend(_o,o),a:false,w:$(this).addClass('jqmID'+s),s:s};if(_o.trigger)$(this).jqmAddTrigger(_o.trigger);});};$.fn.jqmAddClose=function(e){hs(this,e,'jqmHide');return this;};$.fn.jqmAddTrigger=function(e){hs(this,e,'jqmShow');return this;};$.fn.jqmShow=function(t){return this.each(function(){if(!H[this._jqm].a)$.jqm.open(this._jqm,t)});};$.fn.jqmHide=function(t){return this.each(function(){if(H[this._jqm].a)$.jqm.close(this._jqm,t)});};$.jqm={hash:{},open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(/^\d+$/.test(h.w.css('z-index')))?h.w.css('z-index'):c.zIndex,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});h.t=t;h.a=true;h.w.css('z-index',z);if(c.modal){if(!A[0])F('bind');A.push(s);o.css('cursor','wait');}
else if(c.overlay>0)h.w.jqmAddClose(o);else o=false;h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):false;if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in{Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}
if(c.ajax){var r=c.target||h.w,u=c.ajax,r=(typeof r=='string')?$(r,h.w):$(r),u=(u.substr(0,1)=='@')?$(t).attr(u.substring(1)):u;r.load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
else if(cc)h.w.jqmAddClose($(cc,h.w));if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);(c.onShow)?c.onShow(h):h.w.show();e(h);return false;},close:function(s){var h=H[s];h.a=false;if(A[0]){A.pop();if(!A[0])F('unbind');}
if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();}return false;}};var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version=="6.0"),i=$('<iframe src="javascript:false;" class="jqm"></iframe>').css({opacity:0}),e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i);f(h);},f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(e){}},F=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return!r;},hs=function(w,e,y){var s=[];w.each(function(){s.push(this._jqm)});$(e).each(function(){if(this[y])$.extend(this[y],s);else{this[y]=s;$(this).click(function(){for(var i in{jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return false;});}});};})(jQuery);

//jQuery-Plugin "pngFix" * Version: 1.2, 09.03.2009 * by Andreas Eberhard, andreas.eberhard@gmail.com * Copyright (c) 2007 Andreas Eberhard * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
(function($){jQuery.fn.pngFix=function(settings){settings=jQuery.extend({blankgif:'blank.gif'},settings);var ie55=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1);var ie6=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1);if(jQuery.browser.msie&&(ie55||ie6)){jQuery(this).find("img[src$=.png]").each(function(){jQuery(this).attr('width',jQuery(this).width());jQuery(this).attr('height',jQuery(this).height());var prevStyle='';var strNewHTML='';var imgId=(jQuery(this).attr('id'))?'id="'+jQuery(this).attr('id')+'" ':'';var imgClass=(jQuery(this).attr('class'))?'class="'+jQuery(this).attr('class')+'" ':'';var imgTitle=(jQuery(this).attr('title'))?'title="'+jQuery(this).attr('title')+'" ':'';var imgAlt=(jQuery(this).attr('alt'))?'alt="'+jQuery(this).attr('alt')+'" ':'';var imgAlign=(jQuery(this).attr('align'))?'float:'+jQuery(this).attr('align')+';':'';var imgHand=(jQuery(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:'+jQuery(this).width()+'px;'+'height:'+jQuery(this).height()+'px;';strNewHTML+='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader'+'(src=\''+jQuery(this).attr('src')+'\', sizingMethod=\'scale\');';strNewHTML+=imgStyle+'"></span>';if(prevStyle!=''){strNewHTML='<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:'+jQuery(this).width()+'px;'+'height:'+jQuery(this).height()+'px;'+'">'+strNewHTML+'</span>';}
jQuery(this).hide();jQuery(this).after(strNewHTML);});jQuery(this).find("*").each(function(){var bgIMG=jQuery(this).css('background-image');if(bgIMG.indexOf(".png")!=-1){var iebg=bgIMG.split('url("')[1].split('")')[0];jQuery(this).css('background-image','none');jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+iebg+"',sizingMethod='scale')";}});jQuery(this).find("input[src$=.png]").each(function(){var bgIMG=jQuery(this).attr('src');jQuery(this).get(0).runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader'+'(src=\''+bgIMG+'\', sizingMethod=\'scale\');';jQuery(this).attr('src',settings.blankgif)});}
return jQuery;};})(jQuery);


var spinLock = false;

// PwC.com widget code by Brendon Hicks 
$(function(){
// Initialize options
	window.widgetOptions = window.widgetOptions || {};
	window.widgetOptions.accordion = {"height" : 0,"multiple" : false,"initial" : 0,"min" : 0	};
	window.widgetOptions.tabs = {"initial" : 1, "width" : 0,"height" : 0, "borders" : 0};
	window.widgetOptions.carousel={	"height": 200};
	window.widgetOptions.pubCarousel={
		"visible":4,
		"circular":true,
		"scroll":4,
		"width":744,
		"popupwidth":300, 
		"arrows":"big",
		"titles":false,
		"borders":true,
		"timer":0,
		"hideOriginal":false,
		"filter":false};

// Accordion code:
$("div.accordian div.pcontent").hide();
$("div.accordion").each(function(){
//add style for page colors:
	$(this).children("h2").addClass("strong");
// Get parameters
	var o = widgetOptions[this.id] || widgetOptions.accordion;
	if (o.height > 0) $(this).children("div.pcontent").height(o.height);
	if (o.initial > 0) $(this).children("h2:eq("+(o.initial -1) +")").next("div.pcontent").slideDown(1);
// Make it work
	$(this).children("h2.ptitle").click(function(){
		var $a = $(this).parent(), $target= $(this).next("div.pcontent"), o = window.widgetOptions[$a[0].id] || window.widgetOptions.accordion;
		if (o.min > 0) $target.slideDown()
		else $target.slideToggle();
		if (!o.multiple) $a.children("div.pcontent:visible").not($target[0]).slideUp();
	});
});

//Tabbed panels code:
$("div.tabs").each(function(){
	//Get parameters
	var o = widgetOptions[this.id] || widgetOptions.tabs;
	if(o.height>0) $(this).children("div.pcontent").height(o.height);
	if(o.width>0) $(this).width(o.width);
	if(o.borders > 0) $(this).children("div.pcontent").css("borderWidth", o.borders);
	
	
	// Turn h2's into tabs;
	$(this).prepend("<div class='tabTitles'> </div>");
	$("h2.ptitle",this).addClass(".homesubheading").appendTo("div.tabTitles",this)

	// now make them functional	
	.click(function(){
		$(this).addClass("selected").siblings("h2.selected").removeClass("selected");
		var x = $(this).prevAll().length;
		$(this).parent().parent().children("div.pcontent").removeClass("selected").eq(x).addClass("selected");
	});
	
	$(this).children("div.pcontent").eq((o.initial - 1)).addClass("selected");
	$(this).children("div.tabTitles").children("h2").eq((o.initial - 1)).addClass("selected");
	
});


//Generic Carousel code:
$("div.carousel").each(function(){
	//Get parameters
	var o = widgetOptions[this.id] || widgetOptions.carousel;
	$(this).jCarouselLite({auto: 5000});
	if(o.height>0)
		$(this).children("li").height(o.height);
	if(o.content){
		$.each(o.content, function(){
		if (typeof this == "string"){
			// make new LI
		} else if (typeof this == "object") {
			// make new LI
		}
		});
	}
});

//Pub carousel code:
$("ul.pub_carousel_list").each(function(){
	//Get parameters
	var o = widgetOptions[this.id] || widgetOptions.pubCarousel;
	o.visible = o.visible 	|| widgetOptions.pubCarousel.visible;
	o.width = 	o.width 	|| widgetOptions.pubCarousel.width;
	o.timer = 	o.timer		|| widgetOptions.pubCarousel.timer;
	o.popupwidth =  o.popupwidth 	|| widgetOptions.pubCarousel.popupwidth;
	o.arrows =  o.arrows 	|| widgetOptions.pubCarousel.arrows;
	o.scroll = o.scroll || widgetOptions.pubCarousel.scroll;
	if(!o.hasOwnProperty("circular")) o.circular = widgetOptions.pubCarousel.circular;
	if(!o.hasOwnProperty("titles")) o.titles = widgetOptions.pubCarousel.titles;
	if(!o.hasOwnProperty("hideOriginal")) o.hideOriginal= widgetOptions.pubCarousel.hideOriginal;
	if(!o.hasOwnProperty("borders")) o.borders = widgetOptions.pubCarousel.borders;
	if(!o.hasOwnProperty("filter")) o.filter = widgetOptions.pubCarousel.filter;

	//Calculate dimensions
	var 	marg = (o.arrows="big")? 70:40,
		step = o.width - marg, 
		itemWidth = Math.ceil(step / o.visible),
		carouselWidth = (itemWidth * $(this).children("li").length) + 2,
		arrowDimensions = (o.arrows == "little")? "width='20px' height='20px' " : "width='35px' height='35px' ",		
	
	//Build carousel
		
		$list = $(this).before('<div class="pub_container" style="width:'+o.width+'px;"><div class="pop_up_box" style="width:'+o.popupwidth+'px;"></div><a class="pub_left pub_navigate" href="back" ><img src="/EN_gx/gx/assets/widgets/'+o.arrows+'Left.png" alt="previous publications" '+ arrowDimensions + ' /></a><a class="pub_right pub_navigate" href="./more" ><img src="/EN_gx/gx/assets/widgets/'+o.arrows+'Right.png" alt="more publications" '+ arrowDimensions + ' /></a><div class="pub_pubs" style="width:'+ (o.width - marg) +' ;"></div></div>'),
		carousel = $list.prev('div.pub_container'),
		carousel_pubs = carousel.find('div.pub_pubs');
		
	$list.clone().removeClass("pub_carousel_list").addClass("clone_carousel_list").appendTo(carousel_pubs)
		.width(carouselWidth)
		.find("li").width(itemWidth);
	if(o.hideOriginal) $list.remove();
	if(o.borders) carousel.children("div.pub_pubs").children("ul").children("li").children("a img:first").css("border", "1px solid #ccc");
				
		
	//Make it spin
	carousel.find("a.pub_left").click(function(){
		if (window.spinLock) return false;
		var $carousel = $(this).nextAll("div.pub_pubs").children("ul.clone_carousel_list"),
			c_left = $carousel.css("left").slice(0,-2);
			c_left = parseInt(c_left);
			
		if (c_left < 10 - step){
			window.spinLock = true;
			$carousel.animate({left:"+="+step},700,"easeOutExpo",function(){window.spinLock = false;});
		}
		return false;
	});
		
	carousel.find("a.pub_right").click(function(){
		if (window.spinLock) return false;
		var $carousel = $(this).nextAll("div.pub_pubs").children("ul.clone_carousel_list"),
		c_left = parseInt($carousel.css("left").slice(0,-2));
	
		if ((c_left-2) > step - carouselWidth){
			window.spinLock = true;
			$carousel.animate({left:"-="+step},700,"easeOutExpo",function(){window.spinLock = false;});
		}
		return false;
	});
	
	// make it pop
	if(o.popupwidth)
		carousel.children("div.pub_pubs").children("ul").children("li").hover(
			function(){
				var $doc = $(this),
				    $carousel = $doc.closest("ul"),
				    leftpx = parseInt($doc.attr('offsetLeft')) + $carousel.attr('offsetLeft') ,
				    $popup = $doc.closest("div.pub_container").children("div.pop_up_box").html("");
				$doc.children("div.pub_info").clone().appendTo($popup).css('width','auto');
				leftpx = (leftpx < o.popupwidth) ? leftpx + (itemWidth): leftpx - (o.popupwidth);
				leftpx +=  35;
				//$popup.css('top', (0 - ($popup.height() - $doc.height)) + "px"); 
				$popup.css('left',leftpx+'px').show();
				},
			function(){
				$(this).closest("div.pub_container").children("div.pop_up_box").html("").hide();
			}
		);
		
		$(this).children("li").hover(
			function(){$(this).addClass("hover");},
			function(){$(this).removeClass("hover");}
		).click(function(){
			location.href = this.firstChild.href;
		});
	//endif

	if(o.titles) $("span.cTitle, span.pub_display_title").css("display","block");
});

//Modal window code:
$("div.modalContent").each(function(){
	var newHTML = '<div class = "modalStripe strong">'+ this.title +'<span  class="jqmClose"> Close</span></div><div class="modalcontent">'	+ this.innerHTML + '</div><div class="modalStripe strong"></div>';
	$(this).addClass('jqmWindow').html(newHTML).jqm({"trigger" : "#"+this.id+"_trigger" , toTop : true});
});

$(document).pngFix();

});

