
function SetCurrency(control)
{
	document.forms[0].basecurrency.value = control.options[control.options.selectedIndex].value;
	document.forms[0].submit();
}




function getId(id)
{
    return document.getElementById(id);
}

// Used to remove particular item from the array
Array.prototype.Remove = function (removeValue) 
{
    var r = new Array();
    for(iCount = 0; iCount < this.length; iCount++)
    {
	    if(!(this[iCount]==removeValue))
	    {
		    r[r.length] = this[iCount];
	    }
    }
    
    return r;
};

//Used to validate paricular item present in the array
Array.prototype.Contains = function(searchValue)
{
    var isExist = false;
    for(iCount = 0; iCount < this.length; iCount++)
    {
        if(this[iCount] == searchValue)
        {
            isExist = true;
        }
    }
    
    return isExist;
};

// Used to get index of the item from the array
Array.prototype.GetIndex = function (itemValue)
{
    var index = -1;
    for(iCount = 0; iCount < this.length; iCount++)
    {
	    if(this[iCount] == itemValue)
	    {
		    index = iCount;
		    break;
	    }
    }
    
    return index;
};

// Used to replace the item in the array
Array.prototype.Replace = function (oldItem,newItem)
{
    var r = new Array();
    for(iCount = 0; iCount < this.length; iCount++)
    {
	    if(this[iCount]==oldItem)
	    {
		    r[r.length] = newItem;
	    }
	    else
	    {
	        r[r.length] = this[iCount];
	    }
    }

    return r;
};


var commonClass = {

    DisplayIfNone : "-",
    
    DefaultPerfChart : "images/FundCentre/PerformanceChart.gif",
    
    DefaultSlidingChart : "images/FundCentre/SlidingChart.gif",
    
    QueryStringNames : new Array("citicode","sectorcode","range"),
    
    PrevRangeIndex : 0,
    
    CurrRangeIndex : 0,

    AllStr : "All",
    
    ResultStr : "Result..",
    
    EmptyStr: "",
    
    BodyStr : "Body",
    
    TableInstrument : 20,
    
    ChartInstrument : 10,
    
    DropDownIds : new Array("FundRangeDD","FundManagerDD","FundSectorDD","FundCurrenyDD","FundResultDD","RebaseDD"),
    
    Tabs : new Array("CumBelowTab","CumAboveTab","DisTab","AnnTab"),
    
    FieldTypes : new Array("KEY","CHK","FUND","CONTENT","DEL"),
    
    SelectedCodes : new Array(),
    
    SelectedColors : new Array(),
    
    TotalCodes : new Array(),
    
    HiddenCodes : new Array(),
    
    ChartColors : new Array("003354","776699","FF3377","DD6611","DD3311","5793AA","878787","57B6CF","447711","AACC87"),

    ChartLetters : new Array("A","B","C","D","E","F","G","H","I","J"),
    
    //ChartColors : new Array("003354","776699","FF3377","DD6611"),

    //ChartLetters : new Array("A1","B2","C3","D4"),
    
    MaintainLastDeletedColor : new Array(),
    
    IsAddition : false,
    
    MinDate : new Date(),
    
    MaxDate : new Date(),
    
    IsChartUpdate : false,
    
    Span : 0,
    
    IsAllowTab : false,
    
    IsBelowOneYearTab : false,

    PopulateDataOption : function(id,text,value)
    {
        if($('#'+ id + ' option[value = "'+value+'"]').html() == null)
        {
            $('#'+ id).append("<option value='"+value+"' title='"+text+"'>"+text+"</option>");
        }
    },
    
    PopulateDataOptionLabel: function(id,text,value,label)
    {
        if($('#'+ id + ' optgroup[label="'+label+'"]').html() == null)
        {
           $('#'+ id).append('<optgroup label="'+label+'"></optgroup>');
           $('#'+ id + ' optgroup[label='+label+']').append("<option value='"+value+"' title='"+text+"'>"+text+"</option>");
        }
        else 
        {
           $('#'+ id + ' optgroup[label="'+label+'"]').append("<option value='"+value+"' title='"+text+"'>"+text+"</option>");
        }
    },
    
    RemoveOptions : function(id)
    {
        $('#'+id).empty();
    },
    
    GetQueryString: function(key)
    {
        var defaultValue= '';
        key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
        var qs = regex.exec(window.location.href);
        return qs? qs[1] : defaultValue;
    },
    
    ResetChartData : function()
    {
        this.RangeIndex = 0;
        this.SelectedCodes = new Array();
        this.SelectedColors = new Array();
        this.TotalCodes = new Array();
        this.HiddenCodes = new Array();
        this.MaintainLastDeletedColor = new Array();
        this.MinDate = new Date();
        this.MaxDate = new Date();
        this.Span = 0;
        this.IsChartUpdate = false;
    }
}


var modalPopUpClass = {

    popupStatus : 0,

    LoadPopup:function()
    {
        if(this.popupStatus==0)
        {
            $("#backgroundPopup").css({"opacity": "0.7"});
            $("#backgroundPopup").css({"display":"block"});
            $("#popupContact").css({"display":"block"});
            this.popupStatus = 1;
        }
    },

    DisablePopup: function(){
        if(this.popupStatus==1)
        {
            $("#backgroundPopup").css({"display":"none"});
            $("#popupContact").css({"display":"none"});
            this.popupStatus = 0;
        }
    },

    CenterPopup: function(){
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $("#popupContact").height();
        var popupWidth = $("#popupContact").width();
        $("#popupContact").css({"position": "absolute","top": (windowHeight/2-popupHeight/2)+document.documentElement.scrollTop,"left": windowWidth/2-popupWidth/2});

        var version=0;
        if (navigator.appVersion.indexOf("MSIE") != -1)
        {
            version = parseFloat(navigator.appVersion.split("MSIE")[1]);
        }

        if(version != 6)
        {
            $("#backgroundPopup").css({"height": windowHeight});
        }
        else
        {
            windowHeight = $(document).height();
            $("#backgroundPopup").css({"position": "absolute","height": windowHeight});
        }
    },

    RespPageState: function(ch,messageStr)
    {
	    if(ch == 0)
	    {
	        $('select').css("visibility","visible");
		    this.DisablePopup();
	    }
	    else
	    {
	        $('select').css("visibility","hidden");
	        $('#popupContact').html(messageStr)
		    this.LoadPopup();
		    this.CenterPopup();
	    }
    }
}

$(window).scroll(function () 
{
    modalPopUpClass.CenterPopup();
});
