var imgN=new Array();
var imgL=0;
var WTHRPLUGN='<embed src="http://www.weatherlet.com/weather.swf?locid=93721&unit=s" quality="high" wmode="transparent" bgcolor="transparent" width="175px" height="60px" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
var img_path='/templates/images/';
var username;
var currentIEV=8; // Ensure viewer is reminded about IE updates due to Windows' monopoly...

function cacheImages(){
 if(!document.images){
  return;
 }else{
//  img_path+'FresnoIncorp.jpg',
  inames=new Array(
  img_path+'FlagofFresno.jpg',
  img_path+'FresnoDay.jpg',
  img_path+'FresnoTowerDistrict.jpg',
  img_path+'SolidWaste.jpg',
  img_path+'Fresno.jpg',
  img_path+'FAX.jpg',
  img_path+'FresnoNight.jpg',
  img_path+'FresnoWater.jpg',
  img_path+'FresnoCityYard.jpg',
  img_path+'FresnoPoliceHQ.jpg',
  img_path+'FresnoParks.jpg'
  );
  imgL=inames.length;
  for(i=0;i<imgL;i++){
   imgN[i]=new Image();
   imgN[i].src=inames[i];
  }
 }
}

function loadPage(){
// Initially handled from server...
d=new Date();
time=d.getHours();
phaseImg='';
 if(time>06&&time<18){
  phaseImg=img_path+'FresnoCityHallDay.jpg';
 }else{
  phaseImg=img_path+'FresnoCityHallNight.jpg';
 }
 if(phaseImg!=document.getElementById('FCH').src){
  document.getElementById('FCH').src=phaseImg;
 }
 weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
 month=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
 if(time>05&&time<12){
  frame="Good morning";
 }else if(time>11&&time<18){
  frame="Good afternoon";
 }else{
  frame="Good evening";
 }
 if(username!=''){
  frame=frame+" "+username;
 }
 format=frame+", today is: "+weekday[d.getDay()]+", "+month[d.getMonth()]+" "+d.getDate()+", "+d.getFullYear();
 document.getElementById('date').innerHTML=format;
 document.getElementById('weather').innerHTML=WTHRPLUGN;
}

var millisec=2500;
var Icounter=Irack=3;
var fobj='';
function ccO(){
strt=100;
end=0;
var speed=Math.round(millisec/100);
var timer=0;
fobj=document.getElementById('I3').style;
 for(i=strt;i>=end;i--){
  time=setTimeout('changeO('+i+')',(timer*speed));
  timer++;
 }
 setTimeout('ccI()',2250);
}

function ccI(){
document.getElementById('I1').src=document.getElementById('I2').src;
document.getElementById('I2').src=document.getElementById('I3').src;
document.getElementById('I3').src=inames[Icounter];
Icounter++;
if(Icounter>=imgL){Icounter=0;}
strt=0;
end=100;
var speed=Math.round(millisec/100);
var timer=0;
 for(i=strt;i<=end;i++){
  time=setTimeout('changeO('+i+')',(timer*speed));
  timer++;
 }
}

function changeO(i){
 rate=i/100;
 fobj.opacity=rate;
 fobj.MozOpacity=rate;
 fobj.KhtmlOpacity=rate;
 fobj.filter='alpha(opacity='+i+')';
}

var swapA,swapB=null;
function opTabs(i,c){
var t='';
 if(i!=0){
  if(swapA==i&&swapA==null){return;}
 }
 if(swapA!=null){
  if(swapA!=0){document.getElementById(swapA).className='toff';}
  document.getElementById(swapB).style.display='none';
 }else{
  document.getElementById('main').style.display='none';
 }
 switch(c){
 case 'news':
  t="Present FCEA News";
  break;
 case 'networking':
  t="FCEA Associative Services Listings";
  break;
 case 'events':
  t="Upcoming FCEA Events";
  break;
 case 'desk':
  t="FCEA President\'s Desk";
  break;
 case 'rights':
  t="Your Weingarten Rights";
  break;
 case 'contact':
  t="FCEA Contact Information";
  break;
 default:
  t="Fresno City Employees Association";
  break;
 }
 if(i!=0){document.getElementById(i).className='ton';}
 document.getElementById('contentTop').innerHTML=t;
 document.getElementById(c).style.display='block';
 window.scrollTo(0,165);
 swapA=i;
 swapB=c;
}

function testBrowser(){
 browserName=navigator.appName;
 browserVer=parseFloat(navigator.appVersion.split("MSIE")[1]);
 if(browserName=="Microsoft Internet Explorer"&&browserVer<currentIEV){
  bContent='<fieldset style="width:250px;"><legend style="color:skyblue;">&nbsp;NOTIFICATION&nbsp;</legend><p class="j i p" style="font-family:Arial;font-size:11px;">Presently you are using an antiquated version of Internet Explorer.&nbsp;&nbsp;Perhaps you might be interested in expanding your horizons?</p><br />';
  bContent+='<div class="c"><a id="icn1" class="icons" href="http://www.microsoft.com/windows/internet-explorer/default.aspx" target="_ie" title="Download Internet Explorer"><img class="trans" src="/templates/images/ie.png" height="40px" width="40px" border="0" alt="Download Internet Explorer" /></a>';
  bContent+='&nbsp;&nbsp;<a id="icn2" class="icons" href="http://www.mozilla.com/en-US/firefox/" target="_ff" title="Download Firefox"><img class="trans" src="/templates/images/ff.png" height="40px" width="40px" border="0" alt="Download Firefox" /></a>';
  bContent+='&nbsp;&nbsp;<a id="icn3" class="icons" href="http://www.apple.com/safari/download/" target="_apple" title="Download Safari"><img class="trans" src="/templates/images/safari.png" height="40px" width="40px" border="0" alt="Download the Safari Web-browser" /></a>';
  bContent+='&nbsp;&nbsp;<a id="icn4" class="icons" href="http://www.opera.com/download/" target="_opera" title="Download the Opera Web-browser"><img class="trans" src="/templates/images/opera.png" height="40px" width="40px" border="0" alt="Download the Opera Web-browser" /></a></div>';
  bContent+='<img style="z-index:-1;position:relative;top:-10px;left:0px;" src="/templates/images/dock.png" height="20px" width="205px" border="0" alt="" /></fieldset>';
  document.getElementById('iBrowsers').innerHTML=bContent;
  a=document.getElementById('leftContentBottom').offsetHeight;
  b=document.getElementById('lowerLnks').offsetHeight;
  c=document.getElementById('iBrowsers').offsetHeight;
  sum=(a-30)-(b+c);
  document.getElementById('iBrowsers').style.marginTop=sum+'px';
 }
}

function fetchNE(f,p){
 opTabs('n1','news');
 document.getElementById('fetchedNE').innerHTML='';
 $(document).ready(function(){
  $.post("functions/fetchNE.php",{fData:f,pData:p},function(data){
   result=eval('('+data+')');
   $('#fetchedNE').append(result);
  });
 });
}

// Rising jQuery menu >>>
$(document).ready(function(){
 $('#navdini div a').hover(function(){
  var e=this;
  $(e).find('img.trans').stop().animate({paddingBottom:'14px'},1,function(){
   $(e).find('img.trans').animate({marginTop:'-14px'},250);
   $(e).find('img.trans').animate({marginTop:'-10px'},250);
  });
 },function(){
  var e=this;
  $(e).find('img.trans').stop().animate({paddingBottom:'0'},1,function(){
   $(e).find('img.trans').animate({marginTop:'4px'},250);
   $(e).find('img.trans').animate({marginTop:'0'},250);
  });
 });
});

///////////////
var iconsec=75;
var thisIcon='';
var upordown='';

function repoIconUp(){
strt=0;
end=10;
var speed=Math.round(iconsec/100);
var timer=0;
 for(i=strt;i<=end;i++){
  time=setTimeout('iActuator('+i+')',(timer*speed));
  timer++;
 }
}

function repoIconDown(){
strt=10;
end=0;
var speed=Math.round(iconsec/100);
var timer=0;
 for(i=strt;i>=end;i--){
  time=setTimeout('iActuator('+i+')',(timer*speed));
  timer++;
 }
}

function iActuator(i){
 thisIcon.style.top=upordown+i+'px';
}

window.onload=function(){
 cacheImages();
 setInterval('ccO()',15000);
 setInterval('loadPage()',600000); // 10-minute checks...
 testBrowser();

// Load and hide JSON gif...
 $(document).ready(function(){
  $('#loadingNE').bind("ajaxSend",function(){
   $(this).show();
  }).bind("ajaxComplete",function(){
   $(this).hide();
  });
 });

/*
 $(document).ready(function(){
  $('.icons').hover(
  function(){
// Fire on mouseover
  if(document.getElementById('icn1').style.top!='0px'){

   thisIcon='icn1';
   upordown='';
   repoIconDown();
  }
  if(document.getElementById('icn2').style.top!='0px'){

   thisIcon='icn2';
   upordown='';
   repoIconDown();
  }
  if(document.getElementById('icn3').style.top!='0px'){

   thisIcon='icn3';
   upordown='';
   repoIconDown();
  }
  if(document.getElementById('icn4').style.top!='0px'){

   thisIcon='icn4';
   upordown='';
   repoIconDown();
  }
  thisIcon=document.getElementById(this.id);
  upordown='-';
  repoIconUp();
  },
  function(){
// Fired on mouseout
  upordown='';
  repoIconDown();
  });
 });
*/
}

// for friendly URL setting -- if(window.location.hash=='#'){}
// window.location.hash='Focus';
