// www.nothingrhymes.com


// =======================================
// popup
// =======================================
popW =""
function pop(link,w,h,l,t){
  // eg <a href="javascript:pop('pix:pam.jpg','300','400','20','c')">Test</a>

  h = parseInt(h)+20
  w = parseInt(w)
  topPos  = parseInt(t);
  leftPos = parseInt(l); 

  // center popup window if asked for
  if (t == 'c') {
    if (screen) {topPos = (screen.height - h)/2}
    if (topPos <0) {topPos = 10}
  }
  if (l == 'c') {
    if (screen) {leftPos = (screen.width - w)/2}
    if (leftPos <0) {leftPos = 10}
  }

  if (popW && !popW.closed){
    popW.close()
  }

  evalStr = "popW = open('popup.html?close.html&"+link+"','popW','status=no,menubar=no,toolbar=no,location=no,resizable=yes,left="+leftPos+",top="+topPos+",height="+h+",width="+w+"');"
  eval(evalStr);
  popW.focus();
} 
// end of pop() function



// index.html scripts

// slideshow

myPix = new Array;
link = new Array;

myPix[0] = "images/grandmother_after.jpg";
link[0]  = "restoration06.html";

myPix[1] = "images/lady_full_after.jpg";
link[1]  = "restoration02.html";

myPix[2] = "images/grandfather_after.jpg";
link[2]  = "restoration03.html";

myPix[3] = "images/lily_after.jpg";
link[3]  = "restoration04.html";

myPix[4] = "images/martin_after.jpg";
link[4]  = "restoration05.html";


imgCt = myPix.length - 1;

var zzz = Math.random();
thisPic = Math.round( (zzz * myPix.length) + 0.5 )-1 ;

function processPrevious() {
  if (document.images) {
    thisPic--
    if (thisPic <0) {
       thisPic = imgCt
    }
    document.myPicture.src = myPix[thisPic]
  }
}

function processNext() {
  if (document.images) {
    thisPic++
    if (thisPic > imgCt) {
       thisPic = 0
    }
    document.myPicture.src = myPix[thisPic]
  }
}

function newLocation() {
  document.location.href = link[thisPic]
}

galleryStr = '<div id="sideimage"><p><a href="javascript:newLocation()"><img src="'+myPix[thisPic]+'" width="200" name="myPicture" alt="Imaging example - click for details" \/><\/A><br clear="left"><a href="javascript:processPrevious()">previous example<\/a>&nbsp;|&nbsp;<a href="javascript:processNext()">next example<\/a><\/p><\/div>'


function loadGallery() {
  if (document.images) {
    img1 = new Image ; img1.src = "images/thumb_mask.gif";
  }
}




// =======================================
// converts all links flagged with rel="external" so they
// open in new window
// eg <a href="document.html" rel="external">external link</a>
// from http://www.sitepoint.com/article/1041
// "New-Window Links in a Standards-Compliant World"
// by Kevin Yank
// =======================================
function externalLinks() { 
 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"; 
 } 
} 
// end of externalLinks() function



function dostuffonload() { 
   externalLinks();
   loadGallery();
} 

window.onload = dostuffonload




// =======================================
// twitter feeds
// =======================================


// =======================================
// feed to <ul id="twitter_update_list_1">
// =======================================
function twitterCallback_1(obj) {
	var twitters = obj;
	var statusHTML = "";
	var username = "";
	for (var i=0; i<twitters.length; i++){
		username = twitters[i].user.screen_name
		statusHTML += ('<li><span>'+twitters[i].text+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+relative_time(twitters[i].created_at)+'</a></li>')
	}
	document.getElementById('twitter_update_list_1').innerHTML = statusHTML;
}

// =======================================
// feed to <ul id="twitter_update_list_2">
// =======================================
function twitterCallback_2(obj) {
	var twitters = obj;
	var statusHTML = "";
	var username = "";
	for (var i=0; i<twitters.length; i++){
		username = twitters[i].user.screen_name
		statusHTML += ('<li><span>'+twitters[i].text+'</span> '+relative_time(twitters[i].created_at)+'</li>')
	}
	document.getElementById('twitter_update_list_2').innerHTML = statusHTML;
}


// =======================================
// converts tweet time stamp to text
// =======================================
function relative_time(time_value) {
  var values = time_value.split(" ");
  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  var parsed_date = Date.parse(time_value);
  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  delta = delta + (relative_to.getTimezoneOffset() * 60);

  if (delta < 60) {
    return '&lt;1&nbsp;minute&nbsp;ago';
  } else if(delta < 120) {
    return '1&nbsp;minute&nbsp;ago';
  } else if(delta < (60*60)) {
    return (parseInt(delta / 60)).toString() + '&nbsp;minutes&nbsp;ago';
  } else if(delta < (120*60)) {
    return '1&nbsp;hour&nbsp;ago';
  } else if(delta < (24*60*60)) {
    return (parseInt(delta / 3600)).toString() + '&nbsp;hours&nbsp;ago';
  } else if(delta < (48*60*60)) {
    return '1&nbsp;day&nbsp;ago';
  } else {
    return (parseInt(delta / 86400)).toString() + '&nbsp;days&nbsp;ago';
  }
}
// =======================================
// end of twitter feeds
// =======================================


























// end scripts.js