//jQuery.noConflict();
(function ($) {
	$(window).load(function(){
		 //$("li.find ul").hide();
		 
	});
	
	

	/*---------------------------------------------------start of isutcbutton function------------------------------------------------*/
                $.fn.IsUtcButton = function(options)
                {              
                                var settings = {
                                                                                   };                                                                             
                                if(options)
                                {
                                                $.extend( settings, options );
                                }

                                $(this).css({'margin':'0px','background':'none', 'border':'0px', 'padding':'0px', 'height':'auto', 'width':'auto','float':'left', 'margin':'0px'});
                                
                                var btnholder = "<div class='btn_holder'></div>";
                                var btnright = "<div class='btn_right'></div>";
                                
                                $(this).wrap(btnholder).parent().css(settings.holderstyle);                                         
                                
                                $(this).css(settings.innerstyle);
                                
                                $(this).after(btnright);//.css(settings.leftstyle);                 
                                
                                $(this).css('margin-left', settings.paddingleft);
                                $(this).css('margin-right', (settings.paddingleft-6));
                                
                                var pwidth = $(this).outerWidth()+((settings.paddingleft*2)-6)+6;
                                $(this).parent().css('width',pwidth+'px');
                                
                                var ctop = ($(this).parent().innerHeight()/2)-($(this).outerHeight()/2) ;
                                $(this).css('top',ctop);
                                
                                $(this).parent().mouseover(function(){
                                                $(this).css('background-position','0px -32px');
                                                $(this).children('.btn_right').css('background-position','0 -32');
                                                
                                });
                                
                                $(this).parent().mouseout(function(){
                                                $(this).css('background-position','0px 0px');
                                                $(this).children('.btn_right').css('background-position','0px 0px');
                                                
                                });
                }

/*---------------------------------------------------end of isutcbutton function------------------------------------------------*/
	
    $(document).ready(function () {     
		
		/*
			START .ms-WPBody  object{ style related...
			This code segment is added to fixed the media web part displaying issue.
			first time released this on Client Release 2.2.1.0
		*/
		
		//collect all objects under .ms-WPBody div
		if($('.ms-WPBody  object') != null)
		{
			$('.ms-WPBody  object').each(function(index) {
			
				var objectType = $(this).attr('type');
				
				//Check object is a silverlight object
				if(objectType.indexOf("silverlight") != -1)
				{
					//yes silverlight object
					//get the parent (.ms-WPBody div) width and height
					
					var parentWidth = $(this).parent().css('width');
					var parentHeight = $(this).parent().css('height');
					
					//set width height to the object	
					$(this).css('width',parentWidth);
					$(this).css('height',parentHeight);
				}
				
			});
		}
		
		/*
			END .ms-WPBody  object{ style related...
		*/
	
	/*Start of main navigation-----------------------------------------------------------------------------------------------------------------------*/
	
	//hilight second level navigation 
	$('#zz1_TopNav > div > ul > li > ul > li').each(function(){
		var pagename = $(".breadcrumbs td:last").children('a').html();
		
		if($(this).children('a').find('.menu-item-text').html() == pagename)
		{
			$(this).parent().show().delay(0).hide();
			$(this).parent().parent().children('a').children('span').css('color','#ffffff');
		}
		
	});
	
	//hilight first level navigation 
	$('#zz1_TopNav > div > ul > li').each(function(){
		var pagename = $(".breadcrumbs td:eq(1)").children('a').html();
		
		if($(this).children('a').find('.menu-item-text').html() == pagename)
		{			
			$(this).children('a').find('.menu-item-text').css('color','#ffffff');
		}		
	});
	//Remove breadcrumb node events
	$("td[id*='PlaceHolderTitleBreadcrumb']").removeAttr("onmouseover");
	$("td[id*='PlaceHolderTitleBreadcrumb']").removeAttr("onkeyup");
	$("td[id*='PlaceHolderTitleBreadcrumb']").removeAttr("onmouseout");
	
	var ismouseout = true;	
	
	$('#zz1_TopNav > div > ul').mouseleave(function(){		
		ismouseout = true;
		
		if(ismouseout)
			 $('#zz1_TopNav > div > ul li ul').delay(5000).fadeOut(1000,function(){$('#header').css('z-index','5');});
	});
	
	$('#zz1_TopNav > div > ul').mouseenter(function(){	
		 $('#header').css('z-index','100');
		 
		$('#zz1_TopNav > div > ul li ul').css('z-index','1');
		$(this).children('ul').clearQueue().stop().css('z-index','2000').fadeTo(1,10);
	});
	
	$('#zz1_TopNav > div > ul > li').click(function(){
		$('#zz1_TopNav > div > ul > li').children('a').find('.menu-item-text').css('color','#AAD2F8');
		$(this).children('a').find('.menu-item-text').css('color','#ffffff');
	});
	
	$('#zz1_TopNav > div > ul > li').mouseenter(function(){
		 $('#header').css('z-index','100');
		 
		ismouseout = false;
		
		$('#zz1_TopNav > div > ul li ul').css('z-index','1');
		$(this).children('span').css('color','#ffffff');
		$(this).children('ul').clearQueue().stop().css('z-index','2000').fadeTo(1,10,function(){
				$('#zz1_TopNav > div > ul li ul').not(this).hide();
				$(this).show();
		});	

		if($(this).children('ul').length < 1)
		{
			$('#zz1_TopNav > div > ul li ul').clearQueue().stop().hide();
		}
	});			
	
	$('#zz1_TopNav > div > ul li ul').mouseenter(function(){
		 $('#header').css('z-index','100');
		 
		ismouseout = false;
		
		$('#zz1_TopNav > div > ul li ul').clearQueue().stop();
	});
	
	$('#zz1_TopNav > div > ul li ul').mouseleave(function(){
		ismouseout = true;
		
		if(ismouseout)
			 $('#zz1_TopNav > div > ul li ul').delay(4000).fadeOut(1000,function(){$('#header').css('z-index','5');});
	});
	/*End of main navigation-----------------------------------------------------------------------------------------------------------------------*/

	
	if($('.ms-cui-tts').css('display') == undefined)	
	{
		$('#MainImage').children('div').eq(3).css('display','none');
	}

	
        //Remove the empty p elements

		
		
		
		$('p').each(function () {
		if($.trim($(this).html()).match(/&nbsp;/g))
                {
             $(this).html($.trim($.trim($(this).html().replace("&nbsp;"," "))));
                }
			});
		/*
		
  $('p').filter(function () {
            return ($(this).attr('class').length == 0 && $.trim($(this).text()).length == 0);
        }).remove();*/
	 
	 
		
        //Remove &nbsp; from headers 
		$('h1').each(function()
		{
			if($(this).html().match(/&nbsp;/g))
			{
				var strNoSpaces = $(this).html().replace(/&nbsp;/g,'');
				$(this).html(strNoSpaces);
			}
			
			/*
			
			
			if($(this).html().match(/Fire &amp; Security Services/g))
			{
				$("#actions").css({ top: '365', right: '310' });
			}
			
			*/
			
		});
		/* --------------- Remove &nbsp; from page ( e )------------------*/

		$('.product').each(function(){			
			$(this).contents().filter(function()
			{
				if(this.nodeType == 3)
				{
					$(this).wrap("<p></p>");
				}
			});
			
			var elements = $(this).children('div,p').filter(function(){
				if($(this).hasClass('image1'))
					return;
				else if($(this).parent().hasClass('pbrand'))
					return
				else					
					return $(this);				
			});
			
			if(elements.length > 0){
				var stemp1 = elements.text().trim();
				elements.remove();
				
				/*if(stemp1.length > 190)
				{				
					var stemp2 = stemp1.substr(0,185);
					stemp2 += "...";		
					$(this).children('h3').eq(0).after('<p>'+stemp2+'</p>');		
				}
				else{*/
					$(this).children('h3').eq(0).after('<p>'+stemp1+'</p>');					
				/*}*/
			}
		});
		
		$('.brand').each(function(){			
			$(this).contents().filter(function()
			{
				if(this.nodeType == 3)
				{
					$(this).wrap("<p></p>");
				}
			});
			
			var elements = $(this).children('div,p').filter(function(){
				if($(this).hasClass('image2'))
					return;				
				else					
					return $(this);				
			});
			
			if(elements.length > 0){
				var stemp1 = elements.text().trim();
				elements.remove();
				
				$(this).children('h3').eq(0).after('<div>'+stemp1+'</div>');			
			}
		});
				
/* --------------- Remove &nbsp; from page ( E )------------------*/


/* --------------- Remove <br/> from page ( S )------------------*/


		//var nospace = spacer.replace(/(<br>)*/g,"");


/* --------------- Remove <br/> from page ( E )------------------*/


        // disble scroller less than 9 item in Brand Filter
        var x1 = $(".cf li").size();

        if ((x1 < 9)) {
            //alert ("test");
            $("div.scrollBar").each(function () {
                $(this).removeClass("scrollBar");
            });

        }

        // Titile in editable area


        if (jQuery.browser.version == "7.0") {

            $("input[id$='TextField']").before("<br/>");
        }


        if ($("#PressReleaseLayout").length > 0) {
            var pressReleaseUrl = $("span.menu-item-text:contains('Press Releases')").parent().parent().attr("href");
            //alert(pressReleaseUrl);
            $("td.breadcrumbs").each(function (index) {
                if (index == 1) {
                    $(this).find("a:contains('Newsroom')").after("<span id = 'extraPressReleaseNode'> > <a href = '" + pressReleaseUrl + "'> Press Releases</a></span>");
                }
            });
        }

        //Case Study Bread Crumb Fix
        else if ($("#CaseStudyPageLayout").length > 0) {
            var caseStudyReleaseUrl = $("span.menu-item-text:contains('Case Studies')").parent().parent().attr("href");
            //alert(pressReleaseUrl);
            $("td.breadcrumbs").each(function (index) {
                if (index == 1) {
                    $(this).find("a:contains('Newsroom')").after("<span id = 'extraCaseStudyNode'> > <a href = '" + caseStudyReleaseUrl + "'> Case Studies</a></span>");
					/*
					var trimmedLastNodeText = $("td#ctl00_PlaceHolderTitleBreadcrumb_Menu2n1 td").text();
					if(trimmedLastNodeText != null && trimmedLastNodeText.length > 58){
					$("td#ctl00_PlaceHolderTitleBreadcrumb_Menu2n1 td").text(trimmedLastNodeText.substring(0,58) + "..");
					}
					*/
                }
            });
        }
		
		// Breadcrumb width Fix ----------------------- 
		/*
		var breadcrumbLength = $(".titlerow-table").innerWidth();
		var lengthyBreadcrumbNodeText = $("table[id*='PlaceHolderTitleBreadcrumb'] > tbody > tr > td:last a").text();
		
		var bNodeLength = $("table[id*='PlaceHolderTitleBreadcrumb'] > tbody > tr > td").length - 2;		
		
		var bSelector = "table[id*='PlaceHolderTitleBreadcrumb'] > tbody > tr > td:eq(" + bNodeLength + ")";
		if($(bSelector).offset() != null)
		{
			var bSelectorLeft = $(bSelector).offset().left;
			var bSelectorTop = $(bSelector).offset().top;
		
		var breadLength = 9;
		
		$(".breadcrumbs>table>tbody>tr>td").each(function(){
			var breadText = $(this).find("a:last").text();
			
			if(breadText.length > 0 )
			{
				breadLength += breadText.length;
			}
			else
			{
				breadLength += 3;
			}
			//alert("breadLength =" + breadLength);
			//predict = ($("table[id*='PlaceHolderTitleBreadcrumb']").innerWidth()/42)*7;
			predict = 90;
			//alert("predict =" + predict)
			if(breadLength > predict)
			{
				var tmptext = $(this).find("a:last").text();				

				if($('.lastbreadcrumbdiv').length < 1)
				{
					$(".titlerow-table").after("<div id='lastbread' class = 'lastbreadcrumbdiv' style = 'margin-top:15px;display:none;text-align:right;background-color:white;position:absolute;color:#797979;z-index:1000;'></div>");
					
					if($.browser.msie)
					{
						if (jQuery.browser.version == "7.0") 
						{			
							//$(".lastbreadcrumbdiv").css('top','120px');
						}
					}					
				}
							
				//remove last empty node
				if($(this).text() != '')
				{
					$('#lastbread').append('&nbsp;&gt;&nbsp;');
					
				}
				
				$(this).find("a:last").clone().appendTo("#lastbread");
				
				$(this).find("a:last").text(tmptext.substring(0,(tmptext.length-3)-(breadLength-predict))+'...');
				
			}
		})
}		
		
		$("table[id*='PlaceHolderTitleBreadcrumb'] > tbody > tr > td:last").live('mouseover', function() {
				var currentStyle = $(".lastbreadcrumbdiv").attr("style");
				$(".lastbreadcrumbdiv").removeAttr("style");
				currentStyle = currentStyle + "top:"+$(this).position().top + "px";
				//alert(currentStyle)
				$(".lastbreadcrumbdiv").attr("style", currentStyle)
				//alert(currentStyle)
				//alert($(".lastbreadcrumbdiv").attr("style"));
				if($.browser.msie)
					{
						if (jQuery.browser.version == "7.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',$(this).position().top + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
						else if (jQuery.browser.version == "8.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',$(this).position().top + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
					}
				$(".lastbreadcrumbdiv").show();
		});
		
		$("div.lastbreadcrumbdiv").live('mouseover', function() {	
			
				var currentStyle = $(".lastbreadcrumbdiv").attr("style");
				$(".lastbreadcrumbdiv").removeAttr("style");
				currentStyle = currentStyle + "top:"+$("table[id*='PlaceHolderTitleBreadcrumb'] > tbody > tr > td:last").position().top + "px";
				//alert(currentStyle)
				$(".lastbreadcrumbdiv").attr("style", currentStyle)
				//alert(currentStyle)
				//alert($(".lastbreadcrumbdiv").attr("style"));
				if($.browser.msie)
					{
						if (jQuery.browser.version == "7.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',$(this).position().top + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
						else if (jQuery.browser.version == "8.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',$(this).position().top + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
					}
				$(".lastbreadcrumbdiv").show();
		});
		
		$("div.lastbreadcrumbdiv").live('mouseout', function() {	
		var currentStyle = $(".lastbreadcrumbdiv").attr("style");
			$(".lastbreadcrumbdiv").removeAttr("style");
				currentStyle = currentStyle + "top:"+$("table[id*='PlaceHolderTitleBreadcrumb'] > tbody > tr > td:last").position().top + "px";
				$(".lastbreadcrumbdiv").attr("style", currentStyle);
				if($.browser.msie)
					{
						if (jQuery.browser.version == "7.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',$(this).position().top + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
						else if (jQuery.browser.version == "8.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',$(this).position().top + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
					}
				$(".lastbreadcrumbdiv").hide();
		});
		
		$("table[id*='PlaceHolderTitleBreadcrumb'] > tbody > tr > td:last").live('mouseout', function() {	
			var currentStyle = $(".lastbreadcrumbdiv").attr("style");
			$(".lastbreadcrumbdiv").removeAttr("style");
				currentStyle = currentStyle + "top:"+$(this).position().top + "px";
				$(".lastbreadcrumbdiv").attr("style", currentStyle);
				if($.browser.msie)
					{
						if (jQuery.browser.version == "7.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',$(this).position().top + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
						else if (jQuery.browser.version == "8.0") 
						{			
							$(".lastbreadcrumbdiv").css('top',($(this).position().top - 5) + 'px');
							//alert($(".lastbreadcrumbdiv").css('top'));
						}
					}
				$(".lastbreadcrumbdiv").hide();
		});		
		
		*/
		
        var firstNode = $("td.breadcrumbs table tr td:eq(0) table tr td a").text();
        if (firstNode == "Home") {
            $("#tdhome").remove();
        }

        var totalEmptyTd = $("td.breadcrumbs > table > tbody > tr > td:empty").length;
        $("td.breadcrumbs > table > tbody > tr > td:empty").each(function (index) {
            if (totalEmptyTd == index + 1) { }
            else {
                //$(this).text(" > ");
                $(this).html("&nbsp;&nbsp;&gt;&nbsp;&nbsp;");

            }


            // arrow for home node -----------------------

            var arrowNode = $("td#tdhome span#sphome").text();


            if (arrowNode != "Home > ") {

                $('span#sphome').html("<a href='/'>Home</a>&nbsp;&gt;&nbsp;");

            }

            // Check IE 7 -----------------------

            // var arrowNode = $("td#tdhome span#sphome").text();






        });
        //Remove empty image tags for fire and security products 
        $(".productsThumbnail").each(function () {
            if ($(this).attr("src").length == 0) {
                $(this).remove();
            }
        });

        /*var childContent = $("#zz1_TopNav").children("div").html();
        $("#zz1_TopNav").children("div").remove();
        $("#zz1_TopNav").html(childContent);*/
        $("#zz1_TopNav div").removeAttr("class");
        $("#zz1_TopNav ul li").removeAttr("class");
        $("#zz1_TopNav ul").removeAttr("class");
		$("#zz1_TopNav ul ul").removeAttr("class");
		$("#zz1_TopNav ul ul").removeAttr("style");	
        
       // $('p #actions').removeClass('');
		//$("p ").addClass('');
        //$('#actions').removeClass('actions').addClass('actionsPS'); 
        //$('#actions p').attr('actions', 'actionsPS');.removeClass('actions').addClass('actionsPS')
        
        
      
      //  alert($('#content table > tbody > tr:eq(0) > td:eq(2)').html());

        
        
        // $('#content').css({ position: 'auto', width: '500px !important', float: 'right !important' });
     //var action = $('#actions').css({ position: 'absolute !important', right: '310px !important;', top: '365px !important' });
		//alert($('#content').html());

        /* $("#zz1_TopNav ul li").removeAttr("sizcache");
        $("#zz1_TopNav ul li").removeAttr("sizeset");
        $("#zz1_TopNav ul li").removeAttr("class"); 
        $("#side1 div").removeAttr("class");
        $("#zz11_CurrentNav div").removeAttr("class");*/

        /*
        $("#zz11_CurrentNav ul li").removeAttr("class");
        $("#zz1_TopNav ul").removeAttr("class");
        
        */



        // Register a JS function to be triggered when a pageload or an ajax response is occurred
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_pageLoaded(pageLoaded);

        // This method gets triggered in a page load or an ajax response
        function pageLoaded(sender, args) {
            var panels = args.get_panelsUpdated();

            // Only in an Ajax response
            if (panels.length > 0) {
                var hiddenAjaxResponseStatusElement = document.getElementById("AjaxResponseStatus");
                // Only if the Email Sender Control is available
                if (hiddenAjaxResponseStatusElement) {
                    // Only if the Email Sender Ajax Postback was successful
                    if (hiddenAjaxResponseStatusElement.value == "Success") {
                        // Hide the popup

                        p = $("#popupEmail")
                        popupHide(p);
                        $('#Preload').hide();
                        $("#popupEmail").css({ top: '', left: '' });
                    }
                }
            }
        }

        $('#search input').each(function () {
            this._default = this.value;
            $(this).focus(function () {
                if (this.value == this._default)
                    this.value = '';
            }).blur(function () {
                if (this.value == '')
                    this.value = this._default;
            });
        });

        $("a.share").live('click', function (e) {
            $("#popupShare").removeClass("popupHide");
            var l;
            var t;
            //Share popup alignment inside the popup - Download Library.
                        if ($(".pp_inline div.image p.actions").length > 0 || $(".pp_inline div.video p.actions").length > 0) {
                                                    if($("#actions2").length > 0)
                                                                {
                                                                                var self = $("#actions2");
                                                                                var pos = self.position();
                                                                                l = pos['left'] - 234;
                                                                                t = pos['top'] - 30;
                                                                }
                                                                ////Share popup alignment inside the popup -Case Study.
                                                                else
                                                                {
                                                                                var self = $('.pp_inline div.image img').filter(":visible"); 
                                                                                var pos = self.position();
                                                                                l = pos['left'] - 84;
                                                                                t = pos['top'] + self.attr('height') - 100;
                                                                }
                                                                
                                                }


			
			//Share popup alignment inside the popup - Product Showcase.
			else if($(".pp_inline").hasClass("popupTabs")) 
			{ 
					var self = $('.pp_inline div.image img').filter(":visible"), pos = self.position();
					l = pos['left'] + self.attr('width') - $("#popupShare").width() - 50; 
					t = pos['top']-10; 
			}
			//Share popup alignment for general places.
            else {
                var self = $(this), pos = self.position();
				l = pos['left'] + 186;
				t = pos['top'] - 35;
				
				if($(".home #content").length>0)
				{
					l = l - 100;
				}
            }

            $("#popupShare").css({ top: t, left: l });
            $("#popupShare").show();
			 e.preventDefault();
        });




        $("a.print").live('click', function () {
            var hostName = window.location.host;
            var protocolName = window.location.protocol;
            var rootSite = protocolName + "//" + hostName;
            var currentLocation = window.location.href;
            window.open(rootSite + "/Pages/print.aspx?pr=" + currentLocation);

        });


        $("a.printImage").live('click', function () {
            var hostName = window.location.host;
            var protocolName = window.location.protocol;
            var rootSite = protocolName + "//" + hostName;
            var currentLocation = window.location.href;
            var lowResImage = $(this).attr("lowResImageSrc");
            window.open(rootSite + "/Pages/printImage.aspx?pr=" + lowResImage);

        });

        $('.popup a.close').live('click', function () {
	
		var thisid = $(this).parent().attr('id');
		
		if(thisid.indexOf('EmailPopupUpdatePanel') > -1)
		{
			var temp = $('textarea[id $= "messageTextBox"]').val();
			
			$(':input','#popupEmail')
				 .not(':button, :submit, :reset, :hidden')
				 .val('')
				 .removeAttr('checked')
				 .removeAttr('selected')
				 .removeAttr('style');
			$('span.error').hide();
			$(this).parent().children('textarea').attr('readonly','readonly');	
			$('span[id$="_SuccessMessageLabel"]').hide();
			$('textarea[id $= "messageTextBox"]').val(temp);
				 var p = $(this).parent().parent().parent();
					popupHide(p);
					return false;
		}
		
            var p = $(this).parent('.popup');
            popupHide(p);
            return false;
        });

        $('.email a.emailpop').live('click', function (e) {
            var hide = $('.popup a.close').parent('.popup');

            $('#popupShare').addClass('popupHide').css({ left: '', top: '' });
            ps = $('#popupShare')
            popupHide(ps);
            var poss2 = jQuery('#MainNav').offset().left;
            $("#popupEmail").removeClass("popupHide");

            var l;
            var t;
			//Email popup alignment inside the popup - Download Library Images.
            if ($(".pp_inline div.image p.actions").length > 0) {
                var self = $(this), pos = self.position();
                l = pos['left'] - 77;
                t = pos['top'] - 20;
            }
			//Email popup alignment inside the popup - Download Library Videos.
            else if ($(".pp_inline div.video p.actions").length > 0) {
                var self = $(this), pos = self.position();
                l = pos['left'] + 20;
                t = pos['top'] - 20;
            }
			//Email popup alignment inside the popup - Product Showcase.
			else if($(".pp_inline").hasClass("popupTabs")) 
			{ 
				var self =$(".pp_inline div.image img").filter(":visible"), pos = self.position(); 
				l = pos['left'] + self.attr('width') - $("#popupEmail").width() - 50; 
				t = pos['top'] - 10; 
			}
			//Share popup alignment for general places.
			else {
                var self = $(this), pos = self.position();
                l = pos['left'] + 4;
                t = pos['top'] - 90;
				if($(".home #content").length>0)
				{
					l = l - 100;
				}
            }
            $("#popupEmail").css({ top: t, left: l });
            $("#popupEmail").show();
			e.preventDefault();
			
        });

        $("#LaunchHistoricalTimelineButton").click(function () {
            var HistoricalTimeline = $("#LaunchHistoricalTimelineButton").position();
            $("#LaunchHistoricalTimelinePopUp").removeClass("popupHide").css({ top: HistoricalTimeline.top - 35, left: HistoricalTimeline.left - 0 });
        });



        $("#LaunchRssButton").click(function () {
            var LaunchRss = $("#LaunchRssButton").position();
            $("#LaunchRssPopUp").removeClass("popupHide").css({ top: LaunchRss.top - 35, left: LaunchRss.left - 310 });
        });



        function bodyClick(ev) {
            var el = $(ev.originalTarget);
            if (!el.hasClass('popup') && !el.parents('.popup').length)
                popupHide();
        }
        function popupHide(p) {
            if (!p)
                p = $('.popup');
            p.addClass('popupHide').css({ left: '', top: '' });
            $(document.body).unbind('click', bodyClick);
            $('#overlay').hide();
        }


        $('#GlobalNav .lang a').click(function () {
            $('#popupLang').removeClass('popupHide').css({ left: '50%', top: '200px' });
            $('#overlay').show();
            $(document.body).bind('click', bodyClick);
            return false;
        });


        var h = Math.max($(document).height(), $(window).height());
        $('#overlay').height(h - 90);


        if ($('.results').length) {
            var thumbs = $('.results li a.thumb');
			
			$('.results li a').click(function () {
				document.body.scroll="no";
				function stopScroll() {
				return false;
				}	
				document.onmousewheel=stopScroll;
			});
            thumbs.hover(function () {
                var self = $(this), p = $('#popupThumb'), pos = self.position(),
				img = self.parent().addClass('active').find('img.hover');

                p.find('.content').html('<img src="' + img.attr('src') + '" class="resizeHover"/>');

                var topHeight = p.find('.top').height();
                var contentHeight = p.find('.content').height();
                var bottomHeight = p.find('.bottom').height();
                var imgHoverHeight = $('#popupThumb div.content img').height();
                var imgHoverWidth = $('#popupThumb div.content img').width();
                var contentWidth = p.find('.content').width();
                var imgHoverTopMargin = (topHeight + contentHeight + bottomHeight - imgHoverHeight) / 2;
                var imgHoverLeftMargin = (contentWidth - imgHoverWidth) / 2;

                $('#popupThumb div.content img').css('padding-top', imgHoverTopMargin + 'px');
                $('#popupThumb div.content img').css('padding-bottom', imgHoverTopMargin + 'px');
                $('#popupThumb div.content img').css('padding-left', imgHoverLeftMargin - 10 + 'px');
                $('#popupThumb div.content img').css('padding-right', imgHoverLeftMargin + 'px');

                var l = pos['left'] - contentWidth;
                var t = pos['top'] - imgHoverHeight / 2;
                p.removeClass('popupHide').css({
                    left: l + 'px',
                    top: t + 'px'
                });
            }, function () {
                var p = $('#popupThumb');
                popupHide(p);
                $(this).parent().removeClass('active');
            });

            if ($.fn.prettyPhoto) {
                $('.popup4').hide();

                thumbs.prettyPhoto({
                    opacity: 0.25,
                    allowresize: false,
                    showTitle: false,
                    animationSpeed: 'fast',
                    theme: 'utcfs'
                });

                //			thumbs.eq(1).click();
            }

        }

        $('.filters h6.toggle a').click(function () {
            var self = $(this), div = self.parent().parent().find('div.toggle');
            div[(self.hasClass('active') ? 'hide' : 'show')]();
            self.html((self.hasClass('active') ? 'More Filtering Options' : 'Filter Results By'));
            self.toggleClass('active');
            return false;
        });


        var tPopup5 = null;

        $('.brand .image2 a').hover(function () {
            if (tPopup5)
                clearTimeout(tPopup5);
            popupHide();
            var self = $(this), id = self.parents('.brand')[0].id, p = $('#popup-' + id), pos = self.offset();
            var l = pos['left'] + self.outerWidth() - 10;
            var t = pos['top'] - 10;
            p.removeClass('popupHide').css({
                left: l + 'px',
                top: t + 'px'
            });
        }, function () {
            var self = $(this), id = self.parents('.brand')[0].id, p = $('#popup-' + id);
            tPopup5 = setTimeout(function () {
                popupHide(p);
            }, 400);
        });
        $('.popup5').hover(function () {
            if (tPopup5)
                clearTimeout(tPopup5);
        }, function () {
            var self = $(this);
            tPopup5 = setTimeout(function () {
                popupHide(self);
            }, 400);
        });



        var tPopup6 = null;

        $('#Brands li a').hover(function (e) {
            if (tPopup6)
                clearTimeout(tPopup6);
            popupHide();
            //offset of object selected 
            var self = $(this), id = self.parents('li')[0].id, p = $('#popup-' + id);
            var pos = self.position();
            var l = pos['left'] - 10;
            var t = pos['top'] - 10;

            if ($(".ms-cui-topBar2").length > 0) {
                t = t - $(".ms-cui-topBar2").height();
            }

            p.removeClass('popupHide').css({ left: l + 410, top: t + 100 });

        }, function () {
            var self = $(this), id = self.parents('li')[0].id, p = $('#popup-' + id);
            tPopup6 = setTimeout(function () {
                popupHide(p);
            }, 400);
        });
        $('.popup6').hover(function () {
            if (tPopup6)
                clearTimeout(tPopup6);
        }, function () {
            var self = $(this);
            tPopup6 = setTimeout(function () {
                popupHide(self);
            }, 400);
        });


        var tSel = null;
        function cancelSel() {
            if (tSel) {
                clearTimeout(tSel);
                tSel = null;
            }
        }
        function setSel(w) {
            w = w || $('div.select1');
            tSel = setTimeout(function () {
                w.removeClass('select1Active');
            }, 200);
        }
        var zi = 99;
        $('.select1').each(function () {
            var s = $(this).hide();
            s.wrap('<div class="select1 selectArea-' + s[0].name + ' cf"></div>');
            var w = s.parents('.select1').css({ zIndex: zi-- });
            w.append('<a class="main" href="#"><span></span></a><ul></ul>');
            var a = w.find('a.main'), ul = w.find('ul'), l = 0;
			
			if(this.options != null){
            for (var i = 0; i < this.options.length; i++) {
                ul.append('<li><a href="#" class="index-' + i + '">' + this.options[i].text + '</a></li>');
                l = Math.max(l, this.options[i].text.length);
            }
			

            $('.select1 a.main').unbind('click');
            $('.select1 a.main').bind('click', dropDownClicked);
            $('.select1 ul a').unbind('click');
            $('.select1 ul a').bind('click', dropDownElementClicked);
			
			 a.find('span').html(this.options[this.selectedIndex].text);
			 }
			 //});
            function bodyClickSelect(ev) {
                var el = $(ev.originalTarget);
                if (!el.hasClass('select1') && !el.parents('div.select1').length) {
                    setSel();
                    $('.select1 a.main').unbind('click');
                    $('.select1 a.main').bind('click', dropDownClicked);
                }
            }

            function dropDownElementClicked() {
                var w = $(this).parents('.select1'), a = w.find('a.main'), ul = w.find('ul');
                var sl = w.find('select.select1');
                var i = parseInt(this.className.split('-')[1]);
                sl.selectedIndex = i;
                var options = sl.find('option');

                for (var index = 0; index < options.length; index++) {
                    if ($(options.get(index)).attr('selected') != false) {
                        options.removeAttr('selected');
                    }

                    if (index == i) {
                        $(options.get(index)).attr('selected', 'selected');
                    }
                }


                if (sl.attr('onchange') != null) {
                    //setTimeout('__doPostBack(\'' + sl.name + '\',\'SelectedIndexChanged\',\'' + sl.selectedIndex + '\')', 0);
                    sl.trigger('onchange');
                } else {
                    a.find('span').html(this.innerHTML);
                    w.removeClass('select1Active');

                    $(this).unbind('click');
                    a.unbind('click');
                    a.bind('click', dropDownClicked);
                }

                return false;
            }

            function dropDownClicked() {
                var a = $(this), w = a.parents('.select1'), ul = w.find('ul');
                ul.css('width', 150);

                if (w.hasClass('select1Active')) {
                    w.removeClass('select1Active');
                } else {
                    $(document.body).unbind('click', bodyClickSelect);
                    $(document.body).bind('click', bodyClickSelect);
                    a.unbind('click');
                    w.addClass('select1Active');
                    $('.select1 ul a').unbind('click');
                    $('.select1 ul a').bind('click', dropDownElementClicked);
                }
                return false;
            }

           
			

        });



        //        if ($('#MapLarge').length) {
        //            var mapLarge = $('#MapLarge'),
        //			mapAll = 'americas europe ukisa middle asia australasia', mapItems = mapAll.split(' ');

        //            function popupHideMap(p) {
        //                var id = p[0].id.split('-')[1];
        //                popupHide(p);
        //                mapLarge.find('.' + id).removeClass('hover');
        //            }

        //            mapLarge.find('a').hover(function () {

        //                mapLarge.find('> div').removeClass('hover');
        //                mapLarge.find('.' + this.id).addClass('hover');

        //                if (tPopup6)
        //                    clearTimeout(tPopup6);
        //                popupHide();

        //                var self = $(this), p = $('#popup-' + this.id), pos = self.offset();
        //                var l = pos['left'] + Math.round(self.width() * 0.25) - p.outerWidth();
        //                var t = pos['top'] + Math.round(parseInt(self.css('paddingTop')) + parseInt(self.css('lineHeight')) / 2) - 44;

        //                switch (this.id) {
        //                    case 'americas':
        //                        l += 55;
        //                        break;
        //                }
        //                switch (this.id) {
        //                    case 'ukisa':
        //                        l -= 10;
        //                        break;
        //                }

        //                switch (this.id) {
        //                    case 'europe':
        //                        l += 10;
        //                        break;
        //                }


        //                p.removeClass('popupHide').css({
        //                    left: l + 'px',
        //                    top: t + 'px'
        //                });

        //            }, function () {

        //                //			mapLarge.find('.' + this.id).removeClass('hover');

        //                var p = $('#popup-' + this.id);
        //                tPopup6 = setTimeout(function () {
        //                    popupHideMap(p);
        //                }, 300);

        //            }).click(function () {
        //                serviceChange(this.id);
        //                return false;
        //            });

        //            for (var c in mapItems) {
        //                mapLarge.append('<div class="' + mapItems[c] + '"></div>');

        //                var p = $('#popup-' + mapItems[c]);
        //                p.bind('mouseleave', function () {
        //                    var p = $(this);
        //                    tPopup6 = setTimeout(function () {
        //                        popupHideMap(p);
        //                    }, 300);
        //                });
        //            }

        //            function serviceChange(id) {
        //                mapLarge.find('.active').removeClass('active').end().
        //				find('.' + id).addClass('active');

        //                $('#LeftNav > ul > li').removeClass('active').filter('.' + id).addClass('active');
        //                $('#content > div').hide().filter('.' + id).show();

        //                var brands = $('#Brands ul > li').hide().filter('.empty').remove().end().filter('.' + id).show();
        //                var sLI = '<li class="empty">&nbsp;</li>';
        //                if (brands.length < 8) {
        //                    var s = '';
        //                    for (var i = brands.length; i < 8; i++)
        //                        s += sLI;
        //                    $('#Brands ul').append(s);
        //                }
        //                else if (brands.length % 2) {
        //                    $('#Brands ul').append(sLI);
        //                }

        //                slider.reset();
        //            }
        //        }


        if ($.fn.accordion) {
            $("#Accordion").accordion({
                header: '> h3',
                icons: {
                    header: "closed",
                    headerSelected: "active"
                },autoHeight: false,clearStyle: true,
                change: function (event, ui) {
                    $('#Accordion h3').removeClass('down');	//$('#Accordion .content').height('290px');	    
                    ui.newHeader.prevAll().addClass('down');
                }
            });
        }

        if ($('#slideshow').length) {
            var slideshow = $('#slideshow'), slides = slideshow.find('.slide'), nav = slideshow.find('.nav'),
			tSlides = null, i = 1, speedFade = 600, pauseTime = 8000, fadeMax = 1;

            if ($.browser.msie == true) {
                fadeMax = parseInt($.browser.version) == 8 ? .8 : .95;
                slideshow.addClass('ie');
            }

            slides.each(function () {
                this.id = 'slide-' + (i++);
            }).find('.info').css('left', 0).not($(this).eq(0)).hide();

            var s = '<a href="#" id="slideTrigger-prev">&lt;</a> <span><em class="start-1">';
            for (var i = 1; i <= slides.length; i++)
                s += '<a href="#" id="slideTrigger-' + i + '">' + i + '</a>';
            s += '</em></span> <a href="#" id="slideTrigger-next">&gt;</a>';

            nav.html(s);

            nav.find('a').click(function () {
                var id = this.id.split('-')[1];
                switch (id) {
                    case 'prev':
                        id = parseInt(slides.filter('.active')[0].id.split('-')[1]);
                        id = (id == 1 ? slides.length : id - 1);
                        break;
                    case 'next':
                        id = parseInt(slides.filter('.active')[0].id.split('-')[1]);
                        id = (id == slides.length ? 1 : id + 1);
                        break;
                    default:
                        var active = parseInt(slides.filter('.active')[0].id.split('-')[1]);
                        id = parseInt(id);
                        if (id == active)
                            id = 0;
                }
                if (id)
                    slideshowGo(id);
                return false;
            });
            var navEm = nav.find('em').css('width', 20 * slides.length);

            function slideshowGo(i) {
                var next = $('#slide-' + i), active = slides.filter('.active');
                next.addClass('next').show();
		active.fadeOut(speedFade);
		
		if($.browser.msie)
		{
			active.find('.info').fadeOut(speedFade, function (){ 
				 active.removeClass('active');
				$(next).find('.info').fadeTo(speedFade,0.75);
				
				next.addClass('active').removeClass('next');
				
				nav.find('a').removeClass('active').filter('#slideTrigger-' + i).addClass('active');
				var start = parseInt(nav.find('em')[0].className.split('-')[1]);
				if ((i > start) && (i - start > 3))
				    navEm[0].className = 'start-' + (i - 3);
				if (i < start)
				    navEm[0].className = 'start-' + i;
			});
		}
		else
		{
			active.find('.info').fadeOut(speedFade, function () {	
				 active.removeClass('active');
				$(next).find('.info').fadeIn(speedFade);
				next.addClass('active').removeClass('next');
				nav.find('a').removeClass('active').filter('#slideTrigger-' + i).addClass('active');
				var start = parseInt(nav.find('em')[0].className.split('-')[1]);
				if ((i > start) && (i - start > 3))
				    navEm[0].className = 'start-' + (i - 3);
				if (i < start)
				    navEm[0].className = 'start-' + i;
			});
		}
		
			
                /*active.find('.info').fadeOut(speedFade, function () {
                    if ($.browser.msie)
                        active.find('.info').addClass('temp');

                        active.find('.info').fadeOut(speedFade, function () {
                        active.removeClass('active');
                        var info = next.addClass('active').removeClass('next');
			
                        if ($.browser.msie)
                            info.addClass('temp');
                        info.fadeIn(speedFade, function () {
                            $(this).removeClass('temp');
                        });
			
			$(next).find('.info').fadeIn(speedFade);
			
                        nav.find('a').removeClass('active').filter('#slideTrigger-' + i).addClass('active');
                        var start = parseInt(nav.find('em')[0].className.split('-')[1]);
                        if ((i > start) && (i - start > 3))
                            navEm[0].className = 'start-' + (i - 3);
                        if (i < start)
                            navEm[0].className = 'start-' + i;

                    });
		    
                });*/
            }

            function slideshowTimer() {
                var active = slides.filter('.active'), id = parseInt(active[0].id.split('-')[1]);
                id = (id == slides.length ? 1 : id + 1);
                slideshowGo(id);
            }

            function slideshowPause(pause) {
                if (!pause) {
                    tSlides = setInterval(slideshowTimer, pauseTime + 3 * speedFade);
                }
                else {
                    clearInterval(tSlides);
                }
            }

            slideshow.hover(function () {
                slideshowPause(true);
            }, function () {
                slideshowPause(false);
            });

            var info = slides.filter('.active').find('.info')
            if ($.browser.msie)
                info.addClass('temp');
            info.fadeIn(speedFade, function () {
                $(this).removeClass('temp');
                slideshowPause(false);
            });
            $('#slideTrigger-1').addClass('active');
        }

        if ($('.slideshow2').length) {
            var slideshow = $('.slideshow2');

            
            slideshow.find('.slider').jCarouselLite({
                btnPrev: '.slideshow2 a.prev',
                btnNext: '.slideshow2 a.next',
		        visible: 3
            });
	     
	     slideshow.find('.slider li').boxLinks();
        }

        if ($.fn.prettyPhoto) {
            $('.popupTabs').each(function () {
                var self = $(this), h = 0;
                self.find('.tab').each(function () {
                    h = Math.max(h, $(this).outerHeight());
                });
                self.find('.tabArea').height(h);
                self.find('.tab').not(':eq(0)').hide();
            });

			
				
            $('.popup4').hide();

            $('.results2 li a').click(function () {
                document.body.scroll="no";
				function stopScroll() {
				return false;
				}	
				document.onmousewheel=stopScroll;
				
				
				$('.popupTabs').each(function () {
                    var self = $(this), img = self.find('.image').hide().filter(':eq(0)').show();
                    //var w = (img.hasClass('imageH') ? 790 : 660);
                    //self.width(w);
                });
				return false;
            });
				$('.buttoncs').click(function () {
				document.body.scroll="no";
				function stopScroll() {
				return false;
				}	
				document.onmousewheel=stopScroll;
				});
			
			
              $('.image3 a, .results2 li a, .buttoncs,#image4 btn_holder a').prettyPhoto({
                opacity: 0.25,
                allowresize: false,
                showTitle: false,
                animationSpeed: 'fast',
                theme: 'utcfs'
            });            

            $(document.body).
			delegate('.popupTabs .tabs a', 'mouseenter', function () {
			    var id = $(this).attr('href').split('#')[1],
					pp = $('.pp_pic_holder');
			    var pid = $('#' + pp.attr('data-id')).add($(this).parents('.popupTabs'));
			    pid.find('.tab').hide().filter('.' + id).show();
				
			}).
			delegate('.popupTabs .thumbs a', 'click', function () {
			    var id = $(this).attr('href').split('#')[1];
			    var pt = $(this).parents('.popupTabs'),
					pp = $('.pp_pic_holder'), pc = $('.pp_content');

			    var pid = $('#' + pp.attr('data-id')).add(pt);

			    var img = pid.find('.' + id);
			    pid.find('.image').hide();
			    img.show();
				var x = img.filter(":visible").find("img").attr('width');
				var w = x + 360;
			       pid.width(w);
			        $.prettyPhoto.open('#' + pp.attr('data-id'));
			        pp.find('.popupTabs').width(w);
			   return false;
			});
        }


        $('#CalloutBox li').boxLinks();


        slider.init();




        if ($.browser.msie) {
            try { document.execCommand("BackgroundImageCache", false, true); } catch (err) { };
            if (typeof (DD_belatedPNG) != 'undefined') {
                DD_belatedPNG.fix('img, a.close, .actions a, #MainNav ul, #MapSmall div, #MapLarge div, #slideshow .info');
                DD_belatedPNG.fix('.popup, .popup .top, .popup .content, .popup .bottom');
            }
        }

    });

    var slider = {
        wheel: false,
        init: function () {
            $('.scroll').removeClass('scroll').addClass('scrollWrap').wrapInner('<div class="scrollArea"></div>').each(function () {
                //			$(this).parents('.scrollWrap').attr('id', this.id);
                //			this.id = '';
            });
            $('#Brands .scrollWrap').each(function () {
                var ha = $(".scrollArea").css("height");
                var hw = $(".scrollWrap");
                //alert($('.scrollArea').attr('innerHeight'));
                var ha = 408;
                var hw = 272;
                if (ha > hw) {
                    $('.scrollWrap').append('<div class="scrollBar"><div class="scrollBarIn"></div></div>');
                    var sb = $('.scrollBarIn', this)[0];
                    $.data(sb, 'ha', ha);
                    $.data(sb, 'hw', hw);
                    $('.scrollBarIn', this).css({ height: (hw - 80) + 'px' }).slider({
                        orientation: 'vertical',
                        min: 0,
                        max: 100,
                        slide: slider.slide,
                        change: slider.slide
                    }).slider('value', 100);
                    $('.scrollBar a.dn', this).click(slider.dn);
                    $('.scrollBar a.up', this).click(slider.up);
                }
            }).bind('updateScroll', function () {
                var ha = $('.scrollArea', this).height();
                var sb = $('.scrollBarIn', this)[0];
                $.data(sb, 'ha', ha);
            }).bind('mousewheel', function (ev, delta) {
                var sb = $('.scrollBarIn', this)[0];
                slider.wheel = true;
                slider[(delta > 0 ? 'up' : 'dn')].apply(sb);
                slider.wheel = false;

                return false;
            });

        },
        reset: function () {
            $('.scrollWrap').each(function () {
                var ha = $('.scrollArea', this).height();
                var hw = $(this).height();
                var sb = $('.scrollBarIn', this);
                $.data(sb[0], 'ha', ha);
                $.data(sb[0], 'hw', hw);

                sb.slider('value', 100);

                $('.scrollArea', this).css('top', 0);
            });
        },
        slide: function (event, ui) {
            var sl = $(ui.handle.parentNode);
            var ha = $.data(sl[0], 'ha');
            var hw = $.data(sl[0], 'hw');
            var hs = ha - hw;
            var t = (-hs * (100 - ui.value) / 100);
            if (hs > 0)
                $('.scrollArea', sl.parents('.scrollWrap')).css('top', t + 'px');
        },
        up: function () {
            var sl = $(this).parents('.scrollBar').find('.scrollBarIn');
            var val = sl.slider('value');
            sl.slider('value', val + 5 * (slider.wheel ? 3 : 1));
            return false;
        },
        dn: function () {
            var sl = $(this).parents('.scrollBar').find('.scrollBarIn');
            var val = sl.slider('value');
            sl.slider('value', val - 5 * (slider.wheel ? 3 : 1));
            return false;
        }
    };
    $.fn.boxLinks = function (settings) {
        if (!this.length)
            return;

        var items = this, options = $.extend({
            trigger: 'a',
            classHover: 'hover',
            classFocus: 'focus'
        }, settings || {});

        items.
		filter(function () {
		    return $(this).find(options.trigger).length > 0;
		}).each(function () {
		    var self = $(this), t = self.css('cursor', 'pointer').find(options.trigger);
		    $.data(this, 'trigger', t);
		    $.data(t[0], 'parent', self);
		}).bind('mouseenter', function () {
		    var t = $.data(this, 'trigger');
		    $(this).addClass(options.classHover);
		    window.status = t.attr('href');
		}).bind('mouseleave', function () {
		    $(this).removeClass(options.classHover);
		    window.status = '';
		}).bind('click', function (ev) {
		    /*var t = $.data(this, 'trigger');
		    t.trigger('click');
		    ev.stopPropagation();
		    return false;*/
		});

        items.find(options.trigger).
		bind('focus', function () {
		    var parent = $.data(this, 'parent');
		    parent.addClass(options.classFocus);
		}).bind('blur', function () {
		    var parent = $.data(this, 'parent');
		    parent.removeClass(options.classFocus);
		}).click(function (ev) {
				if ($(this).attr('id').indexOf("videoPopupanchor")>-1){
				window.location = $(this).attr('href');
				ev.stopPropagation();
				return false;
				}
				else{
					window.open($(this).attr('href'));
					return false;
				}
		});

        return items;
    };

    $.fn.equalHeights = function (add) {
        var tallest = 0;
        $(this).each(function () {
            tallest = Math.max(tallest, $(this).outerHeight());
        });
        $(this).each(function () {
            var t = $(this), p = 0;
            $.each(['borderTopWidth', 'paddingTop', 'paddingBottom', 'borderBottomWidth'], function (i, n) {
                p += parseInt(t.css(n));
            });
            var h = tallest - p;
            if (add && add[this.id])
                h += add[this.id];
            if ($.browser.msie && $.browser.version <= 6)
                t.css({ 'height': h });
            t.css({ 'min-height': h });
        });
        return this;
    };

    // Right side column show and hide 
    $(document).ready(function () {
        if ($("#side2").children().size() > 0) {
            // Right side column show
            $("#side2").show();
        }
        else {
            // Right side column hide and width reset  
            $("#side2").hide();
            $("#wrapSec").width(910);
            $("#content").width(750);
            $("#ctl00_MSO_ContentDiv").width(910);

        }
        // Webpart management mepositioning
        if ($("td#MSOTlPn_MainTD")) {
            $('#WebpartManagement').html("");
            $('#MSOTlPn_MainTD').appendTo('#WebpartManagement');
        }

        //Find Left Nav
        if ($(".menu-vertical ul li:has(ul)")) {
            //Add plus image, find class and hide all ul's
            $(".menu-vertical ul li").has("ul").prepend("<div class='PlusImg'></div>");
            $(".menu-vertical ul li").has("ul").addClass('find');
            $(".menu-vertical ul li").not(".find").prepend("<div></div>");
           // $("li.find ul").hide();

            var n = 0;

            //Expand menu 		
            $("div.PlusImg").live("click", function () {
                //remove plus image of clicked item and add minus image

                $(this).removeClass('PlusImg').addClass('MinusImg');
                $(this).parent("li").filter(".open").removeClass('open');
                $(this).parents("li").filter(".close").removeClass('close');
                $(this).parents('.find').filter(':first').addClass('open');
                $(this).parent().filter('.open').children('ul').css('display','block');
                
                
                
				 if($(this).parent().parent('ul').filter('.root').attr('id') == '')
									   {
												   $(this).parent().parent('ul').attr('id',1);
												   $(this).parent().children('ul').attr('id',2);
									   }
									   else
									   {
												   var no = $(this).parent().parent('ul').attr('id');
												   $(this).parent().children('ul').attr('id',++no);
									   }

									   if($(this).parent().children('ul').attr('id')==5)
									   {
												  $(this).parent().children('ul').children('li').children('div').removeClass('PlusImg');
									   }
                

                //$(".menu-vertical ul li.open").find('ul').hide();
                $(this).parent().siblings('.open').removeClass('open').addClass('close').children('ul').hide();
                $(this).parent().siblings('.close').children('div').removeClass('MinusImg').addClass('PlusImg');
                //$(this).siblings('ul').show();


						if($(this).parent().children('ul').children('li').children('ul').length == 0)
						{
							$(this).parent().children('ul').children('li').css('padding','0px');
							$(this).parent().children('ul').children('li').children('div').css('display','none');
							$(this).parent().children('ul').children('li').children('a').css('margin','0px');
							$(this).parent().children('ul').children('li').children('a').css('margin-left','15px');
						}

                /*
                $(".menu-vertical ul li.find").filter(".open").addClass('before');
                $(".menu-vertical ul li.open").filter('.before').children('div.MinusImg').removeClass('MinusImg').addClass('PlusImg').removeClass('before').removeClass('open');
                $(".menu-vertical ul li.open").filter('.before').children('div.PlusImg').children('ul').hide();
                $('.before').find('ul').hide();
                */
                /*
                var a = $("div.MinusImg");                
                //	if (a != null) { a.removeClass('MinusImg').addClass('PlusImg'); }
                $(this).removeClass('PlusImg').addClass('MinusImg');
                $("li.find ul").hide();
                $(this).parents('.find').filter(':first').children('ul').show();
                $(this).parents('.find').filter(':first').children('ul').css('padding-left','10px')
                
                $(this).parents('.find').filter(':first').removeClass('close').addClass('open');
                $('.open').children('ul').show();
                */
            });
            //Minimise menu 
            $("div.MinusImg").live("click", function () {
                //var index = $("div.MinusImg").index(this);

                $(this).removeClass('MinusImg').addClass('PlusImg');

                $(this).parents('.find').filter(':first').removeClass('open').addClass('close');
                $('.close').children('ul').hide();
            });
            //alert($('span.s4-breadcrumbCurrentNode').html());
            //var x = $(".menu-vertical").text();
            $(".menu-vertical").find($('span.s4-breadcrumbCurrentNode').text());
            //if($('span.s4-breadcrumbCurrentNode:contains(".menu-vertical")'))

        }
	
	
		var lastBreadcrumbNode = $('.breadcrumbs:last > table > tbody > tr > td:last a').text().trim();
		//alert($('ul.root').length);
		$('ul.root').children('li').each(function(){
			$(this).find('span:contains("'+lastBreadcrumbNode+'")').parent().parent().siblings('ul').show();
			$(this).find('span:contains("'+lastBreadcrumbNode+'")').parent().parent().siblings('div.PlusImg').removeClass('PlusImg').addClass('MinusImg');
			//	alert($(this).find('span:contains("'+lastBreadcrumbNode+'")').html());
			
		})  
		$('.menu-vertical span.menu-item-text').each(function(){
			if($(this).text() == lastBreadcrumbNode)
			{
				$(this).parents('ul').show();
				$(this).parents('ul').filter('div.PlusImg').removeClass('PlusImg').addClass('MinusImg');
				$(this).parents('ul').siblings().filter('div.PlusImg').removeClass('PlusImg').addClass('MinusImg');
			}
		});
        // Top navigation 
        /*
      
        $("li.dynamic-children").live("hover", function () {
        //Offset of main Menu
        var poss = $("#MainNav").offset().left;
        //Offset of dropdown menu
        var hoverPos = $("li.dynamic-children:hover").children("ul.dynamic").offset().left;
        //set the dropdown menu position 
        var leftPoss = poss - hoverPos;
        $("li.hover > ul.dynamic").css('left', leftPoss);
        });
      
      
        $("li.dynamic-children").mouseleave(function () {
        //hide the dropdown menu
        $("ul.dynamic").css('left', '-1000em');
        });*/


		
        // breadcrumbs ------------------
        var LastText = $(".breadcrumbs td:last").text();
        $(".breadcrumbs td:last").remove();
        $(".breadcrumbs td:last").html("<td><span>>&nbsp;&nbsp;" + LastText + "</span></td>");
		/*$(".breadcrumbs td:last").*/
/*
        var breadcrumbText = $("td.breadcrumbs > table > tbody > tr > td:last").text();
        breadcrumbText = breadcrumbText.replace(/[^a-zA-Z 0-9]+/g, '');
        var topNavCurrentLink = $("#zz1_TopNav > div > ul > li > ul > li:contains('" + breadcrumbText + "')");*/

        //topNavCurrentLink.each(function () {
        //    $(this).addClass("currentPageTopNav");
        //    $(this).parent('ul').parent('li').child('span').addClass("currentPageTopNav");
        //});
		
$('[id$="_descriptionTextBox"]').keypress(function(){
		limitNum = 50;
		if($(this).val().length > limitNum)
		{
			$(this).val($(this).val().substring(0,limitNum));
		}		
	});
   

   });
	
		



    /* ------------------ Start: Left Nav expanding menu ---------------


    $(document).ready(function () {
    $('ul.root li a').each(function (index) {
    if ($(this).attr('href').toUpperCase() == window.location.href.toUpperCase())
    if ($(this).siblings('div').attr('class') == 'PlusImg')
    $(this).siblings('div.PlusImg').click();
    else
    $(this).parents('ul').siblings('div.PlusImg').click();
    });
    });

    /* ------------------End : Left Nav expanding menu ---------------*/

 /*jQuery model dialog box-----------------------------------------------*/
 $.ShowPop = function (options) {
        var settings = {
            'width': 400,
            'height': 175,
            'message': 'null',
            'title': 'null',
            'button': 'yesno',
            'ismodel': true,
            'ifpositivefunction': 'null',
            'ifnegativefunction': 'null'
        };

        if (options) {
            $.extend(settings, options);
        }

        if ($(document).find('.popholder').length < 1) {
            $('body').append('	<div class="popholder"> \
							<div class="popoverlay"></div> \
							<div class="popwraper"> \
								<a class="btnclose" href="#">Close </a> \
								<div class="poptop"> \
									<div class="top_l"></div> \
									<div class="top_m"></div> \
									<div class="top_r"></div> \
								</div> \
								<div class="popmiddle"> \
									<div class="mid_l"></div> \
									<div class="mid_m"> \
										<div class="poptitle"></div> \
										<div class="popbody"></div> \
										<div class="popfooter"></div> \
									</div> \
									<div class="mid_r"></div> \
								</div> \
								<div class="popbottom"> \
									<div class="bot_l"></div> \
									<div class="bot_m"></div> \
									<div class="bot_r"></div> \
								</div> \
							</div> \
						</div>');
        }
        else {
            return;
        }

        $('.popwraper').width(settings.width);
        $('.top_m').width(settings.width - 20);
        $('.mid_m').width(settings.width - 20);
        $('.bot_m').width(settings.width - 20);

        $('.popwraper').height(settings.height);
        $('.mid_l').height(settings.height - 20);
        $('.mid_m').height(settings.height - 20);
        $('.mid_r').height(settings.height - 20);

        $('.poptitle').html(settings.title);
        $('.popbody').html(settings.message);

		$('.popholder').css('height',$(document).height()).css('top','0px');
		
        if (settings.button == 'yesno') {            
            $('.popfooter').append('<input id="btnno" class="popbutton" type="button" value="No"/>');
			$('.popfooter').append('<input id="btnyes" class="popbutton" type="button" value="Yes"/>');
			
            if (settings.ifpositivefunction != 'null')
                $('#btnyes').bind('mousedown', settings.ifpositivefunction);
            if (settings.ifnegativefunction != 'null')
                $('#btnno').bind('mousedown', settings.ifnegativefunction);

            $('#btnyes, #btnno').bind('mouseup', function () { $(document).find('.popholder').hide().remove(); $('html').css('overflow', 'auto'); });
        }
	else if (settings.button == 'ok') {
            $('.popfooter').append('<input id="btnok" class="popbutton" type="button" value="Ok"/>');

            if (settings.ifpositivefunction != 'null')
                $('#btnok').bind('mousedown', settings.ifpositivefunction);

            $('#btnok').bind('mouseup', function () { $(document).find('.popholder').hide().remove(); $('html').css('overflow', 'auto'); });
        }
        else if (settings.button == 'yes') {
            $('.popfooter').append('<input id="btnyes" class="popbutton" type="button" value="Yes"/>');

            if (settings.ifpositivefunction != 'null')
                $('#btnyes').bind('mousedown', settings.ifpositivefunction);

            $('#btnyes').bind('mouseup', function () { $(document).find('.popholder').hide().remove(); $('html').css('overflow', 'auto'); });
        }
	else if (settings.button == 'ok') {
            $('.popfooter').append('<input id="btnok" class="popbutton" type="button" value="Yes"/>');

            if (settings.ifpositivefunction != 'null')
                $('#btnok').bind('mousedown', settings.ifpositivefunction);

            $('#btnok').bind('mouseup', function () { $(document).find('.popholder').hide().remove(); $('html').css('overflow', 'auto'); });
        }
        else if (settings.button == 'yescancel') {            
            $('.popfooter').append('<input id="btncancel" class="popbutton" type="button" value="Cancel"/>');
			$('.popfooter').append('<input id="btnyes" class="popbutton" type="button" value="Yes"/>');

            if (settings.ifpositivefunction != 'null')
                $('#btnyes').bind('mousedown', settings.ifpositivefunction);
            if (settings.ifnegativefunction != 'null')
                $('#btncancel').bind('mousedown', settings.ifnegativefunction);

            $('#btnyes, #btncancel').bind('mouseup', function () { $(document).find('.popholder').hide().remove(); $('html').css('overflow', 'auto'); });
        }

        if ($.browser.msie) {
            $('.popholder').show();
        }
        else {
            $('.popholder').fadeTo(300, 1);
            $('.popoverlay').fadeTo(1, 0.95);
            $('.popwraper').fadeTo(1, 1);
        }
		
		centerForm();
        $(document).css('overflow', 'hidden');

        

        $('.popholder').click(function () {
            if (!settings.ismodel) {
                $(document).find('.popholder').hide().remove();
                $('html').css('overflow', 'auto');
            }
        });

        $('.btnclose').click(function () {
            $(document).find('.popholder').hide().remove();
            $('html').css('overflow', 'auto');
        });

        $('.popwraper').click(function () {
            return false;
        });

        $(window).resize(function () {
            centerForm();
        });
		
		$(window).scroll(function () {
            centerForm();
        });

        function centerForm() {
            //if ($(window).height() > $('.popwraper').height()) {
                 pHeight = $(window).height() / 2;
                pWidth = $(window).width() / 2;
				
                cHeight = $('.popwraper').height() / 2;
                cWidth = $('.popwraper').width() / 2;

                xpos = pWidth - cWidth;
                ypos = pHeight - cHeight;

                $('.popwraper').offset({ top: ypos+$(document).scrollTop(), left: xpos });
				
				//$('.popholder').css('top',$(document).scrollTop());
            /*}
            else {
                pWidth = $(window).width() / 2;
                cWidth = $('.popwraper').width() / 2;
                xpos = pWidth - cWidth;
                $('.popwraper').offset({ top: 30, left: xpos });
                $('.popholder').css('overflow-y', 'scroll');
                $('.popoverlay').css('height', $('.popwraper').height() + 60);
            }*/
        }
    }
 /*jQuery model dialog box-----------------------------------------------*/

})(jQuery);

