 // JavaScript Document

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_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_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];}
}

var lipservice = {
	
	picNo: 1,
	
	__construct: function () {
		this.navswap();
		this.startSlideShow();
		this.patron();
		this.podcasts();
		this.wlvideo();
		this.linksBlur();
	},
	
	linksBlur: function () {
		$('a').focus(function () {
			$(this).blur();
		})
	},
		
	navswap: function () {
		var nav_images = $('#nav').find('img');
		nav_images.mouseover(function () {
			var imageId = $(this).attr('id');
			var arg = 'images/' + imageId + 'f2.gif';
			MM_swapImage(imageId,'',arg,0);
		})
		
		nav_images.mouseout(function () {
			MM_swapImgRestore();
		})
	},
	
	startSlideShow: function () {
		if($('#slideShow').length == 0){return false;}
		//swap();
		setInterval(this.swap,7500);
	},
	
	swap: function () {
		var source = 'images/slideShow' + lipservice.picNo + '.jpg';
		$('#slideShow').attr('src',source);
		if(lipservice.picNo++ == 6){lipservice.picNo = 1};
	},			
	
	patron: function() {
		var patronmail = $('#patronmail').find('a');
		patronmail.eq(0).click(function () {
			var href = $(this).attr('href');
			var popUp = window.open(href,'patron_signup','height=500,width=640,scrollBars=1,resizable=0');
			popUp.focus();
			return false;
		})
	},
	
	podcasts: function() {
		if(!document.getElementById('footer')){return false;}
		var links = document.getElementById('footer');
		var events = links.getElementsByTagName('a');
		for(var i=0; i<events.length; i++){
			if(events[i].name == 'popup') {
				events[i].onclick = function(){
				var popUp = window.open(this.href,'podcast','height=200,width=420,scrollBars=0,resizable=0');
				popUp.focus;
				return false;
				}
			}
		}
	},
	
	wlvideo: function () {
		if(!document.getElementById('wlvideo')){return false;}
		var link = document.getElementById('wlvideo');
		var event = link.getElementsByTagName('a');
		event[0].onclick = function(){
			popUp = window.open(this.href,'wlvideo','height=200,width=420,scrollBars=0,resizable=0');
			popUp.focus;
			return false;
		}
	}
}

var DOMNews = {

	/*
		DOMnews 1.0 
		homepage: http://www.onlinetools.org/tools/domnews/
		released 11.07.05
	*/
	
	/* Variables, go nuts changing those! */
	// initial position 
	dn_startpos: 0, 			
	// end position
	dn_endpos: 0, 			
	// Speed of scroller higher number = slower scroller 
	dn_speed: 1,				
	// ID of the news box
	dn_newsID: 'news',			
	// class to add when JS is available
	dn_classAdd: 'hasJS',		
	// Message to stop scroller
	dn_stopMessage: 'Stop scroller',	
	// ID of the generated paragraph
	dn_paraID: 'DOMnewsstopper',
	dn_interval: null,
	dn_scrollpos: 0,

	__construct: function () {
		MM_preloadImages('images/buttonBlogf2.gif','images/buttonBookf2.gif','images/buttonCompanyf2.gif','images/buttonContactf2.gif','images/buttonFriendf2.gif','images/buttonHomef2.gif','images/buttonJobsf2.gif','images/buttonLinksf2.gif','images/buttonShowsf2.gif','images/buttonAccessf2.gif','images/slideShow1.jpg','images/slideShow2.jpg','images/slideShow3.jpg','images/slideShow4.jpg','images/slideShow5.jpg');
		this.dn_endpos = $('#news').find('ul').eq(0).height() * -1;
		this.dn_startpos = $('#news').height();
		this.dn_scrollpos = this.dn_startpos;
		this.initDOMnews();
	},
	
	__destruct: function () {
		clearInterval(this.dn_interval);
	},
	
	initDOMnews: function () {
		var n = $('#'+this.dn_newsID);
		n.attr('className', this.dn_classAdd);
		this.dn_interval = setInterval(this.scrollDOMnews, this.dn_speed);
		var newa = document.createElement('a');
		var newp = document.createElement('p');
		newp.setAttribute('id',this.dn_paraID);
		newa.href='#';
		newa.appendChild(document.createTextNode(this.dn_stopMessage));
		newa.onclick=function(){
			stopDOMnews();
			return false;
		}
		newp.appendChild(newa);
		var stopper = document.getElementById('scrollstop');
		stopper.appendChild(newp);
		n.mouseover(function () {		
			clearInterval(DOMNews.dn_interval);
		});
		n.mouseout(function () {
			DOMNews.dn_interval = setInterval(DOMNews.scrollDOMnews,DOMNews.dn_speed);
		});
	},

	stopDOMnews: function () {
		clearInterval(this.dn_interval);
		var n=document.getElementById('news');
		n.className='';
		var remove = document.getElementById('DOMnewsstopper');
		var stopper = document.getElementById('scrollstop');
		stopper.removeChild(remove);
	},
	
	scrollDOMnews: function () {
		var n=document.getElementById(DOMNews.dn_newsID).getElementsByTagName('ul')[0];
		n.style.top=DOMNews.dn_scrollpos+'px';	
		if(DOMNews.dn_scrollpos==DOMNews.dn_endpos){DOMNews.dn_scrollpos=DOMNews.dn_startpos;}
		DOMNews.dn_scrollpos--;	
	}
}

$(document).ready(function() {
	lipservice.__construct();
	DOMNews.__construct();
});