Template:Stockholm/Top9

From 2010.igem.org

(Difference between revisions)
m
m
Line 3: Line 3:
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
-
  <script type="text/javascript">
+
<script type="text/javascript">
-
  $(document).ready(function(){
+
var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
 +
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
-
    $(function(){
+
if (document.getElementById){ //DynamicDrive.com change
-
    var path = location.pathname.substring(1);
+
document.write('<style type="text/css">\n')
-
    var last = path.split("/");
+
document.write('.submenu{display: none;}\n')
-
    if ( last[1] ) {
+
document.write('</style>\n')
-
      $('#headover ul li a[href*="' + last[1] + '"]').addClass("curlink").css("color","#ea8828");
+
}
-
    }
+
-
    else {
+
-
      $('#headover ul li a[href$="' + path + '"]').addClass("curlink").css("color","#ea8828");
+
-
    }
+
-
    });
+
-
    $('#menuback').mouseover(function() {
+
function SwitchMenu(obj){
-
    $('#headover').stop().animate({height:'150px',top:'0px'},1000);
+
if(document.getElementById){
-
    });
+
var el = document.getElementById(obj);
 +
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
 +
if(el.style.display != "block"){ //DynamicDrive.com change
 +
for (var i=0; i<ar.length; i++){
 +
if (ar[i].className=="submenu") //DynamicDrive.com change
 +
ar[i].style.display = "none";
 +
}
 +
el.style.display = "block";
 +
}else{
 +
el.style.display = "none";
 +
}
 +
}
 +
}
-
    $('#menu').mouseleave(function() {
+
function get_cookie(Name) {  
-
    $('.listhead').not('.curlink').css("color","#ffffff");
+
var search = Name + "="
-
    $('.listmain').not('.curlink').css("color","#dddddd");
+
var returnvalue = "";
-
    $('#headover ul').fadeOut(500);
+
if (document.cookie.length > 0) {
-
    $('#headover').stop().animate({height:'50px',top:'100px'},1000);
+
offset = document.cookie.indexOf(search)
-
    });
+
if (offset != -1) {
 +
offset += search.length
 +
end = document.cookie.indexOf(";", offset);
 +
if (end == -1) end = document.cookie.length;
 +
returnvalue=unescape(document.cookie.substring(offset, end))
 +
}
 +
}
 +
return returnvalue;
 +
}
-
    $('.listhead').mouseover(function(){
+
function onloadfunction(){
-
    $('.listhead').not('.curlink').css("color","#ffffff");
+
if (persistmenu=="yes"){
-
    $(this).css("color","#444444");
+
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
-
    $('#headover ul').css("display","none");
+
var cookievalue=get_cookie(cookiename)
-
    var vActive = $(this).attr("id");
+
if (cookievalue!="")
-
    $('.'+vActive).stop(true, true).fadeIn(500);
+
document.getElementById(cookievalue).style.display="block"
-
    });
+
}
 +
}
-
    $('.listmain').mouseover(function(){
+
function savemenustate(){
-
    $('.listmain').not('.curlink').css("color","#dddddd");
+
var inc=1, blockid=""
-
    $(this).css("color","#ea8828");
+
while (document.getElementById("sub"+inc)){
-
    });
+
if (document.getElementById("sub"+inc).style.display=="block"){
 +
blockid="sub"+inc
 +
break
 +
}
 +
inc++
 +
}
 +
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
 +
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
 +
document.cookie=cookiename+"="+cookievalue
 +
}
-
    $('#headover').mouseleave(function(){
+
if (window.addEventListener)
-
    $('.listmain').not('.curlink').css("color","#dddddd");
+
window.addEventListener("load", onloadfunction, false)
-
    });
+
else if (window.attachEvent)
 +
window.attachEvent("onload", onloadfunction)
 +
else if (document.getElementById)
 +
window.onload=onloadfunction
-
  });
+
if (persistmenu=="yes" && document.getElementById)
-
  </script>
+
window.onunload=savemenustate
 +
 
 +
</script>
    
    
  </head>
  </head>

Revision as of 13:52, 23 October 2010