// JavaScript Document
//################################################# 
//## JavaScript developed by www.thenetspider.com # 
//## Version 1.0 # 
//## StreetMap.co.uk Map Display Script. # 
//################################################# 
function MapDisplay(postcode) { 
 streetmapurl = "http://www.streetmap.co.uk/streetmap.dll?Postcode2Map?";
 titleurl = "&title=EXHIBITION+,+ATTRACTION+and+MODEL+SHOP+LOCATION+FINDER&nolocal=Y";
 mapurl = streetmapurl + postcode + titleurl; 
 MapDisplayWindow = window.open(mapurl, "MapDisplayWindow", "width=750, height=500, resizable=yes, scrollbars=yes, top=0, left=0"); 
} 
// End

//################################################# 
//## JavaScript developed by www.ukmodelshops.co.uk # 
//## Version 1.0 # 
//## Google Maps Display Script. # 
//################################################# 
function GoogleMapDisplay(lat, lng, when, time, name, exhibit, venue, town, title) { 
 googlemapurl = "/includes/google_maps.php";
 varLat = "?Lat=" + lat;
 varLng = "&Lng=" + lng;
 varWhen = "&When=" + when;
 varTime = "&Time=" + time;
 varName = "&Name=" + name;
 varEvent = "&Exhibit=" + exhibit;
 varVenue = "&Venue=" + venue;
 varTown = "&Town=" + town;
 varTitle = "&Title=" + title;
 mapurl = googlemapurl + varLat + varLng + varWhen + varTime + varName + varEvent + varVenue + varTown + varTitle;
 MapDisplayWindow = window.open(mapurl, "MapDisplayWindow", "width=650, height=750, resizable=yes, scrollbars=yes, top=0, left=0"); 
}
// End

// Begin other stuff
function MM_jumpMenu(targ,selObj,restore) { //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// End

// Other Code  
function flipBox(who) { 
 var tmp; 
 if (document.images["b_" + who].src.indexOf("_on") == -1) { 
  tmp = document.images["b_" + who].src.replace("_off", "_on"); 
  document.getElementById('box_' + who).style.display = "none"; 
  document.images["b_" + who].src = tmp; 
 } else { 
  tmp = document.images["b_" + who].src.replace("_on", "_off"); 
  document.getElementById('box_' + who).style.display = "block"; 
  document.images["b_" + who].src = tmp; 
 } 
} 
// End

// Begin e-mail cloak
var link = "";
var email1 = "";
var email2 = "";
var email3 = "";
var tag1 = "mail";
var tag2 = "to:%20";
var subject = "Enquiry via the UK Model Shop Directory.";

function print_mail_to_link() {	
    document.write("<a h" + "ref=" + tag1 + tag2 + email1 + "@" + email2 + email3 + "?subject=" + escape(subject) + ">" + email1 + "<img src='/graphics/at.gif' width='11' height='11' border='0'>" + email2 + email3 + "</a>");
}

function print_mail_to_image() {
    document.write("<a h" + "ref=" + tag1 + tag2 + email1 + "@" + email2 + email3 + "?subject=" + escape(subject) + ">");
    document.write("<img src='/graphics/icon_email.gif' width='20' height='20' border='0' alt='< s e n d  m a i l >'></a>");
}
// End
var url;
var varEID;
var varSID;
var varTitle;
var varType;
var baseurl;
var DisplayWindow;

function subMail(EID, SID, title, type) { 
    url = "/includes/mailDisplay.php";
    varEID = "?eid=" + EID;
    varSID = "&sid=" + SID;
    varTitle = "&title=" + title;
    varType = "&type=" + type;
    baseurl = url + varEID + varSID + varTitle + varType;
    DisplayWindow = window.open(baseurl, "DisplayWindow", "width=450, height=500, location=no, resizable=yes, scrollbars=yes, top=150, left=250"); 
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
  // toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes
}

function dummy(){
}

 var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// Hide tags with id="noprint" when printing
function printSetup()
 {
  var a = document.all.item("noprint");
  if (a!=null) {
    if (a.length!=null) {
      //multiple tags found
      for (i=0; i<a.length; i++) {
       a(i).style.display = window.event.type == "beforeprint" ? "none" :"inline";
      }
    } else 
    //only one tag
    a.style.display = window.event.type == "beforeprint" ? "none" :"inline";
  }
} 
// end

function searchFunction(i) {
    if (i==1) {
      document.searchForm.target = "";
      document.searchForm.action = "/script/search";
    }
    document.searchForm.submit();
}

function sendApril(myform) {
    myform.action = "/script/april";
}

function sendto(myform) {
    myform.action = "/script/j4m";
}

function sendLinks(myform) {
    myform.action = "/script/links";
}

function sendEvents(myform) {
    myform.action = "/script/event";
}

// Function to allow one JavaScript file to be included by another.
// Copyright (C) 2006 www.cryer.co.uk
function IncludeJavaScript(jsFile) {
    document.write('<script type="text/javascript" src="' + jsFile + '"></script>'); 
}

function putFocus(formInst, elementInst) {
    if (document.forms.length > 0) {
        document.forms[formInst].elements[elementInst].focus();
    }
}

function classChange(styleChange, item) {
    item.className = styleChange;
}

//SuckerTree Horizontal Menu (Sept 14th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/

var menuids=["nav01"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight-2+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)

