﻿//Objects

function ThumbNail(sID) {
    this.id = sID;
    this.TimerID="";
    this.PercentSize = 100;
    this.X = 0;
    this.Y = 0;
    this.CurrentX = 0;
    this.CurrentY = 0;
    this.MaxX = 0;
    this.MaxY = 0;
    this.IncrementX = 0;
    this.IncrementY = 0;
    this.Step = .1; //Calculate increment step by this percent of Max - Starting
    this.Used = false;
    this.Expanding = true;
}
//End Objects


//Gallery Image Handlers
var arrThumbNails = new Array();
var iMaxPercentGrow = 1.25;

var iStandardWidth = parseFloat("500").toFixed(2);


function GetThumbNailObject(sID) {
    var retImg;
    //var arrImgs = document.getElementsByName("ThumbNailPic");
    for (i = 0; i < arrThumbNails.length; i++) {
        if (arrThumbNails[i].id == sID) {
            return arrThumbNails[i];
        }    
    }
}

function GrowThumb(elObject) {
    elObject.className = "td_PhotoOutline";
    return;
}
function ShrinkThumb(elObject) {
    elObject.className = "td_Photo";
    return;
    
}
function ViewPhoto(sURL, iCount) {
    //Create an IMG element
    //Add it to the position:relative div (divPhotoAnchor) that is ABOVE the top div holding the photo list
    //Uncover the background div (the one that covers the whole page)
    //Show the relative div and move its z-index above the background div's z-index
    
    //reset to clear last click
    FreeThePage("divPhotoAnchor");
    
    var oImage = new Image();
    oImage.src = sURL;
    oImage.id = "imgDisplayedImage";
    oImage.name = "imgDisplayedImage";
    oImage.onClick = "FreeThePage()";
    document.getElementById("divPhotoAnchor").appendChild(oImage);
    //setTimeout("UnveilElement('imgDisplayedImage')", 500);
    UnveilElement("imgDisplayedImage");
    return;

    
    
    
}
function UnveilElement(sImageID) {
    document.getElementById("divBackgroundCover").className = "coverDiv";
    document.getElementById("divPhotoAnchor").className = "UnVeil";
    //document.getElementById("divPhoto").className = "UnVeil";
   
    var elImage = document.getElementById(sImageID);
    //Quickly get the width and height
    var iOriginalHeight = parseFloat(getImageHeight(sImageID)).toFixed(2);
    var iOriginalWidth = parseFloat(getImageWidth(sImageID)).toFixed(2);
    var iNewHeight = ((iOriginalHeight / iOriginalWidth) * iStandardWidth).toFixed(2);
    var iNewWidth = 500;
    
    elImage.height = iNewHeight;
    elImage.width = iNewWidth;
    
}
//End Gallery Image Handlers

function FreeThePage(sCoverElementID) {
    //Tuck the cover div away
    if (!sCoverElementID) {
        sCoverElementID = "divPhotoAnchor";
    }
    try {
        var oCover = document.getElementById(sCoverElementID);
        oCover.className = "uncoverDiv";
        oCover.removeChild(oCover.childNodes[0]);
        document.getElementById("divBackgroundCover").className = "uncoverDiv";
    }
    catch (e) { }
    
 

}

function SendMessage() {
    var Query = "&Name=" + escape(document.getElementById("txtName").value);
    Query += "&Phone=" + escape(document.getElementById("txtPhone").value);
    Query += "&Email=" + escape(document.getElementById("txtEmail").value);
    Query += "&Subject=" + escape(document.getElementById("txtSubject").value);
    Query += "&Message=" + escape(document.getElementById("txtMessage").value);

    var oHTTP = GetHTTPReqObject();
    oHTTP.open("GET", "Default.aspx?Msg=True" + Query, false)
    oHTTP.setRequestHeader("Content-Type", "text/xml")
    oHTTP.send("")
    var xDoc = new ActiveXObject("Msxml2.DOMDocument.4.0")
    var sResp = oHTTP.responseText
    alert("Thank you.  Your email has been sent.")
    try {
        document.getElementById("windowcontent").style.visibility = "hidden"
    }
    catch (e) {
        document.location.href = document.location.href;
     }

}

function GetHTTPReqObject() {
    var ReqObject;
    if (window.XMLHttpRequest) {
        ReqObject = new XMLHttpRequest();
    }
    else {
        try {
            ReqObject = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                ReqObject = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                ReqObject = false;
            }
        }
    }
    return ReqObject;
}
