win = null;

function fixopera() {
var agt=navigator.userAgent;
if (agt.search(/opera/gi) != -1) {
var sURL = window.location.href;
if (sURL.search(/purge/gi) == -1) {
window.location.replace(sURL + "?action=purge");
}
}
}

function poppic(img){
if (win && win.open && !win.closed) win.close();
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    interval=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  w=foto1.width+50;
  h=foto1.height+70;
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  features="width="+w+",height="+h+",top="+wint+",left="+winl;
  win=window.open("","Preview",features);
  if (parseInt(navigator.appVersion) >= 4) { win.focus(); }
with (win.document) {
  open("text/html", "replace");
  write("<html><head><link rel='stylesheet' type='text/css' href='http://www.nameyourgift.com/css/nyg.css'><title>Preview</title></head><body><center><img src="+img+"><br><br><b><font color='#7689bc'><a href='' onclick='window.close();'>Close Window</a></font></b><center></body></html>");
  close();
}
function closeWin() {
  win.close();
}

if (win.Event) win.document.captureEvents(Event.ONCLICK);
win.document.onclick = closeWin;
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=465,left = 475,top = 255');");
}

function pv() {
for (i=0;i<document.order.op1.length;i++) {
	if (document.order.op1[i].checked) {
		productcolor = document.order.op1[i].id;
	}
}
for (i=0;i<document.order.op5.length;i++) {
	if (document.order.op5[i].checked) {
		lettercolor = document.order.op5[i].id;
	}
}
for (i=0;i<document.order.op6.length;i++) {
	if (document.order.op6[i].checked) {
		letterstyle = document.order.op6[i].id;
	}
}
producturl = document.product.id + "-" + productcolor + "-" + lettercolor + letterstyle + ".jpg";
var img = new Image();
img.onload = function () {
document.images.product.src = producturl;
}
img.onerror = function () {
//do nothing if image doesn't exist.
}
img.src = producturl;
}
