var ctr=1;
var intervalId;
var swooshOpacityTime=500;
var swooshOpacity=100;
var swooshOpacityGap=50;

function drawSection(){
	if(ctr<54){
		opacity('sw_'+ctr,0,swooshOpacity,swooshOpacityTime);
	}else{
		//alert('clearing ' + intervalId);
		clearInterval(intervalId);
	}
	ctr++;
}

function drawSwoosh(){
	intervalId=setInterval(drawSection,swooshOpacityGap);
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
    //alert('done');
}

//change the opacity for different browsers
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 showPopup(pos){
	document.getElementById("popup").style.display="inline";
	changeOpac(0,'popup');
	document.getElementById('popup').style.left=pos;
	opacity('popup',0,100,700);
}

function closePopup(){
	opacity('popup',100,0,700);
	document.getElementById("popup").style.display="none";	
}

function swapImage(name){	
	document.getElementById("januvia").style.display="none";
	document.getElementById("elegantBridal").style.display="none";
	document.getElementById("bdirect").style.display="none";
	document.getElementById("newMe").style.display="none";
	document.getElementById(name).style.display="inline";
}

