﻿function clickclear(thisfield, defaulttext) {
    // alert("hi");
    //thisfield.value="";
    if (thisfield.value == defaulttext) {
        thisfield.value = ""
    }
}
function clickrecall(thisfield, defaulttext) {
    if (thisfield.value == "") {
        thisfield.value = defaulttext;
    }
}
function ClearText() {
    var param = trim(document.getElementById("txtGetQuote").value);
    if (param == 'Enter company Name') {
        document.getElementById("txtGetQuote").value = "";
    }
}
function ClearTextPanCard() {
    var param = trim(document.getElementById("txtPanCard").value);
    if (param == 'Enter Pan Card No.') {
        document.getElementById("txtPanCard").value = "";
    }
}
function validation() {


    var PanCardNo = document.getElementById('txtPanCard');
    if (!ChkBlank(PanCardNo, "Pan card No.") ||
                          !isSpclChar(PanCardNo, "Pan Card")) {
        return false;

    }
    else {
        var pancard = document.getElementById('txtPanCard').value;
        window.open('ClientStatusPopUp.aspx?Pan=' + pancard, "childwin", " width=400,height=450,toolbar=no,status=no,menubar=no,address=no");
        document.getElementById('txtPanCard').value = "";
        return true;
    }

}

function isSpclChar(objID, strMsg) {
    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
    var txtPan = objID.value;
    for (var i = 0; i < txtPan.length; i++) {
        if (iChars.indexOf(txtPan.charAt(i)) != -1) {
            alert(strMsg + ": Special Charatcers are not allowed");
            objID.focus();
            objID.select();
            return false;
        }
        else {
            return true;
        }
    }
}
function ChkBlank(objID, strMsg) {
    var Txt = "Should Not be Blank";

    if (objID.value == "Enter Pan Card No." || objID.value == "") {
        alert(strMsg + " : " + Txt);
        objID.focus();
        objID.select();
        return false;
    }
    else {
        return true;
    }
}
function toUpper() {
    var PanCardNo = document.getElementById('txtPanCard');
    PanCardNo.innerText = PanCardNo.value.toUpperCase();

}

function trim(val) {
    var ret = val.replace(/^\s+/, '');
    ret = ret.replace(/\s+$/, '');
    return ret;
}
function GetQuotes() {
    if (document.getElementById("txtGetQuote").value == "Enter Company Name") {
        alert("Please select a Company Name from List");
        document.getElementById("txtGetQuote").focus();
        return false;
    }
    else {
        try {
            var URL = "http://www.angelbroking.com/Company/GetQuoteNew.aspx?id=" + document.getElementById("txtGetQuote_hidden").value;



            setTimeout("__doPostBack('stock','')", 2000);
            document.getElementById("txtGetQuote").value = "Enter Company Name";
            window.open(URL,"_self");
        } catch (e)
                { }
    }
    return false;
}

function myparentsensex(sensex, senact, sentime, ck, sentdate) {

    try {

        //  document.getElementById('sensex_time').innerHTML = sentdate +" "+sentime;
        document.getElementById('sensexPerChg').innerHTML = senact;
        document.getElementById('sensexVal').innerHTML = sensex;
        if (ck == "0") {
            document.getElementById('sensexVal').style.color = "#fa0909";
            document.getElementById('sensexPerChg').style.color = "#fa0909";
            document.getElementById('senImg').src = "images/red_triangle.png";



        } else {
            document.getElementById('sensexVal').style.color = "#039000";
            document.getElementById('sensexPerChg').style.color = "#039000";
            document.getElementById('senImg').src = "images/green_triangle.png";
        }
    } catch (e) {

    }
}
function myparentnifty(nifty, nifact, niftime, ck, niftydate) {
    try {
        document.getElementById('nifty_time').innerHTML = niftydate + " " + niftime;
        document.getElementById('nifPerChg').innerHTML = nifact;
        document.getElementById('nifVal').innerHTML = nifty;
        if (ck == "0") {
            document.getElementById('nifVal').style.color = "#fa0909";
            document.getElementById('nifPerChg').style.color = "#fa0909";
            document.getElementById('nifImg').src = "images/red_triangle.png";
        } else {
            document.getElementById('nifVal').style.color = "#039000";
            document.getElementById('nifPerChg').style.color = "#039000";
            document.getElementById('nifImg').src = "images/green_triangle.png";
        }
    } catch (e) {
    }

}

function openSite(ID) {
            if (ID == '1') {
                window.open('http://www.angelbroking.com', '_blank')
            }
            else if (ID == '2') {
                window.open('http://www.angelmf.com', '_blank')
            }
            else if (ID == '3') {
                window.open('http://www.angelcommodities.com', '_blank')
            }
            else if (ID == '4') {
                window.open('http://www.angelsecurelife.com', '_blank')
            }
            else if (ID == '5') {
                window.open('http://www.angelsecurities.in', '_blank')
            }
            else {
                return false;
            }
        }




        var win = null;
        function NewWindow(mypage, myname, w, h, scroll, pos) {
            if (pos == "random") { LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100; TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100; }
            if (pos == "center") { LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100; }
            else if ((pos != "center" && pos != "random") || pos == null) { LeftPosition = 0; TopPosition = 20 }
            settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
            win = window.open(mypage, myname, settings);
        }

 function myparentsensex(sensex, senact, sentime, ck,sentdate) {

            try {
      
                document.getElementById('sensex_time').innerHTML = sentdate +" "+sentime;
                document.getElementById('sensexPerChg').innerHTML = senact;
                document.getElementById('sensexVal').innerHTML = sensex;
                if (ck == "0") {
                    document.getElementById('sensexVal').style.color = "#fa0909";
                    document.getElementById('sensexPerChg').style.color = "#fa0909";
                    document.getElementById('senImg').src = "images/red_triangle.png";



                } else {
                document.getElementById('sensexVal').style.color = "#039000";
                document.getElementById('sensexPerChg').style.color = "#039000";
                    document.getElementById('senImg').src = "images/green_triangle.png";
                }
            } catch (e) {
            
            }
        }
        function myparentnifty(nifty, nifact, niftime, ck,niftydate) {
            try {
                document.getElementById('nifty_time').innerHTML =niftydate+" "+ niftime;
                document.getElementById('nifPerChg').innerHTML = nifact;
                document.getElementById('nifVal').innerHTML = nifty;
                if (ck == "0") {
                    document.getElementById('nifVal').style.color = "#fa0909";
                    document.getElementById('nifPerChg').style.color = "#fa0909";
                    document.getElementById('nifImg').src = "images/red_triangle.png";
                } else {
                document.getElementById('nifVal').style.color = "#039000";
                document.getElementById('nifPerChg').style.color = "#039000";
                    document.getElementById('nifImg').src = "images/green_triangle.png";
                }
            } catch (e) {
            }

        }
        
