
var styles='#newTargets li{display:none;} #references li {display:none;}';

var preload = new Array('/i/selectBoxReplacement/select0_1_small.png', '/i/selectBoxReplacement/select0_2_small.png', '/i/selectBoxReplacement/select0_3_small.png', '/i/selectBoxReplacement/select1_1_small.png', '/i/selectBoxReplacement/select1_2_small.png', '/i/selectBoxReplacement/select1_3_small.png','/i/selectBoxReplacement/select2_1_small.png', '/i/selectBoxReplacement/select2_2_small.png', '/i/selectBoxReplacement/select2_3_small.png', '/i/selectBoxReplacement/select3_1_small.png', '/i/selectBoxReplacement/select3_2_small.png', '/i/selectBoxReplacement/select3_3_small.png');

var loader = new Array();
for(var i = 0; i < preload.length; i++){
   loader[i] = new Image();
   loader[i].src = preload[i];
}
var styles;
	for (var x = 0; x <= 3; x++)
   {
		styles=styles +" * html ul.select"+x+" li.first-child{background:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/i/selectBoxReplacement/select"+x+"_1_small.png',sizingMethod='crop');} ";
		styles=styles +"* html ul#select"+x+".hover li.first-child{background:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/i/selectBoxReplacement/select"+x+"_2_small.png',sizingMethod='crop');} ";
		styles=styles +"* html ul#select"+x+".active li.first-child{background:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/i/selectBoxReplacement/select"+x+"_3_small.png',sizingMethod='crop');} ";
   }


document.write('<style type="text/css">'+styles+'<\/style>');



jQuery(document).ready(function() {
	$("#newTargets li").css("display", "block");
	$("#references li").css("display", "block");
    jQuery("#newTargets").jcarousel({
        scroll: 1
    });
    jQuery("#references").jcarousel({
        scroll: 1
    });	
	

	
});

$(document).ready(function()
 {
 

	 $('div.textLifts div.fragment1, div.textLifts div.fragment2, div.textLifts div.fragment3').syncHeight();
	 $('div.fourCol div.fragment1, div.fourCol div.fragment2, div.fourCol div.fragment3, div.fourCol div.fragment4').syncHeight();
	
 	$("select.replaceSelect").each(function(i) {
		var selectIndex=i;
        var ulReplacement = document.createElement('ul');
		 ulReplacement.className = 'selectReplacement select'+i+'';
		 ulReplacement.id = 'select'+i+'';
		$(this).children("option").each(function(s) {
			 var option = document.createElement('li');
			 var optionText=$(this).text().split("-");
			 if(s == 0)
			 {
				
			 	if(optionText[1] !=null)
				{
					$(option).append("<strong>"+optionText[0]+"</strong> - "+optionText[1]);
				}
				else{$(option).append("<strong>"+optionText[0]+"</strong>");}
				
			 }
			 if(s > 0)
			 {
			 	$(option).append($(this).text());
				$(option).click(function() {
						location.href = $("select.replaceSelect").eq(selectIndex).children("option").eq(s).val();
				 });
			}	 	
			
				$(ulReplacement).append(option);
		 });
		$(this).parent().append($(ulReplacement));
		$("ul.selectReplacement li").hide();

		$("ul.selectReplacement li:first-child").show().addClass("first-child");
		

	
    });
	
	if($.browser.msie && $.browser.version < 7)
	{
		$("ul.selectReplacement").each(function(i) {
			$(this).children("li:first-child").css("background", "none");

		 });
	 }
	$("ul.selectReplacement li:first-child").hover(function(){
			$(this).parent("ul").addClass("hover");
			if($.browser.msie && $.browser.version < 7)
			{
				$("ul.selectReplacement").each(function(i) {
					$(this).children("li:first-child").css("background", "none");
				 });
				 
			 }
			
		  return false;
		
		},function(){
			$(this).parent("ul").removeClass("hover");
		  return false;
		});		


	$("ul.selectReplacement li:first-child").toggle(function(){
			$(this).parent("ul").siblings("ul").children("li").not(".first-child").hide();
			$(this).parent("ul").siblings("ul").removeClass("active");
			$(this).parent("ul").addClass("active");
			$(this).parent("ul").children("li").gt(0).show();
		  return false;
		
		},function(){
			$(this).parent("ul").removeClass("active");
			
		
			$(this).parent("ul").children("li").gt(0).hide();
		  return false;
		});		


	
	$("ul.selectReplacement li").not(".first-child").hover(function(){
			$(this).addClass("hover");
		  return false;
		
		},function(){
			$(this).removeClass("hover");
		  return false;
		});		
	
 
});


/**
 * syncHeight - jQuery plugin to automagically Snyc the heights of columns
 * Made to seemlessly work with the CCS-Framework YAML (yaml.de)
 * @requires jQuery v1.0.3
 *
 * http://blog.ginader.de/dev/syncheight/
 *
 * Copyright (c) 2007 
 * Dirk Ginader (ginader.de)
 * Dirk Jesse (yaml.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 1.0
 *
 * Usage:
 	$(document).ready(function(){
		$('p').syncHeight();
		$(window).resize(function(){ //if you want to update the columns after a Browser resize (optional)
			$('p').syncHeight();
		});
	});
 */

(function($) {
	$.fn.syncHeight = function(settings) {
		var max = 0;
		var browser_id = 0;
		var property = [
		   ['min-height','0px'],
			['height','1%']
		];
		// check for IE6 ...
		if($.browser.msie && ( /msie 6.0/.test(navigator.userAgent.toLowerCase()) && !/opera/.test(navigator.userAgent.toLowerCase()))){
			browser_id = 1;
		}
		
		// get maximum element height ...
		$(this).each(function() {
			// fallback to auto height before height check ...
			$(this).css(property[browser_id][0],property[browser_id][1]);
			var val=$(this).height();
			if(val > max){
			   max = val;
			}

		});
		
		// set synchronized element height ...
 		$(this).each(function() {
  			$(this).css(property[browser_id][0],max+'px');
		});
		return this;
	};	
})(jQuery);
