﻿function showSendComment()
{
    var SendComment = document.getElementById("divComments");
    if(SendComment.style.display == 'none')
    {
        SendComment.style.display = '';

        return;
    }
    if(SendComment.style.display == '')
    {
        SendComment.style.display = 'none';
        return;
    }
}
function checkMail(entry)
{
    var x = entry.value;
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(x)) {return true;}
    else {return false;}
}
function get_radio_value (radio_array)
{
  var i;
  for (i = 0; i < radio_array.length; i++)
   if (radio_array[i].checked)
    return radio_array[i].value;
  return null;
}

var LeftPos=(screen.width)?(screen.width-600)/2:100;
var TopPos=(screen.height)?(screen.height-250)/2:100;  

function Vote () 
{
    var vote = document.getElementsByName('vote');
    var id = get_radio_value(vote);
    
    if(id!=null)
        window.open("/VoteResult.aspx?VoteItem_ID=" + id,null,'height=250,width=600,status=no, resizable=no,scrollbar=no,toolbar=no,location=no,menubar=no,Left= '+LeftPos+',top='+TopPos);
    else
        alert('Bạn hãy lựa chọn ý kiến của mình!');
}

function ShowVoteResult () {
    window.open("/VoteResult.aspx",null,'height=250,width=600,status=no, resizable=no,scrollbar=no,toolbar=no,location=no,menubar=no,Left= '+LeftPos+',top='+TopPos);
}
function LoadImage(id,src)
{
    if (id.getAttribute("loi") == null)
    {  
        id.setAttribute("loi","1");
    } 
    else 
    { 
        id.setAttribute("loi",eval(id.getAttribute("loi")) + 1);
    }

    if (eval(id.getAttribute("loi")) >=2)
    { 
        var width = src.substr(src.lastIndexOf("=") + 1,src.length - src.lastIndexOf("=")); 
        id.onerror = null; 
        id.src = "/Images/no_image.jpg"; 
    } 
    else 
    {
        id.src = src;
    }
}
function ykien() {
    document.getElementById('ykienform').style.display = '';
    document.getElementById('idComment').style.display = 'none';
    document.getElementById('tdykien').style.backgroundImage = "url('/images/img_active.gif')";
    document.getElementById('tdguiykien').style.backgroundImage = "url('/images/img_inactive.gif')";
    document.getElementById('lnkguiykien').className = "comment_inactive";
    document.getElementById('lnkykien').className = "comment_active";
}

function guiykien() {
    document.getElementById('idComment').style.display = '';
    document.getElementById('ykienform').style.display = 'none';
    document.getElementById('tdykien').style.backgroundImage = "url('/images/img_inactive.gif')";
    document.getElementById('tdguiykien').style.backgroundImage = "url('/images/img_active.gif')"
    document.getElementById('lnkguiykien').className = "comment_active";
    document.getElementById('lnkykien').className = "comment_inactive";
}
function AjaxRequestURLNew(url) {

    var xmlHttp;
    try {
        if (!document.all) {
            xmlHttp = new XMLHttpRequest();
        }
        else {
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
    }
    catch (e) {
        alert("Your browser does not support AJAX!");
        return false;
    };
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            alert(xmlHttp.responseText);
        }
    };
    xmlHttp.open("GET", url, true); xmlHttp.send(null);
}
function Innit() {
    for (i = 1; i <= SumImage; i++) {
        if (document.getElementById(preName + i)) {
            if (i != 1) {
                var oldtop = eval(document.getElementById(preName + eval(i - 1)).offsetTop);
                var oldheight = 115;
                document.getElementById(preName + i).style.top = eval(oldtop + oldheight + HeightSeparator) + "px";
            }
        }
    }
}
function Loop() {
    for (i = 1; i <= SumImage; i++) {
        if (document.getElementById(preName + i)) {
            var newtop = eval(document.getElementById(preName + i).offsetTop) - eval(HeightStep);
            document.getElementById(preName + i).style.top = newtop + "px";
        }
    }
    for (i = 1; i <= SumImage; i++) {
        if (document.getElementById(preName + i)) {
            var j = i + SumImage - 1;//j = anh o duoi ; anh o dau se bi day xuong duoi cung
            if (j > SumImage) j = j - SumImage;
            var height = document.getElementById(preName + i).offsetHeight;
            if (eval(document.getElementById(preName + i).offsetTop) < -height) {
                var oldtop = eval(document.getElementById(preName + j).offsetTop);
                var oldheight = eval(document.getElementById(preName + j).offsetHeight);
                document.getElementById(preName + i).style.top = eval(oldtop + oldheight + HeightSeparator) + "px";
            }
        }
    }
    t = setTimeout("Loop()", speed);
}
function statLoop() { t = setTimeout("Loop()", speed); }
function stopLoop() { clearTimeout(t) }