//Image preview on home page (photo gallery)
var gallerypreview = function(){
  var id       = 'gallery';
  var top      = 3;
  var left     = 3;
  var maxw     = 640;  //originally was 300
  var speed    = 10;
  var timer    = 20;
  var endalpha = 95;
  var alpha    = 0;
  var lcl_img_width  = 640;
  var lcl_img_height = 480;
  var gallery,t,c,b,h;
  var ie = document.all ? true : false;
  return{
    show:function(v,w){
      if(gallery == null){
        gallery = document.createElement('div');
        gallery.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');
        gallery.appendChild(t);
        gallery.appendChild(c);
        gallery.appendChild(b);
        document.body.appendChild(gallery);
        gallery.style.opacity = 0;
        gallery.style.filter = 'alpha(opacity=0)';
        document.onmousemove = this.pos;
      }
      gallery.style.display = 'block';
      c.innerHTML = '<div style="border: 1px solid #000000"><img src="' + v + '" width="' + lcl_img_width + '" height="' + lcl_img_height + '" style="margin:1px;border: 1px solid #ffffff" /></div>';
      gallery.style.width = w ? w + 'px' : 'auto';
      if(!w && ie){
        t.style.display = 'none';
        b.style.display = 'none';
        gallery.style.width = gallery.offsetWidth;
        t.style.display = 'block';
        b.style.display = 'block';
      }
      if(gallery.offsetWidth > maxw){gallery.style.width = maxw + 'px'}
      h = parseInt(gallery.offsetHeight) + top;
      clearInterval(gallery.timer);
      gallery.timer = setInterval(function(){gallerypreview.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;
      //gallery.style.top = ((u - h)+(480/2)) + 'px';
   gallery.style.top  = lcl_img_height/2  + 'px';
      gallery.style.left = ((l + left)-(lcl_img_width+55)) + '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);
        gallery.style.opacity = alpha * .01;
        gallery.style.filter = 'alpha(opacity=' + alpha + ')';
      }else{
        clearInterval(gallery.timer);
        if(d == -1){gallery.style.display = 'none'}
      }
    },
    hide:function(){
      clearInterval(gallery.timer);
      gallery.timer = setInterval(function(){gallerypreview.fade(-1)},timer);
    }
  };
}();

///////////////////////////////////////////////////////////////////////////////
//Snow Falling Javascript for page header
///////////////////////////////////////////////////////////////////////////////
function displaySnowFalling() {
  getcontent()

  if (ie || ns6 || opera) {
     	if (ns6) {
        		textwidth-=2*textborder
        		textheight-=2*textborder
     	}
     	document.write("<table border=0 cellpadding=0 cellspacing=0><tr><td width="+textwidth+" height="+textheight+" valign=bottom>")
     	document.write("<div id=\"roof\" style=\"position:relative;width:"+textwidth+"px;height:"+textheight+"px;font-family:\'"+textfont+"\';border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;background-color:"+textbgcolor+";overflow:hidden\">")
     	document.write("<div id=\"ticker\" style=\"position:absolute;top:"+-textborder+"px;left:"+-textborder+"px;width:"+textwidth+"px;height:"+textheight+"px;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";font-style:"+textitalic+";border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;background-color:"+textbgcolor+";overflow:hidden\;filter:alpha(opacity=100)\">")
     	document.write("</div>")

     	for (i=0;i<=snowmax;i++) {
          	document.write("<div id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</div>")
     	}

     	document.write("</div>")
     	document.write("</td></tr></table>")
     	window.onload=initsnow
  } else if (ns4) {
        document.write("<table border=0 cellpadding=0 cellspacing=0><tr><td width="+textwidth+" height="+textheight+" valign=top>")
        document.write("<ilayer name=\"roof\" width="+textwidth+" height="+textheight+">")
        document.write("<layer name=\"tickerframe\" width="+textwidth+" height="+textheight+" top=0 left=0 bgcolor="+textbgcolor+">")
    	document.write(framecontent)
  		document.write("</layer>")
    	document.write("<layer name=\"ticker\" width="+textwidth+" height="+textheight+" top=0 left=0>")
    	document.write()
  		document.write("</layer>")
    	document.write("</ilayer>")
    	document.write("</td></tr></table>")
     	window.onload=changecontent
  }
}

// Type the messages into the text-Array here. Add as many as you like.
//var text=new Array("The team at Hypergurl hope you have a merry Christmas.", "And a great New Year.", "May you always be safe.", "And your loved ones happy.")
//var text=new Array("<div id=\"mainLogo\"><img src=\"../images/headers/main_logo_xmas.jpg\" alt=\"\" border=\"0\" /></div>")
//var text=new Array("<div id=\"mainLogo\"><img src=\"../images/headers/main_logo_hfo_2009.jpg\" alt=\"\" border=\"0\" /></div>")

//var text=new Array("<div id=\"mainLogo\"><img src=\"../images/headers/main_logo_snow_santahat.jpg\" alt=\"\" border=\"0\" /></div>")
//var text=new Array("<div id=\"mainLogo\"><img src=\"../images/headers/main_logo_snow2.jpg\" alt=\"\" border=\"0\" /></div>")
var text=new Array("<div id=\"mainLogo\"><img src=\"../images/headers/main_logo_snow.jpg\" alt=\"\" border=\"0\" /></div>")
//var text=new Array("<div id=\"mainLogo\"><img src=\"../images/headers/main_logo_thanksgiving.jpg\" alt=\"\" border=\"0\" /></div>")

// Type a link for each message. If you don't want to add a link add a "#" instead
//var textlink=new Array("http://www.hyperegurl.com","http://www.hypergurl.com","http://www.hypergurl.com","http://www.hypergurl.com")
var textlink=new Array("http://www.diehardpaintball.com")

// Type the target-window for each link. Accepted values are "_blank", "_top", "_parent" or the name of any frame
//var texttarget=new Array("_blank","_blank","_blank","_blank")
var texttarget=new Array("")

// Set the font for the headline-fader
var textfont="Arial"

// Set the font-color for the headline-fader (hexadecimal triplet values recommended)
var textfontcolor="#AAAAFF"

// Set the rollover-color for the headline-fader (hexadecimal triplet values recommended)
var textfontcolorrollover="#ffff00"

// Set the font-size for the headline-fader (points)
var textfontsize=11

// Set the background-color for the headline-fader (hexadecimal triplet values recommended)
var textbgcolor="#000000"

// Set the width of the headline-fader (pixels)
var textwidth=990

// Set the height of the headline-fader (pixels)
//var textheight=75
var textheight=80

// Set the pause between the messages (seconds)
//var textpause=2
var textpause=0

// Set the borderwidth (pixels)
var textborder=0

// Set the border-color (hexadecimal triplet values recommended)
var textbordercolor="#AAAAFF"

// Set the horizontal text-position. Allowed values are "center" or "left" or "right"
var textalign="center"

// Set the vertical text-position. Allowed values are "middle" or "top" or "bottom"
var textvalign="middle"

// Set the number of snowflakes (more than 20 - 30 not recommended)
var snowmax=30

// Set the colors for the snow. Add as many colors as you like
var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD")

// Set the fonts, that create the snowflakes. Add as many fonts as you like
var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS")

// Set the letter that creates your snowflake (recommended:*)
var snowletter="*"

// Set the speed of sinking (recommended values range from 0.3 to 2)
var sinkspeed=0.6

// Set the maximal-size of your snowflaxes (points)
var snowmaxsize=16

// Set the minimal-size of your snowflaxes (points)
var snowminsize=8

// Set font-style. Acceptable values are "normal" or "italic"
var textitalic="normal"

// Set font-weight. Acceptable values are "normal" or "bold"
var textweight="bold"

// do not edit below this line
var textdecoration="none"
var transparency=100
var transparencystep=5
var x_pos=0
var y_pos=0
var i_text=0
if (textitalic=="italic") {var textitalicA="<i>"; var textitalicB="</i>"}
else {var textitalicA="<i>"; var textitalicB="</i>"}
if (textweight=="bold") {var textweightA="<b>"; var textweightB="</b>"}
else {var textweightA=""; var textweightB=""}
var textweightA="<b>"
var textweightB="</b>"
var tickercontent
var pausefade=40
var oneloopfinished=false
var snow=new Array()
var marginbottom
var marginright
var timer
var i_snow=0
var x_mv=new Array();
var crds=new Array();
var lftrght=new Array();
var textfontsizeHTML=Math.floor(textfontsize/4)
textpause*=1000

if (textfontsizeHTML<1) {textfontsizeHTML=1}
if (textfontsizeHTML>=7) {textfontsizeHTML=7}

var browserinfos=navigator.userAgent 
var ns4=document.layers
var ns6=document.getElementById&&!document.all&&!browserinfos.match(/Opera/)
var ie=document.all&&!browserinfos.match(/Opera/)
var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
var opera=browserinfos.match(/Opera/)  

function changecontent() {
	getcontent()
	i_text++
	if (i_text>=text.length) {i_text=0}	
	if (ie) {
		ticker.innerHTML=content
		//fadein()
	}
	if (ns6) {
		document.getElementById('ticker').innerHTML=content
		//fadein()
	}
	if (opera) {
		document.getElementById('ticker').innerHTML=content
		//var texttimer=setTimeout("changecontent()",textpause*1.5)
	}
	if (ns4) {
		document.roof.document.ticker.document.write(content)
		document.roof.document.ticker.document.close()
		//var texttimer=setTimeout("changecontent()",textpause)
	}	
}

function fadein() {
	if (transparency<100){
		transparency+=transparencystep
		if (ie) {
			document.all.ticker.filters.alpha.opacity=transparency
		}
		if (ns6) {
			document.getElementById('ticker').style.MozOpacity=transparency/100
		}
		var fadetimer=setTimeout("fadein()",pausefade)
	}
	else {
		clearTimeout(fadetimer)
		setTimeout("fadeout()",textpause)
	}
}

function fadeout() {
	if (transparency>0){
		transparency-=transparencystep
		if (ie) {
			document.all.ticker.filters.alpha.opacity=transparency
		}
		if (ns6) {
			document.getElementById('ticker').style.MozOpacity=transparency/100
		}
		var fadetimer=setTimeout("fadeout()",pausefade)
	}
	else {
		clearTimeout(fadetimer)
		setTimeout("changecontent()",1000)
	}
}

//getcontent()

function getcontent() {
	if (ie) {
		var tablewidth=textwidth-2*textborder
		var tableheight=textheight-2*textborder
	}
	else {
		var tablewidth=textwidth
		var tableheight=textheight
	}
	if (ie || ns6 || opera) {	
		var padding=parseInt(textborder)+3
		content="<table width="+tablewidth+" height="+tableheight+" cellpadding="+padding+" cellspacing=0 border=0><tr valign="+textvalign+"><td align="+textalign+">"
		content+="<a href=\""+textlink[i_text]+"\" target=\""+texttarget[i_text]+"\" style=\"position:relative;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";text-decoration:"+textdecoration+";color:"+textfontcolor+";font-style:"+textitalic+";\" onMouseOver=\"this.style.color=\'"+textfontcolorrollover+"\'\" onMouseOut=\"this.style.color=\'"+textfontcolor+"\'\">"
		content+=text[i_text]
		content+="</a></td></tr></table>"
	}
	else {	
		content="<table width="+tablewidth+" height="+tableheight+" cellpadding="+textborder+" cellspacing=0 border=0><tr valign="+textvalign+"><td align="+textalign+">"
		content+="<a href=\""+textlink[i_text]+"\" target=\""+texttarget[i_text]+"\" style=\"position:relative;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";text-decoration:"+textdecoration+";color:"+textfontcolor+";font-style:"+textitalic+";\">"
		content+=text[i_text]
		content+="</a></td></tr></table>"

		framecontent="<table width="+tablewidth+" height="+tableheight+" cellpadding=0 cellspacing=0 border="+textborder+"><tr><td align=\"center\">"
		framecontent+="<font color=\""+textbgcolor+"\">"
		framecontent+="."
		framecontent+="</font>"
		framecontent+="</td></tr></table>"
	}
}

function randommaker(range) {		
	rand=Math.floor(range*Math.random())
    return rand
}

function initsnow() {
	marginbottom = textheight
	marginright = textwidth
	var snowsizerange=snowmaxsize-snowminsize
	for (i=0;i<=snowmax;i++) {
		crds[i] = 0;                      
    	lftrght[i] = Math.random()*15;         
    	x_mv[i] = 0.03 + Math.random()/10;
		snow[i]=document.getElementById("s"+i)
		snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
		snow[i].size=randommaker(snowsizerange)+snowminsize
		snow[i].style.fontSize=snow[i].size
		snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
		snow[i].sink=sinkspeed*snow[i].size/5
		snow[i].posx=randommaker(marginright-snow[i].size)
		snow[i].posy=randommaker(2*marginbottom-marginbottom-2*snow[i].size)
		snow[i].style.left=snow[i].posx
		snow[i].style.top=snow[i].posy
	}
	movesnow();changecontent()
}

function movesnow() {
	for (i=0;i<=snowmax;i++) {
		crds[i] += x_mv[i];
		snow[i].posy+=snow[i].sink
		snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]);
		snow[i].style.top=snow[i].posy
		
		if (snow[i].posy>=marginbottom || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
			snow[i].posx=randommaker(marginright-snow[i].size)
			snow[i].posy=0
		}
	}
	var timer=setTimeout("movesnow()",50)
}

//if (ie || ns6 || opera) {
//	if (ns6) {
//		textwidth-=2*textborder
//		textheight-=2*textborder
//	}
//	document.write("<table border=0 cellpadding=0 cellspacing=0><tr><td width="+textwidth+" height="+textheight+" valign=top>")
//	document.write("<div id=\"roof\" style=\"position:relative;width:"+textwidth+"px;height:"+textheight+"px;font-family:\'"+textfont+"\';border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;background-color:"+textbgcolor+";overflow:hidden\">")
	
//	document.write("<div id=\"ticker\" style=\"position:absolute;top:"+-textborder+"px;left:"+-textborder+"px;width:"+textwidth+"px;height:"+textheight+"px;font-family:\'"+textfont+"\';font-size:"+textfontsize+"pt;font-weight:"+textweight+";font-style:"+textitalic+";border-style:solid;border-color:"+textbordercolor+";border-width:"+textborder+"px;background-color:"+textbgcolor+";overflow:hidden\;filter:alpha(opacity=100)\">")
//	document.write("</div>")
//	for (i=0;i<=snowmax;i++) {
//	document.write("<div id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</div>")
//	}
//	document.write("</div>")
//	document.write("</td></tr></table>")
//	window.onload=initsnow
//}

//else if (ns4) {
//		document.write("<table border=0 cellpadding=0 cellspacing=0><tr><td width="+textwidth+" height="+textheight+" valign=top>")
//	document.write("<ilayer name=\"roof\" width="+textwidth+" height="+textheight+">")
//		document.write("<layer name=\"tickerframe\" width="+textwidth+" height="+textheight+" top=0 left=0 bgcolor="+textbgcolor+">")
//		document.write(framecontent)
//		document.write("</layer>")
//		document.write("<layer name=\"ticker\" width="+textwidth+" height="+textheight+" top=0 left=0>")
//		document.write()
//		document.write("</layer>")
//		document.write("</ilayer>")
//		document.write("</td></tr></table>")
//	window.onload=changecontent
//}

function displayScreenMsg(iMsg) {
  if(iMsg!="") {
     document.getElementById("screenMsg").innerHTML = "*** " + iMsg + " ***&nbsp;&nbsp;&nbsp;";
     window.setTimeout("clearScreenMsg()", (10 * 1000));
  }
}

function clearScreenMsg() {
  document.getElementById("screenMsg").innerHTML = "";
}

//function sendToRSS(p_feedname,pID) {
//  s_wintype = "rss"+p_feedname+pID;
//  s_width   = 500;
//  s_height  = 400;

//  x = (screen.availWidth/2) - (s_width/2);
//  y = (screen.availHeight/2) - (s_height/2);

//  OpenWin = window.open(page, s_wintype, "status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width="+s_width+",height="+s_height+",left="+x+",top="+y);
//  if (document.images) {OpenWin.focus();}

//  location.href="admin_events_maint.asp?action=RSS&eventid=" + p_eventid + "&sc_eventname=" + document.getElementById("sc_eventname").value + "&sc_eventyear=" + document.getElementById("sc_eventyear").value;
  
//}
