﻿function DisplayHideSection(sectionId)
{
    if(document.getElementById(sectionId).style.display == 'block')
    {
        document.getElementById(sectionId).style.display = 'none';
        if(sectionId.search('CommentPostId')!=-1 || sectionId.search('QuestionComment')!=-1 || sectionId.search('AnswerComment')!=-1)
        {
            elt = document.getElementById("Div"+sectionId);
            if(elt!=null)
                elt.className="headerHidden";          
        }            
    }
    else
    {
        document.getElementById(sectionId).style.display = 'block'            
        if(sectionId.search('CommentPostId')!=-1 || sectionId.search('QuestionComment')!=-1 || sectionId.search('AnswerComment')!=-1)
        {
            elt = document.getElementById("Div"+sectionId);                
            if(elt!=null)
                elt.className="headerShown";
        }
    }
    return false;                
}

function ConfirmDelete()
{
    return confirm("Are You sure?");
}


function getPrint(print_area, print_area2)
{ 
    //Creating new pagevar 

    pp = window.open();
    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
    pp.document.writeln('<HTML><HEAD>');
    //pp.document.writeln('<LINK href="/style/master.css" type="text/css" rel="stylesheet">');
    //pp.document.writeln('<LINK href="<%=CssStyle.Href%>" type="text/css" rel="stylesheet" media="print">')
    pp.document.writeln('<base target="_self"></HEAD>');
    //Adding Body Tag
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');
    pp.document.writeln(' leftMargin="0" topMargin="0" rightMargin="0">');
    //Adding form Tag
    pp.document.writeln('<form method="post">');
    //Creating two buttons Print and Close within a HTML table
    //pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right>');
    //pp.document.writeln('<DIV id="divPrint"><INPUT ID="PRINT" type="button" value="Print" ');
    //pp.document.writeln('onclick="javascript:document.getElementById(\'divPrint\').style.visibility = \'hidden\';window.print();javascript:location.reload(true); "></DIV>');
    //pp.document.writeln('<INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();">');
    //pp.document.writeln('</TD></TR><TR><TD></TD></TR></TABLE>');
    //Writing print area of the calling page
    pp.document.writeln(document.getElementById(print_area).innerHTML);
    if (print_area2 != null && print_area2 != '')
        pp.document.writeln(document.getElementById(print_area2).innerHTML);
    pp.document.writeln('<scr' + 'ipt language="javascript" type=text/javascript>window.print(); </scr' + 'ipt>');
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>'); 
}

function checkValue(e) 
{
    var val;
    if (typeof e.which != 'undefined') {
        val = e.which;
    }
    else {
        val = e.keyCode;
    }

    switch (val) {
        case 0: //navigation keys in Mozilla
        case 8: //backspace
        case 9: //tab
        case 13: //enter
        case 37: // left arrow
        case 38: // up arrow
        case 39: // right arrow
        case 40: // down arrow
        case 46: // delete
        case 48: //0
        case 49: //1
        case 50: //2
        case 51: //3
        case 52: //4
        case 53: //5
        case 54: //6
        case 55: //7
        case 56: //8
        case 57: //9
        case 96: // 0 num
        case 97: // 1 num
        case 98: // 2 num
        case 99: // 3 num
        case 100: // 4 num
        case 101: // 5 num
        case 102: // 6 num
        case 103: // 7 num
        case 104: // 8 num
        case 105: // 9 num
            return true;
        default:
            return false;
    }
}