//On Load//
$(function(){

/*===========================================*/
/*===============Sliding Door================*/
/*===========================================*/
/*Initial Vars*/
var panelWidth = 540;
var panelHeight = 350;
var totalWidth = 640;
var transTime = 1000;
var curr = 1;

/*Calculated Vars*/
var amt = $('#sd li').length;
var collapsedWidth = (totalWidth - panelWidth) / (amt-1);
 
//Each LI
$('#sd li').each(function(i){	
	var offset = totalWidth / amt * i;
	$(this).css({
		'width':Number(panelWidth+200)+'px',
		'height':panelHeight+'px',
		'left':offset+'px',
		'z-index':i
	}).attr('id','item_'+i);
});//End each

$('#sd li').hover(function(){
	if( Number($('#sd li').index(this)) != curr){
		$(this).find('span').css({'backgroundPosition':'-30px 0px'});
	}
},function(){
	if( Number($('#sd li').index(this)) != curr){
		$(this).find('span').css({'backgroundPosition':'-62px 0px'});
	}else{
		$(this).find('span').css({'backgroundPosition':'5px 0px'});
	}
});//End Click


$('#sd li').click(function(){
	var id = $(this).attr('id');
	id = id.split('_');
	id = id[1];
	mover(id, transTime);
	curr = id;
});//End Click

function mover(id, tt){
//Calculate Positions
$('#sd li').each(function(index){
	if(index <= id ){
		$(this).stop().animate({'left':collapsedWidth*index}, {easing:'easeOutExpo', duration:tt});
	}else if(index > id){
		$(this).stop().animate({'left':(collapsedWidth*(index-1))+panelWidth}, {easing:'easeOutExpo', duration:tt});
	}

	var source = $('#sd li').index(this);


	if(id == index){
		$(this).find('span').css({'backgroundPosition':'5px 0px'});
	}else{
		$(this).find('span').css({'backgroundPosition':'-62px 0px'});
	}

});//End Each

}//End Mover
mover(1, 1000);


/*===========================================*/
/*==============News Scroller================*/
/*===========================================*/
var newsTimer = setInterval(newsAdvance, 6000);
var newsLength = $('#news li').length;
var counter = 0;
var lineHeight = 29;
function newsAdvance(){

	if(counter<newsLength-1){
		counter++;
		var h = (counter * lineHeight);
		h = h+'px';
		$('#news').animate({'top':'-'+h}, 1000);
	}else{
		counter = 0;
		$('#news').animate({'top':'0'}, 1000);

	}
}

$("#story-mid, #story-right").equalizeCols();

/*==========================================*/
/*==============Query String================*/
/*==========================================*/





});//End ready
     function search_onBlurSearch(searchbox) {
         if (searchbox.value == "Search Microsoft") {
             searchbox.className = "msviLSBSearchInactive";
         } else if (searchbox.value == "") {
             searchbox.value = "Search Microsoft";
             searchbox.className = "msviLSBSearchInactive";
         }
         
     }

     function search_onFocusSearch(searchbox) {
         if (searchbox.value == "Search Microsoft") {
             searchbox.className = "msviLSBSearchActive";
             searchbox.value = "";
         }
        
     }


/**
 *
 * Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */
 
(function($) {
	/**
	 * equalizes the heights of all elements in a jQuery collection
	 * thanks to John Resig for optimizing this!
	 * usage: $("#col1, #col2, #col3").equalizeCols();
	 */
	 
	$.fn.equalizeCols = function(){
		var height = 0,
			reset = $.browser.msie && $.browser.version < 7 ? "1%" : "auto";
  
		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, this.offsetHeight);
			})
			.css("height", height)
			.each(function() {
				var h = this.offsetHeight;
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});
			
	};
	
})(jQuery);

