function getH() {		
	var h;	
	if( typeof( window.innerHeight ) == 'number' ) {
	// Non - Internet Explorer
		h = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	// Per Internet Explorer 6
		h = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	// Per altri Internet Explorer
		h = document.body.clientHeight;
	}
	return h;
}

function getW() {	
	var w;	
	if( typeof( window.innerWidth ) == 'number' ) {
	// Non - Internet Explorer
		w = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
	// Per Internet Explorer 6
		w = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
	// Per altri Internet Explorer
		w = document.body.clientWidth;
	}
	return w;
}

var collectionisopen=0;
function opcl(){
	if (collectionisopen==0) {
		new Effect.Morph('collection', { style: 'margin-top:0px', duration: 0.5});
		collectionisopen=1;
	} else  {
		new Effect.Morph('collection', { style: 'margin-top:-370px', duration: 0.5});
		collectionisopen=0;
	}
}

function collection(sel,val,del){
	var myLink = 'collection.asp?sel=' + sel + '&val=' + val +'&del=' + del;
	var IDofCollection = 'collection';
	ajaxpage(myLink,IDofCollection);
}

function anicollection(sel,val,del){
	// doesn't work
	new Effect.Morph('line2',{ style:'height:0px', duration:0.8 });
	setTimeout(collection(sel,val,del),1000);
	new Effect.Morph('line2',{style:'height:50px;', duration:0.8, delay:1.2});
}

// wowowowowoooo
function bgloader(strImg,opt){
	prima();
	document.write('<div id="fakebg" style="display:none;"></div>');
	if (strImg!='no'){
		myLoader = new html5Preloader(strImg);
		myLoader.onfinish = function(){
			document.getElementById('fakebg').style.backgroundImage = 'url('+strImg+')';
			setTimeout(function(){Effect.Appear('fakebg',{ duration:1.0});},500);
		}
	}
}

function anihref(page){
	newstyle = 'margin-top:' + getH() + 'px';
	new Effect.Morph('maincontainer',{duration:0.5, style:newstyle});
	Effect.Fade('fakebg',{duration:0.5});
	if(collectionisopen==1){
		opcl();
	}
	setTimeout(function(){location.href=page},550);
}

function prima(){
	document.getElementById('maincontainer').style.display ='block';
	document.getElementById('maincontainer').style.marginTop=getH()+70+'px';
	new Effect.Morph('maincontainer',{ duration: 1.0, style:'margin-top:70px;'});
}
var sldpos=1;
function slideit(p){
	//how many position?
	document.getElementById('arr_right').style.display='block';
	var Sdiv = document.getElementById('productslider');
	//maxpos = Math.round((Sdiv.scrollWidth/getW())+0.5);
	//alert('maxpos='+maxpos);
	minpos = 1;
	
	nxtpos = sldpos + p;
	//alert('nxtpos='+nxtpos);
	//if (nxtpos>maxpos){nxtpos=maxpos;}
	if (nxtpos<minpos){nxtpos=minpos;}
	mL = (nxtpos - 1)*(-1)*(getW()/2); 
	//alert('mL='+mL);
	newstyle = 'margin-left:' + mL + 'px;';
	new Effect.Morph('productslider',{ duration:0.5, style:newstyle });
	sldpos = nxtpos;
}
