﻿// JavaScript Document

// Strip all HTML tags
function strip_tags(string)
{
    var re= /<\S[^><]*>/g;
    return string.replace(re, "");
}

// Short for document.write
function w(string)
{
    if(string) return document.write(string);
}

function show_page_header(today_date,update_time)
{
    w('<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">');
    w('<tr>');
    w('<td width="110"><img src="images/logo.gif" width="110" height="50" /></td>');
    w('<td align="center"><img src="images/otc_banner.gif"><td width="200">');
    w('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
    w('<tr>');
    w('<td align="center"><font color="#000000"><strong>Ngày ' + today_date + '</strong></font><br/><div id="clock" style="color:blue; padding-top:3px; font-weight:bold">&nbsp;</div></td>');
    w('</tr>');
    w('<tr>');
    w('<td align="center">&nbsp;</td>');
    w('</tr>');
    w('</table>');
    w('</td>');
    w('</tr>');
    w('</table>');
    w('<div align="left" style="float: left; height:20; color:#ffffff; padding-top:3px"> <strong>Bảng giá được cập nhật lúc: '+ update_time + '</strong></div>');
    w('<div align="right" style="float: right; height:20; color:#FFFF00; padding-top:3px">Đơn vị tính: <strong>1.000 VNĐ</strong> - Khối lượng: <strong>100 CP</strong></div>');
    w('<div style="clear: both"></div>');

}

function show_otc_table_head()
{
    w('<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">');
}

function show_otc_title()
{
    w('<tr>');
    w('<td width="50" rowspan="2" align="center" class="title_td"><strong>Mã</strong></td>');
    w('<td rowspan="2" align="center" class="title_td"><strong>Tên cty</strong></td>');
    w('<td rowspan="2" align="center" class="title_td"><strong>Mệnh giá</strong></td>');
    w('<td rowspan="2" align="center" class="title_td"><strong>Giá TC GN </strong></td>');
    // w('<td colspan="6" align="center" class="title_td"><strong>DƯ MUA </strong></td>');
    w('<td colspan="3" align="center" class="title_td"><strong>GD gần nhất</strong></td>');
    //w('<td colspan="6" align="center" class="title_td"><strong>DƯ BÁN </strong></td>');
    w('</tr>');
    w('<tr>');
    // w('<td align="center" class="title_td"><strong>Giá 3</strong></td>');
    //w('<td align="center" class="title_td"><strong>KL 3</strong></td>');
    //w('<td align="center" class="title_td"><strong>Giá 2</strong></td>');
    //w('<td align="center" class="title_td"><strong>KL 2</strong></td>');
    //w('<td align="center" class="title_td"><strong>Giá 1</strong></td>');
    //w('<td align="center" class="title_td"><strong>KL 1</strong></td>');
    w('<td align="center" class="title_td"><strong>Giá khớp 1</strong></td>');
    w('<td align="center" class="title_td"><strong>Giá khớp 2</strong></td>');
    w('<td align="center" class="title_td"><strong>+/-</strong></td>');
    // w('<td align="center" class="title_td"><strong>Giá 1</strong></td>');
    //w('<td align="center" class="title_td"><strong>KL 1</strong></td>');
    //w('<td align="center" class="title_td"><strong>Giá 2</strong></td>');
    //w('<td align="center" class="title_td"><strong>KL 2</strong></td>');
    //w('<td align="center" class="title_td"><strong>Giá 3</strong></td>');
    //w('<td align="center" class="title_td"><strong>KL 3</strong></td>');
    w('</tr>');
}

function color_price(price1,price2)
{
    if(price1>0)
    {
        if (price1 > price2)
            return '<font color=#33CCFF>' + price1.toFixed(2) + '</font>';
        else if (price1 < price2)
            return '<font color=red>' + price1.toFixed(2) + '</font>';
        else
            return price1.toFixed(2);
    }
    else
        return price1.toFixed(2);
		
}

function arrow_price(chenhlech)
{
    if(chenhlech>0)
    {
        return '<img src="./images/up.gif">+';
    }
    else if(chenhlech<0)
    {
        return '<img src="./images/down.gif"> ';
    }
    else
    {
        return '<img src="./images/stand.gif"> ';
    }
		
}

function show_otc_row(otc_no,otc_id,otc_code,price,otc_info,open_price,match_price_1,match_price_2,chenh_lech)
//function show_otc_row(otc_no,otc_id,otc_code,price,otc_info,open_price,match_price,match_vol,is_fixed,chenh_lech)
{
    if((otc_no%2) ==0) class_no=1;
    else class_no=2;

    w('<tr height=17>');
    w('<td class="ma_otc_td' + class_no + '">' + otc_code + '</td>');
    w('<td class="ten_cty_td' + class_no + '">' + otc_info + '</td>');
    w('<td class="menh_gia_td' + class_no + '">' + price + '</td>');
    w('<td class="gia_tc_td' + class_no + '">' + open_price.toFixed(2) + '</td>');
    //w('<td class="du_mua_td' + class_no + '">' + color_price(buy_price3,open_price) + '</td>');
    // w('<td class="du_mua_td' + class_no + '">' + buy_vol3 + '</td>');
    //w('<td class="du_mua_td' + class_no + '">' + color_price(buy_price2,open_price) + '</td>');
    //w('<td class="du_mua_td' + class_no + '">' + buy_vol2 + '</td>');
    // w('<td class="du_mua_td' + class_no + '">' + color_price(buy_price1,open_price) + '</td>');
    //w('<td class="du_mua_td' + class_no + '">' + buy_vol1 + '</td>');
    w('<td class="khop_td' + class_no + '">' + color_price(match_price_1, open_price) + '</td>');
    w('<td class="khop_td' + class_no + '">' + color_price(match_price_2, open_price) + '</td>');
    w('<td class="khop_td' + class_no + '">' + arrow_price(chenh_lech) + chenh_lech.toFixed(2) + ' ' + '</td>');
    //w('<td class="khop_td' + class_no + '">' + arrow_price(chenh_lech) + '<?=$cl?> ' + chenh_lech + ' ' + '</td>');
    //w('<td class="du_ban_td' + class_no + '">' + color_price(sell_price1,open_price) + '</td>');
    //w('<td class="du_ban_td' + class_no + '">' + sell_vol1 + '</td>');
    //w('<td class="du_ban_td' + class_no + '">' + color_price(sell_price2,open_price) + '</td>');
    //w('<td class="du_ban_td' + class_no + '">' + sell_vol2 + '</td>');
    //w('<td class="du_ban_td' + class_no + '">' + color_price(sell_price3,open_price) + '</td>');
    //w('<td class="du_ban_td' + class_no + '">' + sell_vol3 + '</td>');

    w('</tr>');
}

function show_otc_table_foot()
{
    w('</table>');
}

function show_page_footer()
{
    w('<br/><div align="center" class="footer">Bản quyền <a href="http://www.dnsc.com.vn" target="_blank">Công ty chứng khoán Đà Nẵng (Da Nang Securities Company).</a></div>');
}
