

//image fade in effect
var isIe = (window.ActiveXObject)?true:false;
var intAlphaStep = (isIe) ? 2 : 0.01;
var imgObj = null;
var imgOpacity = null;

//image change effect
var ImageMax = 4;
var imgValue = -1;
var timeInternal = 6000;
var arrAd = new Array(4);
var timer;

function openwindow( url )
{
	window.open(url, "ct6open", "location=yes,menubar=yes,status=yes,toolbar=yes,scrollbars=yes,resizable=yes");
}

function BannerContinue( bid )
{    

 

    	     // alert(bid);		
		nextBannerID = (parseInt(bid) + 1) % ImageMax;
		imgValue = nextBannerID - 1;
		//alert(imgValue);
		//alert(nextBannerID);
		if ( timer != null ){clearTimeout(timer);}  
		timer = setTimeout('BannerSwitch(' + nextBannerID + ')', timeInternal);    
    
}

function BannerSelected( bid )
{
   clearTimeout(timer);  
   var currentBanner = document.getElementById("fadein");

  //alert(bid);
  //alert(currentBanner.name);
  
   if ( bid == currentBanner.name )
   {
      return;   
   }
   else
   {   
      
      //imgValue = bid;  
      //timer = setTimeout('BannerSwitch(' + bid + ')', 0);
      change_image(bid); 
   }   
   
    //alert(bid);
}

function BannerSwitch( bid )
{
//alert(bid);
  var currentBanner = document.getElementById("fadein");
  //alert(currentBannerid.name);

      
		imgValue++;
		if(imgValue==ImageMax)
		{		
			imgValue = -1;
			if ( timer != null ){clearTimeout(timer);}  
			timer = setTimeout('BannerSwitch(0)', 0);
		}
		else
		{		
		    change_image(bid); 
		    nextBannerID = (parseInt(bid) + 1) % ImageMax;
		    
		    if ( timer != null ){clearTimeout(timer);}  
		    timer = setTimeout('BannerSwitch(' + nextBannerID + ')', timeInternal);			
		}
		
       
       //alert(bid);
       //alert(currentBanner.name);
   if ( bid == currentBanner.name )
   { return; }
   else
   { 
      change_image(bid); 
   }   
}

function change_image( bid )
{
	arrAd[0] = '<img src="../images/crazytalk6/headphoto01.jpg" border="0" id="fadein" name="0" style="filter:alpha(opacity=0);-moz-opacity:0;opacity:0;" usemap ="#bannermenu">';
	arrAd[1] = '<img onclick="javascript:openwindow(\'http://www.reallusion.com/reallusiontv/VID/Product/ct6demopainting.html\');" src="../images/crazytalk6/headphoto02.jpg" border="0" id="fadein" name="1" style="cursor:pointer;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;" usemap ="#bannermenu">';
	arrAd[2] = '<img onclick="javascript:openwindow(\'http://www.reallusion.com/reallusiontv/VID/Product/ct6democomics.html\');" src="../images/crazytalk6/headphoto03.jpg" border="0" id="fadein" name="2" style="cursor:pointer;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;" usemap ="#bannermenu">';
	arrAd[3] = '<img onclick="javascript:openwindow(\'http://www.reallusion.com/reallusiontv/VID/Tutorial/ct6webavatar.html\');" src="../images/crazytalk6/headphoto04.jpg" border="0" id="fadein" name="3" style="cursor:pointer;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;" usemap ="#bannermenu">';

	var ad = document.getElementById("CT6BANNER");
	//alert(ad.src);
	
	if(ad != null)
	{			
		ad.innerHTML = arrAd[bid];	
		imgOpacity=0;		
		setTimeout("fade_in()", 1);		
	}
}

function fade_in()
{
    var imgObj = document.getElementById("fadein");
    if(isIe)
	{
		imgObj.filters.alpha.opacity += intAlphaStep;
		if (imgObj.filters.alpha.opacity < 100)
		{
		    setTimeout('fade_in()',1);
		}
	}
	else
	{
	//alert(imgOpacity);
		imgOpacity += intAlphaStep;
		imgObj.style.opacity = imgOpacity;
		if (imgOpacity < 1)
		{
		    setTimeout('fade_in()',1);
		}
	}
}    
