 /* $Id: secondary.js,v 1.2 2010/01/19 18:41:19 btamilio Exp $ */

  

$(document).ready(function(){
						 
 
		// $(".second_tier LI").wrapInner('<a href="javascript:"></a>');
 	 


		// formatting
	    $("#regservices_table TR:even").css("background-color", "#efefef");	
		
		
		$(".order_info TR:odd").each(function(index) { 
							$(this).css("background-color", "#efefef");	
		});
		
		
				
		$("#searchbox").keyup().autocomplete("/handlers/search_predict.php", {
			width: 170,
			max: 5,
			highlight: false,
	 
			scroll: true,
			scrollHeight: 300
		});
		 
		$("#searchbox").keypress(function (e) {
			if (e.which == 13) {
					   $("#searchform").submit();
			}
		});
		  
 		// if there are tabs...
		$('#tabs').tabs();
	
	
		// searchbox
		$("#searchbox").click(function () {
			 $("#searchbox").val("");				
		});
		
		$("#searchgo").hover(function () {
			$(this).css({'background-color' : '#ac1d23'});
		}, function () {
			$(this).css({'background-color' : '#ee0000'});
		});

		// logo click
		 $("#logo").hover(function () {
			$(this).css({'cursor' : 'pointer'});
		}, function () {
			$(this).css({'cursor' : 'hand'});
		});
 		
		$("#logo").click(function () {
				// alert("hai!");
			 	location.replace("/");			   	
		});
		


		// leftnav
		// figure out where we are and set the CSS

	 
 		var leftnav_local = -1;
		
 		var current_path = jQuery.url.attr("path");
		var current_section = jQuery.url.segment(1);
		var t;
		
		 if (current_section) {
					// set the local section active
					$.each($("#left_navigation .navitem").children(), function(i,n) {
							thischild = jQuery.url.setUrl($(n).attr("href")).segment(1);
							 if (thischild) {
								 if (thischild.replace(".html", "") == current_section.replace(".html", "")) {
										if (!($(n).hasClass("navitemsub"))) {
											$(n).addClass("active");
											
											// set leftnav_local
											t = $(n).parent().attr("id");
											tmp = t.split("_");
										 	leftnav_local = tmp[1];
			
										 }
								 } 
							 }
					 });
		 }
 
 							
		// set the subnav active
		setsubnav = 0;
		$.each($("#left_navigation .navitemsub LI").children(), function(i,n) {
				 if (jQuery.url.setUrl($(n).attr("href")).attr("path") == current_path) {
					 $(n).parent().addClass("subactive");
					 setsubnav = 1;
				 } 	  
		 });
				
 
		// If the "subnav" fails, perhaps we're deeper. check the second leaf and highlight that section (if possible!)
	 	if (setsubnav == 0) { 
				$.each($("#left_navigation .navitemsub LI").children(), function(i,n) {
						prevchild = jQuery.url.setUrl($(n).attr("href")).attr("path");
						 if (jQuery.url.setUrl(prevchild.replace(".html", "")).segment(2) == jQuery.url.setUrl(current_path).segment(2) ) {
						 	$(n).parent().addClass("subactive");
				 	 	} 	  
				 });
		}
 
	
 
		var leftnav_operable = true;
		var collapse_timer = 0;
		var active_nav = leftnav_local;
		
		 $(".navitemsub").hide();
  
		if (parseInt(leftnav_local) > -1) { 
			$("#navitemsub_"+leftnav_local).show();	
		}
		
		$("#left_navigation").mouseout(function() {
			clearTimeout(collapse_timer);
			collapse_timer = setTimeout(function() { collapseToLocal() }, 3000);
		});
		
		$("#left_navigation").hover(function() {
			clearTimeout(collapse_timer);
		});
	
		$(".navitem").mouseover(function() {
				return;
				// remove above for hover nav
				clearTimeout(collapse_timer);
				if (leftnav_operable == true) { 
				
							tmp = $(this).attr("id").split("_");
							div_id = tmp[1]; 
							
						if ($("#navitemsub_"+div_id).length > 0 ) {
							leftnav_operable = false;
 
							collapseNavs (div_id);
							active_nav = div_id;
 
							$("#navitemsub_"+div_id).show("slow", function() { 
													leftnav_operable = true;  
							});
						 }
				 
				}
		});
		
		function showLocalNav () {
			if (parseInt(leftnav_local) > -1) { 
				$("#navitemsub_"+leftnav_local).show("slow");
			}
		}
		
		function collapseNavs (ignore) {
 
					 for (i=0; i<20; i++) {
						
						if ($("#navitemsub_"+i).length > 0 ) {
							if (i != ignore) {
								$("#navitemsub_"+i).hide("slow");
							}
					 	}
						
					 }			
		}
		
		function collapseToLocal () {
			
				if (leftnav_operable == true) {
					if (active_nav != leftnav_local) { 
						collapseNavs ();
 						showLocalNav ();
					}
				}
		}
	
	
		// expand GS nav if we're there..
 		if ($("#gs_rightnav").length > 0 )  {
					$("#gs_rightnav  .navitemsub").show();
		}


				
		 // flash detection		 
		 var hasProductInstall = DetectFlashVer(6, 0, 65);
		 var hasReqestedVersion = DetectFlashVer(9,0,0)
		 
		 if ( hasProductInstall && !hasReqestedVersion ) {
			var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
			var MMredirectURL = window.location;
		
			AC_FL_RunContent(
				"src", "/swf/playerProductInstall",
				"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType,
				"width", "550",
				"height", "300",
				"align", "middle",
				"id", "detectionExample",
				"quality", "high",
				"bgcolor", "#fffff",
				"name", "detectionExample",
				"allowScriptAccess","always",
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
			);
		} else if (hasReqestedVersion) {
				// ok!

		} else {  
		
				// flash is too old or we can't detect the plugin
			
							$("body").prepend('<div id="noflash">&nbsp;&nbsp;This content requires the Adobe Flash Player. <strong><a href="http://www.adobe.com/go/getflash/">Get Flash</a> &raquo;</strong></div>');
		
 
		}
		 




}); 
			
// sIFR Setup
/*
var myriadpro = { src: '/swf/sifr/myriadpro.swf' };

sIFR.useStyleCheck = true;
 
sIFR.replace(myriadpro, {
  selector: '#section_header SPAN',
  css: '.sIFR-root { color: #FFFFFF; letter-spacing: 2; }',
    wmode: 'transparent',
	offsetLeft: '6.5em',
	antiAliasType: 'advanced',
    filters: {
        DropShadow: {
			angle: 120,
            knockout: false,
            distance: 4,
            color: '#000000',
            strength: 1,
            blurX: 4,
            blurY: 4,
			quality: 1
		}
    }
});
sIFR.activate(myriadpro);

			
	*/
			
function ucwords (str) {
	return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase( ); } );
}


function checkEmail(str) {
	rx = new RegExp("^ *[-a-zA-Z0-9\\_\\.\\-]+@[-a-zA-Z0-9\\_\\.\\-]+\\.[a-zA-Z]{2,3}?$");
	return (rx.exec(str) == null) ? false : true;
}




