//---------------------------------------
//    Functions from Fireworks
//---------------------------------------

/* Function that displays status bar messages. */
function MM_displayStatusMsg(msgStr)  { //v3.0
	status=msgStr; document.MM_returnValue = true;
}

/* Functions that finds images. */
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;
}
/* Functions that swaps images. */
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];}
}
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;
}

//---------------------------------------
//    Web Page Boot Sequence
//---------------------------------------

if (document.images) {
  menu_home_f2 = new Image(73 ,30); menu_home_f2.src = "system/images/menu_home_f2.jpg";
  menu_home_f1 = new Image(73 ,30); menu_home_f1.src = "system/images/menu_home.jpg";
  menu_facilities_f2 = new Image(94 ,30); menu_facilities_f2.src = "system/images/menu_facilities_f2.jpg";
  menu_facilities_f1 = new Image(94 ,30); menu_facilities_f1.src = "system/images/menu_facilities.jpg";
  menu_entertainment_f2 = new Image(129 ,30); menu_entertainment_f2.src = "system/images/menu_entertainment_f2.jpg";
  menu_entertainment_f1 = new Image(129 ,30); menu_entertainment_f1.src = "system/images/menu_entertainment.jpg";
  menu_about_f2 = new Image(97 ,30); menu_about_f2.src = "system/images/menu_about_f2.jpg";
  menu_about_f1 = new Image(97 ,30); menu_about_f1.src = "system/images/menu_about.jpg";
  menu_contact_f2 = new Image(93 ,30); menu_contact_f2.src = "system/images/menu_contact_f2.jpg";
  menu_contact_f1 = new Image(93 ,30); menu_contact_f1.src = "system/images/menu_contact.jpg";
}

//---------------------------------------
//    KCSRC Website Functions
//---------------------------------------
var page_footer  = "Information for members and their guests";
    page_footer += "<br>Kurnell C.S.R.C. Encourages responsible service of alcohol and provision of gaming.";
    page_footer += "<br>Is gambling a problem for you? Call G Line counselling services(NSW)  1800 633 635";
    page_footer += "<br>";

var path_to_main = "";

var available_block_sets = new Array('bistro','bottles','entrance','flag','palm','shadecloth','view');
var sub_menu_block_count = 20;

var sub_menus_text = new Array(0);
var sub_menus_links = new Array(0);

function draw_page_headder(){

var docstr = "";
    docstr += '<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3"><tr>';
    docstr += '<td rowspan="2" valign="top">';
    docstr += '<img border="0" src="system/images/kcsrc_main_logo.jpg" width="136" height="115"></td>';
    docstr += '<td width="100%" rowspan="2" valign="top" background="system/images/headder_extender.jpg"></td>';
    docstr += '<td valign="top">';
    docstr += '<img border="0" src="system/images/kcsrc_title.jpg" width="458" height="85"><img border="0" src="system/images/headder_trailer.jpg" width="81" height="85"></td>';
    docstr += '</tr><tr><td valign="top">';
    docstr += '<img border="0" src="system/images/menu_starter.jpg" width="53" height="30">';

    docstr += return_menu_html('index.html','menu_home','system/images/menu_home.jpg','system/images/menu_home_f2.jpg');
    docstr += return_menu_html('facilities.htm','menu_facilities','system/images/menu_facilities.jpg','system/images/menu_facilities_f2.jpg');
    docstr += return_menu_html('entertainment.htm','menu_entertainment','system/images/menu_entertainment.jpg','system/images/menu_entertainment_f2.jpg');
    docstr += return_menu_html('about.htm','menu_about','system/images/menu_about.jpg','system/images/menu_about_f2.jpg');
    docstr += return_menu_html('contact.htm','menu_contact','system/images/menu_contact.jpg','system/images/menu_contact_f2.jpg');

    docstr += '</td></tr></table>';
    document.write(docstr);
}

function return_menu_html(link,menu_name,imageup,imagedown){
var menu_html  = '<a href="';
    menu_html += link;
    menu_html += '" onMouseOut="MM_displayStatusMsg(\'Kurnell, Community Sports and Recreation Club\');MM_swapImgRestore();return document.MM_returnValue"';
    menu_html += ' onMouseOver="MM_displayStatusMsg(\'Kurnell Commmunity, Sports and Recreation Club\');MM_swapImage(\''
    menu_html += menu_name;
    menu_html += '\',\'\',\'';
    menu_html += imagedown;
    menu_html += '\',1);return document.MM_returnValue"><img name="';
    menu_html += menu_name;
    menu_html += '" src="';
    menu_html += imageup;
    menu_html += '" border="0" alt="" ></a>';
    return menu_html;
}

function draw_sub_menus(block_set){
  var block_id = 1;
  var docstr = '';
  if (block_set==null) {
    //choose random block set
    setnum = Math.random() * (available_block_sets.length-1);
    setnum = Math.round(setnum);
    block_set = available_block_sets[setnum];
  }

  docstr += '<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">';
  var more_blocks = true;
  var smid = 0;
  while (more_blocks == true){
    if (block_id < sub_menu_block_count){
      docstr += '<tr><td width="100%"><img border="0" src="system/images/sub_menu_blocks/'
      docstr += block_set + '_' + block_id;
      docstr += '.jpg" width="160" height="26"></td></tr>';

      block_id += 2;
    }

    docstr += '<tr><td width="100%"><img border="0" src="system/images/sub_menu_blocks/white_spacer.jpg" width="160" height="4"></td></tr>';

    if (smid < sub_menus_text.length){
      docstr += '<tr><td width="100%" background="system/images/page_title_colour_block.jpg" class="sub_menu_text"><p class="sub_menu_text"><a class="sub_menu_text" href="'
      docstr += sub_menus_links[smid];
      docstr += '">';
      docstr += sub_menus_text[smid];
      docstr += '</a></p></td></tr>';
      docstr += '<tr><td width="100%"><img border="0" src="system/images/sub_menu_blocks/white_spacer.jpg" width="160" height="4"></td></tr>';
      block_id += 2;
      smid     += 1;
    }

    if ((block_id >= sub_menu_block_count)) {
      more_blocks = false;
    }
  }

  docstr += '</table>';

  document.write(docstr);
}

function add_sub_menu(sub_menu_text,sub_menu_link){
  sub_menus_text[sub_menus_text.length] = sub_menu_text;
  sub_menus_links[sub_menus_links.length] = sub_menu_link;
}

//---------------------------------------
//    Bosey Functions
//---------------------------------------

function write_page_footer(){
var docstr  = '<p class="page_footer_text">';
    docstr += page_footer;
    docstr += '</p>';
    document.write(docstr);

}

function bosey_tag_line(){
var docstr  = '<p class="bosey_tag"><a href="http://www.bosey.com/">';
    docstr += '<img border="0" src="'
    docstr += path_to_main;
    docstr += 'system/images/bosey_tag.jpg" class="bosey_tag" width="259" height="29"></a></p>';
    document.write(docstr);
}
