﻿

function TimerCloseThenOpen(What2Close, When2Close, What2Open) {
    y = document.getElementById(What2Close)
    if (y.style.display == "block") {
        setTimeout("document.getElementById('" + What2Close + "').style.display = 'none'", When2Close);
        setTimeout("document.getElementById('"+ What2Open +"').style.display = 'block'", When2Close + 750);
    }
}


function showHilite(HiliteWhat) {

    document.getElementById(HiliteWhat).style.display = "block";
}
function hideHilite(UnHiliteWhat) {

    document.getElementById(UnHiliteWhat).style.display = "none";
}
function SetOpacityFull(ItemID) {
    document.getElementById(ItemID).style.opacity = 1;
    document.getElementById(ItemID).filters.alpha.opacity = 100
}
function SetOpacityNone(ItemID) {
    document.getElementById(ItemID).style.opacity = 0;
    document.getElementById(ItemID).filters.alpha.opacity = 0
}

function ChangeBGImage(Item2Change, ImageLocation) {
    document.getElementById(Item2Change).style.backgroundImage = ImageLocation;
}

function CloseWindow(WindowID) {
    document.getElementById(WindowID).style.display = "none"
}

function OpenWindow(WindowID) {
    document.getElementById(WindowID).style.display = "block"
}

function ExpandColapseTwistie(WindowID, IMGName, LoopLen) {


        f = document.getElementById(WindowID)
        if (f.style.display == "block") {
            document.getElementById(WindowID).style.display = "none"
            document.images[IMGName].src = "/images/EArrow.png"
        }
        else {

            document.getElementById(WindowID).style.display = "block"
            document.images[IMGName].src = "/images/SEArrow.png"
        }

    }


function ColapseAllTwistie(LoopLen) {
    var i = 0;
    for (i = 0; i <= LoopLen; i++) {
        try {

            document.getElementById('SubContent' + i).style.display = "none"
            document.images['Twistie' + i].src = "/images/EArrow.png"

        }
        catch (err) {
        }
    }
}

function ShowHide(ItemID) {
    x = document.getElementById(ItemID)
    if (x.style.display == "block") {
        document.getElementById(ItemID).style.display = "none"
    }
    else {
        document.getElementById(ItemID).style.display = "block"
    }
}
        


//----------VIEWPORT SIZE FINDER--------------------------------
function getViewprotSize() {
 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
   }

   //HERE IS WHAT TO DO WITH THE INFORMATION CONTAINED ABOVE

if (viewportheight > 590)
{
    document.getElementById("maincontainer").style.height = viewportheight - 10 + "px";
    document.getElementById("maincontainer").style.margin = -(viewportheight - 10) / 2 + "px 0px 0px 0px";
    document.getElementById("maincontainer").style.top = "50%";
    document.getElementById("WindowContainer").style.height = viewportheight - 70 + "px";
    document.getElementById("WindowBody").style.height = viewportheight - 585 + "px";
    document.getElementById("WindowContent").style.height = viewportheight - 294 + "px";
}

else{
    document.getElementById("maincontainer").style.height = "570px";
    document.getElementById("maincontainer").style.top = "0px";
    document.getElementById("maincontainer").style.margin = "5px 0px 5px 0px";
}


}
//----------END VIEWPORT SIZE FINDER----------------------------


//----------CLOCK SCRIPT-----------------
function updateClock() {
    var currentTime = new Date();

    var currentHours = currentTime.getHours();
    var currentMinutes = currentTime.getMinutes();
    var currentSeconds = currentTime.getSeconds();

    // Pad the minutes and seconds with leading zeros, if required
    currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
    currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;

    // Choose either "AM" or "PM" as appropriate
    var timeOfDay = (currentHours < 12) ? "AM" : "PM";

    // Convert the hours component to 12-hour format if needed
    currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;

    // Convert an hours component of "0" to "12"
    currentHours = (currentHours == 0) ? 12 : currentHours;

    // Compose the string for display
    var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

    // Update the time display
    document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}


//---------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------
//EVERYTHING BELOW HERE WAS FOR VISUPHORIA.....ONLY USE IF NEEDED AND COPY TO ABOVE THIS LINE
//--------------------------------------------------------------------------------------------------------------------------------

//detect browser:
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 3) browserVer = "1";
else if (browserName == "Microsoft Internet Explorer" && browserVer == 4) browserVer = "1";
else browserVer = "2";

//preload images:
if (browserVer == 1) {
    a1 = new Image(0, 0);
    a1.src = "images/ButtonGallery.png";
    a2 = new Image(0, 0);
    a2.src = "images/ButtonGalleryRollover.png";
    b1 = new Image(0, 0);
    b1.src = "images/ButtonInfo.png";
    b2 = new Image(0, 0);
    b2.src = "images/ButtonInfoRollover.png";
    c1 = new Image(0, 0);
    c1.src = "images/ButtonBlog.png";
    c2 = new Image(0, 0);
    c2.src = "images/ButtonBlogRollover.png";
    d1 = new Image(0, 0);
    d1.src = "images/ButtonContact.png";
    d2 = new Image(0, 0);
    d2.src = "images/ButtonContactRollover.png";
}

//image swapping function:
function hiLite(imgDocID, imgObjName, comment) {
    if (browserVer == 1) {
        document.images[imgDocID].src = eval(imgObjName + ".src");
        window.status = comment; return true;
    }
}

//Open OVERLAY
  function OpenIMG(ImgPOPHold, ImgPOP, RedirectTo) {  
      document.getElementById(ImgPOPHold).style.display = "block";
      document.getElementById(ImgPOP).style.display = "block";
      document.getElementById(ImgPOP).src = RedirectTo;
}


//Close OVERLAY
function CloseIMG(ImgPOP) {
    
    document.getElementById(ImgPOP).style.display = "none";
}

function HiliteGalThumb(IMGName, IMGColorSrc) {
    document.images[IMGName].src = IMGColorSrc;
}

function RestoreGalThumb(IMGName, IMGBWSrc) {
    document.images[IMGName].src = IMGBWSrc;
}

//Form Validation

//RequiredFieldValidator
function validate_required(field, alerttxt) {
    with (field) {
        if (value == null || value == "") {
            alert(alerttxt); return false;
        }
        else {
            return true;
        }
    }
}
function validate_form(thisform) {
    with (thisform) {
        if (validate_required(BlogTitle, "You MUST Add a Title") == false)
        { BlogTitle.focus(); return false; }
    }
    with (thisform) {
        if (validate_required(BlogSubTitle, "You MUST Add a Sub-Title") == false)
        { BlogTitle.focus(); return false; }
    }
}


//Email Validator
function validate_email(field, alerttxt) {
    with (field) {
        apos = value.indexOf("@");
        dotpos = value.lastIndexOf(".");
        if (apos < 1 || dotpos - apos < 2)
        { alert(alerttxt); return false; }
        else { return true; }
    }
}

function validate_address(thisform) {
    with (thisform) {
        if (validate_email(email, "It does not appear that you have entered a valid e-mail address!") == false)
        { email.focus(); return false; }
    }
}

//END FORM VALIDATION

function LoadEditorContent() {
    tinyMCE.activeEditor.setContent('<span>some</span> html');
}


//REDIRECT

function redirect(link) {
    window.location = link;
}

function setLink(elementID, link) {
    document.getElementById(elementID).href = link
}

function EvalSound() {
    var thissound = document.getElementById("Applet1");
    thissound.Play();
}




