function uiRotator() {
	

	var rot = this;
	var timerRotator = null;
	var cont = $(".carousel", rot);
	var slides = $(".carousel li", rot);
	var slidewidth = $(".carousel li", rot).width()
	var slideHeight = $(".carousel li", rot).height();
	

	$(".slides").css("height", slideHeight + "px");
	$(".carousel").css("width", (slidewidth * ($(".carousel li").length + 1))  + "px");
	$(".carousel").css("height", slideHeight + "px");
	
	var pixs = $(".jump li", rot);
	var targetslide = 0;

	if (slides.length < 2) {
		$(".jump, .prev, .next", rot).hide();
		return false;
	}
	function start() {
        setTimeout(function() {
			$('.next, .prev', rot).fadeTo('slow', 0.4);
			setTimeout(function(){
				$(".prev, .next", rot).fadeTo('slow', 0.01);
			}, 1000);
		}, 1000);
		queue();
	}
	function queue() {
		clearTimeout(timerRotator);
		timerRotator = setTimeout(function() {
			targetslide++;
			if ((slides.length-1) < targetslide) targetslide = 0;
			change();
		}, 10000);
	}
	function change(isfast) {
		cont.stop(true);
		clearTimeout(timerRotator);
		var targetpos = -1*targetslide*slidewidth;
		pixs.removeClass('active');
		cont.animate({left:targetpos+'px'}, isfast ? 400 : 1200, function() {
			pixs.eq(targetslide).addClass('active');
			queue();
		});
	}

	pixs.click(function() {
		if (targetslide == pixs.index(this)) return false;
		targetslide = pixs.index(this);
		change();
	});
	$('.next', rot).click(function() {
		if (targetslide < (slides.length-1)) {
			targetslide++;
			change(1);
			if (targetslide == (slides.length-1)) $(this).stop().fadeTo('slow', 0.01);
		}
	});
	$('.prev', rot).click(function() {
		if (targetslide > 0) {
			targetslide--;
			change(1);
			if (targetslide == 0) $(this).stop().fadeTo('slow', 0.01);
		}
	});
    $('.prev, .next', rot).mouseover(function() {
		if (($(this).is('.prev') && targetslide > 0) || ($(this).is('.next') && targetslide < (slides.length-1))) {
			$(this).stop().fadeTo('fast', 0.6);
		}
	}).mouseout(function() {
		$(this).stop().fadeTo('slow', 0.01);
	});


	start();
}

function uiTabSelect() {
	var lis = $(this).parent().find('li');

	var panels = $(this).parents('div.box-1col, div.box-2col').eq(0).find('.entry');
	var i = lis.index(this);
	lis.removeClass('active');
	$(this).addClass('active');
	panels.hide();
 	panels.eq(i).removeClass('js').show();
}

$(window).load(function() {
    // do this here instead of document.ready because the image load time is 
    // preventing the carousel from displaying when the page is refreshed
    $('.carousel').before('<div class = "jump">').cycle({pager:  '.jump', activePagerClass: 'activeSlide'});
});

//When the DOM tree is loaded
$(document).ready(function() {
	
   /*  var pixs = $(".jump ul li");
     pixs.click(function() {
		alert("jdjdj");
		//if (targetslide == pixs.index(this)) return false;
		//targetslide = pixs.index(this);
		//change();
	});	*/

	
//   $(".slideShow").each(uiRotator);


    $(".caseStudiesHolder .compHolderVid .smallLogo a, .videoLogo a").each(function() {

        
        var width = $(this).find("#width").val();
        var height = $(this).find("#height").val();




        $(this).fancybox({


            'autoDimensions': false,
            'autoScale': false,
            'scrolling': 'no',
            'padding': 0,
            'margin': 0,
            'type': 'iframe',
            'centerOnScroll': true,
            'overlayColor': 'black',
            'overlayOpacity': 0.7,
            'enableEscapeButton': false,
            'hideOnOverlayClick': false,
            'titleShow': false,
            'height': parseInt(height),
            'width': parseInt(width)
            
        
        
        
        }


            );

    });


    $(".locationHolder .linkHolder a").each(function() {


        if ($(this).attr("rel") == $("#" + $(".locationHolder").attr("rel")).val()) {

            $(this).css("font-weight", "bold");
            $(this).css("background-color", "#cbcbcb");
            $(this).parent().parent().parent().find(".showSel").html($(this).html())


        }


    });

    $(".statusHolder .linkHolder a").each(function() {


        if ($(this).attr("rel") == $("#" + $(".statusHolder").attr("rel")).val()) {

            $(this).css("font-weight", "bold");
            $(this).css("background-color", "#cbcbcb");
            $(this).parent().parent().parent().find(".showSel").html($(this).html())


        }


    });
    $(".sectorHolder .linkHolder a").each(function() {


        if ($(this).attr("rel") == $("#" + $(".sectorHolder").attr("rel")).val()) {

            $(this).css("font-weight", "bold");
            $(this).css("background-color", "#cbcbcb");
            $(this).parent().parent().parent().find(".showSel").html($(this).html())


        }


    });

    $(".yearHolder .linkHolder a").each(function() {
        if ($(this).attr("rel") == $("#" + $(".yearHolder").attr("rel")).val()) {
            $(this).css("font-weight", "bold");
            $(this).css("background-color", "#cbcbcb");
            $(this).parent().parent().parent().find(".showSel").html($(this).html())


        }


    });

    $(".officeHolder .linkHolder a").each(function() {
        if ($(this).attr("rel") == $("#" + $(".officeHolder").attr("rel")).val()) {
            $(this).css("font-weight", "bold");
            $(this).css("background-color", "#cbcbcb");
            $(this).closest(".searchHolder").find(".showSel").html($(this).html())
        }


    });




    $(".countryHolder .linkHolder a").each(function() {


        if ($(this).attr("rel") == $("#" + $(".countryHolder").attr("rel")).val()) {

            $(this).css("font-weight", "bold");
            $(this).css("background-color", "#cbcbcb");
            $(this).parent().parent().parent().find(".showSel").html($(this).html())


        }


    });

    if ($(".rightCol").height() < $(".leftCol").height()) {


        $(".rightCol").css("height", $(".leftCol").height() + "px");

    }


    $(".functionHolder .linkHolder a").each(function() {


        if ($(this).attr("rel") == $("#" + $(".functionHolder").attr("rel")).val()) {

            $(this).css("font-weight", "bold");
            $(this).css("background-color", "#cbcbcb");
            $(this).parent().parent().parent().find(".showSel").html($(this).html())


        }


    });








    $(".nameSlide").each(function() {

/*
        if ($("#" + $(this).attr("rel")).val() == "1") {
            $(this).find("img").css("top", "1px");
            $(this).find("img").attr("src", "/css/images/buttons/searchDown.png");

            $(this).css("color", "#595959");
            $(this).parent().find(".hidPan").css("display", "block");

        }
*/

    });

    $(".nameSlide").hover(function() {

        $(this).css("cursor", "pointer");

    },

   function() {

       $(this).css("cursor", "normal");


   });

    $(".nameSlide").toggle(function() {

        if ($(this).parent().find(".hidPan").is(':hidden')) {
            $("#" + $(this).attr("rel")).val("1");



            $(this).find("img").attr("src", "/css/images/buttons/searchDown.png");
            $(this).find("img").css("top", "1px");
            $(this).css("color", "#595959");

            $(this).parent().find(".hidPan").slideToggle("fast", function() {



            });

        }
        else {


            $("#" + $(this).attr("rel")).val("");
            $(this).css("color", "#AF006E");
            $(this).find("img").css("top", "");
            $(this).find("img").attr("src", "/css/images/buttons/search.png");
            $(this).parent().find(".hidPan").slideToggle("fast", function() {



            });

        }

    },
    function() {
        if ($(this).parent().find(".hidPan").is(':hidden')) {
            $("#" + $(this).attr("rel")).val("1");



            $(this).find("img").attr("src", "/css/images/buttons/searchDown.png");
            $(this).find("img").css("top", "1px");
            $(this).css("color", "#595959");

            $(this).parent().find(".hidPan").slideToggle("fast", function() {



            });

        }
        else {


            $("#" + $(this).attr("rel")).val("");
            $(this).css("color", "#AF006E");
            $(this).find("img").css("top", "");

            $(this).find("img").attr("src", "/css/images/buttons/search.png");
            $(this).parent().find(".hidPan").slideToggle("fast", function() {



            });

        }




    });








    $(".bookmarkImg").click(function() {



    });
    //Add pointer class to .photo .item
    $(".photo .item").addClass("pointer");

    //Hover over photo fade in hidden span
    $(".photo .item").hover(
        function() {
            $(this).find("span").fadeIn();
        },
        function() {
            $(this).find("span").fadeOut();
        }
    );

    $(".interactiveMenu a, a.mapButton").hover(function() {

        $(this).find("img").each(function() {

            $(this).attr("src", $(this).attr("src").replace(".png", "-on.png"));

        });


    },
        function() {

            $(this).find("img").each(function() {

                $(this).attr("src", $(this).attr("src").replace("-on.png", ".png"));

            });

        });

    $(".newsStory:last").css("border-bottom", "0px");

    $(".inputContText").focus(function() {
        if ($.trim($(this).val()) != "") {
            $(this).val("");

        }
    });

    if ($(".inputContText").val() == "") {

        $(".inputContText").val("Search...");

    }

    $(".rightSearchButton").click(function() {


        if ($.trim($(".inputContText").val()) == "" || $.trim($(".inputContText").val()) == "Search...") {

            return false;

        }

    });


    $(".inputContText").blur(function() {
        if ($.trim($(this).val()) == "" && $.trim($(this).val()) != $(".searchTransText").val() + "...") {
            $(this).val($(".searchTransText").val() + "...");

        }
    });



});


function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}


$(window).load(function () {

 $(".compHolder .smallLogo img").each(function() {

	if($(this).parent().parent().height()  > $(this).height()){
        $(this).css("margin-top", (($(this).parent().parent().height() - $(this).height()) / 2) + "px");
	}	




    });


});


