// balance columns
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}

}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

function popup(strURL, x, y)
{
  var winleft = (screen.width - x) / 2;
  var winUp = (screen.height - y) / 2;
  var strAttr = "scrollbars=yes,width=" + x + ",height=" + y + ",resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,left="+winleft+",top="+winUp+"";

  var popupref = window.open(strURL, "", strAttr);
}

function club_change() {
	if (document.forms['club'].item_choice.value=="Up") {
		popup('club-upload-page.html','700', '550');
		return false;
	} else if(document.forms['club'].item_choice.value!="Top"){
		window.location.href="dba-results.html?"+document.forms['club'].item_choice.value;
	}
}

function dynamicLayout(){
    var browserWidth = getBrowserWidth();

    //Load Thin CSS Rules
    if (browserWidth < 950){
        changeLayout("thin","_200");
    }
    //Load Wide CSS Rules
    if ((browserWidth >= 950) && (browserWidth <= 1200)){
        changeLayout("wide","_400");
    }
    //Load Wider CSS Rules
    if (browserWidth > 1200){
        changeLayout("wider","_600");
    }
}
function getBrowserWidth(){
    if (window.innerWidth){
        return window.innerWidth;}  
    else if (document.documentElement && document.documentElement.clientWidth != 0){
        return document.documentElement.clientWidth;    }
    else if (document.body){return document.body.clientWidth;}      
        return 0;
}

function changeLayout(description,suffix){
   var i, img_name, img_width;
   img_width=suffix.substring(1)+"px";
   document.getElementById("rotator").style.width=img_width;
   for (i=1;i<=5;i++) {
	   img_name="pic"+i;
	   document.getElementById(img_name).src="assets/images/dba/boxes/"+img_name+suffix+".jpg";
   }
   if (description=="thin") {
		if(document.getElementById("leftcontent")) document.getElementById("leftcontent").style.width="150px";
		if(document.getElementById("rightcontent")) document.getElementById("rightcontent").style.width="150px";
		if(document.getElementById("centrecontent3col")) document.getElementById("centrecontent3col").style.marginRight="190px";
		if(document.getElementById("centrecontent3col")) document.getElementById("centrecontent3col").style.marginLeft="190px";
		if(document.getElementById("centrecontent2col")) document.getElementById("centrecontent2col").style.marginLeft="190px";
   } else {
	   	if(document.getElementById("leftcontent")) document.getElementById("leftcontent").style.width="200px";
		if(document.getElementById("rightcontent")) document.getElementById("rightcontent").style.width="200px";
		if(document.getElementById("centrecontent3col")) document.getElementById("centrecontent3col").style.marginRight="240px";
		if(document.getElementById("centrecontent3col")) document.getElementById("centrecontent3col").style.marginLeft="240px";
		if(document.getElementById("centrecontent2col")) document.getElementById("centrecontent2col").style.marginLeft="240px";
   }
}

// slideshow
var d=document, imgs = new Array(), imgs1 = new Array(), zInterval = null, current=0, pause=false;

function so_init()
{
	if(!d.getElementById || !d.createElement)return;
	imgs = d.getElementById('rotator').getElementsByTagName('img');
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = 'block';
	imgs[0].xOpacity = .99;
	setTimeout(so_xfade,8000);
}

function so_xfade()
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;

	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);

	if(cOpacity<=0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(so_xfade,8000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity>.99)
		{
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}

//addEvent() by John Resig
function addEvent( obj, type, fn ){ 
   if (obj.addEventListener){ 
      obj.addEventListener( type, fn, false );
   }
   else if (obj.attachEvent){ 
      obj["e"+type+fn] = fn; 
      obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
      obj.attachEvent( "on"+type, obj[type+fn] ); 
   } 
} 

//Run dynamicLayout function when page loads and when it resizes.
addEvent(window, 'load', dynamicLayout);
addEvent(window, 'load',  so_init);
addEvent(window, 'resize', dynamicLayout);
// -->

