function imageholderclass(){
	this.over=new Array();
	this.down=new Array();
	this.src=new Array();
	this.store=store;
	
	function store(src, down, over){
		var AL=this.src.length;
		this.src[AL]=new Image(); this.src[AL].src=src;
		this.over[AL]=new Image(); this.over[AL].src=over;
		this.down[AL]=new Image(); this.down[AL].src=down;
	}
}

var ih = new imageholderclass();
var mouseisdown=0;

function preloader(t){
	for(i=0;i<t.length;i++){
		if(t[i].getAttribute('srcover')||t[i].getAttribute('srcdown')){
			
			storeimages(t[i]);
			var checker='';
			checker=(t[i].getAttribute('srcover'))?checker+'A':checker+'';
			checker=(t[i].getAttribute('srcdown'))?checker+'B':checker+'';
			
			switch(checker){
			case 'A' : mouseover(t[i]);mouseout(t[i]); break;
			case 'B' : mousedown(t[i]); mouseup2(t[i]); break;
			case 'AB' : mouseover(t[i]);mouseout(t[i]); mousedown(t[i]); mouseup(t[i]); break;
			default : return;			
			}
			
			if(t[i].src){t[i].setAttribute("oldsrc",t[i].src);}
		}
	}
}
function mouseup(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");this.oldmouseup();}

	}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");}}
	t.onmouseup=newmouseup;
}

function mouseup2(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");this.oldmouseup();}
		}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");}}
	t.onmouseup = newmouseup;
}

function mousedown(t){
	var newmousedown;
	if(t.onmousedown){
		t.oldmousedown=t.onmousedown;
		newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");this.oldmousedown();}}
	}
	else{newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");}}}
	t.onmousedown=newmousedown;
}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover){
		t.oldmouseover=t.onmouseover;
		newmouseover=function(){this.src=this.getAttribute("srcover");this.oldmouseover();}
	}
	else{newmouseover=function(){this.src=this.getAttribute("srcover");}}
	t.onmouseover=newmouseover;
}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout=function(){this.src=this.getAttribute("oldsrc");this.oldmouseout();}
	}
	else{newmouseout=function(){this.src=this.getAttribute("oldsrc");}}
	t.onmouseout=newmouseout;
}

function storeimages(t){
	var s=(t.getAttribute('src'))?t.getAttribute('src'):'';
	var d=(t.getAttribute('srcdown'))?t.getAttribute('srcdown'):'';
	var o=(t.getAttribute('srcover'))?t.getAttribute('srcover'):'';
	ih.store(s,d,o);
}

function preloadimgsrc(){
	if(!document.getElementById) return;
	var it=document.getElementsByTagName('IMG');
	var it2=document.getElementsByTagName('INPUT');
	preloader(it);
	preloader(it2);
}

if(window.addEventListener){window.addEventListener("load", preloadimgsrc, false);} 
else{
	if(window.attachEvent){window.attachEvent("onload", preloadimgsrc);}
	else{if(document.getElementById){window.onload=preloadimgsrc;}}
}

function $(v) { return(document.getElementById(v)); }
function $S(v) { return($(v).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v), 0)); }
function isset(v) { return((typeof(v) == 'undefined' || v.length == 0)?false:true); }
function XYwin(v) { 
	var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth);
	return(isset(v)?z[v]:z);
}

function pop_close() {
	$S('pop_box').display='none';
	$S('pop_bg').display='none';
}

function pop_box(i, e, c, l, d, m) {
 	var psz = getPageSize();
 	var psc = getPageScroll();
	var lnk = l != 'http://'?"<div><a href=\""+l+"\" target=\"_new\"><img src=\"images/link.gif\" alt=\"open link!\" border=0 align=absmiddle></a> <a href=\""+l+"\" target=\"_new\">link</a></div>":"";
	var img = m?'<div><img class=pop_img src="./images/events/'+i+'.jpg" alt="'+e+'"></div>':'';
	
	$S('pop_bg').height = XYwin(0)+'px';
	$S('pop_bg').display='block';
	$('pop_box').innerHTML = '<h1><span style="color: #333;">'+d+' | </span> '+e+'</h1>'+c+lnk+'<br>'+img;
	$S('pop_box').left = Math.round((XYwin(1)-530)/2)+'px';
	var xt = psc[1] + ((psz[3] - 700 - $S('pop_box').height) / 2);
	xt = psc[1]+20;
	$S('pop_box').top = (xt < 0) ? "0px" : xt + "px";
	$S('pop_box').width = '530px';
	$S('pop_box').display='block';
}

function pop_image(i, c) {
	$S('pop_bg').height = XYwin(0)+'px';
	$S('pop_bg').display='block';
	$('pop_box').innerHTML = '<h1>'+c+'</h1><div><img class=pop_img src="'+i+'" alt="'+c+'"></div>';
	$S('pop_box').left = Math.round((XYwin(1)-530)/2)+'px';
	$S('pop_box').width = '530px';
	$S('pop_box').display='block';
}

function choose_punk(i) {
    if ($('optionf_'+i).value == '') {
		$S('choose_error_'+i).display = 'block';
		return false;
	} else return true;
}


function getPageSize(){

 var xScroll, yScroll;

 if (window.innerHeight && window.scrollMaxY) {
 xScroll = document.body.scrollWidth;
 yScroll = window.innerHeight + window.scrollMaxY;
 } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
 xScroll = document.body.scrollWidth;
 yScroll = document.body.scrollHeight;
 } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
 xScroll = document.body.offsetWidth;
 yScroll = document.body.offsetHeight;
 }

 var windowWidth, windowHeight;
 if (self.innerHeight) { // all except Explorer
 windowWidth = self.innerWidth;
 windowHeight = self.innerHeight;
 } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
 windowWidth = document.documentElement.clientWidth;
 windowHeight = document.documentElement.clientHeight;
 } else if (document.body) { // other Explorers
 windowWidth = document.body.clientWidth;
 windowHeight = document.body.clientHeight;
 }

 // for small pages with total height less then height of the viewport
 if(yScroll < windowHeight){
 pageHeight = windowHeight;
 } else {
 pageHeight = yScroll;
 }

 // for small pages with total width less then width of the viewport
 if(xScroll < windowWidth){
 pageWidth = windowWidth;
 } else {
 pageWidth = xScroll;
 }


 arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
 return arrayPageSize;
}

function getPageScroll(){

 var yScroll;

 if (self.pageYOffset) {
 yScroll = self.pageYOffset;
 } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
 yScroll = document.documentElement.scrollTop;
 } else if (document.body) {// all other Explorers
 yScroll = document.body.scrollTop;
 }

 arrayPageScroll = new Array('',yScroll)
 return arrayPageScroll;
}