﻿
var imgWidth;
var imgHeight;
var imgLeft;
var imgTop;
var zoom;
var obj;
var varient;

function zoooom() {
    if (varient > 20) {
        return;
    }
    obj.style.marginLeft = -imgWidth / 8 + 'px';
    obj.style.marginTop = -3 * imgHeight / 32 + 'px';
    obj.style.width = imgWidth + 'px';
    obj.style.height = 3 * imgHeight / 4 + 'px';
    imgWidth += 4;
    imgHeight += 4;
    varient += 4;
    zoom = setTimeout('zoooom()', 25);
}
function zoomOutPartner(index) {
    var id = 'imPartner' + index;
    var x = findPosX(document.getElementById(id));  //- 4;
    var y = findPosY(document.getElementById(id));  //- 4;
    var divId = 'divPartner' + index;
    document.getElementById(divId).style.display = 'block';
    document.getElementById(divId).style.position = 'absolute';
    document.getElementById(divId).style.left = x + 'px';
    document.getElementById(divId).style.top = y + 'px';
    var image = document.getElementById('imgDivPartner' + index);
    var orgImage = document.getElementById(id);
    imgWidth = orgImage.width;
    imgHeight = orgImage.height;
    image.style.marginLeft = imgWidth;
    image.style.marginTop = imgHeight;
    obj = image;
    varient = 0;
    zoooom();
    var partnerCount = document.getElementById('ctl00_cphBody_hdnPartnerCount').value;
    for (var i = 0; i < partnerCount; i++) {
        if (i != index) {
            zoomInPartner(i);
        }
    }
}
function zoomInPartner(index) {
    var id = 'divPartner' + index;
    document.getElementById(id).style.display = 'none';
}
function zoomOutClient(index) {
    var id = 'imgClient' + index;
    var x = findPosX(document.getElementById(id)) - 2;
    var y = findPosY(document.getElementById(id)) - 2;
    var divId = 'divClient' + index;
    document.getElementById(divId).style.display = 'block';
    document.getElementById(divId).style.position = 'absolute';
    document.getElementById(divId).style.left = x + 'px';
    document.getElementById(divId).style.top = y + 'px';
    var partnerCount = document.getElementById('ctl00_hdnClientCount').value;
    for (var i = 0; i < partnerCount; i++) {
        if (i != index) {
            zoomInClient(i);
        }
    }
}
function zoomInClient(index) {
    var id = 'divClient' + index;
    document.getElementById(id).style.display = 'none';
}
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
function smallIcon(image) {
    image.height = image.height - 4;
    image.width = image.width - 4;
}
function showDesc(index) {
    var caseCount = document.getElementById('ctl00_cphBody_hdnCaseCount').value;
    for (var i = 0; i < caseCount; i++) {
        if (i != index) {
            hideDesc(i);
        }
    }
    document.getElementById('ctl00_cphBody_hdnCaseIndex').value = index;
    document.getElementById('case' + index).style.display = 'block';
    document.getElementById('caseTab' + index).style.color = '#ff6c00';
}
function hideDesc(index) {
    document.getElementById('case' + index).style.display = 'none';
    if (index > 0 && index < 4) document.getElementById('caseTab' + index).style.color = '#959698';
}
function loadCaseStudy() {
    var index = document.getElementById('ctl00_cphBody_hdnCaseIndex').value;
    index = 'casestudy.aspx?flag=' + index;
    window.location = index;
}

function closePopup() {
    document.getElementById('contactPopup').style.display = 'none';
}
function openPopup(index) {
    document.getElementById('contactPopup').style.display = 'block';
    showContact(index);
}
function openPopupDiiv() {
    document.getElementById('contactPopup').style.display = 'block';
    var index = document.getElementById('ctl00_cphBody_hdnContact').value;
    showContact(index);
}
function hideContact(index) {
    document.getElementById('con' + index).style.display = 'none';
}
function showContact(index) {
    document.getElementById('ctl00_cphBody_hdnContact').value = index;
    for (var i = 1; i < 8; i++) {
        if (i != index) {
            hideContact(i);
        }
    }
    document.getElementById('con' + index).style.display = 'block';
}

function showDiv() {
    //show popup window
    document.getElementById("subcontent").style.display = 'inline';
}
function hideDiv() {
    //hide popup window
    document.getElementById("subcontent").style.display = 'none';
}

function getNumber(e) {
    var key;
    if (window.event) {
        key = window.event.keyCode; //IE
    }
    else {
        key = e.charCode; //alert(key); //firefox
    }
    //alert(key);
    if (!((key >= 97 && key <= 122) || (key >= 65 && key <= 90) || (key == 32) || (key == 0) || (key == 46))) {
        return false;
    }
}
