﻿var MenuAnimationTimers = new Array();
MenuAnimationTimers[0] = 0;
MenuAnimationTimers[1] = 0;
MenuAnimationTimers[2] = 0;
MenuAnimationTimers[3] = 0;
MenuAnimationTimers[4] = 0;
MenuAnimationTimers[5] = 0;
MenuAnimationTimers[6] = 0;
MenuAnimationTimers[7] = 0;
MenuAnimationTimers[8] = 0;
MenuAnimationTimers[9] = 0;
MenuAnimationTimers[10] = 0;

function ConfigAsForm()
{
    document.getElementById("DivPictures").style.display = "none";
    document.getElementById("DivContent").style.height = "350px";
    document.getElementById("DivContent").style.width = "810px";
}

function SetImageBorder()
{
    document.getElementById("DivPictures").style.display = "none";
}

function SetContent(GivenId, GivenContent)
{
    document.getElementById(GivenId).innerHTML = GivenContent;
 }

function SetContentSubMenu(GivenId)
{
    document.getElementById(GivenId).style.display = "block";
}
function SetParent(GivenId, GivenChildId)
{
    var Parent = document.getElementById(GivenId);
    var Child = document.getElementById(GivenChildId);
    Parent.appendChild(Child);
}

function SetImageDirect(GivenId, GivenImage)
{
    document.getElementById(GivenId).src = GivenImage;
}
function SetImage1(GivenId, GivenImage,SenderID)
{
   Transition1.Start('SwapFade', GivenId, GivenImage, 2, '');
}

function SetImage(GivenId, GivenImage, SenderId)
{
    if (SenderId != undefined && document.getElementById(SenderId).src.toLowerCase().indexOf("imgpixelblank.gif") >= 0) return;
        Transition1.Start('SwapFade', GivenId, GivenImage, 2, '');
        return;
        var RandomNo = Math.floor(Math.random() * 13);
	    switch(RandomNo)
	    {
		    case 0 :
                Transition1.Start('SwapFade', GivenId, GivenImage, 2, '');
			    break;
		    case 1 :
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'lr');
			    break;
		    case 2 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'rl');
			    break;
		    case 3 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'tb');
			    break;
		    case 4 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'bt');
			    break;
		    case 5 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'tlbr');
			    break;
		    case 6 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'trbl');
			    break;
		    case 7 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'bltr');
			    break;
		    case 8 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'brtl');
			    break;
		    case 9 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'cve');
			    break;
		    case 10 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'che');
			    break;
		    case 11 : 
                Transition1.Start('CrossWipe', GivenId, GivenImage, 2, '', 'cc');
			    break;
		    default : 
                Transition1.Start('CrossFade', GivenId, GivenImage, 2, '');
			    break;
	 }
}
   
function MenuOverBg(GivenMenuId, CurrentLength)
{
    document.getElementById("Menu" + GivenMenuId).style.textShadow='1px 1px 6px yellow';
    document.getElementById("Menu" + GivenMenuId).style.filter = 'progid:DXImageTransform.Microsoft.Glow(strength=1,color=yellow)';
}
function MenuOutOfBg(GivenMenuId, CurrentLength)
{
    document.getElementById("Menu" + GivenMenuId).style.textShadow='';
    document.getElementById("Menu" + GivenMenuId).style.filter='';
}
    
function EnterLinkOver(GivenImageId, GivenImageName)
{
    var GivenObj = document.getElementById(GivenImageId);
    if (ReallyOver(GivenObj))
    {       
        GivenObj.style.cursor = 'hand';
        GivenObj.src = GivenImageName; 
   }
}

function EnterLinkOut(GivenImageId, GivenImageName)
{
    var GivenObj = document.getElementById(GivenImageId);
    if (ReallyOut(GivenObj))
    {       
        GivenObj.style.cursor='pointer'
        GivenObj.src = GivenImageName; 
    }
}

function ReallyOver(src) 
{   
    if (!window.event) 
    {
        return true;
    }
    var event = window.event;
    var from = event.fromElement;
    var to = event.toElement;
    return ( to == src || src.contains(to) ) && !src.contains(from) && src != from;
}

function ReallyOut(src) 
{
    if (!window.event) 
    {
        return true;
    }
    var event = window.event;
    var from = event.fromElement;
    var to = event.toElement;
    return (src == from || src.contains(from)) && !src.contains(to) && src != to;
}

function GetCookie(NameOfCookie)
{
    if (document.cookie.length > 0) 
    { 
        begin = document.cookie.indexOf(NameOfCookie + "="); 
        if (begin != -1)
        { 
            begin += NameOfCookie.length + 1; 
            end = document.cookie.indexOf(";", begin);
            if (end == -1) 
            {
                end = document.cookie.length;
            }
            return unescape(document.cookie.substring(begin, end)); 
        } 
    }
    return null; 
}

function SetCookie(NameOfCookie, value, expiredays) 
{
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function DelCookie (NameOfCookie) 
{
    if (GetCookie(NameOfCookie)) 
    {
        document.cookie = NameOfCookie + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
} 
 
function getPos(el) 
{ 
    // yay readability 
    for (var lx=0, ly=0;  
         el != null; 
         lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent); 
    return {x: lx,y: ly}; 
} 

function InStr(TargetString, SubString)
{
    return (String(TargetString).indexOf(SubString, 0) + 1);
}  

function Mid(TargetString, StartFrom, n)
{
    if ((n <= 0) || (StartFrom <=0) ||(StartFrom > String(TargetString).length))
       return "";
    else if (n > String(TargetString).length - StartFrom + 1)
       return String(TargetString).substr(StartFrom - 1 , String(TargetString).length - StartFrom + 1);
    else 
       return String(TargetString).substr(StartFrom - 1, n );
}
function Left(TargetString, n)
{
    if (n <= 0)
        return "";
    else if (n > String(TargetString).length)
        return TargetString;
    else
        return String(TargetString).substr(0, n);
}
function Right(TargetString, n)
{
    if (n <= 0)
       return "";
    else if (n > String(TargetString).length)
       return TargetString;
    else 
       return String(TargetString).substr(String(TargetString).length - n, n);
}

function FormatNumber(GivenAmount) 
{        
    var strAmount = GivenAmount.toString().replace(/,/g , '');
    var dblAmount;
    var dblDecimalPart;
    var MinusSign = '';
    var strDecimalPart;
    var strThousandsPart;
    var strLacsPart;
    var strLacsProcessed;
                                        
    dblAmount = parseFloat(strAmount); 
                        
    if (isNaN(dblAmount)) 
    {
        return "0.00"; 
    }
    else
    {
        //Check and save Minus sign for later use
        if (dblAmount < 0) 
        { 
            MinusSign = '-'; 
        }
        //Convert the number to a string with decimal values as well
        strAmount = new String(Math.abs(dblAmount));
       
        //Get the two digit decimal portion of the string and leave the rest in the source string
       
        if (InStr(strAmount, ".") <= 0)
        {
        
         strDecimalPart = ".00"; 
        
        }
        else
        {
            strDecimalPart = Mid(strAmount, InStr(strAmount, "."), 3); 
            strAmount = Left(strAmount, InStr(strAmount, ".") - 1);
        }

        //Get the thousands portion of the string and leave the rest in the source string
        if (strAmount.length >= 3)
        {
            strThousandsPart = Right(strAmount, 3);
            
        }
        else
        {
            strThousandsPart = strAmount;
        }
        strAmount = Left(strAmount, strAmount.length - 3);

        //the remaining string is lacs and above so process it and insert commas
        strLacsPart = (((strAmount.length % 2) == 0) ? "" : Mid(strAmount, 1, 1) + ",");
      
        for (Count = (((strAmount.length % 2) == 0) ? 1 : 2); Count <= strAmount.length; Count+=2)
        {
            strLacsPart += Mid(strAmount, Count, 2) + ",";
            
        }
        
      return (MinusSign + strLacsPart + strThousandsPart + strDecimalPart);
    }
}

function GetPageDimensions() 
{ 
    this.ViewPortWidth; 
    this.ViewPortHeight; 
    this.DocWidth; 
    this.DocHeight; 
 
    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight 
    if (typeof window.innerWidth != 'undefined') 
    { 
        this.ViewPortWidth = window.innerWidth, 
        this.ViewPortHeight = window.innerHeight 
    } 
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) 
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) 
    { 
        this.ViewPortWidth = document.documentElement.clientWidth, 
        this.ViewPortHeight = document.documentElement.clientHeight 
    } 
    // older versions of IE 
    else 
    { 
        this.ViewPortWidth = document.getElementsByTagName('body')[0].clientWidth, 
        this.ViewPortHeight = document.getElementsByTagName('body')[0].clientHeight 
    }

    this.DocHeight  = Math.max(
        Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
        Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
        Math.max(document.body.clientHeight, document.documentElement.clientHeight)
    );

    this.DocWidth  = Math.max(
        Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
        Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
        Math.max(document.body.clientWidth, document.documentElement.clientWidth)
    );
}

function setPageLayout(GivenId)
{
    var PageDim = new GetPageDimensions();
    var Height = 620 + 15;
    if (PageDim.ViewPortHeight > Height )
    {
        document.getElementById(GivenId).style.paddingTop = Math.floor(((PageDim.ViewPortHeight - Height)/2)).toString() + "px";
    }
    else
    {
        document.getElementById(GivenId).style.paddingTop = "0px";
    }
}

