
/* 
 ================================================
 PVII Fixed Scroll scripts
 Copyright (c) 2011 Project Seven Development
 www.projectseven.com
 Version: 1.1.0 -build 04
 ================================================
 
*/

var p7FSCi=false,p7FSCa=false,p7FSCel=[],p7FSCctl=[];
function P7_FSCaddLoad(){
	if(!document.getElementById){
		return;
	}
	if(window.addEventListener){
		document.addEventListener("DOMContentLoaded",P7_initFSC,false);
		window.addEventListener("load",P7_initFSC,false);
		window.addEventListener("resize",P7_FSCsync,false);
		window.addEventListener("scroll",P7_FSCsync,false);
	}
	else if(window.attachEvent){
		document.write("<script id=p7ie_fsc defer src=\"//:\"><\/script>");
		document.getElementById("p7ie_fsc").onreadystatechange=function(){
			if(this.readyState=="complete"){
				if(p7FSCctl.length>0){
					P7_initFSC();
				}
			}
		};
		window.attachEvent("onload",P7_initFSC);
		window.attachEvent("onresize",P7_FSCsync);
		window.attachEvent("onscroll",P7_FSCsync);
	}
}
P7_FSCaddLoad();
function P7_opFSC(){
	if(!document.getElementById){
		return;
	}
	p7FSCctl=arguments;
}
function P7_initFSC(){
	var i,tD,bd,x,k=0;
	if(p7FSCi){
		return;
	}
	p7FSCi=true;
	bd='html';
	if(/KHTML|WebKit/i.test(navigator.userAgent) || P7_FSCgetIEver()==5 ){
		bd='body';
	}
	document.fscEL=bd;
	for(i=0;i<p7FSCctl.length;i++){
		tD=document.getElementById(p7FSCctl[i]);
		if(tD){
			x= parseInt(P7_FSCgetPropValue(tD,'left','left'),10);
			if(x){
				p7FSCel[k]=tD;
				tD.fscDefLeft=x;
				tD.style.left=x+'px';
				k++;
			}
		}
	}
	P7_FSCsync();
	p7FSCa=true;
}
function P7_FSCsync(){
	var i,bD,tD,tg,stp,dy=10,dur=200;
	if(!document.fscEL){
		return;
	}
	bD=(document.fscEL=='html')?document.body.parentNode:document.body;
	for(i=0;i<p7FSCel.length;i++){
		tD=p7FSCel[i];
		tg=(bD.scrollLeft*-1)+tD.fscDefLeft;
		tD.fscTime=0;
		tD.fscBegin=parseInt(tD.style.left,10);
		tD.fscFinish=tg;
		tD.fscDelay=dy;
		stp=dur/dy;
		tD.fscDuration=stp;
		if(p7FSCa){
			if(!tD.fscGliderRunning){
				tD.fscGliderRunning=true;
				tD.fscGlider=setInterval("P7_FSCglider('"+tD.id+"')",tD.fscDelay);
			}
		}
		else{
			p7FSCel[i].style.left=tg+'px';
		}
	}
}
function P7_FSCglider(d){
	var tD,lf;
	tD=document.getElementById(d);
	tD.fscTime++;
	lf=P7_FSCInOutQuad(tD.fscTime,tD.fscBegin,tD.fscFinish-tD.fscBegin,tD.fscDuration);
	tD.style.left=lf+'px';
	if(tD.fscTime>=tD.fscDuration){
		clearInterval(tD.fscGlider);
		tD.fscGliderRunning=false;
	}
}
function P7_FSCInOutQuad(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 P7_FSCgetPropValue(ob,prop,prop2){
	var h,v=null;
	if(ob){
		if(ob.currentStyle){
			v=ob.currentStyle[prop];
		}
		else if(window.getComputedStyle){
			v=document.defaultView.getComputedStyle(ob,null).getPropertyValue(prop2);
		}
	}
	return v;
}
function P7_FSCgetIEver(){
	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;
}

