if(!hdtour)var hdtour={};

if(document.getElementById("countdown")){
	hdtour.currentDate = new Date();
			
		// Accommodate for DST in same/local timezone.
	hdtour.dOffset = hdtour.currentDate.getTimezoneOffset();
	hdtour.eventdateOffset = hdtour.eventDate.getTimezoneOffset();
	hdtour.eventDate.setMinutes(hdtour.eventDate.getMinutes() + (hdtour.eventdateOffset - hdtour.dOffset) );
		// End: Accommodate for DST in same/local timezone.	
							
	hdtour.countdown=function(){
		//Convert both today's date and the event date into seconds.                           
		var count = Math.round((hdtour.eventDate.getTime() - hdtour.currentDate.getTime())/1000);
		var days = Math.floor(count / (60 * 60 * 24));
		count %= (60 * 60 * 24);
		var hours = Math.floor(count / (60 * 60));
		count %= (60 * 60);
		var minutes = Math.floor(count / 60);
		count %= 60;
		var seconds = count;		
		document.getElementById("cdDays").innerHTML = days;
		document.getElementById("cdHours").innerHTML = hours;
		document.getElementById("cdMins").innerHTML = minutes; 
		document.getElementById("cdSecs").innerHTML = seconds;																		    
		hdtour.currentDate.setSeconds(hdtour.currentDate.getSeconds() + 1);
		setTimeout(hdtour.countdown, 1000);  			
	}
	
	hdtour.countdown();
}

if(document.getElementById("socialBkmrks")){
	(function(){
		// add social bookmarking links
		var socialBkmrks=document.getElementById("socialBkmrks").getElementsByTagName("a");
		for (var i=0;i<socialBkmrks.length;i++){
			var bm=socialBkmrks[i];
			if(bm.href.match(/del\.icio\.us/)){
				bm.onclick=function(){window.open('http://del.icio.us/post?v=4&noui&jump=close&url='
																					+encodeURIComponent(location.href)
																					+'&title='+encodeURIComponent(document.title),'delicious','toolbar=no,width=700,height=400'); 		
																					return false;};
			}else if(bm.href.match(/digg/)){
				bm.onclick=function(){window.open('http://digg.com/submit?url='
																					+encodeURIComponent(location.href)
																					+'&title='+encodeURIComponent(document.title)
																					+'&bodytext='+encodeURIComponent(document.description)
																					+'&media=news&topic=television','digg','toolbar=no');
																					return false;};
			}else if(bm.href.match(/reddit/)){
				bm.onclick=function(){window.open('http://reddit.com/submit?url='
															 +encodeURIComponent(location.href)
															 +'&title='+encodeURIComponent(document.title),'reddit','toolbar=no,width=626,height=636');
															 return false;};
			}else if(bm.href.match(/newsvine/)){
				bm.onclick=function(){window.open('http://www.newsvine.com/_wine/save?popoff=1&u='
																					+encodeURIComponent(location.href),'newsvine',
																					'toolbar=no,width=590,height=600,resizable=yes,scrollbars=yes');
																					return false;};
			}else if(bm.href.match(/facebook/)){
				bm.onclick=function(){window.open('http://www.facebook.com/sharer.php?u='
																					+encodeURIComponent(location.href)
																					+'&t='+encodeURIComponent(document.title),'sharer','toolbar=0,status=0,width=626,height=436');
																					return false;};
			}
		}
	})();
}

if(document.getElementById("hdtourContainer")){
	(function(){
		// add tracking strings
		var lnks=document.getElementById("hdtourContainer").getElementsByTagName("a");
		for(var i=0;i<lnks.length;i++){
			if(!lnks[i].href.match(/HDtourPoll.html/)){
				lnks[i].onmouseup=function(){this.href=intelliTrak({'href':this.href,'from':'studio'});};
				lnks[i].onmousedown=function(){setClick();};
			}
		}
	})();
}

if(document.getElementById("ocm")){
	(function(){
		// pick OCM image to load
		var newOCM=hdtour.ocms[parseInt(Math.random()*hdtour.ocms.length)];
		if(document.getElementById("ocm")){
			document.getElementById("ocm").innerHTML=newOCM.name;
			document.getElementById("ocmimg").src=newOCM.img;
			document.getElementById("quote").innerHTML=newOCM.quote;
		}
	})();
}



	