// #### Start Cookie Functions ####
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
// #### End Cookie Functions ####

// resize popup window to fit image
function ResizeToFit(dlg, picHeight, picWidth) {
 var imgWidth;
 var imgHeight;
 imgWidth = picWidth + 60; 
 imgHeight = picHeight + 110;
 dlg.resizeTo(imgWidth, imgHeight);
}

// build popup window
function mssDisplayImages(img, name, width, height){
 features = 
    "toolbar=no,location=no,directories=no,status=no,menubar=no," +
    "scrollbars=no,resizable=no,width=" + width + ",height=" + height;
 dlg = window.open ("","Details",features);
 dlg.document.write("<html><head><title>" + name + " Zoom</title></head>");
 dlg.document.write("<body bgcolor=white onLoad=\"javascript:opener.ResizeToFit(self,  picImg.height, picImg.width);\"><center>");
 dlg.document.write("<table width=100% height=100%>");
 dlg.document.write("<tr><td align=center valign=middle>");
 dlg.document.write("<img name=\"picImg\" src=" + img + ">");
 dlg.document.write("</td></tr>");
 dlg.document.write("<tr><td align=center valign=middle>");
 dlg.document.write("<a href=# onClick=window.close();>");
 dlg.document.write("<font size=1 face=Arial>Click to close</font></a>");
 dlg.document.write("</td></tr>");
 dlg.document.write("</table></body></html>");
 dlg.document.close();
}

// bookmark function
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function showLayer(x){
  var el=document.getElementById(x);
  if (el)el.style.display="block";
}

function changeImage(id){
   for(var i = 1; i<7; i++){
      if(document.getElementById('image'+i)){
         document.getElementById('image'+i).style.display='none';
      }
   }
   document.getElementById(id).style.display='block';
}

function mssPopup(link,width,height){
 features = "toolbar=0,location=0,status=0,directories=0,menubar=0,resizable=1,scrollbars=1,width=" + width + ",height=" + height;
 window.open (link,"Application_Icons",features);

 
}
