//	Const

var imageryPath = '';
// 	Content Fixes and Interactions

function tick() {
		
}

(function( $ ) {
		  
	$.extend({
			 
		delay : function(time, callback){
		    jQuery.fx.step.delay = function(){};
		    return this.animate({delay:1}, time, callback);
		},			 
			 
		setBackground : function () {
				var currentInlineMenuItem = $(".cedInlineMenu li.cedCurrent");
				if (currentInlineMenuItem.length) {
					//alert($(currentInlineMenuItem).parent("ul").css("backgroundImage"));
					var src = "url(" + imageryPath + $(currentInlineMenuItem).children("img.cedBkgImage").attr("src") + ")";
					//alert(src);
					$(currentInlineMenuItem).parent("ul").css("backgroundImage", src);	
					//alert($(currentInlineMenuItem).parent("ul").css("backgroundImage"));
				}			
		},
		
	
		init: function() {
		
			$(window).resize (function() {
			});

			$(window).load(function(){
									
				// Suckerfish menu
				
				var menuItems = $(".cedMenu > li");
				for (var i=0; i < menuItems.length; i++) {
					menuItems[i].onmouseover = function () {
						$(this).addClass("cedHover");
						var selectIE6Fix = $(".ie6 .cedUnderMenuSelect");
						if (selectIE6Fix.length) {
							$(selectIE6Fix).hide();
						}
					}
					menuItems[i].onmouseout = function () {
						$(this).removeClass("cedHover");
						var selectIE6Fix = $(".ie6 .cedUnderMenuSelect");
						if (selectIE6Fix.length) {
							$(selectIE6Fix).show();
						}						
					}					
					
					if ($(menuItems[i]).children("ul").length) { 
						$(menuItems[i]).addClass("cedGotChildren");
					}
					
					if (($(menuItems[i]).children("ul").length) && ($(menuItems[i]).hasClass('cedCurrent'))) {
						$(menuItems[i]).addClass("cedCurrentGotChildren");
					}
				}
				
				
				// News Ticker				
				$('.cedActualListContainer').jCarouselLite({  
                    vertical: true,  
                    visible: 5,  
                    auto:5000,  
                    speed:1000  
                });  

                // Popup
                $(".cedServicesMenu li.cedMailLink a").click(function(){
                    $(".cedPopupContainer .cedPopup1").show();
                });
                $(".cedPopupContainer .cedPopup a.cedClose").click(function(){
                    $(".cedPopupContainer .cedPopup").hide();   
                });
                /*
                $(".cedPopupContainer .cedPopup1 fieldset .cedSubmit").click(function(){
                    $(".cedPopupContainer .cedPopup1").hide();
                    $(".cedPopupContainer .cedPopup2").show();
                });
                */
					
				$.setBackground();
				var inlineMenuItems = $(".cedInlineMenu li");
				for (var i=0; i < inlineMenuItems.length; i++) {
					inlineMenuItems[i].onmouseover = function () {
						$(".cedInlineMenu li.cedCurrent").removeClass('cedCurrent');
						this.className = 'cedCurrent';	
						$.setBackground();
					}
				}
									
				var accordeonItems = $("ul.cedAccordeon > li");
				for (var i=0; i<accordeonItems.length; i++) {
					if (accordeonItems[i].className.indexOf("cedCurrent") < 0)	{
						$(accordeonItems[i]).addClass("cedClosed");
					}
					
					accordeonItems[i].onclick = function () {
						$("ul.cedAccordeon > li").not(this).addClass("cedClosed");
						$(this).toggleClass("cedClosed");
					}
				}
				
     //FAQ

                $(".cedFaq li.cedItem > a").each(function(){
                    $(this).click(function(){
                        $(".cedFaq li.cedItem.cedItemOpened").removeClass("cedItemOpened");
                        $(this).parent().addClass("cedItemOpened");
			return false;
                    });
                });
				
			});			
		}
	});
	
} )(jQuery);

jQuery( function( $ ) {
	$.init(); // Inits content fixes
} );
