﻿/////////////////////
// common js scripts
// mainly CSS purpose
/////////////////////

function MouseOverRightButtons(eltId) {
    document.getElementById(eltId).className = "HoverRightButton";
}

function MouseOutRightButtons(eltId) {
    document.getElementById(eltId).className = "RightButtons";
}

function AccordionHeaderPress(eltId) {
    document.getElementById(eltId).className = "menuHeaderPressed";
    return false;
}


// About Company > History page
var historyYears = [ 1994, 1996, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ];
function ShowText(year) {
    // lets hide all history text and set CSS style to default
    var curYear; // div
    for(var i = 0; i < historyYears.length; i++)
    {
        curYear = document.getElementById("History_" + historyYears[i]);
        curYear.style.visibility = "hidden";
        curYear.style.display = "none";
        
        curYear = document.getElementById("History_" + historyYears[i] + "_a");
        curYear.style.color = "#999999";
    }
    
    curYear = document.getElementById("History_" + year);
    curYear.style.display = "block";
    curYear.style.visibility = "visible";
    
    curYear = document.getElementById("History_" + year + "_a");
    curYear.style.color = "#405D6C";    
}

// About Company > Results page
var resultsYears = [ 2006, 2007, 2008, 2009 ];
function ShowResults(year) {
    // lets hide all results graphics and set CSS style to default
    var curYear; // div
    for(var i = 0; i < resultsYears.length; i++)
    {
        curYear = document.getElementById("Results_" + resultsYears[i]);
        curYear.style.visibility = "hidden";
        curYear.style.display = "none";
        // deselect anchor
        curYear = document.getElementById("Results_" + resultsYears[i] + "_a");
        curYear.style.color = "#999999";
    }
    
    curYear = document.getElementById("Results_" + year);
    curYear.style.display = "block";
    curYear.style.visibility = "visible";
    
    // select anchor
    curYear = document.getElementById("Results_" + year + "_a");
    curYear.style.color = "#405D6C";
    
    switch(year)
    {
        case 2006:
            document.getElementById("LeftResults").style.height = "1173px";
            break;
        case 2007:
            document.getElementById("LeftResults").style.height = "1226px";
            break;
        default:
            document.getElementById("LeftResults").style.height = "1128px";
    }    
}

// About Company > Sponsorship page

// About Company > Management page
function ShowPicture(no) {
    // lets hide all management pics and set anchors text CSS style to default
    var curMan;    
    for(var i = 1; i < 6; i++)
    {
        // pics
        curMan = document.getElementById("Management_" + i);
        curMan.style.visibility = "hidden";
        curMan.style.display = "none";
        // anchors text
        curMan = document.getElementById("Management_" + i + "_a");
        curMan.style.color = "#999999";
    }
    // selected pic
    curMan = document.getElementById("Management_" + no);
    curMan.style.display = "block";    
    curMan.style.visibility = "visible";
    // selected text
    curMan = document.getElementById("Management_" + no + "_a");
    curMan.style.color = "#405D6C";    
}

// Insurance > Insurance Policy page
function ShowPolicy(no) {
    // lets hide all Policy pics and set anchors text CSS style to default
    var curPol;    
    for(var i = 1; i < 10; i++)
    {
        // pics
        curPol = document.getElementById("Policy_" + i);
        curPol.style.visibility = "hidden";
        curPol.style.display = "none";
        // anchors text
        curPol = document.getElementById("Policy_" + i + "_a");
        curPol.style.color = "#999999";
    }
    // selected pic
    curPol = document.getElementById("Policy_" + no);
    curPol.style.display = "block";    
    curPol.style.visibility = "visible";
    // selected text
    curPol = document.getElementById("Policy_" + no + "_a");
    curPol.style.color = "#405D6C";    
}

// Reinsurance page
function ShowRe(no) {
    // lets hide all Re pics and set anchors text CSS style to default
    var curRe;    
    for(var i = 1; i < 22; i++)
    {
        // pics
        curRe = document.getElementById("Re_" + i);
        curRe.style.visibility = "hidden";
        curRe.style.display = "none";
        // anchors text
        curRe = document.getElementById("Re_" + i + "_a");
        curRe.style.color = "#999999";
    }
    // selected pic
    curRe = document.getElementById("Re_" + no);
    curRe.style.display = "block";    
    curRe.style.visibility = "visible";
    // selected text
    curRe = document.getElementById("Re_" + no + "_a");
    curRe.style.color = "#405D6C";    
}

// Useful Information > About Ukraine page
function ShowUkr(no) {
    // lets hide all pics, bottom text and set anchors text CSS style to default
    var curUkr;    
    for(var i = 1; i < 17; i++)
    {
        // pics
        curUkr = document.getElementById("Ukr_" + i);
        curUkr.style.visibility = "hidden";
        curUkr.style.display = "none";
        // anchors text
        curUkr = document.getElementById("Ukr_" + i + "_a");
        curUkr.style.color = "#999999";
        // bottom text
        curUkr = document.getElementById("Ukr_" + i + "_txt");
        curUkr.style.visibility = "hidden";
        curUkr.style.display = "none";
    }
    // selected pic
    curUkr = document.getElementById("Ukr_" + no);
    curUkr.style.display = "block";    
    curUkr.style.visibility = "visible";
    // selected anchor
    curUkr = document.getElementById("Ukr_" + no + "_a");
    curUkr.style.color = "#405D6C";
    // selected bottom text
    curUkr = document.getElementById("Ukr_" + no + "_txt");
    curUkr.style.display = "block";    
    curUkr.style.visibility = "visible";    
}

// Useful Information > About Kharkov page
function ShowKh(no) {
    // lets hide all pics, bottom text and set anchors text CSS style to default
    var curKh;    
    for(var i = 1; i < 6; i++)
    {
        // pics
        curKh = document.getElementById("Kh_" + i);
        curKh.style.visibility = "hidden";
        curKh.style.display = "none";
        // anchors text
        curKh = document.getElementById("Kh_" + i + "_a");
        curKh.style.color = "#999999";
        // bottom text
        curKh = document.getElementById("Kh_" + i + "_txt");
        curKh.style.visibility = "hidden";
        curKh.style.display = "none";
    }
    // selected pic
    curKh = document.getElementById("Kh_" + no);
    curKh.style.display = "block";    
    curKh.style.visibility = "visible";
    // selected anchor
    curKh = document.getElementById("Kh_" + no + "_a");
    curKh.style.color = "#405D6C";
    // selected bottom text
    curKh = document.getElementById("Kh_" + no + "_txt");
    curKh.style.display = "block";
    curKh.style.visibility = "visible";
}

// this function prints current selection (<div id=selection )
function getPrint() {
    //Creating new page
    var pp = window.open();    
    //Adding HTML opening tag with <HEAD> ... </HEAD> portion
    pp.document.writeln('<HTML><HEAD><title>Print Preview</title>');
    pp.document.writeln('<LINK href="Style.css" type="text/css" rel="stylesheet">');
    pp.document.writeln('<LINK href="PrintStyle.css" 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('<INPUT ID="PRINT" type="button" value="Print" ');
    pp.document.writeln('onclick="javascript:location.reload(true);window.print();">');
    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
    var masterContent = document.getElementById("MasterContent");
    if(masterContent)
        pp.document.writeln(masterContent.innerHTML);
    //Ending Tag of </form>, </body> and </HTML>
    pp.document.writeln('</form></body></HTML>');
}

// this function cuts entered into Feedback>Question textarea symbols to max value
// <textarea maxlength="1000"
function TextareaMaxLength(obj)
{
    var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : "" ;
    if (obj.getAttribute && obj.value.length > mlength)
        obj.value=obj.value.substring(0, mlength);
}
