/* ========================================================================== */
/* All code copyright First Union Mortgages Ltd 2007                          */
/*                                                                            */
/* Description : Video Animation hooks                                        */
/* ========================================================================== */

var iVideoStatus = new Array(3); // 0 = Static, 1 = Pulsing, 2=Faded
iVideoStatus[0]=0;
iVideoStatus[1]=0;
iVideoStatus[2]=0;
iVideoStatus[3]=0;

var iVideoNames = new Array(3);
iVideoNames[0] = "fuAM";
iVideoNames[1] = "fuAL";
iVideoNames[2] = "fuCall";
iVideoNames[3] = "fuFree";
var dirName = 'images/';

function setPos(elem,coords)
{
	elem.style.top = coords[1] + 'px';
	elem.style.left = coords[0] + 'px';
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
    {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
        {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function VideoSelectImage0()
{
    StartFade(2,0,40);
}

function VideoSelectImage1()
{
    StartFade(2,1,40);
}

function VideoSelectImage2()
{
    StartFade(2,2,40);
}

function VideoSelectImage3()
{
    StartFade(2,3,40);
}

function VideoShowList()
{
    // Get items
    var md = document.getElementById('mainDiv');
    var btn = document.getElementById('fuAM');
    var btnITY = document.getElementById('fuITY');
    
    // Get button position
    pos = findPos(btn);
    
    // Set position of list in relation to button
    pos[1] = pos[1] - (md.offsetHeight-btn.offsetHeight)/2;
    setPos(md,pos);
        
    // Fade in the graphic
    btnITY.src = dirName + 'fuITYFadeIn.gif';

    // Show the list
	md.style.visibility = 'visible';
}

function VideoHideDiv()
{
    var x = document.getElementById('mainDiv');
	x.style.visibility = 'hidden';
    document["fuITY"].src = dirName + 'fuITYStatic.gif';
}

function VideoHideList()
{
    var x = document.getElementById('fuITY');
    if (x == null) return;
    document["fuITY"].src = dirName + 'fuITYFadeOut.gif';
    mytime=setTimeout('VideoHideDiv()',1300)
}

function CallNowHighlight()
{
    document["fuCallNow"].src = dirName + 'fuCallHighlight.gif';
}

function VideoResetImages()
{
    StartFade(2,0,100);
    VideoHideList();
}

function HighlightPC()
{
    var pc = document.getElementById('perc96');
    Highlight(pc);
}

function ResetPC()
{
    var pc = document.getElementById('perc96');
    ResetHighlight(pc);
}

function Highlight(pc)
{
    pc.style.backgroundColor='#FFFF00';
}

function ResetHighlight(pc)
{
    pc.style.backgroundColor='#FFFFFF';
}

function FlashAbout()
{
    var btn = document.getElementById('fpAnimswapImgFP2');
    btn.src = 'images/newnav/menu_inactive/2aboutFlash.gif';
    mytime=setTimeout('ResetAbout()',1000)
}

function ResetAbout()
{
    var btn = document.getElementById('fpAnimswapImgFP2');
    btn.src = 'images/newnav/menu_inactive/2about.gif';
}

function HideLoader()
{
    var x = document.getElementById('fuLoader');
    if (x == null) return;
	x.style.visibility = 'hidden';
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        { 
            c_start=c_start + c_name.length+1 
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        } 
    }
    return ""
}