// Dead Letter Art | JavaScript prepared by Monzilla Media | Copyright 2007 | x.edit



// ******************************************************************************
/* addDOMLoadEvent @ http://www.thefutureoftheweb.com/
 * Syntax:
 *    function something() {
 *       // do something
 *    }
 *    addDOMLoadEvent(something);
 *    addDOMLoadEvent(function() {
 *        // do other stuff
 *    });
 */
 
function addDOMLoadEvent(func) {
   if (!window.__load_events) {
      var init = function () {
          // quit if this function has already been called
          if (arguments.callee.done) return;
      
          // flag this function so we don't do the same thing twice
          arguments.callee.done = true;
      
          // kill the timer
          if (window.__load_timer) {
              clearInterval(window.__load_timer);
              window.__load_timer = null;
          }
          
          // execute each function in the stack in the order they were added
          for (var i=0;i < window.__load_events.length;i++) {
              window.__load_events[i]();
          }
          window.__load_events = null;
          
          // clean up the __ie_onload event
          /*@cc_on @*/
          /*@if (@_win32)
              document.getElementById("__ie_onload").onreadystatechange = "";
          /*@end @*/
      };
   
      // for Mozilla/Opera9
      if (document.addEventListener) {
          document.addEventListener("DOMContentLoaded", init, false);
      }
      
      // for Internet Explorer
      /*@cc_on @*/
      /*@if (@_win32)
          document.write("<scr"+"ipt id=__ie_onload defer src=javascript:void(0)><\/scr"+"ipt>");
          var script = document.getElementById("__ie_onload");
          script.onreadystatechange = function() {
              if (this.readyState == "complete") {
                  init(); // call the onload handler
              }
          };
      /*@end @*/
      
      // for Safari
      if (/WebKit/i.test(navigator.userAgent)) { // sniff
          window.__load_timer = setInterval(function() {
              if (/loaded|complete/.test(document.readyState)) {
                  init(); // call the onload handler
              }
          }, 10);
      }
      
      // for other browsers
      window.onload = init;
      
      // create event function stack
      window.__load_events = [];
   }
   
   // add function to event stack
   window.__load_events.push(func);
}



// dynamic clock | xClock pimped by Monzilla Media

function xClock() {
   xC = new Date;
   xV = vClock(xC.getHours()) + ":" + vClock(xC.getMinutes()) + ":" + vClock(xC.getSeconds());
  if(document.getElementById('xClock')) {
   document.getElementById('xClock').innerHTML = xV;
   setTimeout("xClock()", 1000);
  }
}
function vClock(v) {
   return (v > 9) ? "" + v : "0" + v;
}
addDOMLoadEvent(xClock);



// spamless email @ http://perishablepress.com/press/2006/08/28/spamless-email-address-via-javascript/
// xmail - spamless email - adapted from meyerweb.com

function xmail(name) {
   var obj = document.getElementById('xmail');
   if (obj) {
      switch(name) {
         case 'j': name += 'oker';   break;
         case 's': name += 'econd';  break;
         case 't': name += 'third';  break;
         case 'f': name += 'fourth'; break;
      }
      var domain = new Array('com','.','ter','let','ad','de').reverse().toString();
      domain = domain.replace(/\,/g,'').replace(/(ter)/g,'$1art');
      obj.href = 'mailto:' + name + '@' + domain + '?subject=DLa%20Business';
   }
   return true;
}



// open external links the "standards" way! @ http://www.sitepoint.com/print/1041

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
addDOMLoadEvent(externalLinks);



// slideshow for the people @ http://www.ricocheting.com/js/slide2.html
theimage = new Array();

theimage[0] = ["http://deadletterart.com/dla/images/slideshow/1.jpg", "http://deadletterart.com/", "Dla 18 Setupz"];
theimage[1] = ["http://deadletterart.com/dla/images/slideshow/2.jpg", "http://deadletterart.com/", "DLa Biz Meeting"];
theimage[2] = ["http://deadletterart.com/dla/images/slideshow/3.jpg", "http://deadletterart.com/", "DLa 20.50 Setupz"];
theimage[3] = ["http://deadletterart.com/dla/images/slideshow/4.jpg", "http://deadletterart.com/", "DLa 19 Setupz"];
theimage[4] = ["http://deadletterart.com/dla/images/slideshow/5.jpg", "http://deadletterart.com/", "DLa 17 Setupz"];
theimage[5] = ["http://deadletterart.com/dla/images/slideshow/6.jpg", "http://deadletterart.com/", "DLa Printing Biz"];
theimage[6] = ["http://deadletterart.com/dla/images/slideshow/7.jpg", "http://deadletterart.com/", "DLa 19 Production"];
theimage[7] = ["http://deadletterart.com/dla/images/slideshow/8.jpg", "http://deadletterart.com/", "DLa Molecule"];
theimage[8] = ["http://deadletterart.com/dla/images/slideshow/9.jpg", "http://deadletterart.com/", "DLa Zine Lirary"];

playspeed       = 7777;          // t interval
dotrans         = 1;             // 1 or 0 for IE only
transtype       = 'revealtrans'; // blendTrans or revealtrans
transattributes = '12';          // duration = seconds, transition = # < 24

i = 0; // array position key

function SetRandom() {
	tempimage = new Array();
	for(p=0; p<theimage.length; p++){
		for(p1=0; p1>-1; p1) {
			tempNum = Math.floor(Math.random()*theimage.length)
			if(!tempimage[tempNum]){
				tempimage[tempNum]=theimage[p];
				break;
			}
		}
	}
	for(p=0;p<theimage.length;p++)theimage[p]=tempimage[p];
}
SetRandom() // if random order

window.onload=function(){
	preloadSlide(); // preload images into browser
	GetTrans();     // set transitions
	SetSlide(0);    // set first slide
	PlaySlide();    // autoplay
}

function SetSlide(num) {
	i = num%theimage.length;         // too big
	if( i<0 ) i = theimage.length-1; // too small
	// switch the image
	if(!document.images.imgslide) return; // x.edit
	if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Apply()')
	document.images.imgslide.src=theimage[i][0];
	if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Play()')
}

function PlaySlide() {
	if (!window.playing) {
		PlayingSlide(i+1);
		if(!document.slideshow) return; // x.edit
		if(document.slideshow.play){
			document.slideshow.play.value="   Stop   ";
		}
	}
	else {
		playing=clearTimeout(playing);
		if(document.slideshow.play){
			document.slideshow.play.value="   Play   ";
		}
	}
	if(document.images.imgPlay){
		setTimeout('document.images.imgPlay.src="'+imgStop+'"',1);
		imgStop=document.images.imgPlay.src
	}
}

function PlayingSlide(num) {
	playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed);
}

function GetTrans() {
	// si = document.slideshow.trans.selectedIndex;
	if(!document.slideshow) return; // x.edit
	if((document.slideshow.trans && document.slideshow.trans.selectedIndex == 0) || (!document.slideshow.trans && dotrans==0)){
		dotrans=0;
	}
	else if ((document.slideshow.trans && document.slideshow.trans.selectedIndex == 1) || (!document.slideshow.trans && transtype == 'blendTrans')){
		dotrans=1;
		transtype='blendTrans';
		document.imgslide.style.filter = "blendTrans(duration=1,transition=1)";
	} else {
		dotrans=1;
		transtype='revealtrans';
		if(document.slideshow.trans) transattributes=document.slideshow.trans[document.slideshow.trans.selectedIndex].value;
		document.imgslide.style.filter = "revealTrans(duration=1,transition=" +transattributes+ ")";
	}
}

function preloadSlide() {
	for(k=0;k<theimage.length;k++) {
		theimage[k][0]=new Image().src=theimage[k][0];
	}
}



// FLASH DETECT 3 | (c) 1997-2004 Ryan Parman and mjac | http://www.skyzyx.com/scripts/flash.php
// This script will test up to the following version.
flash_versions = 20;

// Initialize variables and arrays
var flash = new Object();
flash.installed=false;
flash.version='0.0';

// Dig through Netscape-compatible plug-ins first.
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
			flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
			flash.installed = true;
			break;
		}
	}
}

// Then, dig through ActiveX-style plug-ins afterwords
else if (window.ActiveXObject) {
	for (x = 2; x <= flash_versions; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {
				flash.installed = true;
				flash.version = x + '.0';
			}
		}
		catch(e) {}
	}
}

// Create sniffing variables in the following style: flash.ver[x]
// Modified by mjac
flash.ver = Array();
for(i = 4; i <= flash_versions; i++) {
	eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
}



// fin.283 *