﻿var stopflip = "go"
var tooltip=function(){
 var id = 'tt';
 var top = 3;
 var left = -200;
 var maxw = 300;
 var speed = 10;
 var timer = 20;
 var endalpha = 95;
 var alpha = 0;
 var tt,t,c,b,h;
 var ie = document.all ? true : false;
 return{
  show:function(v,w){
   if(tt == null){
    tt = document.createElement('div');
    tt.setAttribute('id',id);
    t = document.createElement('div');
    t.setAttribute('id',id + 'top');
    c = document.createElement('div');
    c.setAttribute('id',id + 'cont');
    b = document.createElement('div');
    b.setAttribute('id',id + 'bot');
    tt.appendChild(t);
    tt.appendChild(c);
    tt.appendChild(b);
    document.body.appendChild(tt);
    tt.style.opacity = 0;
    tt.style.filter = 'alpha(opacity=0)';
    document.onmousemove = this.pos;
   }
   tt.style.display = 'block';
   c.innerHTML = v;
   tt.style.width = w ? w + 'px' : 'auto';
   if(!w && ie){
    t.style.display = 'none';
    b.style.display = 'none';
    tt.style.width = tt.offsetWidth;
    t.style.display = 'block';
    b.style.display = 'block';
   }
  if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
  h = parseInt(tt.offsetHeight) + top;
  clearInterval(tt.timer);
  tt.timer = setInterval(function(){tooltip.fade(1)},timer);
  },
  pos:function(e){
   var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
   var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
   tt.style.top = (u - h) + 'px';
   tt.style.left = (l + left) + 'px';
  },
  fade:function(d){
   var a = alpha;
   if((a != endalpha && d == 1) || (a != 0 && d == -1)){
    var i = speed;
   if(endalpha - a < speed && d == 1){
    i = endalpha - a;
   }else if(alpha < speed && d == -1){
     i = a;
   }
   alpha = a + (i * d);
   tt.style.opacity = alpha * .01;
   tt.style.filter = 'alpha(opacity=' + alpha + ')';
  }else{
    clearInterval(tt.timer);
     if(d == -1){tt.style.display = 'none'}
  }
 },
 hide:function(){
  clearInterval(tt.timer);
   tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
  }
 };
}();

function pageLoad() {

}

function onButtonClick(evt, context) {
}

function indexRedirect() {
}

function postok() {
$get("postmsgspan").className = "hide"
}

function clearmessage() {
	var msgids = clearmessage.arguments;
	for (var i=0; i < msgids.length; i++) {
        setTimeout(String.format("$get('{0}').innerHTML=''", msgids[i]), 4000)
    }
}

function toggle(obj) {
    if ($get(obj).style.display != "none") {
        $get(obj).style.display = "none"   
    } else {
        $get(obj).style.display = "block"
    }
}

function homeload() {
    if (top == this) {
        window.top.location = "/default.aspx"
    }  
    $get("up1").style.display = "block"
    $get("up2").style.display = "none"
    $get("up3").style.display = "none"
    $get("up4").style.display = "none"
}

function featureflip(featno) {
    if (stopflip != "stop") {
        feature(featno)
        featno += 1
        if (featno == 5) {
            featno = 1
        }
        setTimeout(String.format("featureflip({0})", featno), 8000)
    }
}

function halt(featno) {
    stopflip = "stop"
    if (featno > 0) {
        feature(featno)
    }
}

function feature(featno) {
    //setIFrameSrc("featureframe", String.format("features/features{0}.aspx", featno))
    $get("featureframe").src = String.format("/features/features{0}.aspx", featno) 
    $get("f1").style.color = ""
    $get("f2").style.color = ""
    $get("f3").style.color = ""
    $get("f4").style.color = ""
    switch (featno){
    case 1:
    $get("banner").innerHTML = "<a href='http://www.hypercast.net/ihsa' target='_top'><img src='/images/hcnbanner.jpg' style='border:solid 1px #333333'  height='80' width='310'/></a>"
    break
    case 2:
    $get("banner").innerHTML = "<a href='http://www.hypercast.net/threeriverschurch' target='_top'><img src='/images/threeriverslogo.gif' height='80' width='310' /></a>"
    break
    case 3:
    $get("banner").innerHTML = "<a href='http://www.hypercast.net/plaqueminesparish' target='_top'><img src='/images/default_logo.gif'  height='77' width='267'/></a>"
    break
    case 4:
    $get("banner").innerHTML = "<a href='http://www.hypercast.net/idlewild' target='_top'><img src='/customerdata/logos/idlewild/eibclogo[1].jpg' height='80' width='270' /></a>"
    break
    }
    $get("f" + featno).style.color = "#cccccc"
}

function appendthread(newtext) {
    var intmatchindex = newtext.indexOf("@@&&")
    
    while (intmatchindex != -1) {
        newtext = newtext.replace(/@@&&/, "<")
        intmatchindex = newtext.indexOf("@@&&")
    }
    intmatchindex = newtext.indexOf("&&@@")
    while (intmatchindex != -1) {
        newtext = newtext.replace(/&&@@/, ">")
        intmatchindex = newtext.indexOf("&&@@")
    }
    $get("threaddiv").innerHTML = String.format("{0} {1}", newtext, $get("threaddiv").innerHTML)
}


function setIFrameSrc(iframe, src) {
    var el;
    iframe = YAHOO.util.Dom.get(iframe);
    if (YAHOO.env.ua.ie) {
        // Create a new hidden iframe.
        el = iframe.cloneNode(true);
        el.style.position = "absolute";
        el.style.visibility = "hidden";
        // keep the original iframe id unique!
        el.id = "";
        // Listen for the onload event.
        YAHOO.util.Event.addListener(el, "load", function () {
            // First, remove the event listener or the old iframe
            // we intend to discard will not be freed...
            YAHOO.util.Event.removeListener(this, "load", arguments.callee);
            // Show the iframe.
            this.style.position = "";
            this.style.visibility = "";
            // Replace the old iframe with the new one.
            iframe.parentNode.replaceChild(this, iframe);
            // Reset the iframe id.
            this.id = iframe.id;
        });
        // Set its src first...
        el.src = src;
        // ...and then append it to the body of the document.
        document.body.appendChild(el);
    } else {
        iframe.src = src;
    }
}