/*
<-- INTERACTIVE IMAGEING  -->


<-- IMAGE FUNCTIONS-->
function randomImage(imgArr)
function SlideShow(slideList, image, speed, name)          
function SlideShow_play()       

<!-- FORM VALIDATION --
function allDigits(str)
function inValidCharSet(str,charset)
function isEmailAddr(email)
function validRequired(formField,fieldLabel)
function validEmail(formField,fieldLabel,required)
function validateForm(theForm)

<!-- GENERAL FUNCTIONS -->
function readCookie(name)
function writeCookie(name, value, hours)
function addbookmark(URLpath, URLtitle)
function kbToMb(KB) 
function disableRightClick(e)
function redirect(URLStr)
function setStatusBar(msgStr)
function randomNumber(limit)
function printPage()
function digitalclock() 
function toggle(id) 

<!-- BROWSER SPECIFIC -->
function BrowserInfo()
function browserRedirect()
function setStatusBar(msgStr) 
function browserVer4Detect()

<!-- MESSAGE WINDOWS -->
function photo_open(link, width, height)
function messageWindow(title, msg)
function popUpWindow(URLStr, left, top, width, height)
function popUpMailingList(URLStr, CookieName, left, top, width, height)
function popUpWindowScrolls(URLStr, left, top, width, height)
function messageBox()
*/

<!------------------------------------------------------>

<!-- Downlaod Manager Scripts -->

	function fixUglyIE() {
		for (a in document.links) document.links[a].onfocus = document.links[a].blur;
	}

	if (document.all) {
		document.onmousedown = fixUglyIE;
	}

	function high(which2) {
		theobject = which2;
		highlighting = setInterval("highlightit(theobject)", 50);
	}

	function low(which2) {
		clearInterval(highlighting);
		which2.filters.alpha.opacity = 40;
	}

	function highlightit(cur2) {
		if (cur2.filters.alpha.opacity < 100) {
			cur2.filters.alpha.opacity += 10;
		} else {
			if (window.highlighting) {
				clearInterval(highlighting);
			}
		}
	}

	function MM_displayStatusMsg(msgStr) { //v1.0
	  status = msgStr;
	  document.MM_returnValue = true;
	}

<!-- INTERACTIVE IMAGEING -->

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function switchImage(imgName, imgSrc) {
  if (document.images){if (imgSrc != "none"){document.images[imgName].src = imgSrc;}}
}

function blendImage(imgName, imgSrc) {
  if (document.images){if (imgSrc != "none"){
    document.all.slide.filters.blendTrans.Apply();
    document.images[imgName].src = imgSrc;
	document.all.slide.filters.blendTrans.Play();
	}}
}

<!-- IMAGE FUNCTIONS-->
// * Dependencies * 
// this function requires the following snippet:
// JavaScript/Randomizers/randomNumber

function slideblend(mover, images, object, showlength)
{
  if (document.images) {
    if (mover == 1){
	  if (showspot != showlength) {
	    showspot++
	  }  
	}
	if (mover == 0) {
	  if (showspot != 0) {
	    showspot--
	  }
	}
	document.all.slide.filters.blendTrans.Apply();
	document.all.slide.src=images[showspot]
//	  document.all.slide.alt=texts[showspot]
//	  document.all.textholder.innerHTML=texts[showspot]
	document.all.slide.filters.blendTrans.Play();
  }
}
  
function randomImage(imgArr)
{
  var imgSrc, imgW, imgH, r;
  r = randomNumber(imgArr.length / 3)-1;
  
  imgSrc = imgArr[r * 3];
  imgW = imgArr[(r * 3)+1];
  imgH = imgArr[(r * 3)+2];

  document.write('<IMG SRC='+imgSrc+' WIDTH='+imgW+' HEIGHT='+imgH+'>');
}

// * Dependencies * 
// this function requires the following snippets:
// JavaScript/images/switchImage
//
// BODY Example:
// <body onLoad="mySlideShow1.play(); mySlideShow2.play();">
// <img src="originalImage1.gif" name="slide1">
// <img src="originalImage2.gif" name="slide2">
//
// SCRIPT Example:
// var mySlideList1 = ['image1.gif', 'image2.gif', 'image3.gif'];
// var mySlideShow1 = new SlideShow(mySlideList1, 'slide1', 3000, "mySlideShow1");
// var mySlideList2 = ['image4.gif', 'image5.gif', 'image6.gif'];
// var mySlideShow2 = new SlideShow(mySlideList2, 'slide2', 1000, "mySlideShow2");
function SlideShow(slideList, image, speed, name)          
{
  this.slideList = slideList;
  this.image = image;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
}

SlideShow.prototype.play = SlideShow_play;  
function SlideShow_play()       
{
  with(this)
  {
    if(current++ == slideList.length-1) current = 0;
    switchImage(image, slideList[current]);
    clearTimeout(timer);
    timer = setTimeout(name+'.play()', speed);
  }
}


<!-- FORM VALIDATION -->

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	return result;
}

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function validListChoice(theForm)
{
	var result = true;	
	if (theForm.list.value == 'filler1.lst')
	{
		alert("Please select a valid Mailing List");
		theForm.list.focus();
		result = false;
	}
	if (theForm.list.value == 'filler2.lst')
	{
		alert("Please select a valid Mailing List");
		theForm.list.focus();
		result = false;
	}   
  return result;
}

function validML(formField,fieldLabel,required)
{
	var result = true;	
	if (required && !validRequired(formField,fieldLabel))
		result = false;
	if (formField.value == 'filler1.lst')
	{
		alert("Please select a valid Mailing List");
		formField.focus();
		result = false;
	}
	if (formField.value == 'filler2.lst')
	{
		alert("Please select a valid Mailing List");
		formField.focus();
		result = false;
	}   
  return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	if (required && !validRequired(formField,fieldLabel))
		result = false;
	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
  return result;
}

function validateForm(theForm)
{
	if (!validEmail(theForm.email,"Email Address",true))
		return false;
	return true;
}

function validateML(theForm)
{
	if (!validML(theForm.list,"Mailing List",true))
		return false;
	if (!validEmail(theForm.email,"Email Address",true))
		return false;
	return true;
}

<!-- GENERAL FUNCTIONS -->

/// real-time Digital Clock
var plusm;
var pluss;
var heure;

function go()
{
auj=new Date();
if(auj.getMinutes()<10){plusm="0"}else plusm="";
if(auj.getSeconds()<10){pluss="0"}else pluss="";
heure=auj.getHours()+":"+plusm+auj.getMinutes()+"."+pluss+auj.getSeconds();
document.getElementById('mess').innerHTML=heure;
setTimeout("go()",1000)
}

// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function addbookmark(URLpath, URLtitle) {
	bookmarkurl= URLpath
	bookmarktitle= URLtitle
	if (document.all)
	  window.external.AddFavorite(bookmarkurl, bookmarktitle)
}

function kbToMb(KB) { return KB / 1024; }

function disableRightClick(e)
{
  var message = "Right click disabled";
  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      alert(message);
      return false;
    }
  }
  else
  {
    alert(message);
    return false;
  }
}

function redirect(URLStr) { location = URLStr; }
 
function setStatusBar(msgStr) { self.status = msgStr; }

function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}

function printPage() { print(document); }
 
var plusm;
var pluss;
var heure;
function digitalclock() {
	auj=new Date();
	if(auj.getMinutes()<10){plusm="0"}else plusm="";
	if(auj.getSeconds()<10){pluss="0"}else pluss="";
	heure=auj.getHours()+":"+plusm+auj.getMinutes()+"."+pluss+auj.getSeconds();
	document.getElementById('mess').innerHTML=heure;
	setTimeout("go()",1000)
}

function toggle(id) {
    ul = "ul_" + id;
    img = "img_" + id;
    ulElement = document.getElementById(ul);
    imgElement = document.getElementById(img);
    if (ulElement){
            if (ulElement.className == 'closed'){
                    ulElement.className = "open";
                    imgElement.src = "opened.gif";
                    }else{
                    ulElement.className = "closed";
                    imgElement.src = "closed.gif";
                    }
            }
    }

<!-- BROWSER SPECIFIC -->
// Example:
// var b = new BrowserInfo();
// alert(b.version); 
function BrowserInfo()
{
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
}

function browserRedirect()
{
  var ns4 = document.layers;
  var ns6 = document.getElementById && !document.all;
  var ie4 = document.all;
  
  if(ns4) URLStr = "1.html";
  else if(ns6) URLStr = "2.html";
  else if(ie4) URLStr = "3.html";
  else URLStr = "4.html";
  location = URLStr;
}

function setStatusBar(msgStr) { self.status = msgStr; }

function browserVer4Detect()
{
  if(navigator.appVersion.substring(0,1) < 4)
    URLStr = "1.html";
  else
    URLStr = "2.html";
  window.location = URLStr;
}
	
<!-- MESSAGE WINDOWS -->
function photo_open(link, width, height) {
  var photowindow = window.open(link, "photo", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0,width='+width+',height='+height);
}
  
function messageWindow(title, msg)
{
  var width="300", height="125";
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  var msgWindow = window.open("","msgWindow", styleStr);
  var head = '<head><title>'+title+'</title></head>';
  var body = '<center>'+msg+'<br><p><form><input type="button" value="   Done   " onClick="self.close()"></form>';
  msgWindow.document.write(head + body);
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var popUpWin=0;
function popUpMailingList(URLStr, CookieName, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  if(!readCookie(CookieName) == '4second mailing list') {
    popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  }
}

function popUpWindowScrolls(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=1,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// Example:
// value1 = 3; value2 = 4;
// messageBox("text message %s and %s", value1, value2);
// this message box will display the text "text message 3 and 4"
function messageBox()
{
  var i, msg = "", argNum = 0, startPos;
  var args = messageBox.arguments;
  var numArgs = args.length;
  if(numArgs)
  {
    theStr = args[argNum++];
    startPos = 0;  endPos = theStr.indexOf("%s",startPos);
    if(endPos == -1) endPos = theStr.length;
    while(startPos < theStr.length)
    {
      msg += theStr.substring(startPos,endPos);
      if (argNum < numArgs) msg += args[argNum++];
      startPos = endPos+2;  endPos = theStr.indexOf("%s",startPos);
      if (endPos == -1) endPos = theStr.length;
    }
    if (!msg) msg = args[0];
  }
  alert(msg);
}
