if (window != window.top)
  top.location.href = location.href;

function popUpWindow(page, x, y) {
	popupWin = window.open(page, 'Popup', 'width='+x+', height='+y+', left=50, top=50, scrollbars=yes');
}

function openCentreWindow(url, width, height, opt){
  var top = (screen.height/2)-(height/2);
  var left = (screen.width/2)-(width/2);
  var features = 'height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=' + opt;
  theWin = window.open(url,'',features);
}


/*
 * Validates the contact form input
 */
function validateContactForm(form){

  var realName = form.realname.value;
  var subject = form.subject.value;
  var email = form.email.value;
  var message = form.message.value;

  var errors = "";

  if(realName == "") {
    errors += "Missing name\n";
  }

  if(subject == ""){
    errors += "Missing subject\n";
  }

  if(email == "") {
    errors += "Missing e-mail\n";
  } else if(!isEmail(email)) {
    errors += "Invalid e-mail\n";
  }

  if(message == "") {
    errors += "Missing message";
  }


  if(errors != ""){
    alert("Please correct the following and try again:\n\n" + errors);
    return false;
  }

  return true;
}

/*
 * Checks if a string is empty
 */
function isEmpty(str){
  return (str == null) || (trim(str).length == 0);
}

/*
 * Trims whitespace from beginning and end of a string
 */
function trim(str) { 
  return str.replace(/^\s+|\s+$/, ''); 
};

/*
 * Checks if a string is a valid email address
 */
function isEmail(str){
  var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
  return re.test(str);
}



// Resize pop-up window code
// ===========================================================================================================

// Set the horizontal and vertical position for the popup

PositionX = 50;
PositionY = 50;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 700;
defaultHeight = 600;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
  var isNN=(navigator.appName=="Netscape")?1:0;
  var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}
var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=yes,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL){

var imageTitle = "L-XB photos";

if (isIE){var imgWin=window.open('about:blank','',optIE);}
else {var imgWin=window.open('about:blank','',optNN);}

with (imgWin.document){

writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isIE, height, width;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');

writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[1].width);');
writeln('height=100-(document.body.clientHeight-document.images[1].height);');

writeln('window.resizeTo(width,height);}');

writeln('if (isNN){');      
writeln('width = document.images["George"].width;');
writeln('height = document.images["George"].height;');
writeln('window.innerWidth=width;');
writeln('window.innerHeight=height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');


writeln("function moveToCentre(){");
writeln("var top = (screen.height/2)-(height/2);");
writeln("var left = (screen.width/2)-(width/2);");
writeln("window.moveTo(left, top);}");


writeln('</sc'+'ript>');

if (!AutoClose) 
  writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();moveToCentre();doTitle();self.focus()">')
else 
  writeln('</head><body bgcolor=ffffff scroll="no" onload="reSizeToImage();moveToCentre();doTitle();self.focus()" onblur="self.close()">');

// Write the header and product images
//writeln('<img src="../../images/header_products.gif" style="cursor: pointer;" onclick="self.close()" title="close window">');
writeln('<center><img name="George" src='+imageURL+' style="display:block; cursor: pointer;" onclick="self.close()" title="close window"></center></body></html>');

close();		
}}
