var himg = "";
var imgIdx = 1;
var images = new Array();
var am = 0;
var nm = "";

function preImg(nm2,am2){
am=am2;
nm=nm2;

imgIdx++;
setInterval("rotateImage();",7000);
}

var even = true;
function rotateImage(){
		if(even){
			fadeout('images');
			document.getElementById('nextimg').innerHTML = '<img id="images2" src="img/'+nm+imgIdx+'.jpg" height="262" style="filter:alpha(opacity=10); opacity:0.1;">';
			fadein('images2');
		}else{
			fadeout('images2');
			document.getElementById('mainimg').innerHTML = '<img id="images" src="img/'+nm+imgIdx+'.jpg" height="262" style="filter:alpha(opacity=10); opacity:0.1;">';
			fadein('images');
		}
	if(imgIdx == am){
		imgIdx = 1;
	}else{
		imgIdx++;
	}
	even = (even==true ? false : true);
}


q=1;
fn = null;
function fadein(mainImg)
{
	document.getElementById(mainImg).style.opacity = q/10;
	document.getElementById(mainImg).style.filter = 'alpha(opacity=' + q*10 + ')';
	if(q<=10){
		clearTimeout(fn);
		fn = setTimeout('fadein("'+mainImg+'")',75);
		q=q+1; 
	}else{
		q = 1;	
	}
}
r=10;
fo = null;
function fadeout(mainImg){
	document.getElementById(mainImg).style.opacity = r/10;
	document.getElementById(mainImg).style.filter = 'alpha(opacity=' + r*10 + ')';
	if(r>0){
		clearTimeout(fo);
		fo = setTimeout('fadeout("'+mainImg+'")',75);
		r=r-1; 
	}else{
		r = 10;	
	}
}


function setImg(img){
	if(document.getElementById('mainimgsrc') != null ){
		document.getElementById('mainimgsrc').src = 'img/'+img;
	}
	clearInterval(himg);
	imgIdx = img.match(/\d/)*1+1;
}
function rotateImage2(){
	clearInterval(himg);
	himg = setInterval('rotateImage()', 2500);
}


// SCROLLING FUNCTIONS
function movedown(){

if (window.moveupvar) clearTimeout(moveupvar)
if (iens6&&parseInt(crossobj.style.top)>=(ch))
crossobj.style.top=parseInt(crossobj.style.top)-speed+"px"
movedownvar=setTimeout("movedown()",20)
}

function moveup(){
if (window.movedownvar) clearTimeout(movedownvar)
if (iens6&&parseInt(crossobj.style.top)<-20)
crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",20)
}

function stopscroll(){
if (window.moveupvar) clearTimeout(moveupvar)
if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop(){
stopscroll()
if (iens6)
crossobj.style.top=0+"px"
else if (ns4)
crossobj.top=0
}

function getcontent_height(){
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4)
document.nscontainer.document.nscontent.visibility="show"
}