// convert s to camel case

var HOME_PAGE_REPLACE_INTERVAL = 5000;
var picModulo = 0;

function ConvertToIeNaming(s)
{
  for(var exp=/-([a-z])/; exp.test(s); s=s.replace(exp,RegExp.$1.toUpperCase()));
  return s;
};

function GetStyleProperty(element,propertyName)
{
  var propertyValue=null;
  
  // FF Way
  if(document.defaultView && document.defaultView.getComputedStyle)
  {
    var cs=document.defaultView.getComputedStyle(element,null);
    if(cs && cs.getPropertyValue) propertyValue=cs.getPropertyValue(propertyName);
  }
  
  // IE Way
  else
  if(!propertyValue && element.currentStyle) propertyValue=element.currentStyle[ConvertToIeNaming(propertyName)];
  
  return propertyValue;
};

function shufflePics()
{
    var PicArryTop = new Array();
    PicArryTop[0] = "MobDaily_Aff_1_Body_Top0_Image_1";
    PicArryTop[1] = "MobDaily_Aff_1_Body_Top1_Image_1";
    PicArryTop[2] = "MobDaily_Aff_1_Body_Top2_Image_1";
    
    var PicArryBottom = new Array();
    PicArryBottom[0] = "MobDaily_Aff_1_Body_Bottom0_Image_1";
    PicArryBottom[1] = "MobDaily_Aff_1_Body_Bottom1_Image_1";
    PicArryBottom[2] = "MobDaily_Aff_1_Body_Bottom2_Image_1";

    opacity(PicArryTop[picModulo],100,0,1000);
    opacity(PicArryBottom[picModulo],100,0,1000);
        
    picModulo++;
    picModulo = picModulo%3;
    
    opacity(PicArryTop[picModulo],0,100,1000);
    opacity(PicArryBottom[picModulo],0,100,1000);
    
}

function OnBodyLoad() 
{
    var action = document.getElementById("Action").value;

    if (action == "")
    {
        document.getElementById("Action").value="Online Home";
        action = document.getElementById("Action").value;
    }

    if (action == "Online Home")
    {
        setInterval ( "shufflePics()" , HOME_PAGE_REPLACE_INTERVAL);
    }
    //var bodySitesHeight = GetStyleProperty(document.getElementById("Motf_Aff_1_Body_Sites_1"), "height");
    //var bodyBannerHeight = GetStyleProperty(document.getElementById("Motf_Aff_1_Body_Banner_1"), "height");

//    var bodySitesHeight = document.getElementById("Motf_Aff_1_Body_Sites_1").offsetHeight;
//    var bodyBannerHeight = document.getElementById("Motf_Aff_1_Body_Banner_1").offsetHeight;

//    if (bodySitesHeight > bodyBannerHeight)
//    {
//        document.getElementById("Motf_Aff_1_Body_Sites_1").style.borderRight = "1px solid #dcdcdc";
//        document.getElementById("Motf_Aff_1_Body_Banner_1").style.borderLeft = "none";
//    }
//    else
//    {
//        document.getElementById("Motf_Aff_1_Body_Sites_1").style.borderRight = "none";
//        document.getElementById("Motf_Aff_1_Body_Banner_1").style.borderLeft = "1px solid #dcdcdc";
//    }
}




/*************************************************************************************/

function opacity(id, firstOpacity, finalOpacity, millisec)
{ 
    var rate = Math.round(millisec / 100); 
    var timer = 0; 

    //checks the direction of the opacity changing
    if(firstOpacity > finalOpacity)
    { 
        for(i = firstOpacity; i >= finalOpacity; i--)
        { 
            setTimeout("changeOpacity("+i+",'"+id+"')",(timer*rate)); 
            timer++; 
        } 
    } 
    else if(firstOpacity < finalOpacity) 
    { 
        for(i = firstOpacity; i <= finalOpacity; i++) 
            { 
            setTimeout("changeOpacity("+i+",'"+id+"')",(timer*rate)); 
            timer++; 
        } 
    } 
} 

//adaptation for different browsers 
function changeOpacity(opacity, id)
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100);
    object.MozOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 
/*************************************************************************************/
