// open links in a new window
function formatLinks(){
	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";
	}
}

//Get Month Specific Movies for Intro
function getFeature(){
	var lclArray = new Array(5);
	/*
	Options:
	Home_Snowman.swf
	Home_SnowAngels.swf
	Home_Scarves.swf
	Home_GreenLeaves.swf
	Home_ColoredLeaves.swf
	Home_Sleds.swf
	Home_Shovels.swf
	Home_Umbrellas.swf
	*/
	
	lclArray[0] ='Home_Sleds.swf' ;
	lclArray[1] = 'Home_Shovels.swf';
	lclArray[2] = 'Home_Sleds.swf';
	lclArray[3] = 'Home_Umbrellas.swf';
	lclArray[4] = 'Home_Umbrellas.swf';
	
	 var now = new Date();
	
	var monthnumber = now.getMonth();

	var monthday    = now.getDate();
	var theSWF = "";

	switch(monthnumber){
		case 0:
				//random number to display 0 thru 2 from array for Jan and Feb
			
				num = Math.round( Math.random()*2);
				theSWF= lclArray[num];
			break;
			
		case 1:
				//random number to display 0 thru 2 from array for Jan and Feb
			
				num = Math.round( Math.random()*2);
				theSWF= lclArray[num];
			break;
			
		case 2:
			 if(monthday >= 15){
				 theSWF= lclArray[3];
			 }else{
				 theSWF= lclArray[2];
			 }
			break;
			
		case 3:
				 theSWF= lclArray[3];
			break;
		case  4:
				 theSWF= lclArray[3];
			break;
		case 5:
				 theSWF= lclArray[3];
			break;
		case 6:
				 theSWF= lclArray[3];
			break;
		case 7:
				 theSWF= lclArray[3];
			break;
			
		case 8:
				 theSWF= lclArray[4];
			break;
		case 9:
				 theSWF= lclArray[4];
			break;
			
		case 10:
			 if(monthday <= 15){
				 num = Math.round( Math.random()*1);
				 if (num == 0){
					  theSWF= lclArray[2];
				 }else{
					  theSWF= lclArray[4];
				 }
			 }else{
				 num = Math.round( Math.random()*2);
				theSWF= lclArray[num];
			 }
			break;
			
		case 11:
				num = Math.round( Math.random()*2);
				theSWF= lclArray[num];
			break;
			
			
	}
	return theSWF;
	
}

// popup window for video player
// james[at]cookiecrook[dot]com)
var sUserAgent = navigator.userAgent.toLowerCase();
var isIE = document.all?true:false;
var isNS4 = document.layers?true:false;
var isOp = (sUserAgent.indexOf('opera')!=-1)?true:false;

var isMoz = (sUserAgent.indexOf('mozilla/5')!=-1 && sUserAgent.indexOf('opera')==-1 && sUserAgent.indexOf('msie')==-1)?true:false;

function pop(oAnchor,sWindow,sProps){
	var sUrl = '';
	if(oAnchor.getAttribute) sUrl = oAnchor.getAttribute('href');
	if(sUrl=='' && isIE) sUrl = window.event.srcElement.getAttribute('href');
	if(sUrl=='') sUrl = oAnchor.href;
	var sWindowName = sWindow?sWindow:'_blank';
	if(!sProps) sProps = 'width=640,height=480,scrollbars,resizable,toolbar,status,menubar,location';
	if(sUrl) var oPopup = window.open(sUrl,sWindowName,sProps);
	// An Opera bug returns too early if you focus the window, so we don't focus it in that browser.
	// Only a noticable defect (in that browser) if a window is already open and hidden behind another window.
	if(oPopup && !isOp) oPopup.focus();
	// If popup was created successfully, cancel link in calling window.
	// Acts as regular link in browser that has popup blocking enabled.
	return (oPopup)?false:true;
}

// send a page to the printer
function printpage() {
	if (window.print) {
		window.print()
	} else {
		alert("Sorry, your browser doesn't support this feature. Please print from your browser's \"Print...\" menu.");
	}
}

// @name      The Fade Anything Technique
// @namespace http://www.axentric.com/aside/fat/
// @version   1.0-RC1-m
// @author    Adam Michela
// @modified  Richard Livsey / 28/04/05
// @modified  Adrian Bengtson / 06/10/05

var Fat = {
	make_hex : function (r,g,b) 
	{
		r = r.toString(16); if (r.length == 1) r = '0' + r;
		g = g.toString(16); if (g.length == 1) g = '0' + g;
		b = b.toString(16); if (b.length == 1) b = '0' + b;
		return "#" + r + g + b;
	},
	fade_all : function ()
	{
		var a = document.getElementsByTagName("*");
		for (var i = 0; i < a.length; i++) 
		{
			var o = a[i];
			var r = /fade-?(\w{3,6})?/.exec(o.className);
			if (r)
			{
				if (!r[1]) r[1] = "";
				if (!o.id)
					o.id = 'fader_'+Math.floor(Math.random()*100);
		
				Fat.fade_element(o.id,null,1500,"#"+r[1]);
			}
		}
	},
	fade_element : function (id, fps, duration, from, to) 
	{
		if (!fps) fps = 60;
		if (!duration) duration = 500;
		if (!from || from=="#") from = "#dfffb3";
		if (!to) to = this.get_bgcolor(id);

		if (this.timers[id])
			this.cancel_fade(id);
			
		this.timers[id] = new Array();
		
		var frames = Math.round(fps * (duration / 1000));
		var interval = duration / frames;
		var delay = interval;
		var frame = 0;
		
		if (from.length < 7) from += from.substr(1,3);
		if (to.length < 7) to += to.substr(1,3);
		
		var rf = parseInt(from.substr(1,2),16);
		var gf = parseInt(from.substr(3,2),16);
		var bf = parseInt(from.substr(5,2),16);
		var rt = parseInt(to.substr(1,2),16);
		var gt = parseInt(to.substr(3,2),16);
		var bt = parseInt(to.substr(5,2),16);
		
		var r,g,b,h;
		this.end = false;
		while (frame < frames)
		{
			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
			h = this.make_hex(r,g,b);
		
			this.timers[id][this.timers[id].length] = setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);

			frame++;
			delay = interval * frame; 
		}
		this.timers[id][this.timers[id].length] = setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay);
	},
	cancel_fade : function(id)
	{
		if (!this.timers[id])
			return;
		
		for (var i=0; i<this.timers[id].length; i++)
			clearTimeout(this.timers[id][i]);
	},
	set_bgcolor : function (id, c)
	{
		var o = document.getElementById(id);
		// var tmp = o.innerHTML; // Adrian debug
		// o.innerHTML = tmp + ' ' + c + ' '; // Adrian debug
		o.style.backgroundColor = c;
	},
	get_bgcolor : function (id)
	{
		var o = document.getElementById(id);
		while(o)
		{
			var c;
			/* if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
			if (o.currentStyle) c = o.currentStyle.backgroundColor;
			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; } */
			
			// This is the new part, changed by Adrian to solve a problem with Safari
			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
			else if (o.currentStyle) c = o.currentStyle.backgroundColor;
			else c = document.defaultView.getComputedStyle(o,null).getPropertyValue('background-color');
			if ((c != "" && c != "transparent" && c != "rgba(0, 0, 0, 0)") || o.tagName == "BODY") { break; }
			// End of Adrian change

			o = o.parentNode;
		}
		if (c == undefined || c == "" || c == "transparent" || c == "rgba(0, 0, 0, 0)") c = "#FFFFFF"; // Also changed by Adrian
		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
		return c;
	},
	timers : new Array()
}

/*
	tableruler()
	written by Chris Heilmann for alistapart.
	enables a rollover of rows for each table with the classname Ã¢â‚¬Å“rulerÃ¢â‚¬Â
*/

function tableruler() {
	if (document.getElementById && document.createTextNode) {
		var tables=document.getElementsByTagName('table');
		for (var i=0;i<tables.length;i++) {
			if(tables[i].className=='ruler') {
				var trs=tables[i].getElementsByTagName('tr');
				for(var j=0;j<trs.length;j++) {
					if(trs[j].className=='odd') {
						if(trs[j].parentNode.nodeName=='TBODY') {
							trs[j].onmouseover=function(){this.className='ruled';return false}
							trs[j].onmouseout=function(){this.className='odd';return false}
						}
					}
					if(trs[j].className=='even') {
						if(trs[j].parentNode.nodeName=='TBODY') {
							trs[j].onmouseover=function(){this.className='ruled';return false}
							trs[j].onmouseout=function(){this.className='even';return false}
						}
					}
					if(trs[j].className=='selected') {
						if(trs[j].parentNode.nodeName=='TBODY') {
							trs[j].onmouseover=function(){this.className='ruled';return false}
							trs[j].onmouseout=function(){this.className='selected';return false}
						}
					}
				}
			}
		}
	}
}