// Login Control functions

var isFirstFocusOnUserNameControl = true;
var EditMode = false;

function switchToPass(objRef,cssClassName)
{
	n = objRef.name;
	newInput = document.createElement("INPUT");
	newInput.type = "password";
	newInput.name = objRef.name;
	newInput.value = "";
	newInput.style.width = objRef.offsetWidth;	
	newInput.style.height = objRef.offsetHeight;
	newInput.className = cssClassName;
	passParent = objRef.parentNode;
	passParent.replaceChild(newInput, objRef);
	x = setTimeout(function()
	                {
	                  newInput.focus()
	                },150);
} 
function username_focus(objRef)
{	
	if (isFirstFocusOnUserNameControl)
	{
		objRef.value='';
		isFirstFocusOnUserNameControl = false;
	}
}
function IdCheck(sender, args)
{
    var iIdNumber = parseInt(args.Value);
    if (ClientIDValidate(iIdNumber)) 
    {    
        args.IsValid = true;
    }
    else
    {
       args.IsValid = false;
       return;
    }
}
function ClientIDValidate(idnumber)
{
    var strID = idnumber.toString();
    var leng = strID.length;
    var objRegExp = new RegExp("[^0-9]","g");
    

    if(leng < 9) // checking for leading zero
    {
        var addNull = 9 - leng;
        var addn = "0";
        for( i = 1; i <= (addNull-1); i++ )
        {
            addn += "0";
        }
        strID = addn + idnumber;
        leng = 9;
    }

    if(objRegExp.test(strID))
    {
        return false;
    }
    //****** Algorithm CheckID Number *******************************
    var sum = 0;
    var mul = 1;
    var result;
    var sum2;
    for( var i = 0; i <= (leng - 2); i++ )
    {
    sum2 = mul * Number( strID.substr(i,1) );
    if( sum2 > 9 )
    {
    sum2 -= 9;
    }
    sum += sum2;
    mul = 3 - mul;
    }

    sum = sum % 10;
    var result = 10 - sum;
    if( result == 10 )
    result = 0;

    if( Number( strID.substr(i,1) ) != result )
    {
        return false;
    }
    //ID passed successfuly
    return true;
}




// End Login Control functions

function SaveAsHtml()
{
    if (document.all) 
    {
    
        var OLECMDID_SAVEAS = 4;

        var OLECMDEXECOPT_DONTPROMPTUSER = 2;

        var OLECMDEXECOPT_PROMPTUSER = 1;

        var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";

        document.body.insertAdjacentHTML("beforeEnd", WebBrowser);

        WebBrowser1.ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER);

        WebBrowser1.outerHTML = "";
    } 
    else 
    {
        alert("This is only applicable to Internet Explorer");
    }
}


/* Begin webpart design*/
function SetWebpartBorder()
{
	var arrTableCells = document.getElementsByTagName("td");
	var i = 0;
	
	while(i < arrTableCells.length)
	{
		var cell = arrTableCells[i];
		if(cell.className.toLowerCase() == "ms-wpborder")
		{ 
		    WrapWebpart(cell, false); 
		}
		if(cell.className.toLowerCase() == "ms-wpborderborderonly")
		{  
		    WrapWebpart(cell, true); 
		}
		++i;
	}
	
	var arrTableRows = document.getElementsByTagName("tr");
	var i = 0;
	while(i < arrTableRows.length)
	{
		if(arrTableRows[i].className.toLowerCase() == "ms-wpheader")
		{
			AddBorderCell(arrTableRows[i]);
		}
		++i;
	}
}

function AddBorderCell(parentTr)
{
	var customTd = document.createElement("td");
	customTd.innerHTML = "&nbsp;"
	customTd.className = "ms-WPHeaderSideTd";
	parentTr.appendChild(customTd);
}

function WrapWebpart(cell, addHeaderRow) {

	var arrDivs = cell.getElementsByTagName("div");
	var div = arrDivs[0];
	
	if(navigator.userAgent.indexOf("MSIE") != -1) {
	    var oGPlus = div.getElementsByTagName("g:plusone");
	    if (oGPlus != null) return;
	}
	
	var wpMainTable = div.getElementsByTagName('table');
	
	var HasCombo=null;
	if (wpMainTable[0]!=null && wpMainTable[0]!='undefined')
	{
	    HasCombo =wpMainTable[0].getAttribute('cancel_JS_Border');
	}
	if(HasCombo==null || HasCombo=='')
	{
	var sInnerTable = "";
	sInnerTable += "<table cellpadding='0' cellspacing='0' width='100%'>";

	if(addHeaderRow)
	{
	    sInnerTable += " <tr>";
	    sInnerTable += "     <td class='ms-WPTopLeft'></td>";
	    sInnerTable += "     <td class='ms-WPTopMid'></td>";
	    sInnerTable += "     <td class='ms-WPTopRight'></td>";
	    sInnerTable += " </tr>";
	}
	
	sInnerTable += " <tr>";
	sInnerTable += "     <td class='ms-WPMidLeft'>&nbsp;</td>";
	sInnerTable += "     <td class='" + div.className + "'>" + div.innerHTML + "</td>";
	sInnerTable += "     <td class='ms-WPMidRight'>&nbsp;</td>";
	sInnerTable += " </tr>";
	sInnerTable += " <tr>";
	sInnerTable += "     <td class='ms-WPBottomLeft'></td>";
	sInnerTable += "     <td class='ms-WPBottomMid'></td>";
	sInnerTable += "     <td class='ms-WPBottomRight'></td>";
	sInnerTable += " </tr>";
	sInnerTable += "</table>";
	
	div.innerHTML = sInnerTable;
	}
}

/* End webpart design*/

/* Master Pages Common Functions */
var oZoneToWide = 0;

function HideEmptyZones() {

    //find empty zones and hide them if not having any content
    var oZone = document.getElementById("tdLeftBottom");
    HideRows(oZone, "tdLeftBottom");

    oZone = document.getElementById("tdCenterBottom");
    HideRows(oZone, "tdCenterBottom");

    oZone = document.getElementById("tdRightBottom");
    HideRows(oZone, "tdRightBottom");

    oZone = document.getElementById("tdPlaceHolderMain");
    HideRows(oZone, "tdPlaceHolderMain");
    
    oZone = document.getElementById("tdThreeTop");
    if(oZone != null) {
        HideRows(oZone, "tdThreeTop");
    }
    
    oZone = document.getElementById("tdThreeBottom");
    if(oZone != null) {
        HideRows(oZone, "tdThreeBottom");
    }
}

function HideRows(oZone, sZoneID) {

    if (oZone != null) {
        var iFirstLevelRows = 0;
        var iHiddenRows = 0;
        var sZoneHtml = CleanInnerHTML(oZone.innerHTML);
        var oCol=new Array();
        if (sZoneHtml.length > 10) {
            var oTRs = oZone.getElementsByTagName("tr");

            //new case for 3 columns web part zones
            if (sZoneID == "tdThreeBottom" || sZoneID == "tdThreeTop") {
                if (oTRs.length > 0) {
                    oTRs = oTRs[0].getElementsByTagName("td");
                }
            }

            for (k = 0; k < oTRs.length; k++) {
                if (IsFirstLevelTR(oTRs[k], sZoneID)) {
                    iFirstLevelRows++;
                    var oHTML = oTRs[k].innerHTML.toLowerCase();
                    //test for webpart zone
                    if (sZoneID == "tdThreeBottom" || sZoneID == "tdThreeTop") {
                        oCol[iHiddenRows] = oTRs[k];
                    }
                    if (oHTML.indexOf('<td id="msozonecell_') == -1 &&
                        oHTML.indexOf('<td id=msozonecell_') == -1 &&
                        oHTML.indexOf("<td id='msozonecell_") == -1) {
                        //if it's not webpart zone test for existing content (has at least a table or div inside)
                        var oTables = oTRs[k].getElementsByTagName("table");
                        var oDivs = oTRs[k].getElementsByTagName("div");
                        if (oTables.length == 0 && oDivs.length == 0) {
                            oTRs[k].style.display = "none";
                            if (sZoneID == "tdThreeBottom" || sZoneID == "tdThreeTop") {
                                oCol[iHiddenRows] = null;
                            }
                            iHiddenRows++;
                        }
                    }
                }
            }
        }

        if (iHiddenRows == iFirstLevelRows) {
            //hide separator if all first level rows are hidden
            oZone.style.display = "none";

            if (sZoneID == "tdThreeTop" || sZoneID == "tdThreeBottom") {
                oZone.parentNode.style.display = "none";
            }

            var oSeparatorNode = null;
            if (sZoneID == "tdRightBottom" || sZoneID == "tdCenterBottom") {
                oSeparatorNode = oZone.nextSibling;
                while (oSeparatorNode.nodeType != 1) {
                    oSeparatorNode = oSeparatorNode.nextSibling;
                }
            }

            if (sZoneID == "tdLeftBottom") {
                oSeparatorNode = oZone.previousSibling;
                while (oSeparatorNode.nodeType != 1) {
                    oSeparatorNode = oSeparatorNode.previousSibling;
                }
            }
            if (oSeparatorNode != null) {
                oSeparatorNode.style.display = "none";
            }

            if (sZoneID == "tdRightBottom" || sZoneID == "tdLeftBottom") {
                if (DetectBrowserVersion() == "IE8") {
                /*
                    if (sZoneID == "tdRightBottom") {
                        oZoneToWide++;
                    }
                    if (sZoneID == "tdLeftBottom") {
                        oZoneToWide++;
                    }
                    if (oZoneToWide == 1) {
                        document.getElementById("tdCenterBottom").style.width = "667px";
                    }
                    //else {
                        if (oZoneToWide == 2) {
                            document.getElementById("tdCenterBottom").style.width = "900px";
                        }
                    //}
                    */
                    document.getElementById("tdCenterBottom").style.width = "100%";
                }
                else {
                    document.getElementById("tdCenterBottom").style.width = "100%";
                }
            }
        }
        else {
            if (sZoneID == "tdThreeTop" || sZoneID == "tdThreeBottom") {
                for (j = 0; j < oCol.length; j++) {
                    if (oCol[j] != null) {
                        oCol[j].style.paddingRight = "0px";
                        j = 10;
                    }
                }
            }
        }
    }
}

function CleanInnerHTML(sHtml) {
    var iIndex = 0;
    while ((sHtml.indexOf(" ") > -1 ||
           sHtml.indexOf("\n") > -1 ||
           sHtml.indexOf("\r") > -1 ||
           sHtml.indexOf("\t") > -1) && iIndex<20) {
        sHtml = sHtml.replace(" ", "");
        sHtml = sHtml.replace("\n", "");
        sHtml = sHtml.replace("\r", "");
        sHtml = sHtml.replace("\t", "");
        iIndex++;
    }
    return sHtml;
}

function IsFirstLevelTR(oTR, sZoneID) {

    var iLevel = 0;
    var bIsLevel1 = false;
    while (iLevel<4 && oTR.parentNode!=null && bIsLevel1==false)
    {
        if (oTR.parentNode.id!=null)
        {
            if (oTR.parentNode.id == sZoneID)
            {
                bIsLevel1 = true;
            }
        }
        oTR = oTR.parentNode;
        iLevel = iLevel+1;
    }
    
    return bIsLevel1;
}


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
function DetectBrowserVersion() {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
        var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
        if (ieversion >= 8)
            return "IE8";
        else if (ieversion >= 7)
            return "IE7";
        else if (ieversion >= 6)
            return "IE6";
        else if (ieversion >= 5)
            return "IE5";
    }
    else {
        if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
            var ffversion = new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ffversion >= 3)
                return "FF3";
            else if (ffversion >= 2)
                return "FF2";
            else if (ffversion >= 1)
                return "FF1";
        }
        else {
            return "";
        }
    }
}

function WebpartZoneIsNotEmpty(tdZoneId)
{
	var tdZone = document.getElementById(tdZoneId);
	var iWebpartZoneIsNotEmpty = 0;
	var iMinmumElements = 0;
	
	if(tdZone != null) {
        if(tdZone.getElementsByTagName("div").length == iMinmumElements)
        {
            iWebpartZoneIsNotEmpty = 1;
        }

	}
	return iWebpartZoneIsNotEmpty;
}

function HideEmptyElement(tdZoneId, cellsCount)
{
    var tdZone = document.getElementById(tdZoneId);
    if(tdZone != null)
    {
        if (WebpartZoneIsNotEmpty(tdZoneId) == 1)
        {
            tdZone.style.display = "none";

            document.getElementById("innerSepLeft").style.display = "none";
            document.getElementById("tdCenterBottom").style.width = "100%";
        }
    }
}
/* End of Master Pages Common Functions */

function SetResolution()
{
    var HighResolutionCell = document.getElementById("HighResolutionCell");
    var MasterPageOuterTable = document.getElementById("MasterPageOuterTable");
    
    if(HighResolutionCell != null)
    {   
        if (screen.width >= 920)
        {
            HighResolutionCell.style.display = "";
        }
        else
        {
            MasterPageOuterTable.className = "masterContent";
        }
    }
}

function DetectBrowser()
{
    if (navigator.userAgent.indexOf("MSIE") != -1)
    {
        return "1";
    }
    else
    {
        return "2";
    }
}

function CheSearchChar() {

    if(event.keyCode == 222) {
        return false;
    }
}

// this method serves both the master pages and the search result page layout
function ModifySearchButton(containerId)
{
    if (document.getElementById("SRSB") != null) {
        var oSeachInput = document.getElementById("SRSB").getElementsByTagName("input")[0];
        if (window.addEventListener) { // Mozilla, Netscape, Firefox
            oSeachInput.addEventListener("onkeydown", CheSearchChar, false);
        } else { // IE
            oSeachInput.attachEvent("onkeydown", CheSearchChar);
        }
    }

    var oSearchButton = null;
    if(containerId == null)
    {
        oSearchButton = document.getElementById("SRSB");
     }
     else
     {
        var container = document.getElementById(containerId);
        if(container != null)
        {
            var arrDivs = container.getElementsByTagName("div");
            if(arrDivs != null)
            {
                var i = 0;
                while(i < arrDivs.length && oSearchButton == null)
                {
                    if(arrDivs[i].id.toUpperCase() == "SRSB")
                    {
                        oSearchButton = arrDivs[i];
                    }
                    ++i;
                }
            }
        }
     }

    if(oSearchButton != null)
    {
        var arrImages = oSearchButton.getElementsByTagName("img");
        if(arrImages != null)
        {
            if(arrImages.length > 0)
            {
                ReplaceSearchButtonImage(arrImages[0]);
            }
        }
    }
    
}

function ReplaceSearchButtonImage(img)
{
    var parent = img.parentNode;
    parent.innerHTML = img.getAttribute("title");
    parent.className = "mvs_SearchButton";
    
    /*
    var searchSpan = document.createElement("span");
    var searchText = img.getAttribute("title");
    var searchAltText = img.getAttribute("alt");
    var spanInnerHTML = "";
    spanInnerHTML += "  <table width='100%' height='100%' cellpadding='0' cellspacing='0'>";
    spanInnerHTML += "      <tr>";
    spanInnerHTML += "          <td class='SearchBoxLeftCorner'>&nbsp;</td>";
    spanInnerHTML += "          <td class='SearchBoxCenter'>" + searchText + "</td>";
    spanInnerHTML += "          <td class='SearchBoxRightCorner'>&nbsp;</td>";
    spanInnerHTML += "      </tr>";
    spanInnerHTML += "  </table>";
    searchSpan.innerHTML = spanInnerHTML
    searchSpan.setAttribute("title", searchAltText);
    parent.removeChild(img);
    parent.parentNode.className += " SearchBoxImage";
    parent.appendChild(searchSpan);
    searchSpan.onclick = new Function("this.parentNode.click();");
    */
}

/* Kav Manche Methods */
var arrImageSources = null;

function PopulateImageSourcesArray()
{
	var iTabsCount = 3; //
	var i = 0;		
	arrImageSources = new Array(iTabsCount);
	while(i < iTabsCount)
	{
		arrImageSources[i] = new Array(2); // two image sources for each tab (big & small)
		++i;
	}
	arrImageSources[0][0] = "http://web.bizportal.co.il/export/external/migdal/migdalxml.shtml?type=gifday";
	arrImageSources[0][1] = "http://web.bizportal.co.il/export/external/migdal/migdalxml.shtml?type=gifdayv";
	arrImageSources[1][0] = "http://web.bizportal.co.il/export/external/migdal/migdalxml.shtml?type=gifyear";
	arrImageSources[1][1] = "http://web.bizportal.co.il/export/external/migdal/migdalxml.shtml?type=gifyearv";
	arrImageSources[2][0] = "http://web.bizportal.co.il/export/external/migdal/migdalxml.shtml?type=gifyears";
	arrImageSources[2][1] = "http://web.bizportal.co.il/export/external/migdal/migdalxml.shtml?type=gifyearsv";
}

function SwitchTab(tabClickedRow)
{
	var oldValue = "selected";
	var newValue = "regular";

	if(tabClickedRow.className == "regularTabRow")
	{
		if(arrImageSources == null)
		{
			PopulateImageSourcesArray();
		}
		// switch other tabs
		var MainTabsRow = document.getElementById("MainTabsRow");
		if(MainTabsRow != null)
		{
			var selectedTabRowId = MainTabsRow.getAttribute("selectedTabRowId");
			var selectedTabRow = document.getElementById(selectedTabRowId);
			ModifyTabStyle(selectedTabRow , oldValue , newValue);
		}
		oldValue = "regular";
		newValue = "selected";
		ModifyTabStyle(tabClickedRow , oldValue , newValue);
		MainTabsRow.setAttribute("selectedTabRowId" , tabClickedRow.id);

		var imageSourceId = tabClickedRow.getAttribute("imageIndex");
		var imgBigGraph = document.getElementById("bigGraphImage");
		var imgSmallGraph = document.getElementById("smallGraphImage");
		imgBigGraph.src = arrImageSources[imageSourceId][0];
		imgSmallGraph.src = arrImageSources[imageSourceId][1];
	}
}

function ModifyTabStyle(tabRow, oldClassName, newClassName)
{
	var arrTabCells = tabRow.getElementsByTagName("td");

	if(arrTabCells != null)
	{
		var i = 0;
		tabRow.className = tabRow.className.replace(oldClassName , newClassName);
		while(i < arrTabCells.length)
		{
			arrTabCells[i].className = arrTabCells[i].className.replace(oldClassName , newClassName);
			++i;
		}
	}
}
function OpenLargeImage(obj)
{
    var openWindow = window.open("", "", "resizable=yes,scrollbars=yes,status=yes");
    openWindow.document.write(obj);
    openWindow.document.close();
}


 function Check(e){
    var KeyNum;
    if(window.event){
        KeyNum = e.keyCode;
    }else if(e.which){
        KeyNum = e.which;
    }
    // enter is the pressed key
    if (KeyNum == 13){
        return false;
    }              
    return true;
}

// SELF SERVICE SCRIPTS

function SelfServiceShowDescription(control, display)
{
    if (control)
    {
        div = control.nextSibling.nextSibling;
        if (div)
        {
            div.style.display = display;                   
        }
    }
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
// if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = SelfServiceGetMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function SelfServiceGetMouseXY(e) 
{
  if (IE) 
  {     
  
    var top = document.documentElement.scrollTop ?
                document.documentElement.scrollTop :
                document.body.scrollTop;
    var left = document.documentElement.scrollLeft ?
                document.documentElement.scrollLeft :
                document.body.scrollLeft;          
                
    // grab the x-y pos.s if browser is IE
    tempX = event.clientX + left;
    tempY = event.clientY + top;
  } 
  else 
  {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  
  // catch possible negative values in NS4
  if (tempX < 0)
  {
    tempX = 0;
  }
  if (tempY < 0)
  {
    tempY = 0;
  }  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  // document.Show.MouseX.value = tempX;
  // document.Show.MouseY.value = tempY;
  return true;
}

function SelfServiceCloseMe(control)
{
    if (control)
    {
        control.style.display = 'none';
    }
}

function ShowBubble(control, display) 
{
    if (control)
    {
        div = control.previousSibling;
        if (div)
        {
            if (div.innerText != "")
            {               
                div.style.display = display;
                if (tempX > 0 && tempY > 0)
                {
                    div.style.position = "absolute";
	                div.style.top = tempY - div.offsetHeight - 20;
	                // alert(div.offsetHeight);
	                div.style.left = tempX - 250;
                }
            }
        }
    }
}

function OpenForPrint()
{
    try
    {
        var url = document.URL;
        var separator = url.indexOf("?") > 0 ? "&" : "?";
        var newUrl = url + separator + "PageCurrentMode=PrintDisplay";            
        window.open(newUrl, '', '', '');
    }
    catch (e) {}       
    return false;
}

function ShowOrHideKranot(id, button)
        {
    
            var obj_ = document.getElementById(id);
            var elements = document.getElementsByName(id); 
            var clicker = document.getElementById(button);
            for (i=0;i<=elements.length;i++)
            {
                obj = elements[i];
                if(obj)
                {
                    if(obj.style.display == "block")
                    {
                        if(document.all){
                             clicker.innerText = "+";
                        } else {
                            clicker.textContent = "+";
                        }
                        obj.style.display = "none";
                    }
                    else
                    {
                        if(document.all){
                             clicker.innerText = "-";
                        } else {
                            clicker.textContent = "-";
                        }
                        obj.style.display = "block";
                    }
                }
            } 
            
            return false;
        }

// END SELF SERVICE SCRIPTS

//Start Registration Scripts

function ShowHideExplanation(div)
{

    divObj = document.getElementById(div);
    var e=document.getElementsByTagName("div");
    
    for(var i=0;i<e.length;i++)
    {
        
        if (e[i].title=='...' && divObj!=e[i])
        { 
            e[i].style.display = 'none'; 
            
        }
    }

    if (divObj!=null)
    {
        if (divObj.style.display == 'none')
        {
            divObj.style.display = '';
        }
        else
        {
            divObj.style.display = 'none'
        }
    }
}

//End Registration Scripts

function ActivateFlash()
{
    var theObjects = document.getElementsByTagName("object");
    if(theObjects != null)
    {
        var iObjectsNum = theObjects.length;
        for (var i = 0; i < iObjectsNum; i++)
        {
            theObjects[i].outerHTML = theObjects[i].outerHTML;
        }
    }
}

function ActivateResize() {
    this.parent.ResizeIframe();
}

function ResizeIframe() {

    var oIframes = document.getElementsByTagName('iframe');
    if (oIframes.length > 0) {
        for (iIndexFrame = 0; iIndexFrame < oIframes.length; iIndexFrame++) {
            if (oIframes[iIndexFrame].className.toLowerCase()=="iframesize") {
                ResizeIframeObject(oIframes[iIndexFrame]);
                RewriteATags(oIframes[iIndexFrame]);
            }
        }
    }
}

function RewriteATags(oIframe) 
{
    if (oIframe != null && oIframe != 'undefined') {
        var oTblBody = null;
        if (oIframe.contentDocument) { // DOM
            oTblBody = oIframe.contentDocument.getElementById('TabsMainTable');
        } else {
            if (oIframe.contentWindow) { // IE win
                oTblBody = oIframe.contentWindow.document.getElementById('TabsMainTable');
            }
        }

        if (oTblBody != null) {
            var oATags = oTblBody.getElementsByTagName("a");
            for (iTags = 0; iTags < oATags.length; iTags++) {
                if (oATags[iTags].href.indexOf("mvs") > -1) {
                    try {
                        if (oATags[iTags].href.toLowerCase().indexOf(".pdf") > -1) {
                            oATags[iTags].target = "_blank";
                        }
                        else {
                            oATags[iTags].target = "_parent";
                        }
                    }
                    catch (err) {
                        oATags[iTags].target = "_parent";
                    }
                }
                else {
                    oATags[iTags].target = "_blank";
                }
            }
        }
    }
}

function ResizeIframeObject(oIframe) {
    if (oIframe != null && oIframe != 'undefined') {
        var oTblBody = null;
        if (oIframe.contentDocument) { // DOM
            oTblBody = oIframe.contentDocument.getElementById('TabsMainTable');
        } else {
            if (oIframe.contentWindow) { // IE win
                oTblBody = oIframe.contentWindow.document.getElementById('TabsMainTable');
            }
        }

        if (oTblBody != null) {

            //ie and FF
            oIframe.style.height = oTblBody.scrollHeight + (oTblBody.offsetHeight - oTblBody.clientHeight) + 20 + "px";
        }
    }
}


function DisableBack()
{
    window.history.go(1);
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent;   // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}


function SetParentScroll()
{
    window.scrollTo(0, 0);
}

function CalculatorValidateDDL(oSelect, iErrID) {
    var oErrDiv = document.getElementById(oSelect.id + "_CalculatorErrErr" + iErrID);
    if (oSelect.value !='invalid') {
        oErrDiv.style.display = "none";
        oSelect.style.backgroundColor = "#ffffff";
        return true; 
    }
    oErrDiv.style.display = "inline";
    oSelect.style.backgroundColor = "#F9B2B3";
}

function OpenNewCalculator(oLink) {
    window.open(oLink, "_blank");
    return false;    
}


function ValidateControls(oLink, sDdlFoundType, sDdlStockPercentage, sDdlManagedAsset) {

    var oddlFoundType = document.getElementById(sDdlFoundType);
    var oddlStockPercentage = document.getElementById(sDdlStockPercentage);
    var oddlManagedAsset = document.getElementById(sDdlManagedAsset);

    if (oddlFoundType != null && oddlStockPercentage != null && oddlManagedAsset != null) {
        if (oddlFoundType.value != "invalid" && oddlStockPercentage.value != "invalid" && oddlManagedAsset.value != "invalid") {
            var oInterval = oddlStockPercentage.value.split('-');

            var oErrDiv1 = document.getElementById(sDdlFoundType + "_CalculatorErrErr1");
            var oErrDiv2 = document.getElementById(sDdlStockPercentage + "_CalculatorErrErr2");
            var oErrDiv3 = document.getElementById(sDdlManagedAsset + "_CalculatorErrErr3");
            oErrDiv1.style.display = "none";
            document.getElementById('ddl_' + sDdlFoundType).className = "";
            oErrDiv2.style.display = "none";
            document.getElementById('ddl_' + sDdlStockPercentage).className = "";
            oErrDiv3.style.display = "none";
            document.getElementById('ddl_' + sDdlManagedAsset).className = "";
            
            window.open(oLink + "?FundCategory=" + oddlFoundType.value + "&FromMaxInfo=" + oInterval[0] + "&ToMaxInfo=" + oInterval[1] + "&Period=" + oddlManagedAsset.value, "_blank");
            return false;
        }
        else {
            var oErrDiv1 = document.getElementById(sDdlFoundType + "_CalculatorErrErr1");
            var oErrDiv2 = document.getElementById(sDdlStockPercentage + "_CalculatorErrErr2");
            var oErrDiv3 = document.getElementById(sDdlManagedAsset + "_CalculatorErrErr3");
            
            if (oddlFoundType.value == "invalid") {
                oErrDiv1.style.display = "inline";
                document.getElementById('ddl_' + sDdlFoundType).className = "RedBG";
            }
            else {
                oErrDiv1.style.display = "none";
                document.getElementById('ddl_' + sDdlFoundType).className = "";
            }
            if (oddlStockPercentage.value == "invalid") {
                oErrDiv2.style.display = "inline";
                document.getElementById('ddl_' + sDdlStockPercentage).className = "RedBG";
            }
            else {
                oErrDiv2.style.display = "none";
                document.getElementById('ddl_' + sDdlStockPercentage).className = "";
            }
            if (oddlManagedAsset.value == "invalid") {
                oErrDiv3.style.display = "inline";
                document.getElementById('ddl_' + sDdlManagedAsset).className = "RedBG";
            }
            else {
                oErrDiv3.style.display = "none";
                document.getElementById('ddl_' + sDdlManagedAsset).className = "";
            }
            
            return false;
        }
    }
    return false;
}

function OnSelectedIndexChange(sID) {
    if (document.getElementById(sID) != null && document.getElementById(sID) != "-1") {
        var newUrl = document.getElementById(sID).value;
        setTimeout(function() {
            window.location = newUrl;
        }, 0);
    }
    return false;
}

function ValidateControlsSubjects(sUrl) {

    var oddlFoundType = document.getElementById("ddlSubjects");
    var oddlStockPercentage = document.getElementById("ddlSubSubjects");
    //var oddlManagedAsset = document.getElementById("ddlManagedAsset");

    if (oddlFoundType != null && oddlStockPercentage != null) {
        if (oddlFoundType.value != "-1" && oddlStockPercentage.value != "-1" ) {
            var newUrl = oddlStockPercentage.options[oddlStockPercentage.selectedIndex].value;
            setTimeout(function() {window.location = newUrl;}, 0);
            return true;
        }
        else {
            var oErrDiv1 = document.getElementById("FastErrErr1");
            var oErrDiv2 = document.getElementById("FastErrErr2");

            if (oddlFoundType.value == "-1") {
                oErrDiv1.style.display = "inline";
            }
            else {
                oErrDiv1.style.display = "none";
            }
            if (oddlStockPercentage.value == "-1") {
                oErrDiv2.style.display = "inline";
            }
            else {
                oErrDiv2.style.display = "none";
            }

            return false;
        }
    }
    return false;
}


function GetItemsSubjectsMain(sListName) {
    var oddlSubjects = document.getElementById("ddlSubjects");
    AjaxWebService.GetOptionsMainSubject(sListName,oddlSubjects.options[oddlSubjects.selectedIndex].text, SubjectsMainComplete);
    
 }

 function SubjectsMainComplete(result) {
     var oSubSubjects = document.getElementById("ddlSubSubjects");
     oSubSubjects.options.length = 1;
     
     var result = result.split('#');
     for (iIndex = 0; iIndex < result.length - 1; iIndex++) {
         var oOptions = result[iIndex].split('$');
         oSubSubjects.options[iIndex + 1] = new Option(oOptions[0], oOptions[1]);
     }

     jQuery('#ddlSubSubjects').resetSS();
     jQuery('#ddl_ddlSubjects').focus();
 }

 function RepositionWebpartManager() {
     var oManagerCell = document.getElementById("ctlWPManager");
     var oManagerBox = document.getElementById("MSOTlPn_MainTD");
     if (oManagerBox != null && oManagerCell != null) {
         oManagerCell.innerHTML = oManagerBox.innerHTML;
         oManagerBox.innerHTML = "";
         oManagerBox.style.display = "none";
     }
 }

 function HideSearchRightPart() {
     var oTD = document.getElementById("tdRightBottom");
     if (oTD != null) {
         oTD = oTD.parentNode;
         oTD = oTD.getElementsByTagName("td");
         for (k = 0; k < oTD.length; k++) {
             if (k == 0 || oTD[k].className == "InnerSeparator") {
                 oTD[k].style.display = "none";
             }
         }
     }
 }

 function DoClickLocation(oLink) {
     var sLink = oLink.getAttribute("location");
     window.top.location = sLink;
 }

 function bookmarksite() {
     var title = document.getElementsByTagName('title');
     title = title[0].innerHTML;
     if (title == "") {
         if (document.Title) {
             title = document.Title;
         }
     }
     var url = window.location.href;
     if (window.sidebar) // firefox
         window.sidebar.addPanel(title, url, "");
     else if (window.opera && window.print) { // opera
         var elem = document.createElement('a');
         elem.setAttribute('href', url);
         elem.setAttribute('title', title);
         elem.setAttribute('rel', 'sidebar');
         elem.click();
     }
     else if (document.all)// ie
         window.external.AddFavorite(url, title);
 }
