function getElementsByClassName(classname){
        var rl = new Array();
        var re = new RegExp('(^| )'+classname+'( |$)');
        var ael = document.getElementsByTagName('*');
        var op = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
        if (document.all && !op) ael = document.all;
        for(i=0, j=0 ; i<ael.length ; i++) {
                if(re.test(ael[i].className)) {
                        rl[j]=ael[i];
                        j++;
                }
        }
        return rl;
}

function setupPopups2(){
	ar = getElementsByClassName('imagelink2');
	for(i=0;i<ar.length;i++){
			link = ar[i];
			link.onclick = function(){
				zoomsettings = 'width=450,height=350,menubar=no,toolbar=no,status=no,resizable=yes';
  		        zoomwindow = window.open('gallery.html?id='+this.rel,'',zoomsettings);
				if (window.focus) zoomwindow.focus();
		        return false;
			}
	}	
}

function zoom(stuff) {
  zoom_window = open('','','width=430,height=350,status=no');
  zoom_window.document.open();
  zoom_window.document.write('<html><head><title>Gallery: USB-FlashDrive.co.uk</title><link href="style.css" rel="stylesheet" type="text/css"></head><body style="text-align:center;padding:8px;">');
  zoom_window.document.write(stuff);
  zoom_window.document.write('</body></html>');
}

function flashBasket() {
  x=0;
  setTimeout("darkBasket();",500);
}
function darkBasket() {
  x++
  if (x<=2) {
    document.getElementById('basket').style.backgroundColor='#EEEEEE';
    setTimeout("lightBasket();",100);
  }
}
function lightBasket() {
  document.getElementById('basket').style.backgroundColor='#FAFAFA';
  setTimeout("darkBasket();",100);
}

function flashErrors() {
  x=0;
  setTimeout("darkErrors();",500);
}
function darkErrors() {
  x++
  if (x<=2) {
    navRoot = document.getElementById('errors');
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      node.style.backgroundColor='#EEEEEE';
    }
    setTimeout("lightErrors();",100);
  }
}
function lightErrors() {
  navRoot = document.getElementById('errors');
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    node.style.backgroundColor='#FAFAFA';
  }
  setTimeout("darkErrors();",100);
}

function swapMainImage(newimage)
{
  image = document.getElementById('mainimage');
  image.src = 'http://www.usb-flashdrive.co.uk/uploaded/images/'+newimage;
}

window.onload=setupPopups2;
