﻿function toggleDisplay(target,type) {
	// Checks to see if you're passing an ID or an object
	if (document.getElementById(target)) {
		target = document.getElementById(target);
	}
	// Checks if you specified a display type, or defaults to 'block'
	(type && type != '') ? (displayType = type) : (displayType = 'block');

	// Performs toggle
	if (target.style.display == 'none') {
		target.style.display = displayType;
	}
	else {
		target.style.display = 'none';
	}
}

//function insertCountdown() {
//	   today = new Date();
//	    BigDay = new Date("October 30, 2007")
//	    msPerDay = 24 * 60 * 60 * 1000 ;
//	    timeLeft = ((BigDay.getTime()) - today.getTime());
//	    e_daysLeft = timeLeft / msPerDay;
//	    daysLeft = Math.floor(e_daysLeft);
//	    e_hrsLeft = ((e_daysLeft - daysLeft)*24 - 2);
//	    hrsLeft = Math.floor(e_hrsLeft);
//	    minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
//	    if (daysLeft == -1){
//		    document.write('RACE AT (HOLLAND) already started.');
//	    }else{
//		    document.write('RACE AT (HOLLAND) BEGINS IN <strong>' + daysLeft + '</strong> days <strong>' + hrsLeft +'</strong> hours and <strong>' + minsLeft + '</strong> minutes');
//	    }
//    }            

        function showDate(startDate, todayDate) {	       	        	        
        	        
	        BigDay = new Date(startDate)
	        
	        var d=new Date()
            //var todayESTDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours()-5, d.getUTCMinutes(), d.getUTCSeconds());
            //debugger;
            var todayESTDate = new Date(todayDate);
         	        
	        msPerDay = 24 * 60 * 60 * 1000 ;
	        timeLeft = ((BigDay.getTime()) - new Date(todayESTDate));
	        e_daysLeft = timeLeft / msPerDay;
	        daysLeft = Math.floor(e_daysLeft);
	        e_hrsLeft = ((e_daysLeft - daysLeft)*24 - 1);
	        hrsLeft = Math.floor(e_hrsLeft);
            e_minsLeft = (e_hrsLeft - hrsLeft)*60;
            minsLeft = Math.floor(e_minsLeft);
            secLeft = Math.floor((e_minsLeft - minsLeft)*60);
                    	        
	        setTimeout('displayValues(' + daysLeft + ', ' + hrsLeft + ',' + minsLeft + ', ' + secLeft + ')', 1000);
        }  
    
        function displayValues(days, hours, minutes, seconds)
        {               
            //debugger;        
            document.getElementById('days').innerHTML = days;//checkTime(days);
	        document.getElementById('hours').innerHTML = checkTime(hours);
	        document.getElementById('minutes').innerHTML = checkTime(minutes);
	        document.getElementById('seconds').innerHTML = checkTime(seconds);
	        	        
            seconds = seconds-1;
        
            if(seconds==-1)
            {
                seconds = 59;
                minutes = minutes-1;                
            }
            
            if(minutes==-1)
            {
                minutes = 59;
                hours = hours-1;
            }
        
            if(hours==-1)
            {
                hours = 23;
                days = days-1;
            }
            
//            if(days==-1)
//                document.getElementById('<!%ButtonRefresh.ClientID %>').click();
                   
            setTimeout('displayValues(' + days + ', ' + hours + ', ' +  minutes + ', ' + seconds + ')', 990);//not 1000; ome miliseconds are lost on calculation
        }
        
        function checkTime(i)
        {        
            if (i<10) 
              {i="0" + i}
              return i
        }
    
    function writeFlash(filename,width,height){
    	s='';
	    s+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="'+filename+'" align="middle">';
	    s+='	<param name="allowScriptAccess" value="sameDomain" />';
	    s+='	<param name="movie" value="'+filename+'.swf" />';
	    s+='	<param name="quality" value="high" />';
	    s+='	<param name="wmode" value="transparent" />';
	    s+='	<param name="bgcolor" value="#ffffff" />';
	    s+='	<embed src="'+filename+'.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+filename+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	    s+='</object>';	
	    document.write(s);
    }

function PopupPic(sPicURL) {
  window.open("popup.htm?"+sPicURL, "", "resizable=0,HEIGHT=200,WIDTH=200");
  }
/*
function showRace(R){
	Element.show(R);
}

function hideRace(R){
	Element.hide(R);
}

function hideAll(targets) {
	var allElements = document.getElementsByClassName(targets);
	allElements.each(function(element) {
		Element.hide(element);
	});
}

function fadeInto(from,to){
	Effect.Fade(from);
	Effect.Appear(to);
}

function cycleNewsStart() {
	setTimeout('cycleNews0()',15000);
}

function cycleNews0() {
	fadeInto('newsitem0','newsitem1');
	setTimeout('cycleNews1()',6000);
}

function cycleNews1() {
	fadeInto('newsitem1','newsitem2');
	setTimeout('cycleNews2()',6000);
}

function cycleNews2() {
	fadeInto('newsitem2','newsitem3');
	setTimeout('cycleNews3()',6000);
}

function cycleNews3() {
	fadeInto('newsitem3','newsitem4');
	setTimeout('cycleNews4()',6000);
}

function cycleNews4() {
	fadeInto('newsitem4','newsitem5');
	setTimeout('cycleNews5()',6000);
}

function cycleNews5() {
	fadeInto('newsitem5','newsitem0');
	setTimeout('cycleNews0()',15000);
}
*/

 /*
 function toggleMenu(targetBox1, targetBox2) {
	var target1 = document.getElementById(targetBox1);
	var target2 = document.getElementById(targetBox2);
	if (target1.style.display == 'none') {
		target1.style.display = 'block';
	}
	if (target2.style.display == 'block') {
		target2.style.display = 'none';
	}
}
*/

