﻿// Call From Flash
function FlashMe(obj){
    var myDiv=document.getElementById(obj);
    ShowBackgroundDiv(); 
    ShowNav(myDiv.id);
}

// Login
function logMeIn(){
    var divNoLog = document.getElementById('divNoLog');
    var divIsLog = document.getElementById('divIsLog');
    
    if(document.getElementById('divNoLog').style.display == 'block')
    {
        divNoLog.style.display = "none";
        divIsLog.style.display = "block";
    }
    else
    {
        divNoLog.style.display = "block";
        divIsLog.style.display = "none";
    }
}

// Switches Feature On Home Page
function switchFeature(featureID)
{
    // TURN OFF OTHER FEATURES
    var features = document.getElementsByTagName('TD');
    for (var i = 0; i < features.length; i++){
        if (features[i].id.indexOf('Feature') > -1){
            if (features[i].className == 'featureON'){
                features[i].className = "featureOFF";
            }
        }
    }
    
    var featuresContent = document.getElementsByTagName('DIV');
    for (var i = 0; i < featuresContent.length; i++){
        if (featuresContent[i].id.indexOf('Feature') > -1){
            if (featuresContent[i].style.display == 'block'){
                featuresContent[i].style.display = "none";
            }
        }
    }
    
    // TURN ON FEATURE & CONTENT
    document.getElementById(featureID).className = "featureON";
    document.getElementById(featureID + '_Content').style.display = "block";
}

// Switches Navigation Section
function switchNavSec(SectionID)
{
    // TURN OFF OTHER NAVIGATION SECTIONS
    var sections = document.getElementsByTagName('TD');
    for (var i = 0; i < sections.length; i++){
        if (sections[i].id.indexOf('NavSec') > -1){
            if (sections[i].className == 'featureON'){
                sections[i].className = "featureOFF";
            }
        }
    }
    
    var sectionsContent = document.getElementsByTagName('TABLE');
    for (var i = 0; i < sectionsContent.length; i++){
        if (sectionsContent[i].id.indexOf('NavSec') > -1){
            if (sectionsContent[i].style.display == 'block'){
                sectionsContent[i].style.display = "none";
            }
        }
    }
    
    // TURN ON SECTION & CONTENT
    document.getElementById(SectionID).className = "featureON";
    document.getElementById(SectionID + '_Content').style.display = "block";
}

// Switches Help Section
function switchHelpSec(SectionID)
{
    // TURN OFF OTHER HELP SECTIONS
    var sections = document.getElementsByTagName('TD');
    for (var i = 0; i < sections.length; i++){
        if (sections[i].id.indexOf('HelpSec') > -1){
            if (sections[i].className == 'featureON'){
                sections[i].className = "featureOFF";
            }
        }
    }
    
    var sectionsContent = document.getElementsByTagName('TABLE');
    for (var i = 0; i < sectionsContent.length; i++){
        if (sectionsContent[i].id.indexOf('HelpSec') > -1){
            if (sectionsContent[i].style.display == 'block'){
                sectionsContent[i].style.display = "none";
            }
        }
    }
    
    // TURN ON HELP SECTION & CONTENT
    document.getElementById(SectionID).className = "featureON";
    document.getElementById(SectionID + '_Content').style.display = "block";
}

// Center Div on Screen  
function CenterDiv(DivObject)
{
    //POSITION IN CENTER OF SCREEN
    var iLeft, iTop, iTotalWidth, iTotalHeight, iScrollOffsetX, iScrollOffsetY; 

    iTotalWidth = (window.opera ? window.innerWidth : document.documentElement.clientWidth);  
    iTotalHeight = (window.opera ? window.innerHeight : document.documentElement.clientHeight);    
    iScrollOffsetX = document.documentElement.scrollLeft;
    iScrollOffsetY = document.documentElement.scrollTop;    

    DivObject.style.display = "block";

    iLeft = (iTotalWidth / 2) + iScrollOffsetX - (DivObject.clientWidth / 2);
    iTop = (iTotalHeight / 2) + iScrollOffsetY - (DivObject.clientHeight / 2);       

    DivObject.style.left = iLeft + "px"; 
    DivObject.style.top = iTop + "px";          
}

function ParentCenterDiv(DivObject)
{
    //POSITION IN CENTER OF SCREEN
    var iLeft, iTop, iTotalWidth, iTotalHeight, iScrollOffsetX, iScrollOffsetY; 

    iTotalWidth = (parent.window.opera ? parent.window.innerWidth : parent.document.documentElement.clientWidth);  
    iTotalHeight = (parent.window.opera ? parent.window.innerHeight : parent.document.documentElement.clientHeight);    
    iScrollOffsetX = parent.document.documentElement.scrollLeft;
    iScrollOffsetY = parent.document.documentElement.scrollTop;    

    DivObject.style.display = "block";

    iLeft = (iTotalWidth / 2) + iScrollOffsetX - (DivObject.clientWidth / 2);
    iTop = (iTotalHeight / 2) + iScrollOffsetY - (DivObject.clientHeight / 2);       

    DivObject.style.left = iLeft + "px"; 
    DivObject.style.top = iTop + "px";          
}

// Creates Dim Black Background Div
function ShowBackgroundDiv()
{
    var divBackground = document.getElementById("_divBackground");
    var ifBackground = document.getElementById("_ifBackground");
    var iScrollOffsetX = (window.opera ? 0 : document.documentElement.scrollLeft);
    var iScrollOffsetY = (window.opera ? 0 : document.documentElement.scrollTop); 

    if (divBackground == null)
    {
        divBackground = document.createElement('DIV');
        divBackground.id = '_divBackground';    
        divBackground.style.zIndex = 100000;
        divBackground.style.backgroundColor = "#AAAAAA";
        divBackground.style.opacity = 0.5;
        divBackground.style.filter = "alpha(opacity=50)";
        divBackground.style.position = "absolute";
        document.body.appendChild(divBackground);
    }

    if (document.all && !window.opera && ifBackground == null)
    {
        ifBackground = document.createElement('IFRAME');
        ifBackground.id = '_ifBackground';    
        ifBackground.style.zIndex = 99999;
        ifBackground.style.backgroundColor = "#AAAAAA";
        ifBackground.style.opacity = 0.5;
        ifBackground.style.filter = "alpha(opacity=50)";
        ifBackground.style.position = "absolute"; 
        document.body.appendChild(ifBackground);      
    }
    
    divBackground.style.width = (document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.width) + "px";
    divBackground.style.height = ReturnMaxHeight() + "px";
    divBackground.style.left = iScrollOffsetX + "px";
    divBackground.style.top = "0px";
    divBackground.style.overflow = "hidden";
    divBackground.style.display = "block";  
    

    if (ifBackground != null)
    {
        ifBackground.style.width = (document.width ? document.width : document.documentElement.clientWidth) + "px";
        ifBackground.style.height = (document.height ? document.height : document.documentElement.clientHeight) + "px";    
        ifBackground.style.left = iScrollOffsetX + "px";
        ifBackground.style.top = iScrollOffsetY + "px";    
        ifBackground.style.display = "block";  
    }
}

// Creates Dim Black Background Div
function ParentShowBackgroundDiv()
{
    var divBackground = parent.document.getElementById("_divBackground");
    var ifBackground = parent.document.getElementById("_ifBackground");
    var iScrollOffsetX = (window.opera ? 0 : parent.document.documentElement.scrollLeft);
    var iScrollOffsetY = (window.opera ? 0 : parent.document.documentElement.scrollTop); 

    if (divBackground == null)
    {
        divBackground = parent.document.createElement('DIV');
        divBackground.id = '_divBackground';    
        divBackground.style.zIndex = 100000;
        divBackground.style.backgroundColor = "#AAAAAA";
        divBackground.style.opacity = 0.5;
        divBackground.style.filter = "alpha(opacity=50)";
        divBackground.style.position = "absolute";
        parent.document.body.appendChild(divBackground);
    }

    if (document.all && !window.opera && ifBackground == null)
    {
        ifBackground = parent.document.createElement('IFRAME');
        ifBackground.id = '_ifBackground';    
        ifBackground.style.zIndex = 99999;
        ifBackground.style.backgroundColor = "#AAAAAA";
        ifBackground.style.opacity = 0.5;
        ifBackground.style.filter = "alpha(opacity=50)";
        ifBackground.style.position = "absolute"; 
        parent.document.body.appendChild(ifBackground);      
    }
    
    divBackground.style.width = (parent.document.documentElement.scrollWidth ? parent.document.documentElement.scrollWidth : parent.document.width) + "px";
    divBackground.style.height = ParentReturnMaxHeight() + "px";
    divBackground.style.left = iScrollOffsetX + "px";
    divBackground.style.top = "0px";
    divBackground.style.overflow = "hidden";
    divBackground.style.display = "block";  
    

    if (ifBackground != null)
    {
        ifBackground.style.width = (parent.document.width ? parent.document.width : parent.document.documentElement.clientWidth) + "px";
        ifBackground.style.height = (parent.document.height ? parent.document.height : parent.document.documentElement.clientHeight) + "px";    
        ifBackground.style.left = iScrollOffsetX + "px";
        ifBackground.style.top = iScrollOffsetY + "px";    
        ifBackground.style.display = "block";  
    }
}

// Finds The Maximum Height of Screen
function ReturnMaxHeight()
{
    var iReturn = document.documentElement.scrollHeight;

    if (document.documentElement.clientHeight > iReturn) iReturn = document.documentElement.clientHeight;
    if (document.documentElement.height > iReturn) iReturn = document.documentElement.height;
    if (document.height > iReturn) iReturn = document.height;
    if (document.body.clientHeight > iReturn) iReturn = document.body.clientHeight;
    if (window.innerHeight > iReturn) iReturn = window.innerHeight;
    
    if (document.documentElement.scrollHeight > document.documentElement.clientHeight) iReturn = document.documentElement.clientHeight;
    
    return (iReturn > 2000 ? 2000 : iReturn);  //CAP THE HEIGHT AT 2000, OTHERWISE IE ALLOCATES A LOT OF MEMORY FOR THE DIV
}

// Finds The Maximum Height of Screen
function ParentReturnMaxHeight()
{
    var iReturn = parent.document.documentElement.scrollHeight;

    if (parent.document.documentElement.clientHeight > iReturn) iReturn = parent.document.documentElement.clientHeight;
    if (parent.document.documentElement.height > iReturn) iReturn = parent.document.documentElement.height;
    if (parent.document.height > iReturn) iReturn = parent.document.height;
    if (parent.document.body.clientHeight > iReturn) iReturn = parent.document.body.clientHeight;
    if (parent.window.innerHeight > iReturn) iReturn = parent.window.innerHeight;
    
    if (parent.document.documentElement.scrollHeight > parent.document.documentElement.clientHeight) iReturn = parent.document.documentElement.clientHeight;
    
    return (iReturn > 2000 ? 2000 : iReturn);  //CAP THE HEIGHT AT 2000, OTHERWISE IE ALLOCATES A LOT OF MEMORY FOR THE DIV
}

// Hides background div as well as all popup divs
function HideBackgroundDiv1(obj)
{
    
    var divBackground = document.getElementById("_divBackground");
    var ifBackground = document.getElementById("_ifBackground");
    var myDiv = document.getElementById(obj);
 
    if (divBackground != null) divBackground.style.display = "none";
    if (ifBackground != null) ifBackground.style.display = "none";
    if (myDiv != null) myDiv.style.display = "none";
}

// Opens Navigation Div

function ShowNav(id)
{
    var myDiv = document.getElementById(id);
    if(document.getElementById(id).style.display == "block"){
        HideBackgroundDiv(myDiv);
        }
    else{
        CenterDiv(myDiv);
    }
}

// Opens Help Div
function ShowHelp()
{
    if(document.getElementById('divHelp').style.display == "block"){
        HideBackgroundDiv()
        }
    else{
        CenterDiv(document.getElementById('divHelp'));
    }
}

function ParentShowHelp()
{
    if(parent.document.getElementById('divHelp').style.display == "block"){
        HideBackgroundDiv()
        }
    else{
        ParentCenterDiv(parent.document.getElementById('divHelp'));
    }
}







function PositionDiv(DivObject, PositionObject, BodyWidth, ShowOffset)

{

    var iBodyWidth = BodyWidth, iBodyHeight = 0; 

    var iLef = 0, iTop = 0, iTotalWidth = 0, iTotalHeight = 0, iScrollOffsetX = 0, iScrollOffsetY = 0; 

    var iPositionObjHeight = 0, iPositionObjWidth = 0, iPositionObjX = 0, iPositionObjY = 0;



    iBodyHeight = 30; 

    

    iTotalWidth = document.documentElement.clientWidth;  

    iTotalHeight = document.documentElement.clientHeight;    

    iScrollOffsetX = (window.opera ? 0 : (window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft));

    iScrollOffsetY = (window.opera ? 0 : (window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop)); 

    

    iPositionObjHeight = (PositionObject.clientHeight ? PositionObject.clientHeight : PositionObject.height);

    iPositionObjWidth = (PositionObject.clientWidth ? PositionObject.clientWidth : PositionObject.width);    

   
   

    if ((iTotalWidth - ((iPositionObjX - iScrollOffsetX) + iPositionObjWidth)) < iBodyWidth) 

    {           

        iLeft = iPositionObjX - ((ShowOffset ? iBodyWidth + 5 : 0));	//POSITION IS ON RIGHT EDGE, SHOW DIV TO THE LEFT         

    } 

    else 

    { 

        iLeft = iPositionObjX + (ShowOffset ? iPositionObjWidth : 900);	//SHOW DIV TO THE RIGHT 

    } 

    

    if (iLeft + iBodyWidth + 20 > iTotalWidth)

    {        

        iLeft = iTotalWidth - iBodyWidth - 20 + iScrollOffsetX;        

    } 

   

    //MOVE THE DIV OFF THE SCREEN AND SHOW IT SO WE CAN GET ITS DIMENSIONS

    DivObject.style.left = "-10000px"; 

    DivObject.style.top = "-10000px";    

    DivObject.style.display = "block";   

    iBodyHeight = DivObject.clientHeight;    

       

    var bIsDownOK = ((iPositionObjY + iBodyHeight) < (iTotalHeight));

    var bIsUpOK = ((iPositionObjY - iBodyHeight) > 0);



    if (!bIsDownOK && !bIsUpOK) 

    {   

        iTop = iPositionObjY - (iBodyHeight / 2);	//SHOW IN THE MIDDLE, DOWN AND UP WOULD CUT IMAGE 

    } 

    else if (bIsDownOK || !bIsUpOK) 

    {

        iTop = iPositionObjY + iPositionObjHeight + (ShowOffset ? 0 : 2);	//SHOW DIV DOWN 

    } 

    else 

    {               

        iTop = iPositionObjY - iBodyHeight - (ShowOffset ? 0 : 2);	//POSITION IS TOO FAR DOWN, SHOW DIV UP 

    }    

    

    iTop += iScrollOffsetY;  

   

    if(!document.all)   

    {

        iLeft += "px";

        iTop += "px";

        iBodyWidth += "px";

    }

            

    //NEED TO SHOW THE DIV BEFORE WE GET THE CLIENT HEIGHT

    DivObject.style.left = iLeft; 

    DivObject.style.top = iTop; 

    DivObject.style.width = iBodyWidth; 

}



function CenterDiv(DivObject)

{

    //POSITION IN CENTER OF SCREEN

    var iLeft, iTop, iTotalWidth, iTotalHeight, iScrollOffsetX, iScrollOffsetY; 

    

    iTotalWidth = (window.opera ? window.innerWidth : document.documentElement.clientWidth);  

    iTotalHeight = (window.opera ? window.innerHeight : document.documentElement.clientHeight);    

    iScrollOffsetX = (window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft);

    iScrollOffsetY = (window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop); 	

    

    //MOVE THE DIV OFF THE SCREEN AND SHOW IT SO WE CAN GET ITS DIMENSIONS

    DivObject.style.left = "-10000px"; 

    DivObject.style.top = "-10000px";

    DivObject.style.display = "block";

                            

    iLeft = (iTotalWidth / 2) + iScrollOffsetX - (DivObject.clientWidth / 2);

    iTop = (iTotalHeight / 2) + iScrollOffsetY - (DivObject.clientHeight / 2);       



    DivObject.style.left = iLeft + "px"; 

    DivObject.style.top = iTop + "px";          

}



function CenterDivInsideObject(DivObject, ContainerObject)

{

    var iLeft, iTop, iTotalWidth, iTotalHeight, iScrollOffsetX, iScrollOffsetY; 

    

    iTotalWidth = ContainerObject.clientWidth;  

    iTotalHeight = ContainerObject.clientHeight;    

    iScrollOffsetX = ContainerObject.scrollLeft;

    iScrollOffsetY = ContainerObject.scrollTop; 	

    

    DivObject.style.display = "block";

                            

    iLeft = (iTotalWidth / 2) + iScrollOffsetX - (DivObject.clientWidth / 2);

    iTop = (iTotalHeight / 2) + iScrollOffsetY - (DivObject.clientHeight / 2);       



    DivObject.style.left = iLeft + "px"; 

    DivObject.style.top = iTop + "px";  

}

function ShowBackgroundDiv()

{

    var divBackground = document.getElementById("_divBackground");

    var ifBackground = document.getElementById("_ifBackground");

    var iScrollOffsetX = 0;

    var iScrollOffsetY = (window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop); 

    var iDivHeight = ReturnMaxHeight();



    if (divBackground == null)

    {

        divBackground = document.createElement('DIV');

        divBackground.id = '_divBackground';    

        divBackground.style.zIndex = 100000;

        divBackground.style.backgroundColor = "#AAAAAA";

        divBackground.style.opacity = 0.6;

        divBackground.style.filter = "alpha(opacity=60)";

        divBackground.style.position = "absolute";

        document.body.appendChild(divBackground);

    }



    if (document.all && !window.opera && ifBackground == null)

    {

        ifBackground = document.createElement('IFRAME');

        ifBackground.id = '_ifBackground';    

        ifBackground.style.zIndex = 99999;

        ifBackground.style.backgroundColor = "#AAAAAA";

        ifBackground.style.opacity = 0.6;

        ifBackground.style.filter = "alpha(opacity=60)";

        ifBackground.style.position = "absolute";  

        document.body.appendChild(ifBackground);      

    }

    

    if (iScrollOffsetY > 0 && (iScrollOffsetY - (iDivHeight / 2)) > 0) //IF THE PAGE IS SCROLLED, HAVE THE DIV COVER ABOVE AND BELOW IT EQUALLY

    {

        iScrollOffsetY = (iScrollOffsetY - (iDivHeight / 2));

    }

    else

    {

        iScrollOffsetY = 0;

    }

    

    divBackground.style.width = (document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.width) + "px";

    divBackground.style.height = iDivHeight + "px";

    divBackground.style.left = "0px";

    divBackground.style.top = iScrollOffsetY + "px";

    divBackground.style.display = "block";   

    

    if (ifBackground != null)

    {

        ifBackground.style.width = (document.width ? document.width : document.documentElement.clientWidth) + "px";

        ifBackground.style.height = (document.height ? document.height : document.documentElement.clientHeight) + "px";    

        ifBackground.style.left = "0px";

        ifBackground.style.top = iScrollOffsetY + "px";    

        ifBackground.style.display = "block";  

    }

}



function ReturnMaxHeight()

{

    var iReturn = document.documentElement.scrollHeight;

    

    if (document.documentElement.clientHeight > iReturn) iReturn = document.documentElement.clientHeight;

    if (document.documentElement.height > iReturn) iReturn = document.documentElement.height;

    if (document.height > iReturn) iReturn = document.height;

    if (document.body.clientHeight > iReturn) iReturn = document.body.clientHeight;

    if (window.innerHeight > iReturn) iReturn = window.innerHeight;

    

    return (iReturn > 2000 ? 2000 : iReturn);  //CAP THE HEIGHT AT 2000, OTHERWISE IE ALLOCATES A LOT OF MEMORY FOR THE DIV

}



//function HideBackgroundDiv()

//{

    //var divBackground = document.getElementById("_divBackground");

    //var ifBackground = document.getElementById("_ifBackground");

    

    //if (divBackground != null) divBackground.style.display = "none";

    //if (ifBackground != null) ifBackground.style.display = "none";  

//}



//THIS FUNCTION RETURNS TRUE IF THE USER HIT THE ENTER KEY

function IsEnter(event)

{

	var iKeyPressed;

	

	if(window.event != null) //IE

	{		

		event = window.event;

		iKeyPressed = event.keyCode;

	}

	else //FIREFOX, etc.

	{		

		iKeyPressed = event.which;

	}

		

	if(iKeyPressed == 13)

	{

		event.returnValue = false;

		event.cancel = true;		



		return true;

	}

	

	return false;

}    



function CloseWindow()

{

    window.open('','_parent','');

    window.close();

}



//EITHER DISPLAYS THE LOADING MESSAGE OR HIDES IT

function ShowHideLoading(IsLoading)

{

    var divWorking = document.getElementById("_divWorking");

    

    if (divWorking == null)

    {

        divWorking = document.createElement('DIV');

        divWorking.id = '_divWorking';    

        document.body.appendChild(divWorking);

    }



    divWorking.style.zIndex = 100000;

    divWorking.style.backgroundColor = "transparent";

    divWorking.style.position = "absolute";

    divWorking.style.width = "147";

    divWorking.style.height = "147";

    divWorking.style.verticalAlign = "middle";

    divWorking.innerHTML = "<img src=\"/Marketgate/images/processing.gif\" alt=\"Loading\" />";



    if (IsLoading)

    {

        CenterDiv(divWorking);      

        divWorking.style.display = "block";

    }

    else

    {

        divWorking.style.display = "none";

    }

}



function ShowHideRow(img, rowID)

{

    if (document.getElementById(rowID).style.display == "none")

    {

        document.getElementById(rowID).style.display = (document.all && !window.opera ? "block" : "table-row");  

        if(img != null){ img.src = img.src.replace('plus', 'minus'); }

    }

    else

    {

        document.getElementById(rowID).style.display = "none";

        if(img != null){ img.src = img.src.replace('minus', 'plus'); }

    }

}



function ShowHideGroup(Button, RowID)

{

    var images = Button.getElementsByTagName("img");

    var img;

    

    //THE IMAGE PARENT BEING PASSED IN IS THE TABLE-CELL THAT HOLDS THE ACTUAL IMAGE

    if (images.length > 0)

    {

        img = images[0];    

    }        



    if (document.getElementById(RowID).style.display == "none")

    {

        document.getElementById(RowID).style.display = (document.all && !window.opera ? "block" : "table-row");

        if (img != null) img.src = "../images/Collapse_Up.png";

        

    }

    else

    {        

        document.getElementById(RowID).style.display = "none";

        if (img != null) img.src = "../images/Collapse_Down.png";

    }

}



function ShowHideGroupDiv(Button, DivID)

{

    var images = Button.getElementsByTagName("img");

    var img;

    

    //THE IMAGE PARENT BEING PASSED IN IS THE TABLE-CELL THAT HOLDS THE ACTUAL IMAGE

    if (images.length > 0)

    {

        img = images[0];    

    }        



    if (document.getElementById(DivID).style.display == "none")

    {

        if (img != null) img.src = "images/Collapse_Up.png";

        

    }

    else

    {        

        if (img != null) img.src = "images/Collapse_Down.png";

    }    

    

    AccordionShowHideDiv(document.getElementById(DivID), 300);

}



function AccordionShowHideDiv(DivObject, TimeToSlide)

{

    var bIsClosing = !(DivObject.style.display == "none");

    var iContentHeight;

    

    if (bIsClosing)

    {

        iContentHeight = (DivObject.style.height != "" && DivObject.style.height != "0px" ? DivObject.style.height.replace("px", "") : (DivObject.clientHeight ? DivObject.clientHeight : DivObject.offsetHeight));

        DivObject.setAttribute("OldHeight", iContentHeight);

        DivObject.setAttribute("OldOverflow", DivObject.style.overflow);

        DivObject.style.overflow = "hidden";

    }

    else

    {        

        DivObject.style.display = "block";        

        iContentHeight = DivObject.getAttribute("OldHeight");

    }

    

    window.setTimeout("AccordionSlide(" + new Date().getTime() + "," + TimeToSlide + ",'" + DivObject.id + "'," + iContentHeight + "," + bIsClosing + "," + TimeToSlide + ")", 33); 

}



function AccordionSlide(LastTime, TimeLeft, DivID, ContentHeight, IsClosing, TimeToSlide)

{ 

    var dtCurrentTime = new Date().getTime();

    var iElapsedTicks = dtCurrentTime - LastTime;

    var div = document.getElementById(DivID);



    if(TimeLeft <= iElapsedTicks)

    { 

        if (IsClosing)

        {

            div.style.display = "none";

        }

        else

        {

            if (div.getAttribute("OldOverflow") != null) div.style.overflow = div.getAttribute("OldOverflow");

            div.style.height = ContentHeight + "px";            

        }

        

        div.setAttribute("IsMoving", "false");

        

        return;

    }



    TimeLeft -= iElapsedTicks;

    

    var iNewClosedHeight = Math.round((TimeLeft/TimeToSlide) * ContentHeight);

    

    if(div != null)

    {       

        div.style.height = (IsClosing ? (iNewClosedHeight) : (ContentHeight - iNewClosedHeight)) + 'px';

    }



    window.setTimeout("AccordionSlide(" + dtCurrentTime + "," + TimeLeft + ",'" + DivID + "'," + ContentHeight + "," + IsClosing + "," + TimeToSlide + ")", 33);

}



var _objLastOpenDiv;

var _objLastOpenImage;



function SetLastOpenDiv(DivID, ImageID)

{

    _objLastOpenDiv = document.getElementById(DivID);

    _objLastOpenImage = document.getElementById(ImageID);

    _objLastOpenImage.src = "/IconLibrary/ENB/Soft/V2/16/Navigation_2_Down.png";

}



function ShowHideMultiDiv(DivToOpenID, ImageID)

{

    if (_objLastOpenDiv != null)

    {

        AccordionShowHideDiv(_objLastOpenDiv, 20);

    }

    

    if (_objLastOpenImage != null)

    {

        _objLastOpenImage.src = "/IconLibrary/ENB/Soft/V2/16/Navigation_2_Right.png";

    }

    

    AccordionShowHideDiv(document.getElementById(DivToOpenID), 20);

    

    SetLastOpenDiv(DivToOpenID, ImageID);

}

function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) {

    this.eventTarget = eventTarget;

    this.eventArgument = eventArgument;

    this.validation = validation;

    this.validationGroup = validationGroup;

    this.actionUrl = actionUrl;

    this.trackFocus = trackFocus;

    this.clientSubmit = clientSubmit;

}

function WebForm_DoPostBackWithOptions(options) {

    var validationResult = true;

    if (options.validation) {

        if (typeof(Page_ClientValidate) == 'function') {

            validationResult = Page_ClientValidate(options.validationGroup);

        }

    }

    if (validationResult) {

        if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {

            theForm.action = options.actionUrl;

        }

        if (options.trackFocus) {

            var lastFocus = theForm.elements["__LASTFOCUS"];

            if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {

                if (typeof(document.activeElement) == "undefined") {

                    lastFocus.value = options.eventTarget;

                }

                else {

                    var active = document.activeElement;

                    if ((typeof(active) != "undefined") && (active != null)) {

                        if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) {

                            lastFocus.value = active.id;

                        }

                        else if (typeof(active.name) != "undefined") {

                            lastFocus.value = active.name;

                        }

                    }

                }

            }

        }

    }

    if (options.clientSubmit) {

        __doPostBack(options.eventTarget, options.eventArgument);

    }

}

var __pendingCallbacks = new Array();

var __synchronousCallBackIndex = -1;

function WebForm_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) {

    var postData = __theFormPostData +

                "__CALLBACKID=" + WebForm_EncodeCallback(eventTarget) +

                "&__CALLBACKPARAM=" + WebForm_EncodeCallback(eventArgument);

    if (theForm["__EVENTVALIDATION"]) {

        postData += "&__EVENTVALIDATION=" + WebForm_EncodeCallback(theForm["__EVENTVALIDATION"].value);

    }

    var xmlRequest,e;

    try {

        xmlRequest = new XMLHttpRequest();

    }

    catch(e) {

        try {

            xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");

        }

        catch(e) {

        }

    }

    var setRequestHeaderMethodExists = true;

    try {

        setRequestHeaderMethodExists = (xmlRequest && xmlRequest.setRequestHeader);

    }

    catch(e) {}

    var callback = new Object();

    callback.eventCallback = eventCallback;

    callback.context = context;

    callback.errorCallback = errorCallback;

    callback.async = useAsync;

    var callbackIndex = WebForm_FillFirstAvailableSlot(__pendingCallbacks, callback);

    if (!useAsync) {

        if (__synchronousCallBackIndex != -1) {

            __pendingCallbacks[__synchronousCallBackIndex] = null;

        }

        __synchronousCallBackIndex = callbackIndex;

    }

    if (setRequestHeaderMethodExists) {

        xmlRequest.onreadystatechange = WebForm_CallbackComplete;

        callback.xmlRequest = xmlRequest;

        xmlRequest.open("POST", theForm.action, true);

        xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

        xmlRequest.send(postData);

        return;

    }

    callback.xmlRequest = new Object();

    var callbackFrameID = "__CALLBACKFRAME" + callbackIndex;

    var xmlRequestFrame = document.frames[callbackFrameID];

    if (!xmlRequestFrame) {

        xmlRequestFrame = document.createElement("IFRAME");

        xmlRequestFrame.width = "1";

        xmlRequestFrame.height = "1";

        xmlRequestFrame.frameBorder = "0";

        xmlRequestFrame.id = callbackFrameID;

        xmlRequestFrame.name = callbackFrameID;

        xmlRequestFrame.style.position = "absolute";

        xmlRequestFrame.style.top = "-100px"

        xmlRequestFrame.style.left = "-100px";

        try {

            if (callBackFrameUrl) {

                xmlRequestFrame.src = callBackFrameUrl;

            }

        }

        catch(e) {}

        document.body.appendChild(xmlRequestFrame);

    }

    var interval = window.setInterval(function() {

        xmlRequestFrame = document.frames[callbackFrameID];

        if (xmlRequestFrame && xmlRequestFrame.document) {

            window.clearInterval(interval);

            xmlRequestFrame.document.write("");

            xmlRequestFrame.document.close();

            xmlRequestFrame.document.write('<html><body><form method="post"><input type="hidden" name="__CALLBACKLOADSCRIPT" value="t"></form></body></html>');

            xmlRequestFrame.document.close();

            xmlRequestFrame.document.forms[0].action = theForm.action;

            var count = __theFormPostCollection.length;

            var element;

            for (var i = 0; i < count; i++) {

                element = __theFormPostCollection[i];

                if (element) {

                    var fieldElement = xmlRequestFrame.document.createElement("INPUT");

                    fieldElement.type = "hidden";

                    fieldElement.name = element.name;

                    fieldElement.value = element.value;

                    xmlRequestFrame.document.forms[0].appendChild(fieldElement);

                }

            }

            var callbackIdFieldElement = xmlRequestFrame.document.createElement("INPUT");

            callbackIdFieldElement.type = "hidden";

            callbackIdFieldElement.name = "__CALLBACKID";

            callbackIdFieldElement.value = eventTarget;

            xmlRequestFrame.document.forms[0].appendChild(callbackIdFieldElement);

            var callbackParamFieldElement = xmlRequestFrame.document.createElement("INPUT");

            callbackParamFieldElement.type = "hidden";

            callbackParamFieldElement.name = "__CALLBACKPARAM";

            callbackParamFieldElement.value = eventArgument;

            xmlRequestFrame.document.forms[0].appendChild(callbackParamFieldElement);

            if (theForm["__EVENTVALIDATION"]) {

                var callbackValidationFieldElement = xmlRequestFrame.document.createElement("INPUT");

                callbackValidationFieldElement.type = "hidden";

                callbackValidationFieldElement.name = "__EVENTVALIDATION";

                callbackValidationFieldElement.value = theForm["__EVENTVALIDATION"].value;

                xmlRequestFrame.document.forms[0].appendChild(callbackValidationFieldElement);

            }

            var callbackIndexFieldElement = xmlRequestFrame.document.createElement("INPUT");

            callbackIndexFieldElement.type = "hidden";

            callbackIndexFieldElement.name = "__CALLBACKINDEX";

            callbackIndexFieldElement.value = callbackIndex;

            xmlRequestFrame.document.forms[0].appendChild(callbackIndexFieldElement);

            xmlRequestFrame.document.forms[0].submit();

        }

    }, 10);

}










    
//TAB FUNCTION

var sTableIDs = "tblMarket_1,tblMarket_2";
var sTDIDs = "tdMarket_1,tdMarket_2";

function TabControl(obj)
{
      var tbl = document.getElementById(obj.id.replace('td', 'tbl'));         
      tbl.style.display = (document.all ? "block" : "table");           
}

function TabOff()
{
    var arTDs = new Array();
    arTDs = sTDIDs.split(',');
    var i = 0;
    var td, tbl;
    while (i <= (arTDs.length - 1))
    {
        td = document.getElementById(arTDs[i]);
        tbl = document.getElementById(arTDs[i].toString().replace('td', 'tbl'));
        tbl.style.display = "none";
        td.className = 'tabOFF';
        i++;
    }
}

function ShowHideRow(img, rowID)
{
    if (document.getElementById(rowID).style.display == "none")
    {
        document.getElementById(rowID).style.display = (document.all && !window.opera ? "block" : "table-row");  
        if(img != null){ img.src = img.src.replace('plus', 'minus'); }
    }
    else
    {
        document.getElementById(rowID).style.display = "none";
        if(img != null){ img.src = img.src.replace('minus', 'plus'); }
    }
}

function showContentDiv(d) { 
    document.getElementById(d).style.display = "none";
    document.getElementById('cont').style.display = "block";
}
function showScorecardDiv(d,e) { 
    document.getElementById(d).style.display = "none";
    document.getElementById(e).style.display = "none";  
    document.getElementById('scorecard').style.display = "block";
}
function showComparisonDiv(d,e) {
    document.getElementById(d).style.display = "none";
    document.getElementById(e).style.display = "none";
    document.getElementById('comparison').style.display = "block";
}

function setVis(id, visibility, left) {
            
            var x = document.getElementById(left).style.left;
            var y = document.getElementById(left).style.top;
            document.getElementById(id).style.display = visibility;
            document.getElementById(id).style.left = 210 - x;
            document.getElementById(id).style.top =  y;
           
        }
        
        
function SetValue(id, Value)
{
    document.getElementById(id).value = Value;
    
}
function OpenStatus(DocumentID, LabelID, ImageID)
{
    var str = 'StatusPopUp.aspx?DocumentID=' + DocumentID + '&LabelID=' + LabelID + '&ImageID=' + ImageID;
   
    var obj = window.open(str,'Status', 'width=800,height=700,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,modal=yes');
    
     

    if(obj == null)
        window.alert('Please disable your popup blocking software.');
        
       
}
function CloseStatus(LabelID, Values, ImageID)
{
    var obj = parent.opener.document.getElementById(ImageID);
    if(obj != null)
    {
        obj.alt = Values;
        obj.style.display = 'block';
     }
        
        window.close();
}
function SetAddtionalText(LabelID, TextID)
{
    document.getElementById(LabelID).innerHTML = document.getElementById(TextID).value;
}
function ClearText(HidID)
{
alert('test');
document.getElementById(HidID).value = '';

}
function PopText(Text)
{
    var str = 'PopUp.aspx?Text=' + Text;
    var obj = window.open(str,'Text', 'width=500,height=300,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,modal=yes');
 
  if(obj == null)
        window.alert('Please disable your popup blocking software.');
}
function OpenWindow(url)
{
    var obj = window.open(url, "","","");

 if(obj == null)
        window.alert('Please disable your popup blocking software.');

}

 function setVis(id, visibility, left) {
            
            var x = document.getElementById(left).style.left;
            document.getElementById(id).style.display = visibility;
            document.getElementById(id).style.top = document.getElementById(left).style.top;
            document.getElementById(id).style.left = document.getElementById(id).style.width/50 - x;
        }
        
      
      $.fn.disable = function()
      {
        return this.each(function() {
            if(typeof this.disabled != "undefined") this.disabled = true;
        });
      }
        
function NotAccepted()
{
    $(".ControlContent input").disable();
    $(".ControlContent select").disable();
    
   
 
}
