
// popup function ###############################################################################################/
function open_popup (ref, url, width, height, scroll, menu, toolbar, location, status, resizable, titlebar) {
  var win = window.open(url,
              ref,
              "toolbar=no, location=no, menubar=" + ((menu) ? 'yes' : 'no')  + ", " +
              "scrollbars=" + ((scroll) ? 'yes' : 'no')  + ", " +
              "toolbar=" + ((toolbar) ? 'yes' : 'no')  + ", " +
              "status=" + ((status) ? 'yes' : 'no')  + ", " +
              "location=" + ((location) ? 'yes' : 'no')  + ", " +
              "resizable=" + ((resizable) ? 'yes' : 'no')  + ", " +
		      "titlebar=" + ((titlebar) ? 'yes' : 'no') + ", " +
              "width=" + width + ", height=" + height
             );
  win.focus();
}

function image_rollover (id, image) {
  // change image
  document.images['big-image'].src = '/images/products/detail/' + id + '/' + image + '/medium.jpg';
  document.getElementById("big-image-link").href="javascript:open_popup('viewer','/images/products/detail/" + id + "/" + image + "/large.jpg','536','536');";
}

function add_bookmark(title, url) {
  
  if (window.sidebar) { 
    
    window.sidebar.addPanel(title, url, "");
  
  } else if (window.external) { 
  
    window.external.AddFavorite(url, title); 
  
  } 
}


// capital first string
function capital_first_string (string) {
  if (string) {
    var a = string.split(/\s+/g); // split the sentence into an array of words

    for (i = 0 ; i < a.length ; i ++ ) {
      var firstLetter = a[i].substring(0, 1).toUpperCase();
      var restOfWord = a[i].substring(1).toLowerCase();

      a[i] = firstLetter + restOfWord; // re-assign it back to the array and move on
    }

    string = a.join(' '); // join it back together
  }

  return string;
}




// BUYERS GUIDE POPUPS
function popup(id) {
  closebox();
  document.getElementById(id).style.display = '';
}

function closebox() {
var tags = document.getElementsByTagName('div'), count = tags.length;
while(count--) {
 if(tags[count].id && tags[count].id.indexOf( 'box' ) === 0) {
   tags[count].style.display = 'none';
 }
}
}