/* debug hack for suri's video feed */
sCountry = "US";

var currentSearchBoxHeight = 1;
var searchFX = null;

if (IE6) {
	var searchBoxMin = 1;
	var maxSearchBoxHeight = 28;
} else {
	var searchBoxMin = 0;
	var maxSearchBoxHeight = 20;
}

function toggleSearchBox() {
	if (searchFX == null) {
		searchFX = $("collapsibleSearchBox").effects({duration: 300, transition: Fx.Transitions.Sine.easeInOut});
	}

	if ( parseInt($("collapsibleSearchBox").getStyle("height")) > searchBoxMin){  
		// if its currently open, then close it
		var targetHeight  = [maxSearchBoxHeight,searchBoxMin];
		var targetPadding = [3,0];
	} else {
		// if its currently closed, then open it
		var targetHeight  = [searchBoxMin,maxSearchBoxHeight];
		var targetPadding = [0,3];
	}
	searchFX.start({"height":targetHeight, "paddingTop":targetPadding, "paddingBottom":targetPadding});
	return false;
}

function hover(obj, clickedObj) {
	if (obj.className == 'selected') {
		obj.className = '';
		if (IE6) {
			$ES(".sub-menu", obj)[0].setStyle("display", "none");
		}
	} else {
		if (IE6) {
			$ES(".sub-menu", obj)[0].setStyle("display", "block");
			window.setTimeout("$('" + obj.id + "').className = 'selected';",1);
		} else {
			obj.className = 'selected';
		}
	}
}

window.addEvent('load', function() {

	
	/* Kwick */
	
	var szNormal = 552, szSmall  = 40, szFull   = 552;
	
	var kwicks = $$("#kwicks .kwick");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Sine.easeInOut});
	


	
	kwicks.each(function(kwick, i) {
		kwick.addEvent("mouseover", function(event) {
			var o = {};
			o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
			var current = kwicks[i];
			
				var su_current = current.getElements('div.sliderlink');
				var className = '';
			
			
				kwick.parentNode.className = className;
			
			
				kwicks.each(function(other, j) {
					if(IE6 && (false) ){
						var subdivs = other.getElements('div.sliderlink');
								
						subdivs.each(function(subdiv,j){
							alert(subdiv.outerHTML);
							subdiv.setStyle('display','none');
								
						});	
					}

					if(i != j) {
						var w = other.getStyle("width").toInt();
						if(w != szSmall) o[j] = {width: [w, szSmall]};
					}
				});
			fx.addEvent('onComplete',function(){
				
				kwicks.each(function(other, j) {
					
					var width = parseInt(other.getStyle('width'));
					if(width == szFull){					
						if(IE6 && (!IE7) ){
							var subdivs = other.getElements('div.sliderlink');
							subdivs.each(function(subdiv,j){
							
								subdiv.setStyle('display','block');
							
							});
						}	
						
						
					}
					
				});				
				
			});				
			fx.start(o);
		});
		
		
	});
	
});