/* *************************************************** 		*/
/*															*/
/*  Name:		wow-common.js								*/
/*  Desc:		Common shared javascript functions			*/
/*				for WOW website			*/
/*  Created:	May 2011									*/
/*															*/
/* *************************************************** 		*/


function DomainInfo()
{
	this.domainName = document.domain.toLowerCase();
}


//var b = new BrowserInfo();
//alert("Browser:" + b.codename + "\nVersion:" + 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 switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}


function loadHTML(el, text){

	if (el) {
		el.innerHTML = text;
	}
}

function HTMLSlideShow(slideList, elid, speed, name)          
{
	
  this.slideList = slideList;
  this.elid = elid;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
}
HTMLSlideShow.prototype.play = HTMLSlideShow_play; 
function HTMLSlideShow_play()
{
	with(this)
  {
    if(current++ == slideList.length-1) current = 0;
    loadHTML(document.getElementById(elid), slideList[current]);
    clearTimeout(timer);
    timer = setTimeout(name+'.play()', speed);
  }
}

// * 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);
  }
}

