
function go() {
  addDOM() ; // make sure DOM methods work
  initrolls(rolls) ; // add the rollovers
}

// ------------------------------------------------------- act on url
function auto() {
   if (!/#/.test( window.location.href)) return ;  // nothing doing
   
   var el ;
   var req = window.location.href.replace( /^.*#/ , "") ;
   if ( req  && (el = document.getEl( req)) ) {
      var fn = el.onclick ;
      if ( fn) fn() ;
      else alert( "No function attached to " + el.id) ;
   }
   else alert( "No element found: " + req) ;
}
	

// ----------------------------------------------- image rollovers _on _off
var rolls = [
	     ["cover","I_current"]
	     ,"testdrive"
	     ,"whatis"
	     ,"current"
	     ,"stockists"
	     ,"contact"
	     ,"subscribe"
	     ,"movies"
             ,"media"
];


// ----------------------------------------------- slideshows

var popoptions = {
    _default:{
       A:{ screenX:1, screenY:"50%-170", height:350, width:"50%" }
      ,B:{ screenX:"50%", screenY:"50%-170", height:350, width:"50%"}
      }
   ,introslide:{
       A:{ screenX:20, screenY:"2%", height:530, width:370 } 
      ,B:{ screenX:450, screenY:"2%", height:530, width:370 }
      }
   ,stockists:{
       A:{ screenX:1, screenY:"20%", height:275, width:"50%" }
      ,B:{ screenX:"50%", screenY:"20%", height:275, width:"40%", scrollbars:"yes" }
      }
} ;


var slidepath = "slideshows" ;



// ---------------------------------------------------- pop ups


// avoid opening twice
function mypop( _href, _opts) {
   var opts = _opts ;
   var href = _href ;
   this.pop = function( el) {
      if (el.popup &&  el.popup.close) el.popup.close() ; 
      el.href = "" ;
      el.popup = popup( opts, href) ;
      el.popup.focus() ;
      return false ;
   }
} 

var contact = ( new mypop( "pages/contact.html", {screenX:"5%", screenY:"5%", width: "300", height: "300"})).pop ;

var survey = ( new mypop( "readersurvey/start.html", {screenX:"5%", screenY:"2%", width:600, height:"80%",scrollbars:"yes",resizable:"yes"})).pop ;

var movies = ( new mypop(  "pages/movies.html", {screenX:"5%", screenY:"5%", width:550, height:425})).pop ;


//---------------------------------------------------- data capture
function ok(f, el) {
  if (checkit( document.forms[ f].email)) {
    document[f].submit() ;
  }
  return false ;
}


// ----------------------------------------------------- email validator
function checkit( e) {
  var email = e ;
  if (/\w+@.*\.\w+/.test(email.value)) return true ;
  return false ;
}

