

function open_email(gohere) {
    window.open(gohere, "email", config="height=475,width=500,scrollbars=yes,toolbar=no,menubar=yes,resizable=yes,top=0,left=0")
}

function confirmSubmit() {
    var agree=confirm("Are you sure that you want to delete this record?");

    if (agree) return true ;
    else return false ;
}

function toggle_display(display_area) {
    if (document.getElementById(display_area)) { 
        var display_element = document.getElementById(display_area);
        display_element.style.display = display_element.style.display == "none" ? "block":"none"; 
    }
}
function show_block(block) {
	//alert(block);
	document.getElementById(block).style.display = "block";
}

<!--
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

function show(id) {
    if (ns4) document.layers[id].visibility = "show"
    else if (ie4) document.all[id].style.visibility = "visible"
    else if(!document.all && document.getElementById) document.getElementById(id).style.visibility = "visible"
}

function hide(id) {
    if (ns4) document.layers[id].visibility = "hide"
    else if (ie4) document.all[id].style.visibility = "hidden"
    else if(!document.all && document.getElementById) document.getElementById(id).style.visibility = "hidden"
}
//-->

function open_popup(gohere)
{
window.open(gohere, "popup", config="width=530,height=400,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,top=0,left=0");
}
function open_popup2(gohere)
{
 window.open(gohere, "popup2", congig="width=530,height=430,toolbar=yes,menubar=yes,scrollbars=yes,top=0,left=0");
}
function open_timeline(gohere)
{
window.open(gohere, "popup", config="width=797,height=400,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0");
}

$(document).ready(function(){
	
    var galleryNum = 1;
	$(".ajax_photo_gallery").each(function(){
    	var loadURL = $(this).find("a").attr("href");
        var galleryID = 'ajax_photo_gallery_content'+(galleryNum++)
        $(this).attr("class","ajax_photo_gallery_loading");
        $(this).load(loadURL,null,function(){
        	$(this).attr("class","ajax_photo_gallery_loaded");
            $(this).append('<div id="'+galleryID+'" style="display:none;"><div class="galleria_controls"><img src="http://www.valmont.com/images/galleria_arrow_left.gif" class="left" alt="Previous Image" title="Previous Image"><img src="http://www.valmont.com/images/galleria_arrow_right.gif" class="right" alt="Next Image" title="Next Image"></div></div>');
            
            $('#' + galleryID + ' .galleria_controls').css({opacity:0});
            
            var gallery = $(this).children("ul").galleria({
				history : false,
				clickNext : true,
				insert : "#"+galleryID,
				onImage : function(image,caption,thumb) { // image effects
                	// create facebox
                    $("#"+galleryID).css("display","block");
                    if($("#facebox").length == 0 || $("#facebox").css("display") == "none")
                        jQuery.facebox($("#"+galleryID).remove());
                    
                    // have to reassign variables
                    image = $("#"+galleryID+" .galleria_wrapper img");
                    caption = $("#"+galleryID+" .caption");
                    $('#' + galleryID + ' .galleria_controls').css({opacity:0})
                    $('#' + galleryID + ' .galleria_controls img').unbind('click');
                    $('#' + galleryID + ' .galleria_controls .left').click(function(){$.galleria.prev();});
                    $('#' + galleryID + ' .galleria_controls .right').click(function(){$.galleria.next();});
                    $('#' + galleryID).hover(
                        function(){
                            $(this).find('.galleria_controls').stop().animate({opacity:1},'normal');
                        },
                        function(){
                            $(this).find('.galleria_controls').stop().animate({opacity:0},'normal');
                        }
                    );
                    
					// fade in the image & caption
					if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
						image.css('display','none').fadeIn(500);
					}
					caption.css('display','none').fadeIn(500);
					// fetch the thumbnail container
					var _li = thumb.parents('li');
					
					// add custom caption if provided
					if(_li.find(".caption").html() != null)
						caption.empty().append(_li.find(".caption").html()+"<div style='clear:both'></div>");
					
					// fade out inactive thumbnail
					_li.siblings().children('img.selected').parent().find(".highlight").fadeTo('fast',0);
					
					// fade in active thumbnail
					_li.find(".highlight").fadeTo('fast',1);
					//_li.fadeTo('fast',1);
					thumb.addClass('selected');
					
					// add a title for the clickable image
					image.attr('title','Next image');
                    
                    $(window).trigger('resize');
                    
                    //$('#facebox').css({'left':$(window).width() / 2 - ($('#facebox table').width() / 2)})
                    //$('#faceboxContent').css("overflow","visible");
				},
				onThumb : function(thumb) { // thumbnail effects
				
					// fetch the thumbnail container
					var _li = thumb.parents('li');
					
					// if thumbnail is active, fade all the way.
					var _fadeTo = _li.is('.active') ? '1' : '0';
					// fade the thumbnail
					_li.find(".highlight").css({opacity:_fadeTo});
					_li.click(function(){
						$.galleria.activate($(this).find("img").attr("src"));
					});
				}
			});
            
			$(this).append('<span style="width:1px; height:1px; clear:both; display:block;"></span>');
			$(this).find('li').each(function(){
				var image = $(this).find('img').remove();
				$(this).wrapInner('<div class="caption"></div>');
				$(this).append(image);
				$(this).prepend('<div class="highlight"></div>');
			});

        });
    });
    
    //Set up all pdf links to register to google on click
    $('a[href*=".pdf"]').livequery('click', function(){
    	trackDownload($(this).attr('href'));
    });
});

var pageTracker;
function registerTracker(code){
    try{
        pageTracker = _gat._getTracker(code);
        pageTracker._trackPageview();
    } catch(err) {} 
}
function trackDownload(href){
	try{
    	pageTracker._trackPageview(href);
    } catch(err) {}
}
