/****************************************************************************************
*											*
* 	This software has been developed by SOFTENG Corporation. All rights reserved.	*
*											*
* 	The provided source code is for Intersport use, and can not be sold or 		*
*	transferred to third companies.							*
*											*
* 	Warranty voided if source code is modified without SOFTENG permissions.		*
* 											*
*****************************************************************************************/

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck();


var px = bw.ns4||window.opera?"":"px";

if(document.layers){
	scrX= innerWidth; scrY= innerHeight;
	onresize= function(){if(scrX!= innerWidth || scrY!= innerHeight){history.go(0)} }
}

function scrollerobj(obj,nest){
	nest = (!nest)?"":'document.'+nest+'.'
	this.elm = bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):document.getElementById(obj)
	this.css = bw.ns4?this.elm:this.elm.style
	this.doc = bw.ns4?this.elm.document:document
	this.obj = obj+'scrollerobj'; eval(this.obj+'=this')
	this.x = (bw.ns4||bw.opera5)?this.css.left:this.elm.offsetLeft
	this.y = (bw.ns4||bw.opera5)?this.css.top:this.elm.offsetTop
	this.w = (bw.ie4||bw.ie5||bw.ie6||bw.ns6)?this.elm.offsetWidth:bw.ns4?this.elm.clip.width:bw.opera5?this.css.pixelWidth:0
	this.h = (bw.ie4||bw.ie5||bw.ie6||bw.ns6)?this.elm.offsetHeight:bw.ns4?this.elm.clip.height:bw.opera5?this.css.pixelHeight:0
}

scrollerobj.prototype.moveTo = function(x,y){
	if(x!=null){this.x=x; this.css.left=x+px}
	if(y!=null){this.y=y; this.css.top=y+px}
}
scrollerobj.prototype.moveBy = function(x,y){this.moveTo(this.x+x,this.y+y)}
scrollerobj.prototype.hideIt = function(){this.css.visibility='hidden'}
scrollerobj.prototype.showIt = function(){this.css.visibility='visible'}

//afegit (-150) perque no hi caben les noticies.
var scrollTimer2 = null;
var scrollTimer3 = null;
function scroll2(step){
	clearTimeout(scrollTimer2);
	if ( !busy2 && (step<0&&activePage2.y+activePage2.h>(scroller2.h) || step>0&&activePage2.y<0) ){
		activePage2.moveBy(0,step);
		scrollTimer2 = setTimeout('scroll2('+step+')',60);
	}
}

function scroll3(step){
	clearTimeout(scrollTimer3);
	if ( !busy3 && (step<0&&activePage3.y+activePage3.h>(scroller3.h) || step>0&&activePage3.y<0) ){
		activePage3.moveBy(0,step);
		scrollTimer3 = setTimeout('scroll3('+step+')',60);
	}
}

function stopScroll2(){
	clearTimeout(scrollTimer2);
}

function stopScroll3(){
	clearTimeout(scrollTimer3);
}

var activePage2 = null;
var activePage3 = null;
var busy2 = 0;
var busy3 = 0;
function activate2(num){
if (pages2!=null){
	if (activePage2!=pages2[num] && !busy2){
		busy2 = 1;
		if (transitionOut==0 || !bw.opacity){ activePage2.hideIt(); activateContinue2(num); }
		else if (transitionOut==1) activePage2.blend('hidden', 'activateContinue2('+num+')');
	}
}
}

function activate3(num){
if (pages3!=null){
	if (activePage3!=pages3[num] && !busy3){
		busy3 = 1;
		if (transitionOut==0 || !bw.opacity){ activePage3.hideIt(); activateContinue3(num); }
		else if (transitionOut==1) activePage3.blend('hidden', 'activateContinue3('+num+')');
	}
}
}

function activateContinue2(num){
	busy2 = 1;
	activePage2 = pages2[num];
	activePage2.moveTo(0,0);
	if (transitionIn==0 || !bw.opacity){ activePage2.showIt(); busy2=0; }
	else if (transitionIn==1) activePage2.blend('visible', 'busy2=0');
	else if (transitionIn==2) activePage2.slide(0, slideAcceleration, 60, 'busy2=0');
}


function activateContinue3(num){
	busy3 = 1;
	activePage3 = pages3[num];
	activePage3.moveTo(0,0);
	if (transitionIn==0 || !bw.opacity){ activePage3.showIt(); busy3=0; }
	else if (transitionIn==1) activePage3.blend('visible', 'busy3=0');
	else if (transitionIn==2) activePage3.slide(0, slideAcceleration, 60, 'busy3=0');
}

scrollerobj.prototype.slide = function(target, acceleration, time, fn){
	this.slideFn= fn?fn:null;
	this.moveTo(0,scroller1.h);
	if (bw.ie4&&!bw.mac) this.css.filter = 'alpha(opacity=100)';
	if (bw.ns6) this.css.MozOpacity = 1;
	this.showIt();
	this.doSlide(target, acceleration, time);
}
scrollerobj.prototype.doSlide = function(target, acceleration, time){
	//scroll vertical
	
	this.step = Math.round(this.y*acceleration);
	if (this.step<1) this.step = 1;
	if (this.step>this.y) this.step = this.y;
	this.moveBy(0, -this.step);
	if (this.y>0) this.slideTim = setTimeout(this.obj+'.doSlide('+target+','+acceleration+','+time+')', time);
	else {	
		eval(this.slideFn);
		this.slideFn = null;
	}
	
	//scroll horitzontal
	
	/*this.step = Math.round(this.x*acceleration);
	if (this.step<1) this.step = 1;
	if (this.step>this.x) this.step = this.x;
	this.moveBy(-this.step,0);
	if (this.x>0) this.slideTim = setTimeout(this.obj+'.doSlide('+target+','+acceleration+','+time+')', time);
	else {	
		eval(this.slideFn);
		this.slideFn = null;
	}*/	
}


scrollerobj.prototype.blend= function(vis, fn){
	if (bw.ie5||bw.ie6 && !bw.mac) {
		//if (vis=='visible') this.css.filter= 'blendTrans(duration=0.9)';
		//else this.css.filter= 'blendTrans(duration=0.6)';
		this.elm.onfilterchange = function(){ eval(fn); };
		//this.elm.filters.blendTrans.apply();
		this.css.visibility= vis;
		//this.elm.filters.blendTrans.play();
	}
	else if (bw.ns6 || bw.ie&&!bw.mac){
		this.css.visibility= 'visible';
		vis=='visible' ? this.fadeTo(100, 7, 60, fn) : this.fadeTo(0, 9, 60, fn);
	}
	else {
		this.css.visibility= vis;
		eval(fn);
	}
};

scrollerobj.prototype.op= 100;
scrollerobj.prototype.opacityTim= null;
scrollerobj.prototype.setOpacity= function(num){
	this.css.filter= 'alpha(opacity='+num+')';
	this.css.MozOpacity= num/100;
	this.op= num;
}
scrollerobj.prototype.fadeTo= function(target, step, time, fn){
	clearTimeout(this.opacityTim);
	this.opacityFn= fn?fn:null;
	this.op = target==100 ? 0 : 100;
	this.fade(target, step, time);
}
scrollerobj.prototype.fade= function(target, step, time){
	if (Math.abs(target-this.op)>step){
		target>this.op? this.setOpacity(this.op+step):this.setOpacity(this.op-step);
		this.opacityTim= setTimeout(this.obj+'.fade('+target+','+step+','+time+')', time);
	}
	else {
		this.setOpacity(target);
		eval(this.opacityFn);
		this.opacityFn= null;
	}
}


var pageslidefadeLoaded2 = 0;
var pageslidefadeLoaded3 = 0;
function initPageSlideFade2(name,pagename){
	scroller2 = new scrollerobj(name);
	
	pages2 = new Array();
	for (var i=0; i<numScrollPages; i++){
		pages2[i] = new scrollerobj(pagename+i, name);
		pages2[i].moveTo(0,0);
	}
	bw.opacity = ( bw.ie && !bw.ie4 && navigator.userAgent.indexOf('Windows')>-1 ) || bw.ns6
	//if (bw.ie5||bw.ie6 && !bw.mac) pages2[0].css.filter= 'blendTrans(duration=0.6)'; // Preloads the windows filters.
	
	if (transitionOnload) activateContinue2(0);
	else{
		activePage2 = pages2[0];
		activePage2.showIt();
	}

	if (bw.ie) for(var i=0;i<document.links.length;i++) document.links[i].onfocus=document.links[i].blur;
	pageslidefadeLoaded2 = 1;
}

function initPageSlideFade3(name,pagename){
	scroller3 = new scrollerobj(name);
	
	pages3 = new Array();
	for (var i=0; i<numScrollPages; i++){
		pages3[i] = new scrollerobj(pagename+i, name);
		pages3[i].moveTo(0,0);
	}
	bw.opacity = ( bw.ie && !bw.ie4 && navigator.userAgent.indexOf('Windows')>-1 ) || bw.ns6
	//if (bw.ie5||bw.ie6 && !bw.mac) pages3[0].css.filter= 'blendTrans(duration=0.6)'; // Preloads the windows filters.
	
	if (transitionOnload) activateContinue3(0);
	else{
		activePage3 = pages3[0];
		activePage3.showIt();
	}

	if (bw.ie) for(var i=0;i<document.links.length;i++) document.links[i].onfocus=document.links[i].blur;
	pageslidefadeLoaded3 = 1;
}
