// Global Vars Section
var m_objWindow;
var intWin = 0;

// Reload the main frame
function MainPage(i_strFile,i_intWidth,i_intHeight) {
 //window.idMain.location="welcome.htm";
 if (typeof(i_strFile) !== "undefined") {
  OpenWindow(i_strFile,i_intWidth,i_intHeight,0,0);
 }
}

// This creates the string for the map URL and calls the window function
function OpenGigMap(i_strPostCode,i_strVenue) {
 var strTitle = 'BEAVER+Gig+Guide+Map+:+' + i_strVenue;
 var strFile = 'http://uk.multimap.com/p/browse.cgi?pc=' + i_strPostCode + "&scale=50000&title=" + strTitle;
 OpenWindow(strFile,600,400,1,1,0,0);
}

// Open a new window of size and position, if zero is passed, defaults are set
function OpenWindow(i_strFile,i_intWidth,i_intHeight,i_blnResize,i_blnScroll,i_intLeft,i_intTop) {
 var intAvailWidth,intAvailHeight;
 var intWidth,intHeight;
 var intLeft,intTop;
 var blnResize;
 var blnScroll;

 //Get the available screen dimensions
 intAvailWidth = screen.availWidth;
 intAvailHeight = screen.availHeight;

 // Check if width & height values are passed in.
 if (typeof(i_intWidth) == "undefined") {
  // Set them to a default window size
  intWidth = screen.availwidth - 200;
  intHeight = screen.availheight - 200;	
 }
 else {
  intWidth = i_intWidth;
  intHeight = i_intHeight;
 }

 // Check if the left and top have been passed
 if (typeof(i_intLeft) == "undefined") {
  // Set them to default values for popups - top left
  intLeft = 10;
  intTop = 10;
 }
 else {
  //Work out where to put the left and top to make it centered
  intLeft = (intAvailWidth - i_intWidth) / 2;
  intTop = (intAvailHeight - i_intHeight) / 2;
 }

 // Check to see if resizable is passed
 if (typeof(i_blnResize) == "undefined") {
  blnResize = 'yes';
 }
 else {
  blnResize = i_blnResize;
 }

 // Check to see if resizable is passed
 if (typeof(i_blnScroll) == "undefined") {
  blnScroll = 'yes';
 }
 else {
  blnScroll = i_blnScroll;
 }
  
 // This ensures new window is created
 intWin = intWin + 1;
 var strWindow = "BEAVER" + intWin;
 
 //window.alert(i_strFile);
 //window.alert(strWindow);
 //window.alert('Width Passed = ' + i_intWidth + ": Stored : " + intWidth);
 //window.alert('Height Passed = ' + i_intHeight + ": Stored : " + intHeight);
 //window.alert('Left Passed = ' + i_intLeft + ": Stored : " + intLeft);
 //window.alert('Top Passed = ' + i_intTop + ": Stored : " + intTop);
 //window.alert('Resize Passed = ' + i_blnResize + ": Stored : " + blnResize);
 //window.alert('Scroll Passed = ' + i_blnResize + ": Stored : " + blnScroll);
 
 m_objWindow = window.open(i_strFile, strWindow, "resizable=" + blnResize + ", toolbar=no, menubar=no, location=no, directories=no, status=no, scrollbars=" + blnScroll + ", width=" + i_intWidth + ", height=" + i_intHeight + ", Top=" + intTop + ",left=" + intLeft);
}

// Resizes the framset to a nice size
function Resize_FrameSet() {
 var intAvailWidth,intAvailHeight;
 var intLeft,intTop;

 //Get the available screen dimensions
 intAvailWidth = screen.availWidth;
 intAvailHeight = screen.availHeight;

 //Work out where to put the left and top to make it centered
 intLeft = (intAvailWidth - 790) / 2;
 intTop = (intAvailHeight - 595) / 2;

 this.moveTo(intLeft,intTop);
 this.parent.resizeTo(790,570);
}