// cowalunga.js - CowaLUNGa Website Javascript code module
//
// Author: Kevin P. Wojdak
//         630-373-7068
//         kwojdak@usa.net
//         http://www.wojzworld.com
//
// Date:          April 2003
// Last Updated:  February 2005
//

window.onresize = resizePageWidth;

var widthCheck;
var heightCheck;

if (document.layers) {
	widthCheck = window.innerWidth;
	heightCheck = window.innerHeight;
	window.onResize = resizeFix;
}

function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
		document.location.href = document.location.href;
}

//
//  Determine browser type
//
var navType;
// Browser check: DOM compliant browser
if (document.getElementById) {
    navType="dom";
}
// Browser check: IE DHTML compliant browser 
else if (document.all) {
	navType="ie";
}
// Browser check: NS (4.x) DHTML compliant browser 
else if (document.layers) {
    navType="ns";
}

// *************************
// ***** Image Preload *****
// *************************

if (document.images) {

	niki1    		= new Image();
    niki1.src		= "nikirotate/niki1.jpg" ;
    
	niki2    		= new Image();
    niki2.src		= "nikirotate/niki2.jpg" ;
	
	niki3    		= new Image();
    niki3.src		= "nikirotate/niki3.jpg" ;
	
	niki4    		= new Image();
    niki4.src		= "nikirotate/niki4.jpg" ;
	
	niki5    		= new Image();
    niki5.src		= "nikirotate/niki5.jpg" ;
	
	niki6    		= new Image();
    niki6.src		= "nikirotate/niki6.jpg" ;

	sponsor1    		= new Image();
    sponsor1.src		= "logorotate/gurneeMills.gif" ;
    
	sponsor2    		= new Image();
    sponsor2.src		= "logorotate/FederalAlliedlogo09.gif" ;
	
	sponsor3    		= new Image();
    sponsor3.src		= "logorotate/Sprintlogo09.gif" ;
	
	sponsor4    		= new Image();
    sponsor4.src		= "logorotate/vcsLogo.gif" ;
	
	sponsor5    		= new Image();
    sponsor5.src		= "logorotate/WheelSprocket.gif" ;
	
	sponsor6    		= new Image();
    sponsor6.src		= "logorotate/ClifShotnewMarch09.gif" ;
	
	sponsor7    		= new Image();
    sponsor7.src		= "logorotate/clifbar.gif" ;
	
	sponsor8    		= new Image();
    sponsor8.src		= "logorotate/windycity.gif" ;
	
	//sponsor9    		= new Image();
    //sponsor9.src		= "logorotate/MidtownLogo.gif" ;
	
	//sponsor10    		= new Image();
    //sponsor10.src		= "logorotate/microsoftLogo.gif" ;
	
	//sponsor10    		= new Image();
    //sponsor10.src		= "logorotate/Polar2005.gif" ;
	
	//sponsor10    		= new Image();
    //sponsor10.src		= "logorotate/JewelOsco.gif" ;
	
	//sponsor12    		= new Image();
    //sponsor12.src		= "logorotate/AmericanAirlines.gif" ;
	
	//sponsor11    		= new Image();
    //sponsor11.src		= "logorotate/IzzeLogo.gif" ;
	
	//sponsor14    		= new Image();
    //sponsor14.src		= "logorotate/stretchFruit.gif" ;
	
	//sponsor12    		= new Image();
    //sponsor12.src		= "logorotate/EAC.gif" ;
	
	//sponsor16    		= new Image();
    //sponsor16.src		= "logorotate/ffClubs.gif" ;
	
	//sponsor17    		= new Image();
    //sponsor17.src		= "logorotate/SOD.gif" ;
	
	//sponsor18    		= new Image();
    //sponsor18.src		= "logorotate/tyheart.gif" ;

}


//+----------------------------------------------------------------------------
//  Function:       spotlight
//  Author:         Kevin P. Wojdak (kwojdak@usa.net)
//  Created:        03-2005
//  Description:    Creates changing picture marquee for Sponsor logos.
//                  
//  Arguments:      none
//  Returns:        none
// 
//  Note:           Continues changing until a new page is loaded
//+----------------------------------------------------------------------------
//
var sponsorCnt = 8;  // sponsorCnt = number of sponsors to scroll
var imgCnt = 0;  // image counter
//
function spotlight(){
	if (imgCnt == sponsorCnt) {
		imgCnt = 1;
	} else { 
		imgCnt++; 
	}
	
	// Display next image 
	document.getElementById('sponsorLogo').src = eval( "sponsor" + imgCnt + ".src" );
	
	// set the image to change after a certain interval
	setTimeout("spotlight()", 5000);
}





//+----------------------------------------------------------------------------
//  Function:       nikiRotate
//  Author:         Kevin P. Wojdak (kwojdak@usa.net)
//  Created:        03-2005
//  Description:    Creates changing picture marquee.
//                  
//  Arguments:      none
//  Returns:        none
// 
//  Note:           Continues changing until a new page is loaded
//+----------------------------------------------------------------------------
//
var nikiPics = 6;   // nikiPics = number of pics to scroll
var imgCntNiki = 0; // image counter
//
function nikiRotate(){
	if (imgCntNiki == nikiPics) {
		imgCntNiki = 1;
	} else { 
		imgCntNiki++; 
	}
	
	// Display next image 
	document.getElementById('nikiRotate').src = eval( "niki" + imgCntNiki + ".src" );
	
	// set the image to change after a certain interval
	setTimeout("nikiRotate()", 7000);
}



//+----------------------------------------------------------------------------
//  Function:       displayWindow
//  Author:         Kevin P. Wojdak (kwojdak@usa.net)
//  Created:        08-2000
//  Description:    Displays popup window passing URL and size.
//                  
//  Arguments:      url    = window to display
//                  width  = width of popup window
//                  height = height of popup window
//  Returns:        Win    = reference to new window
// 
//  Note:           
//+----------------------------------------------------------------------------
//
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubar=no,status=no' );
		return Win;
}



//+----------------------------------------------------------------------------
//  Function:       OpenNewDesktop
//  Author:         Kevin P. Wojdak (kwojdak@usa.net)
//  Description:    Opens a URL into a new window with no address bar.
//                  
//  Arguments:      desktopURL = page to open
//  Returns:        none
// 
//  Note:           
//+----------------------------------------------------------------------------
//
function OpenNewDesktop(desktopURL)
{
  var scrWidth = (screen.availWidth - 6);
  var scrHgt = (screen.availHeight - 100);
  var desktop = window.open( desktopURL, "_blank", "top=0,left=0,toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,height=" + scrHgt + ",width="+ scrWidth + ",resizable=yes" );
  
}


//+----------------------------------------------------------------------------
//  Function:       resizePageWidth
//  Author:         Kevin P. Wojdak (kwojdak@usa.net)
//  Description:    Used to resize background elements on a page based on the 
//                  current overall size of the page.  
//                  
//  Arguments:      none
//  Returns:        none - elements resized on the page
//+----------------------------------------------------------------------------
//
function resizePageWidth() {
   var docWidth = document.body.scrollWidth;
   document.getElementById('footerExtend').style.width = docWidth;
}

//+----------------------------------------------------------------------------
//  Function:       resizePageHeight
//  Author:         Kevin P. Wojdak (kwojdak@usa.net)
//  Description:    Used to resize background elements on a page based on the 
//                  current overall size of the page.  
//                  
//  Arguments:      none
//  Returns:        none - elements resized on the page
//+----------------------------------------------------------------------------
//
function resizePageHeight(footId, sideExtendr) {
   	var docHgt = document.documentElement.scrollHeight;
   
   	//var footObj = document.getElementById(footId);
	
   	//var footerTop = footObj.offsetTop;
	var btm = document.documentElement.offsetHeight;
	//var footerTopper = cowbase.style.offsetHeight;
//alert(btm);
   	var sideXtend = document.getElementById(sideExtendr);
   
   	//alert(footerTop + ", " + docHgt + ", " + footerTopper);
	if (navType=="ie") {
		//footObj.style.top = (docHgt + 225) + "px";
		sideXtend.style.height = ((docHgt - sideXtend.offsetTop) + 225) + "px";
	} else if (navType=="ns") {
		//footObj.style.top = (docHgt + 175) + "px";
		sideXtend.style.height = ((docHgt - sideXtend.offsetTop) + 175) + "px";
	} else {
		//footObj.style.top = (docHgt + 175);
		sideXtend.style.height = ((docHgt - sideXtend.offsetTop) + 175);
	}
}


//+----------------------------------------------------------------------------
//  Function:       windowSize
//  Author:         Original alertSize script provided for free by http://www.howtocreate.co.uk. 
//  Modified by:    Kevin P. Wojdak, Pathfinder Associates
//  Description:    Provides the current viewable page size.
//                  
//  Arguments:      none
//  Returns:        height and width of the page as one string delimited by a ","
// 
//  Note:           Modified to return height and width in one return value.  
//                  Use string.split(",") to get separate values.
//+----------------------------------------------------------------------------
//
function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var returnString = myHeight + "," + myWidth;
  return returnString;
}


//+----------------------------------------------------------------------------
//  Function:       getDocHeight
//  Author:         Kevin P. Wojdak, Pathfinder Associates
//  Description:    Gets the current document's visible height.
//                  
//  Arguments:      none
//  Returns:        document height
// 
//  Note:           
//+----------------------------------------------------------------------------
//
function getDocHeight() {
   if (navType=="ie") return (document.body.scrollHeight > document.body.clientHeight) ? document.body.scrollHeight : document.body.clientHeight;
   else if (navType="ns") return (document.height > window.innerHeight) ? document.height : window.innerHeight;
}

function menuLeftNavOn(btnObj) {
        btnObj.style.cursor = 'pointer';
        btnObj.style.backgroundColor = '#efefef';
        btnObj.style.color = '#000000';
        btnObj.style.borderBottom = '1px solid #000000';
        btnObj.style.borderTop = '1px solid #000000';
    }
    
    function menuLeftNavOff(btnObj) {
        btnObj.style.cursor = 'default';
        btnObj.style.backgroundColor = '#d62931';
        btnObj.style.color = '#ffffff';
        btnObj.style.borderBottom = '1px solid #ffffff';
        btnObj.style.borderTop = '1px solid #ffffff';
    }
    
function menuLeftNavSubOn(btnObj) {
        menuLeftNavOn(btnObj);
    }
    
    function menuLeftNavSubOff(btnObj) {
        btnObj.style.cursor = 'default';
        btnObj.style.backgroundColor = '#dedede';
        btnObj.style.color = '#000000';
        btnObj.style.borderBottom = '1px solid #cbcbcb';
        btnObj.style.borderTop = '1px solid #cbcbcb';
    }

