﻿// JScript File
function SetFrameWidth(curframe,lrwidth)
{
  var cw=document.body.clientWidth;//body width
  var framewidth=cw-parseInt(lrwidth);
  framewidth=(framewidth<742)?742:framewidth;
  document.getElementById(curframe).style.width=framewidth+"px";
  document.getElementById('tdFrame').style.width=framewidth+"px";
  
}

function getInnerHeight(iframe)
{
    var d=iframe.contentWindow ?
    iframe.contentWindow.document :
    iframe.contentDocument;
    var h=0;
    if(d){
    if(d.documentElement && d.compatMode &&
    d.compatMode=="CSS1Compat")
    h=d.documentElement.scrollHeight;
    else if(d.body)
    h=d.body.scrollHeight;
    if(h) h+=getInsets(d);
    }

    document.getElementById('imgDiv').style.display='none';
    document.getElementById('mainFrame').style.visibility='visible';
    
     var frameheight="909px";
    if(h>909) frameheight=h+"px";
    return frameheight;
    
    //return (h||850)+"px"; //300 is a default value
}
function getInsets(d)
{
    if(d.body.currentStyle)
    with (d.body.currentStyle)
    return (parseInt(marginTop)||0) +
    (parseInt(marginBottom)||0) +
    (parseInt(paddingTop)||0) +
    (parseInt(paddingBottom)||0);
    if(d.defaultView && d.defaultView.getComputedStyle)
    with (d.defaultView)
    return parseInt(getComputedStyle(d.body,"").
    getPropertyValue("margin-top"))+
    parseInt(getComputedStyle(d.body,"").
    getPropertyValue("margin-bottom"))+
    parseInt(getComputedStyle(d.body,"").
    getPropertyValue("padding-top"))+
    parseInt(getComputedStyle(d.body,"").
    getPropertyValue("padding-bottom"));
    return 0;
}

 function setPage(url)
{
    document.getElementById('tablemaster').focus();
    document.body.scrollTop =0;
    var ifrme = document.getElementById('mainFrame');
    ifrme.src=url;
    ifrme.style.visibility='hidden';
    document.getElementById('imgDiv').style.display='block';
    
   
}

function checkPhoneNo(evt)
{   
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if(charCode==40 || charCode==41 || charCode==43 || charCode==45 || charCode==32) return true;
    if (charCode > 31 && (charCode < 48 || charCode > 57) )
    {
        alert("تشكيل الهاتف / الجوال / الفاكس باستخدام 0-9 + - ( ) مسافه"); 
        return false;
    }
}

function checkIntegers(evt)
{   
    var charCode = (evt.which) ? evt.which : event.keyCode;
    //alert(charCode);
    if (charCode > 31 && (charCode < 48 || charCode > 57))
    { 
        alert("Numbers  0-9 Only");
        return false;
    }
}

var oldwindow;
function showPopUp(url,width,height)
{
    var clwidth=window.parent.document.documentElement.clientWidth;
    var left=clwidth-width;//clwidth-width(popup)
    var settings="width="+width+",height="+height+",left="+left+" ,top=0,toolbar=0,status=0,scrollbars=yes, resizable=no";
    if(oldwindow) oldwindow.close();                      
    oldwindow=window.open(url,"",settings); 
               
}


function closeChild()
{ 
   if(oldwindow)oldwindow.close();                
             
}



function validateNumberKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if(charCode==40 || charCode==41 || charCode==43 || charCode==45 || charCode==32) return true;
    if (charCode > 31 && (charCode < 48 || charCode > 57) )
    {
        return false;
    }
}

//Begin of Get a quote
function showTickers()
{
    var thisDiv = document.getElementById("tickersDiv");
    thisDiv.style.display = "none";
    var mid = document.getElementById("Market").value;
    if(oldwindow)
        oldwindow.close();
    oldwindow = window.open("tickers.aspx?mid="+ mid, "","resizable=0,scrollbars=1,top=0,left=500,width=600,height=1000");
}
function showTickerList()
{
    var thisDiv = document.getElementById("tickersDiv");
    thisDiv.style.display = "block";
    var tickerStr =event.srcElement.value;
    var mid = document.getElementById("Market").value;

    var req;
    if (window.XMLHttpRequest)
        req = new XMLHttpRequest();
    else if (window.ActiveXObject)
        req = new ActiveXObject("Microsoft.XMLHTTP");
    var url = "gettickernames.aspx?tk=" + tickerStr + "&mid=" + mid;
    req.open('GET',url, false); 
    req.send(null);
    var result="";
    if(req.status == 200)
        result = req.responseText;
    thisDiv.innerHTML = result;
   
}
function setTVal(val)
{
    document.getElementById("txtSecurityName").value = val;
    var thisDiv = document.getElementById("tickersDiv");
    thisDiv.style.display = "none";
}
function showTickerInfo()
{
    var thisDiv = document.getElementById("tickersDiv");
    thisDiv.style.display = "none";
    var mid = document.getElementById("Market").value;
    var sid = document.getElementById("txtSecurityName").value;
    if(sid == "")
    {
        alert("أدخل شريط!");
    }
    else
    {
       var str="tickerinfo.aspx?mid=" + mid + "&sid=" + sid;
       setPage(str);
    }
}
//End of Get a quote