$(document).ready(function(){	
	
	//$.preloadImages("/design/images/photo2.jpg", "/design/images/photo3.jpg", "/design/images/photo4.jpg");

	$('#m').accordion({ 
		event: 'mouseover',
		header: 'a.m',
		autoHeight: false,
		fillSpace: false,
		animated: 'custom',
		active: false,
		alwaysOpen: false
	});
	$.ui.accordion.animations.custom = function(options) {
		this.slide(options, {
			duration: 150
		});
	};
	
	$('#temp div a').click(function(){
		$('#tempA').toggle();
		$('#tempB').toggle();
		$('#temp1').toggle();
		$('#temp2').toggle();
		
		//if($('#tempA').css('display') == 'block')
		//	$('#weather').css('background-image', 'url(/design/images/weather/'+$('#tempA').attr('rel')+'.png)')
		//else
		//	$('#weather').css('background-image', 'url(/design/images/weather/'+$('#tempB').attr('rel')+'.png)')
	})
	
	$.photo = Math.floor(Math.random()*8);
	
	setTimeout("Transition()", 10);
	
});

function Transition(){
	
	$("#transition").animate({ opacity: 1 }, 1000, function(){
		Swap();
		$("#transition").animate({ opacity: 0 }, 1000);
	});
	
	setTimeout("Transition()", 5000);
}

function Swap(){
	
	$.photo = $.photo + 1;
	if($.photo > 7)
		$.photo = 1;

	$('#c').css({backgroundPosition:(($.photo-1)*-981)+"px 0px"})
	if($.photo == 1 || $.photo == 4 || $.photo == 7)
		$('#bl6 #bl1 a').css({color:"#5B5B5B"})
	else
		$('#bl6 #bl1 a').css({color:"#FFFFFF"})
	
	//setTimeout("Swap()", 5000);
}

var win= null;
function PopUpWindow(mypage,myname,w,h,scroll,resizeable){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable='+resizeable+',';
  win=window.open(mypage,myname,settings);
  if (win.opener == null) {  // for Nav 2.0x
      win.opener = self  // this creates and sets a new property
   }
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}


