﻿
/////////////////////////////////////////////////////////////////////////
// POPUP WINDOW
/////////////////////////////////////////////////////////////////////////
function openWindow(strURL, wWidth, wHeight) 
{
    if (wWidth == null) wWidth = (screen.width * 80) / 100;
    if (wHeight == null) wHeight = (screen.height * 80) / 100;
    
    //SPECIFY CENTER
    leftVal = (screen.width - wWidth) / 2;
    topVal = (screen.height - wHeight) / 2;
    
    //OPEN NEW WINDOW
    newWindow = window.open(strURL, 'NewWindow', 'width=' + wWidth + ',height=' + wHeight + ',left=' + leftVal + ',top=' + topVal + ',scrollbars=yes');
}

/////////////////////////////////////////////////////////////////////////
// EXTEND OBJECT FUNCTIONALITY
/////////////////////////////////////////////////////////////////////////
document.getElementsByClassName = function(cl) {
    var retnode = [];
    var myclass = new RegExp('\\b' + cl + '\\b');
    var elem = this.getElementsByTagName('*');
    for (var i = 0; i < elem.length; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) retnode.push(elem[i]);
    }
    return retnode;
};

/////////////////////////////////////////////////////////////////////////
// TRANSLATE BY USING GOOGLE
/////////////////////////////////////////////////////////////////////////
function GoTranslate() {
    google.load("language", "1");
    google.setOnLoadCallback(initialize);
}

function initialize() {    
    var goot = document.getElementsByClassName('enTrans');
    if (goot != null) {    
        if (goot.length > 0) {
            document.getElementById('branding').style.display = 'block';
            google.language.getBranding('branding');
        } else { document.getElementById('branding').style.display = 'none'; }
        
        for (i = 0; i < goot.length; i++) {
            if (goot[i].innerHTML != null && goot[i].innerHTML != '') {
                TRes(goot[i]);
            }
        }
    }
}

function TRes(obj) {
    google.language.translate(obj.innerHTML, "en", "es", function(result) {
        if (!result.error) {
            obj.innerHTML = result.translation;
        }
    });
}

/////////////////////////////////////////////////////////////////////////
// SHOW / HIDE GOOGLE TRANSLATION
/////////////////////////////////////////////////////////////////////////
function ShowTranslation() {
    document.getElementById('translatedRemark').style.display = 'block';
    document.getElementById('showT').style.display = 'none';
}

function HideTranslation() {
    document.getElementById('translatedRemark').style.display = 'none';
    document.getElementById('showT').style.display = 'block';
}
