// JavaScript Document $(document).ready(function() { // Hide info hideEm(); // Turn close buttons on $("#plant-map-ctn .close_btn").css("display", "inline"); // Position map absolutely (IE6 fix) //$("#content #content_right #plant-map").css("position", "absolute"); var display_timeout = 0; // If link is hovered over, display marker on proper area of map $("#plant-map-ctn #plant-sections ul li a").hover(function() { // Make sure two timeouts aren't going at once if(display_timeout != 0) { clearTimeout(display_timeout); } // save a reference to 'this' so we can use it in timeout function var this_element = this; // Test to see if an info box is open, if so, do not fire this function var test_active = false; $("#plant-sections ul li a").each(function(i) { if($(this).hasClass("active")) { test_active = true; } }); if(!test_active) { $("#plant-map-ctn img.env_marker").fadeOut("fast").remove(); display_timeout = setTimeout(function() { display_timeout = 0; var curr_elem = $(this_element).attr("rel"); if(curr_elem !== '') { if(curr_elem.split('_').length == 2) { var mark_left = curr_elem.split('_')[0]; var mark_top = curr_elem.split('_')[1]; $("#plant-map-ctn img#marker") .css({ "position" : "absolute", "top" : mark_top + "px", "left" : mark_left + "px" }) .fadeIn("fast"); } else { $("#plant-map-ctn img#marker").fadeOut("fast"); temp = curr_elem.split('-'); for(i=0; i < temp.length; i++) { temp_left = temp[i].split('_')[0]; temp_top = temp[i].split('_')[1]; new_img_src = $("#plant-map-ctn img#marker").attr("src"); new_img = ''; $("#plant-map-ctn").append(new_img); } $("#plant-map-ctn img.env_marker").fadeIn("fast"); } } }, 100); } }, function() { // Make sure two timeouts aren't going at once if(display_timeout != 0) { clearTimeout(display_timeout); } display_timeout = setTimeout(function() { display_timeout = 0; $("#plant-map-ctn img#marker").fadeOut("fast"); $("#plant-map-ctn img.env_marker").fadeOut("fast"); }, 100); }); // Show info when link is clicked $("#plant-map-ctn #plant-sections ul li a").click(showInfo); // Close button is clicked $("#plant-map-ctn .close_btn a").click(closeIt); // HotZone! $("a.hotzone").click(hotZone); }); function showInfo(e) { var display_timeout = 0; // Make sure two timeouts aren't going at once if(display_timeout != 0) { clearTimeout(display_timeout); } // save a reference to 'this' so we can use it in timeout function var this_element = this; temp = $(this).attr("href"); temp_arr = temp.split('#'); var target_div = "#" + temp_arr[1]; display_timeout = setTimeout(function() { display_timeout = 0; if($(this_element).hasClass("active")) { $(target_div).fadeOut(); deactivate(); activateMap(); } else { // Fade out any open windows $("#plant-map-ctn .section-content").fadeOut("fast"); deactivate(); $("a[href=" + target_div + "]").addClass('active'); setTimeout(function() { $(target_div) .css({ "position" : "absolute", "left" : "200px", "z-index" : 1000 }) .addClass('active') .fadeIn('fast'); }, 500); } }, 250); return false; } // function hideEm() { $("#plant-map-ctn .section-content").hide().removeClass('active'); } // function deactivate() { // Make all links "inactive" $("#plant-sections ul li a").removeClass('active'); // Make all sections "inactive" $("#plant-map-ctn .section-content").removeClass('active'); // Make Image Map "inactive" $("#plant-map-ctn #plant-map img").fadeTo("normal", 0.33); // Hide marker $("#plant-map-ctn img#marker, #plant-map-ctn img.env_marker").hide(); // remove hotzone if active $("#plant-map-ctn").find("div.hotzone_marker").fadeOut("fast").remove(); } function activateMap() { $("#plant-map-ctn #plant-map img").fadeTo("normal", 1); } // function closeIt() { $(this).parent().parent().fadeOut(); deactivate(); activateMap(); return false; } function hotZone() { // If markers already exist, get rid of them if($("#plant-map-ctn div.hotzone_marker").size()) { $("#plant-map-ctn").find("div.hotzone_marker").fadeOut("fast", function() { $(this).remove(); }); } else { hideEm(); activateMap(); var imgSrc = $("#plant-map-ctn img#marker").attr("src"); $("#plant-sections ul li a").each(function(i) { var curr_elem = $(this).attr("rel"); if(curr_elem !== '') { if(curr_elem.split('_').length == 2) { var curr_title = $(this).attr("title"); var mark_left = curr_elem.split('_')[0]; var mark_top = curr_elem.split('_')[1]; // Push markers over if(!$.browser.msie) { mark_left = Number(mark_left) + 30; } // Create new image var new_img = '
'; $("#plant-map-ctn").append(new_img); } else { temp = curr_elem.split('-'); for(i=0; i < temp.length; i++) { temp_left = temp[i].split('_')[0]; temp_top = temp[i].split('_')[1]; // Push markers over if(!$.browser.msie) { temp_left = Number(temp_left) + 20; } new_img_src = $("#plant-map-ctn img#marker").attr("src"); // Create new image var new_img = ''; $("#plant-map-ctn").append(new_img); } } } }); // Show markers $("#plant-map-ctn div.hotzone_marker").fadeIn(); } // bind the showInfo function to the click event $("#plant-map-ctn div.hotzone_marker a").bind("click", showInfo); return false; }