
var SDfloatHPSi=false,SDfloatHPSa=false, SDfloatHPSctl=[],SDfloatHPSbuttons=[],SDfloatHPStriggers=[],SDfloatHPSpanels=[],SDfloatHPSmobile=false;
function SDfloat_HPSset(){
	var h,sh='',hd,ie=SDfloat_HPSgetIEver();
	if(!document.getElementById || (ie>0&&ie<6)){
		return;
	}
	sh+='.SDfloatHPSsection {float:left;}\n';
	sh+='.SDfloatHPS_viewport {position:relative;overflow:hidden;padding:0;margin:0;}\n';
	sh+='.SDfloatHPS_slide_wrapper {position:relative;padding:0;margin:0;}\n';
	if (document.styleSheets){
		h='\n<st' + 'yle type="text/css">\n' + sh + '\n</s' + 'tyle>';
		document.write(h);
	}
	else{
		h=document.createElement('style');
		h.type='text/css';
		h.appendChild(document.createTextNode(sh));
		hd=document.getElementsByTagName('head');
		hd[0].appendChild(h);
	}
}
SDfloat_HPSset();
function SDfloat_opHPS(){
	if(!document.getElementById){
		return;
	}
	SDfloatHPSctl=arguments;
}
function SDfloat_HPSaddLoad(){
	var ie=SDfloat_HPSgetIEver();
	if(!document.getElementById || (ie>0&&ie<6)){
		return;
	}
	if(window.addEventListener){
		document.addEventListener("DOMContentLoaded",SDfloat_initHPS,false);
		window.addEventListener("load",SDfloat_initHPS,false);
		window.addEventListener("unload",SDfloat_HPSff,false);
		window.addEventListener("load",SDfloat_HPSauto,false);
		window.addEventListener("resize",SDfloat_HPSrsz,false);
	}
	else if(window.attachEvent){
		document.write("<script id=SDfloatie_hps defer src=\"//:\"><\/script>");
		document.getElementById("SDfloatie_hps").onreadystatechange=function(){
			if(this.readyState=="complete"){
				if(SDfloatHPSctl.length>0){
					SDfloat_initHPS();
				}
			}
		};
		window.attachEvent("onload",SDfloat_initHPS);
		window.attachEvent("onload",SDfloat_HPSauto);
		window.attachEvent("onresize",SDfloat_HPSrsz);
	}
}
SDfloat_HPSaddLoad();
function SDfloat_HPSff(){
	return;
}
function SDfloat_initHPS(){
	var i,x,j,tA,bd,bD,tC,vP,sW,cP,cc,pA,aL;
	if(SDfloatHPSi){
		return;
	}
	SDfloatHPSi=true;
	if(SDfloat_HPSisMobile()){
		SDfloat_HPSsetClass(document.getElementsByTagName('BODY')[0],'SDfloatHPS_mobile');
		SDfloatHPSmobile=true;
		SDfloatHPSctl[1]=0;
	}
	bd='html';
	bD=document.body.parentNode;
	if(/KHTML|WebKit/i.test(navigator.userAgent) || SDfloat_HPSgetIEver()==5 ){
		bd='body';
		bD=document.body;
	}
	document.hpsEL=bd;
	bD.hpsGliderRunning=false;
	vP=document.getElementById('SDfloatHPS_vp');
	vP.hpsIE=SDfloat_HPSgetIEver();
	sW=document.getElementById('SDfloatHPS_sw');
	tA=SDfloat_HPSgetElementsByClassName(SDfloatHPSctl[0]);
	if(vP&&sW&&tA&&tA.length>0){
		x=0;
		cc=0;
		for(i=0;i<tA.length;i++){
			if(tA[i].hash){
				tA[i].hpsID=tA[i].hash.replace('#','');
				cP=document.getElementById(tA[i].hpsID);
				if(cP){
					SDfloatHPStriggers[x]=tA[i];
					tA[i].hpsState='closed';
					tA[i].hpsText=tA[i].firstChild.data;
					tA[i].hpsText=tA[i].innerHTML.replace(/<[^>]*>/,'');
					tA[i].hpsText=tA[i].hpsText.replace(/<\/[^>]*>/,'');
					if(!cP.hpsTrig){
						SDfloatHPSpanels[cc]=cP.id;
						cP.hpsTrig=x;
						pA=cP.getElementsByTagName('A');
						if(pA){
							for(j=0;j<pA.length;j++){
								if(!pA[j].hspState){
									pA[j].hpsTrig=x;
									pA[j].hpsPanel=cP.id;
									pA[j].onfocus=function(){
										if(this.hpsPanel!=document.hpsCurrentPanelID){
											SDfloat_HPStrig(SDfloatHPStriggers[this.hpsTrig]);
										}
									};
								}
							}
						}
						cc++;
					}
					x++;
					tA[i].onclick=function(){
						return SDfloat_HPStrig(this);
					};
					tA[i].onmouseup=function(){
						this.blur();
					};
				}
			}
		}
		sW.style.left='0px';
		sW.hpsVP=vP.id;
		sW.hpsGliderRunning=false;
		if(vP.hpsIE>1&&vP.hpsIE<7){
			vP.style.width=SDfloat_HPSgetWinWidth()+'px';
			sW.style.overflow='hidden';
		}
		if(SDfloatHPSmobile){
			SDfloatHPSctl[1]=parseInt(SDfloatHPSctl[1]/2,10);
		}
		for(i=0;i<sW.childNodes.length;i++){
			if(sW.childNodes[i].nodeType==1){
				sW.childNodes[i].style.width=vP.offsetWidth+'px';
				sW.hpsLastChild=sW.childNodes[i];
			}
		}
		if(sW.hpsLastChild){
			SDfloat_HPSresetWidth(sW,sW.hpsLastChild);
		}
		aL=document.getElementsByTagName('*');
		k=0;
		for(i=0;i<aL.length;i++){
			aT=aL[i].getAttribute('rel');
			if(aT){
				if(aT=='SDfloatHPSprevious'){
					aL[i].hpsAction='previous';
					aL[i].onclick=function(){
						SDfloat_HPSctrl('previous')
						return false;
					};
				}
				else if(aT=='SDfloatHPSnext'){
					aL[i].hpsAction='next';
					aL[i].onclick=function(){
						SDfloat_HPSctrl('next');
						return false;
					};
				}
				SDfloatHPSbuttons[k]=aL[i];
				k++;
			}
		}
		SDfloat_HPSauto();
		if( SDfloatHPSctl[1]>1){
			SDfloatHPSa=true;
		}
	}
}
function SDfloat_HPStrig(a,bp){
	var i,tD,vP,sW,bY,bg,tg,dur,stp,m=false,dy=20;
	if(!a||!a.hpsID){
		return m;
	}
	hs='#'+a.hpsID;
	tD=document.getElementById(a.hpsID);
	vP=document.getElementById('SDfloatHPS_vp');
	sW=document.getElementById('SDfloatHPS_sw');
	if(document.hpsEL=='html'){
		bY=document.body.parentNode;
	}
	else{
		bY=document.body;
	}
	if(tD){
		SDfloat_HPSdown(a);
		bg=parseInt(sW.style.left,10);
		if(vP.scrollLeft!==0){
			bg-=vP.scrollLeft;
			sW.style.left=bg+'px';
			vP.scrollLeft=0;
		}
		tg=tD.offsetLeft*-1;
		tg=(tg>=0)?0:tg;
		sW.hpsTime=0;
		sW.hpsBegin=bg;
		sW.hpsFinish=tg;
		sW.hpsDelay=dy;
		dur=SDfloatHPSctl[1];
		stp=parseInt(dur/dy);
		sW.hpsDuration=(sW.hpsBegin==sW.hpsFinish)?0:stp;
		bY.hpsBYTime=0;
		bY.hpsBYBegin=(SDfloatHPSmobile)?0:bY.scrollTop;
		bY.hpsBYFinish=0;
		bY.hpsBYDelay=dy;
		dur=parseInt(SDfloatHPSctl[1]/2);
		stp=parseInt(dur/dy);
		bY.hpsBYDuration=(bY.hpsBYBegin==bY.hpsBYFinish)?0:stp;
		if(SDfloatHPSa && bp!=1){
			if(!sW.hpsGliderRunning){
				sW.hpsGliderRunning=true;
				sW.hpsPanelGlider=setInterval("SDfloat_HPSpanelGlider('"+sW.id+"')",sW.hpsDelay);
			}
		}
		else{
			sW.style.left=tg+'px';
			bY.scrollTop=0;
		}
	}
	return m;
}
function SDfloat_HPSctrl(ac,pv){
	var i,cp=0,m=true;
	for(i=0;i<SDfloatHPSpanels.length;i++){
		if(SDfloatHPSpanels[i]==document.hpsCurrentPanelID){
			cp=i;
			break;
		}
	}
	if(ac=='previous'){
		cp--;
	}
	else if(ac=='next'){
		cp++;
	}
	else if(ac=='first'){
		cp=0;
	}
	else if(ac=='last'){
		cp=SDfloatHPSpanels.length-1;
	}
	else{
		cp=parseInt(ac,10);
		if(cp&&cp>0){
			cp--;
		}
		else{
			cp=0;
		}
	}
	if( SDfloatHPSctl[2]==1){
		cp=(cp>=SDfloatHPSpanels.length)?0:cp;
		cp=(cp<0)?SDfloatHPSpanels.length-1:cp;
	}
	else{
		cp=(cp<0)?0:cp;
		cp=(cp>=SDfloatHPSpanels.length-1)?SDfloatHPSpanels.length-1:cp;
	}
	if(pv==1){
		return cp;
	}
	else{
		SDfloat_HPStrig(SDfloatHPStriggers[cp]);
		return false;
	}
}
function SDfloat_HPSdown(a){
	var ptt,ntt,lc='';
	for(var i=0;i<SDfloatHPStriggers.length;i++){
		if(SDfloatHPStriggers[i].hpsState=='open'){
			SDfloat_HPSremClass(SDfloatHPStriggers[i],'down');
			SDfloatHPStriggers[i].hpsState='closed';
		}
		if(SDfloatHPStriggers[i]==a||SDfloatHPStriggers[i].href==a.href){
			SDfloat_HPSsetClass(SDfloatHPStriggers[i],'down');
			SDfloatHPStriggers[i].hpsState='open';
		}
	}
	document.hpsCurrentPanelID=a.hpsID;
	if(document.hpsCurrentPanelID==SDfloatHPSpanels[0]){
		lc='first';
	}
	else if(document.hpsCurrentPanelID==SDfloatHPSpanels[SDfloatHPSpanels.length-1]){
		lc='last';
	}
	ptt=SDfloatHPStriggers[SDfloat_HPSctrl('previous',1)].hpsText;
	ptt=(ptt=='')?'Previous':ptt;
	ntt=SDfloatHPStriggers[SDfloat_HPSctrl('next',1)].hpsText;
	ntt=(ntt=='')?'Next':ntt;
	for(i=0;i<SDfloatHPSbuttons.length;i++){
		if(SDfloatHPSbuttons[i].hpsAction=='previous'){
			SDfloatHPSbuttons[i].setAttribute('title',ptt);
		}
		else if(SDfloatHPSbuttons[i].hpsAction=='next'){
			SDfloatHPSbuttons[i].setAttribute('title',ntt);
		}
		if(SDfloatHPSctl[2]!=1){
			if(lc=='first' && SDfloatHPSbuttons[i].hpsAction=='previous'){
				SDfloat_HPSsetClass(SDfloatHPSbuttons[i],'off');
				SDfloatHPSbuttons[i].removeAttribute('title');
			}
			else if(lc=='last' && SDfloatHPSbuttons[i].hpsAction=='next'){
				SDfloat_HPSsetClass(SDfloatHPSbuttons[i],'off');
				SDfloatHPSbuttons[i].removeAttribute('title');
			}
			else{
				SDfloat_HPSremClass(SDfloatHPSbuttons[i],'off');
			}
		}
	}
}
function SDfloat_HPSrsz(){
	var i,bD,sW,vP,cP;
	if(!document.hpsEL){
		return;
	}
	vP=document.getElementById('SDfloatHPS_vp');
	sW=document.getElementById('SDfloatHPS_sw');
	if(sW){
		if(!sW.hpsGliderRunning){
			if(vP.hpsIE>1&&vP.hpsIE<7){
				vP.style.width=SDfloat_HPSgetWinWidth()+'px';
			}
			for(i=0;i<sW.childNodes.length;i++){
				if(sW.childNodes[i].nodeType==1){
					sW.childNodes[i].style.width=vP.offsetWidth+'px';
					sW.hpsLastChild=sW.childNodes[i];
				}
			}
			if(sW.hpsLastChild){
				SDfloat_HPSresetWidth(sW,sW.hpsLastChild);
			}
		}
		if(document.hpsCurrentPanelID){
			cP=document.getElementById(document.hpsCurrentPanelID);
			if(cP){
				sW.style.left=(cP.offsetLeft*-1)+'px';
			}
		}
	}
}
function SDfloat_HPSauto(){
	var i,x=0,hs,m=false;
	hs=window.location.hash;
	if(hs&&hs.length>1){
		for(i=0;i<SDfloatHPStriggers.length;i++){
			if(SDfloatHPStriggers[i].hash==hs){
				x=i;
				break;
			}
		}
	}
	SDfloat_HPStrig(SDfloatHPStriggers[x],1);
}
function SDfloat_HPSpanelGlider(d){
	var tD,bY,nl,nt;
	tD=document.getElementById(d);
	if(document.hpsEL=='html'){
		bY=document.body.parentNode;
	}
	else{
		bY=document.body;
	}
	if(tD.hpsTime<tD.hpsDuration){
		tD.hpsTime++;
		nl=SDfloat_HPSInOutQuad(tD.hpsTime,tD.hpsBegin,tD.hpsFinish-tD.hpsBegin,tD.hpsDuration);
		tD.style.left=nl+'px';
	}
	if(tD.hpsTime>=tD.hpsDuration && bY.hpsBYTime<bY.hpsBYDuration ){
		bY.hpsBYTime++;
		nt=SDfloat_HPSInOutQuad(bY.hpsBYTime,bY.hpsBYBegin,bY.hpsBYFinish-bY.hpsBYBegin,bY.hpsBYDuration);
		bY.scrollTop=nt;
	}
	if(tD.hpsTime>=tD.hpsDuration && bY.hpsBYTime>=bY.hpsBYDuration ){
		clearInterval(tD.hpsPanelGlider);
		tD.hpsGliderRunning=false;
	}
}
function SDfloat_HPSInOutQuad(t,b,c,d){
	if((t/=d/2)<1){
		return c/2*t*t+b;
	}
	else{
		return -c/2*((--t)*(t-2)-1)+b;
	}
}
function SDfloat_HPSresetWidth(dd,lc){
	var bf=2000;
	dd.style.width='19000px';
	dd.style.width=(lc.offsetLeft+lc.offsetWidth+bf)+'px';
}
function SDfloat_HPSgetElementsByClassName(cls){
	var i,x=0,aL,aT,rS=[];
	if(typeof(document.getElementsByClassName)!='function'){
		aL=document.getElementsByTagName('*');
		for(i=0;i<aL.length;i++){
			aT=aL[i].className;
			if(aT&&aT==cls){
				rS[x]=aL[i];
				x++;
			}
		}
	}
	else{
		rS=document.getElementsByClassName(cls);
	}
	return rS;
}
function SDfloat_HPSgetIEver(){
	var j,v=-1,nv,m=false;
	nv=navigator.userAgent.toLowerCase();
	j=nv.indexOf("msie");
	if(j>-1){
		v=parseFloat(nv.substring(j+4,j+8));
		if(document.documentMode){
			v=document.documentMode;
		}
	}
	return v;
}
function SDfloat_HPSgetWinWidth(){
	var h;
	if(document.documentElement&&document.documentElement.clientHeight){
		w=document.documentElement.clientWidth;
	}
	else if(window.innerHeight){
		if(document.documentElement.clientWidth){
			w=document.documentElement.clientWidth;
		}
		else{
			w=window.innerWidth;
		}
	}
	else if(document.body){
		w=document.body.clientWidth;
	}
	return w
}
function SDfloat_HPSisMobile(){
	var i,m=false,ua=navigator.userAgent.toLowerCase();
	var dv=['iphone','ipad','ipod','android','windows ce','iemobile','windowsce','blackberry','palm','symbian','series60',
	'armv','arm7tdmi','opera mobi','opera mini','polaris','kindle','midp','mmp/','portalmmm','smm-mms','sonyericsson','zune'];
	for(i=0;i<dv.length;i++){
		if(ua.search(dv[i])>-1){
			m=dv[i];
			break;
		}
	}
	return m;
}
function SDfloat_HPSsetClass(ob,cl){
	if(ob){
		var cc,nc,r=/\s+/g;
		cc=ob.className;
		nc=cl;
		if(cc&&cc.length>0){
			if(cc.indexOf(cl)==-1){
				nc=cc+' '+cl;
			}
			else{
				nc=cc;
			}
		}
		nc=nc.replace(r,' ');
		ob.className=nc;
	}
}
function SDfloat_HPSremClass(ob,cl){
	if(ob){
		var cc,nc,r=/\s+/g;
		cc=ob.className;
		if(cc&&cc.indexOf(cl>-1)){
			nc=cc.replace(cl,'');
			nc=nc.replace(r,' ');
			nc=nc.replace(/\s$/,'');
			ob.className=nc;
		}
	}
}

