if (window.opera) {
// alert("opera");
document.writeln('<link rel="StyleSheet" type="text/css" href="http://www.primrosehillbooks.com/magic/operahacks.css">');
}


function bigtext() {

document.getElementById("normaltext").style.display = "inline";
document.getElementById("largetext").style.display = "none";
document.getElementById("bigbreak").style.display = "inline"; 
document.getElementById("trbody").style.fontSize = "24px";
document.getElementById("topnav").style.fontSize = "20px";
if ((!document.all) && document.getElementById("mainframe")) document.getElementById("mainframe").style.marginTop = "275px";
if (window.opera && document.getElementById("mainframe")) document.getElementById("mainframe").style.marginTop = "275px";
if ((!document.all) && document.getElementById("mainframe1")) document.getElementById("mainframe1").style.marginTop = "310px";
if (window.opera && document.getElementById("mainframe1")) document.getElementById("mainframe1").style.marginTop = "310px";
return ;
}

function smalltext() {
document.getElementById("normaltext").style.display = "none";
document.getElementById("largetext").style.display = "inline";
document.getElementById("bigbreak").style.display = "none";
document.getElementById("trbody").style.fontSize = "17px";
document.getElementById("topnav").style.fontSize = "17px";
if (!document.all && document.getElementById("mainframe")) document.getElementById("mainframe").style.marginTop = "225px";
if (window.opera && document.getElementById("mainframe")) document.getElementById("mainframe").style.marginTop = "225px";
if (!document.all && document.getElementById("mainframe1")) document.getElementById("mainframe1").style.marginTop = "250px";
if (window.opera && document.getElementById("mainframe1")) document.getElementById("mainframe1").style.marginTop = "250px";
return;
}


var popat="@";
var popend="primrosehillbooks.com";
var poptail="?subject="+escape("Message from the Primrose Hill Books web");

function gopostal(boxnum) {

var popto="mailto:";
if (boxnum=="box2022") popto=popto+"epost"+popat+popend+poptail;
else if (boxnum=="box0134") popto=popto+"events"+popat+popend+poptail;
else if (boxnum=="box0101") popto=popto+"phbooks"+popat+popend+poptail;
else alert("fell through");

window.location=popto;
return;
}

function isValidEmail(strng) {

   if ( (strng.indexOf(".") > 2) && (strng.indexOf("@") > 0) )
   {
   return true;
   }
   else {
   alert("This does not appear to be a valid email address");
   return false;
  }
}

function etotalprice() {
return;


}


function emailValidation(str) {

var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(str.match(emailRegEx)){
return true;
}else{
alert('Please enter a valid email address.');
return false;
}
}

function uc(stuff) {
document.getElementById(stuff).value = document.getElementById(stuff).value.toUpperCase();
return;

}


/*

// var sw=screen.width;
// if (sw<=1024) {
// document.writeln('<link rel="StyleSheet" href="css/smallScreen.css"} 
// type="text/css">'); 
}


function validEml(form) {
  var field = form.email; // email field
  var str = field.value; // email string
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
    alert("Thank your for your feedback."); // this is optional
    return true;
  }
  alert("\"" + str + "\" does not appear to be a valid email"); // this is also optional
  field.focus();
  field.select();
  return false;
}
*/


function checkViewForm (vf){

//alert("in checkViewForm");

vemail=vf.femail.value;
if (!emailValidation(vemail)) {
return false;
}

vname = vf.fname.value;
if (vname == null || vname == "" || vname.length < 4 ) {
alert ("Please provide your name");
return false;
}

vstreet = vf.fstreet.value;
if (vstreet == null || vstreet == "" || vstreet.length < 8 ) {
alert ("Please enter your street address");
return false;
}

vcity = vf.fcity.value;
if (vcity == null || vcity == "" || vcity.length < 2 ) {
alert ("Please enter your city");
return false;
}

vpostcode = vf.fpostcode.value;
if (vpostcode == null || vpostcode == "" || vpostcode.length < 5 ) {
alert ("Please provide your post code");
return false;
}

return true;

}



function checkSOForm (so){

//alert("in checkViewForm");

vemail=so.femail.value;
if (!emailValidation(vemail)) {
return false;
}

vname = so.fname.value;
if (vname == null || vname == "" || vname.length < 4 ) {
alert ("Please provide your name");
return false;
}


return true;

}


function eatHint() {
var str=document.getElementById("fordertext").value;
str=str.replace(/PLEASE REVIEW AND AMEND THIS TEXT AS NECESSARY/i,"");
document.getElementById("fordertext").value=str;
return true;
}

/* paypal buy now processing */

function paypalPunch (item,price) {
document._xclick.item_name.value = item;
document._xclick.amount.value= price;
// alert(document._xclick.item_name.value + "  " + document._xclick.amount.value);
document._xclick.submit();
return true;
}






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";
 }
}
window.onload = externalLinks;


