﻿var intMediaFrame
intMediaFrame = 1;
var intOldFrame
intOldFrame = 1;
var intTheFrame
var intMaxCount
intMaxCount = 2;
var intMediaTimeOut
var intHighlightTimeOut
var intStop = 0
var firstTry = 0
	  
function swapQMedia(){
	setupFrames(intMediaFrame, 0)
	++intMediaFrame;
	if(intMediaFrame > intMaxCount){
		intMediaFrame = 1;
	}
	if(intStop == 0){
		intMediaTimeOut = setTimeout("swapQMedia()", 4000);
	}
}

function setupFrames(intTheFrame){
	if(firstTry == 0){
		firstTry = 1
	}else{
		if(intStop == 0 || bCheck == 1){ 
			var speed = Math.round(500 / 100);
			var timer1 = 0;
			var timer2 = 0;
			
			imageid1 =  intOldFrame
			imageid2 = intTheFrame
			
			
			//for(j=100; j >= 0; j--) {
			//	setTimeout("changeOpac(" + j + ",'" + imageid1 + "')",(timer1 * speed));
			//	timer1++;
			//}
			
			//document.getElementById('selected').id='normal' + imageid1;
			//document.getElementById('normal' + imageid2).id='selected';
			document.getElementById(imageid1).style.display = 'none';
			document.getElementById(imageid2).style.display = 'block';
			
			
			
			//for(i = 0; i <= 100; i++) {
			//	setTimeout("changeOpac(" + i + ",'" + imageid2 + "')",(timer2 * speed));
			//	timer2++;
			//}
			
			intOldFrame = intTheFrame
		}
	
	}
	   
}

function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}        
function holdFrameFor(intTime)
{
	clearTimeout(intMediaTimeOut)
	intMediaTimeOut = setTimeout("swapQMedia()", intTime);
}

function advanceSlide(intCount)
    { 
        clearTimeout(intMediaTimeOut);
        var intTheCount
        intTheCount = intOldFrame + intCount
        if(intTheCount <= 0){
            intTheCount = intMaxCount;
        }else if(intTheCount > intMaxCount){
            intTheCount = 1
        }
        //alert(intTheCount)
        setupFrames(intTheCount)
    }
