/*

	Pacific Power Global Javascript
	ISITE Design

*/

// prototype with jquery. $ = prototype, $j = jquery.
// can still use $ for jQuery within the jQuery document ready function
var $j = jQuery.noConflict();

// prevent ie6 flicker
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}

// sIFR 3
if(typeof sIFR != "undefined") {
	var gillsans = { src: '../_resources/flash/GillSans_sIFR3.swf' };
	sIFR.activate(gillsans);
	
	sIFR.replace(gillsans, {
		selector: 'h1',
		css: '.sIFR-root { background-color: transparent; color: #000000; }',
		wmode: 'transparent',
		repaintOnResize: true
	});
}

// Dom loaded / jQuery
jQuery(function($) {

	// Pull the label, make lowercase, set as default value and hide it
//	$("#sitesearch input").inputSetter(1);

	// ie6 special cases
	if($.browser.msie && parseInt($.browser.version) < 7){
		
		// add class to drop downs and buttons
	    $("#nav li, button, #lead2 a").hover(
			function() { var c = $(this).attr("class").split(" ")[1] || ""; $(this).addClass("over over-"+c); },
			function() { var c = $(this).attr("class").split(" ")[1] || ""; $(this).removeClass("over over-"+c); }
	    );		
		
		// fix elements over selects z-index issue
		// load script without ajax to avoid ActiveX requirement
		function loadScript(src, callback) {
			var script = document.createElement("script");		
			if(script.attachEvent) {
				script.attachEvent("onreadystatechange",
				function() { loadScript.callbackIE(callback); });
			}
			script.src = src;
			document.getElementsByTagName("head")[0].appendChild(script);
		}
		loadScript.callbackIE = function(callback) {
			var target = window.event.srcElement;
			if(target.readyState == "loaded")
			callback.call(target);
		};		
		callback = function() { $("#nav ul, .custom-select-list-wrapper").bgiframe(); };
		
		loadScript("_resources/js/jquery.bgiframe.min.js", callback);
	
	}// if ie6

	// Utah apply pages accordion function.
		$('.slide_container h4').hover(
			function() {
				$(this).addClass('hover');
			},
			function() {
				$(this).removeClass('hover');
			}
		);
				  
		$('.slide_container .accordion_content:not(:first)').hide();
		
		$('.slide_container h4').click(function() {
			$(this).next('.accordion_content').slideToggle('slow').siblings('.accordion_content:visible').slideUp('slow');
			$(this).toggleClass('active');
			$(this).siblings('h4').removeClass('active');
		});
	  //Utah apply pages accordion function

});// document ready

// -------------------------------------------------------------------------- //
// rmurnen commented-out the following block 
// because it was breaking the Google Custom Search (aka site search)
// -------------------------------------------------------------------------- //
// pull label and insert as field. clear with click
// optional lower param if == 1, string toLowerCase
//jQuery.fn.inputSetter = function(lower) {	
//	return this.each(function() {
//		var $input = jQuery(this);
//		var $label = jQuery("label[for='"+$input.attr("id")+"']");
//		var labeltext = lower && lower==1 ? $label.text().toLowerCase() : $label.text();
//		$label.hide();
//		$input.val(labeltext);		
//		$input.focus(function() { if (this.value == labeltext) { this.value = ""; }	})
//			  .blur(function() { if (!this.value.length) { this.value = labeltext; } });		
//	});
//};

