$(document).ready(function(){$('#nav > li').bind('mouseover',jsddm_open);$('#nav > li').bind('mouseout',jsddm_timer);checkTime();$(window).bind("scroll",checkTime);tooltip();$("a[target*='_blank']").click(function(){pageTracker._trackPageview('/link/'+$(this).attr('href'));});});function checkTime(){$("img.live_time").each(function(i){if(!$.belowthefold($(this))){if(!$('#time_'+i).length){$(this).after($('<div/>').attr("id",'time_'+i).addClass("camtime").addClass("statuscam").text("Loading..."));$.getJSON("http://json-head.appspot.com/?callback=?",{url:this.src},function(json){if(json.status_code==200){var stamp=Date.parse(json.headers["last-modified"]);var today=new Date(stamp);var now=Math.floor(new Date().getTime()/1000);var ref=Math.floor(today.getTime()/1000);var delta=now-ref;if(delta>172800){$("#time_"+i).css('color','red');}
$("#time_"+i).text(today.ago());$("#time_"+i+":empty").fadeOut("fast");}
else{$("#time_"+i).fadeOut("fast");}});}}});}
$.belowthefold=function(element){var fold=$(window).height()+$(window).scrollTop();return fold<=$(element).offset().top-0;};Date.prototype.ago=function(now){if(typeof(now)=="undefined"){now=Math.floor(new Date().getTime()/1000);}
var ref=Math.floor(this.getTime()/1000);var delta=now-ref;if(delta<0){return"Live";}else if(delta==0){return"Live";}else if(delta<60){return"Live";}else if(delta<120){return"1 minut ago";}else if(delta<3600){var minutes=Math.floor(delta/60);return minutes+" minutes ago";}else if(delta<7200){return"1 hour ago";}else if(delta<86400){var hour=Math.floor(delta/3600);return hour+" hours ago";}else if(delta<172800){return"1 day ago";}else if(delta<1209600){var day=Math.floor(delta/86400);return day+" days ago";}else if(delta<2592000){var week=Math.floor(delta/604800);return week+" weeks ago";}else if(delta<5184000){return"1 month ago";}else if(delta<31536000){var month=Math.floor(delta/2592000);return month+" months ago";}else if(delta<63072000){return"1 year ago";}else{var year=Math.floor(delta/31536000);return"";}}
var var_timer=null;var iName=null;var iUrl=null;var play_count=null;var play_stop=null;refImg=new Image();refImg.src="http://www.checkcams.com/img/blank.gif";function playImage(aUrl,aName){stopImage();if($("#playing_"+aName).length){$("#playing_"+aName).remove();}
else{pageTracker._trackEvent('Cam','Play',aName);}
$("#"+aName).after($('<div/>').attr("id",'playing_'+aName).addClass("camrefresh").addClass("statuscam").text("Playing(0)"));play_count=null;play_stop=1;$("#play"+aName).hide();$("#pause"+aName).show();iName=aName;iUrl=aUrl;var_timer=setTimeout("stopImage();",90000);playingImage(aUrl,aName);}
function playingImage(){if(play_stop!=null){$("#"+iName).image(iUrl+"?"+Math.random(),function(){if(play_stop!=null){play_count++;$("#playing_"+iName).text("Playing("+play_count+")");setTimeout("playingImage();",200);}});}}
function stopImage(){clearTimeout(var_timer);$('#play'+iName).show();$('#pause'+iName).hide();$("#playing_"+iName).html("Stopped playing");removeDelay("#playing_"+iName);$("#"+iName).image(iUrl+"?"+Math.random(),function(){});play_stop=null;}
function refreshImage(aUrl,aName){pageTracker._trackEvent('Cam','Refresh',aName);if($("#refresh_"+aName).length){$("#refresh_"+aName).remove();}
$("#"+aName).after($('<div/>').attr("id",'refresh_'+aName).addClass("camrefresh").addClass("statuscam").text("Refreshing..."));document.getElementById(aName).src=refImg.src;$("#"+aName).image(aUrl+"?"+Math.random(),function(){$("#refresh_"+aName).text("Refreshed");removeDelay("#refresh_"+aName);});}
function removeDelay(id){setTimeout("$(\""+id+"\").fadeOut(\"slow\");",1000);}
$.fn.image=function(src,f){return this.each(function(){var i=new Image();i.src=src;i.onload=f;this.src=i.src;});}
this.tooltip=function(){xOffset=10;yOffset=20;$("a.tooltip").hover(function(e){this.t=this.title;this.title="";$("body").append("<div id='tooltip'>"+this.t+"</div>");$("#tooltip").css("top",(e.pageY-xOffset)+"px").css("left",(e.pageX+yOffset)+"px").fadeIn("fast");},function(){this.title=this.t;$("#tooltip").remove();});$("a.tooltip").mousemove(function(e){$("#tooltip").css("top",(e.pageY-xOffset)+"px").css("left",(e.pageX+yOffset)+"px");});};function bookmarksite(title,url){if(document.all)
window.external.AddFavorite(url,title);else
alert('Please Press Ctrl + D to bookmark this page');}
var timeout=500;var closetimer=0;var ddmenuitem=0;function jsddm_open(){jsddm_canceltimer();jsddm_close();ddmenuitem=$(this).find('ul').css('display','block');}
function jsddm_close(){if(ddmenuitem)ddmenuitem.css('display','none');}
function jsddm_timer(){closetimer=window.setTimeout(jsddm_close,timeout);}
function jsddm_canceltimer(){if(closetimer){window.clearTimeout(closetimer);closetimer=null;}}
document.onclick=jsddm_close;