// Global Vars
   var URL = unescape(location.href)	// get current URL in plain ASCII
   var xstart = URL.lastIndexOf("/") + 1
   var xend = URL.length
   var hereName = URL.substring(xstart,xend);
   var xdoc, ydoc;


//Write out the footer ..
function WriteFooter() {
document.write('<TABLE cellSpacing=0 cellPadding=0 border=0 width=920>');
document.write('<TR valign="middle" height="141" width=100%>');
document.write('<TD valign="top"><IMG height=141 alt="Rutherglen Wine & Spirit Company" src="/images/logo-smaller.jpg" width=386 border=0></TD>');
document.write('<TD width=127 valign="top" align=center><IMG height=141 alt="The Office: cnr Anderson & Ingles St, Port Melbourne" src="/images/office-smaller.jpg" width=127 border=0></TD>');
document.write('<TD align="right" height="141"><IMG height=141 alt="Vineyards & Mountains"  src="/images/mountains-smaller.jpg" border=0>');
document.write('</TD></TR></TABLE>');
document.write('<TABLE cellSpacing=0 cellPadding=0 width=920 border=0>');
document.write('<TR><TD align="right" class="Footer">');
document.write('<a href="terms_conditions.html" title="Terms and Conditions" target="_self">Terms and Conditions</a> | Copyright © 2006 Rutherglen Wine & Spirit Company');
document.write('</TD></TR></TABLE>');
}

function WriteFooter2() {
document.write('<TABLE cellSpacing=0 cellPadding=0 width=920 border=0>');
document.write('<TR><TD align="right" class="Footer"><BR>');
document.write('<a href="index.html" title="Skip ..." target="_self">Skip Intro ...</a> | Copyright © 2006 Rutherglen Wine & Spirit Company');
document.write('</TD></TR></TABLE>');
}

function WritePageWidths() {
// This function controls the table and main page width of all webpages
document.write('<TABLE cellSpacing=0 cellPadding=0 width=920 border=0><TBODY><TR>');
document.write('<TD width=100% align="center" valign="middle"><p>&nbsp;</p><BR></TD>');
document.write('</TR></TBODY></TABLE>');
document.write('<TABLE cellSpacing=0 cellPadding=0 width=920 border=0>');
}
  
// XML Functions
//initialize first time -- invoked onload
function initContacts() {
    // split references per browser class
    var xFile;
    if (navigator.product && navigator.product == "Gecko") {
        xFile = '/Content/contacts.xml';
    } else {
        xFile = 'http://www.rw-s.com.au/Content/contacts.xml';
    }
    // confirm browser supports needed features and load .xml file
    if (verifySupport(xFile)) {
        // let file loading catch up to execution thread
        setTimeout("drawContactData('ContactData')", 1500);
    }
}

function initDomesticPortfolio() {
    // split references per browser class
    var xFile;
    if (navigator.product && navigator.product == "Gecko") {
        xFile = '/Content/domestic_portfolio.xml';
    } else {
        xFile = 'http://www.rw-s.com.au/Content/domestic_portfolio.xml';
    }
    // confirm browser supports needed features and load .xml file
    if (verifySupport(xFile)) {
        // let file loading catch up to execution thread
        setTimeout("drawDomesticPartnerData('DomesticPartnerData')", 1500);
    }
}

function initDomesticPartnerPortfolio() {
    // split references per browser class
    var xFile;
    if (navigator.product && navigator.product == "Gecko") {
        xFile = '/Content/domestic_portfolio.xml';
    } else {
        xFile = 'http://www.rw-s.com.au/Content/domestic_portfolio.xml';
    }
    // confirm browser supports needed features and load .xml file
    if (verifySupport(xFile)) {
        // let file loading catch up to execution thread
        setTimeout("drawDomesticPartnerPortfolioData('DomesticPartnerPortfolioData')", 1500);
    }
}

function initDomesticPartner() {
    // split references per browser class
    var xFile;
    if (navigator.product && navigator.product == "Gecko") {
        xFile = '/Content/domestic_portfolio.xml';
    } else {
        xFile = 'http://www.rw-s.com.au/Content/domestic_portfolio.xml';
    }
    // confirm browser supports needed features and load .xml file
    if (verifySupport(xFile)) {
        // let file loading catch up to execution thread
        setTimeout("drawDomesticPartnerDetailedData('DomesticPartnerDetailedData')", 1500);
    }
}

// verify that browser supports XML features and load external .xml file
function verifySupport(xFile) {
    if (document.implementation && document.implementation.createDocument) {
        // this is the W3C DOM way, supported so far only in NN6
        ydoc = document.implementation.createDocument("", "theYdoc", null);
    } else if (typeof ActiveXObject != "undefined") {
        // make sure real object is supported (sorry, IE5/Mac)
        if (document.getElementById && typeof document.getElementById("msxml").async != "undefined") {
            ydoc = new ActiveXObject("Msxml.DOMDocument");
            ydoc.async = false;
        }
    }
    if (ydoc && typeof ydoc.load != "undefined") {
        // load external file (from same domain)
        ydoc.load(xFile);
        return true;
    } else {
        var reply = confirm("This site requires a browser with XML support, such as IE5.5+/Windows or Netscape 6+.\n \nGo back to previous page?");
        if (reply) {
            history.back();
        }
    }
    return false;
}

function LoadXmlDocument(xmlFile, cbFun)
{
   if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
   {
      xdoc = new ActiveXObject("Microsoft.XMLDOM");
      xdoc.async = false;
      xdoc.load(xmlFile);
      cbFun(xdoc);
      return true;
   }
   else if( document.implementation && document.implementation.createDocument )
   {
      xdoc = document.implementation.createDocument("", "", null);
      xdoc.load(xmlFile);
      xdoc.onload = function()
      {
         cbFun(xdoc);
      }
      return true;
   }
   else
   {
      return false;
   }
} // LoadXmlDocument

// Draw Contact Data table
function drawContactData(tbody) {
    var im, tr, td, txt, txtfrag, oneRecord;
    tbody = document.getElementById(tbody);
    var frag = document.createDocumentFragment();
    var data = ydoc.getElementsByTagName("rwscontacts")[0];
    for (var i = 0; i < data.childNodes.length; i++) {
		if (data.childNodes[i].nodeType == 1) {
		oneRecord = data.childNodes[i];
		var checkpage = ydoc.getElementsByTagName("varpage");
		var imagevar = ydoc.getElementsByTagName("varimage");		
		if (checkpage[i].firstChild.nodeValue == hereName)  {
		tr = document.createElement("tr");
		td = document.createElement("td");
		txtfrag = document.createDocumentFragment();
		//document.write('Monkey: ' + checkpage + imagevar + '\n');
		txtfrag.appendChild(document.createTextNode(oneRecord.getElementsByTagName("varname")[0].firstChild.nodeValue));
		txtfrag.appendChild(document.createElement("<BR>"));
		txtfrag.appendChild(document.createTextNode(oneRecord.getElementsByTagName("vartitle")[0].firstChild.nodeValue));		
		txtfrag.appendChild(document.createElement("<BR>"));
		txtfrag.appendChild(document.createTextNode(oneRecord.getElementsByTagName("email")[0].firstChild.nodeValue));
		txtfrag.appendChild(document.createElement("<BR>"));
		txtfrag.appendChild(document.createTextNode(oneRecord.getElementsByTagName("phone")[0].firstChild.nodeValue));
		txtfrag.appendChild(document.createElement("<BR>"));
		txtfrag.appendChild(document.createElement("<BR>"));
		td.appendChild(txtfrag);
		tr.appendChild(td);

	 	td = document.createElement("td"); 
		td.appendChild(document.createElement("img")).src =oneRecord.getElementsByTagName("varimage")[0].firstChild.nodeValue;
	    //td.appendChild(document.createElement("img")).src =imagevar[0].firstChild.nodeValue;
        tr.appendChild(td);	
		 frag.appendChild(tr);
         }
		}
        tbody.appendChild(frag);
    }
}

/*
function drawDomesticPartnerData(tbody) {
    var im, tr, td, txtfrag_Partner, txtfrag_TagLine, txtfrag_Desc, i1;
	var oneRecord, td_Image;
	var Partner_URL1, txtfrag_Partner_URL1, txtfrag_Partner_URL2;
    tbody = document.getElementById(tbody);
    var frag = document.createDocumentFragment();
    var data = ydoc.getElementsByTagName("rwsdomesticportfolio")[0];

	for (var i = 0; i < data.childNodes.length; i++) {
		if (data.childNodes[i].nodeType == 1) {
		oneRecord = data.childNodes[i];

		tr = document.createElement("tr");
		i1 = document.createDocumentFragment();
		td_Image = document.createElement("<td valign='top' align='left'>");
		Partner_URL1 = document.createElement("a");
		Partner_URL1.setAttribute('href','domestic/' + oneRecord.getElementsByTagName("varpage")[0].firstChild.nodeValue);
		Partner_URL1.setAttribute('border','0');
		var the_image =	document.createElement("img");
		the_image.setAttribute('src', oneRecord.getElementsByTagName("varpartnerlogo_small")[0].firstChild.nodeValue);
		the_image.setAttribute('border','0');
		the_image.setAttribute('align','center');
		i1.appendChild(the_image);
		
		Partner_URL1.appendChild(i1);
		td_Image.appendChild(Partner_URL1);

		tr.appendChild(td_Image);

		frag.appendChild(tr);
		}
        tbody.appendChild(frag);		
    }  
}  */


// Draw Partner Data table for Domestic Partners
function drawDomesticPartnerDetailedData(tbody) {
    var im, tr, td, txtfrag_Partner, txtfrag_TagLine, txtfrag_Desc, txtfrag_Image;
	var oneRecord, td_Partner, td_TagLine, td_Desc, td_Image;
	var Partner_URL1, Partner_URL2, txtfrag_Partner_URL1, txtfrag_Partner_URL2;
    tbody = document.getElementById(tbody);
    var frag = document.createDocumentFragment();
    var data = ydoc.getElementsByTagName("rwsdomesticportfolio")[0];
    for (var i = 0; i < data.childNodes.length; i++) {
		if (data.childNodes[i].nodeType == 1) {
		oneRecord = data.childNodes[i];
		
		//First Row
		tr = document.createElement("tr");
		//Create Fragments to work with
		txtfrag_Partner = document.createDocumentFragment();
		txtfrag_TagLine = document.createDocumentFragment();

		// Create the table TD elements
		td_Partner = document.createElement("<td valign='top' class='PortfolioHeader'>");
		td_TagLine = document.createElement("<td valign='top' class='PortfolioTagline'>");
		//Create the visible elements
		txtfrag_Partner.appendChild(document.createTextNode(oneRecord.getElementsByTagName("varpartnername")[0].firstChild.nodeValue));
		txtfrag_TagLine.appendChild(document.createTextNode(oneRecord.getElementsByTagName("vartagline")[0].firstChild.nodeValue));		
		td_Partner.appendChild(txtfrag_Partner);
		td_TagLine.appendChild(txtfrag_TagLine)

		// Add them to the row
		tr.appendChild(td_Partner);
		tr.appendChild(td_TagLine);

		frag.appendChild(tr);
		// Second row
		tr = document.createElement("tr");
		//Create Fragments to work with
		txtfrag_Image = document.createDocumentFragment();
		txtfrag_Desc = document.createDocumentFragment();
		
		// Create the table TD elements
		td_Image = document.createElement("<td valign='top' align='left'>");
		td_Desc = document.createElement("<td valign='top' class='PortfolioDescription'>");
		Partner_URL1 = document.createElement("a");
		Partner_URL1.setAttribute('href','domestic/' + oneRecord.getElementsByTagName("varpage")[0].firstChild.nodeValue);
		Partner_URL1.setAttribute('border','0');
		
		//Create the visible elements
		var the_image =	document.createElement("img");
		the_image.setAttribute('src', oneRecord.getElementsByTagName("varpartnerlogo_small")[0].firstChild.nodeValue);
		the_image.setAttribute('border','0');
		txtfrag_Image.appendChild(the_image);

		txtfrag_Desc.appendChild(document.createTextNode(oneRecord.getElementsByTagName("varpartnerdesc")[0].firstChild.nodeValue));

		Partner_URL1.appendChild(txtfrag_Image);
		td_Image.appendChild(Partner_URL1);
		td_Desc.appendChild(txtfrag_Desc);

		// Add them to the row
		tr.appendChild(td_Image);
		tr.appendChild(td_Desc);

		frag.appendChild(tr);

		}
        tbody.appendChild(frag);
    }
}


function MM_displayStatusMsg(msgStr)  { //v3.0
	status=msgStr; document.MM_returnValue = true;
}

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 down images. */
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

/* Functions that handle preload. */
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 mmLoadMenus() {
  if (window.mm_menu_0715184636_0) return;
  window.mm_menu_0715184636_0 = new Menu("root",116,17,"Verdana, Arial, Helvetica, sans-serif",11,"#cccccc","#ffffff","#000000","#000000","center","middle",3,0,1000,-5,7,true,true,false,0,true,true);
  mm_menu_0715184636_0.addMenuItem("About&nbsp;RW&amp;S","window.open('about.html', '_self');");
  mm_menu_0715184636_0.addMenuItem("RW&amp;S&nbsp;Profile","window.open('rws_profile.html', '_self');");
  mm_menu_0715184636_0.addMenuItem("The&nbsp;RW&amp;S&nbsp;Team","window.open('rws_team.html', '_self');");
   mm_menu_0715184636_0.bgImageUp="images/mmmenu2_116x17_up.gif";
   mm_menu_0715184636_0.bgImageOver="images/mmmenu2_116x17_over.gif";
   mm_menu_0715184636_0.fontWeight="bold";
   mm_menu_0715184636_0.hideOnMouseOut=true;
   mm_menu_0715184636_0.bgColor='#000000';
  window.mm_menu_0715184934_1 = new Menu("root",156,17,"Verdana, Arial, Helvetica, sans-serif",11,"#cccccc","#ffffff","#000000","#000000","center","middle",3,0,1000,-5,7,true,true,false,0,true,true);
  mm_menu_0715184934_1.addMenuItem("Domestic&nbsp;Portfolio","window.open('domestic_portfolio.html', '_self');");
  mm_menu_0715184934_1.addMenuItem("International&nbsp;Portfolio","window.open('international_portfolio.html', '_self');");
  mm_menu_0715184934_1.addMenuItem("Reserve&nbsp;Selection","window.open('reserve_portfolio.html', '_self');");
   mm_menu_0715184934_1.bgImageUp="images/mmmenu4_156x17_up.gif";
   mm_menu_0715184934_1.bgImageOver="images/mmmenu4_156x17_over.gif";
   mm_menu_0715184934_1.fontWeight="bold";
   mm_menu_0715184934_1.hideOnMouseOut=true;
   mm_menu_0715184934_1.bgColor='#000000';
  window.mm_menu_0715185115_2 = new Menu("root",95,17,"Verdana, Arial, Helvetica, sans-serif",11,"#cccccc","#ffffff","#000000","#000000","center","middle",3,0,1000,-5,7,true,true,false,0,true,true);
  mm_menu_0715185115_2.addMenuItem("Export","window.open('export_portfolio_mgmt.html', '_self');");
  mm_menu_0715185115_2.addMenuItem("Domestic","window.open('domestic_portfolio_mgmt.html', '_self');");
  mm_menu_0715185115_2.addMenuItem("Warehousing","window.open('warehousing.html', '_self');");
  mm_menu_0715185115_2.addMenuItem("Distribution","window.open('distribution.html', '_self');");
   mm_menu_0715185115_2.bgImageUp="images/mmmenu3_95x17_up.gif";
   mm_menu_0715185115_2.bgImageOver="images/mmmenu3_95x17_over.gif";
   mm_menu_0715185115_2.fontWeight="bold";
   mm_menu_0715185115_2.hideOnMouseOut=true;
   mm_menu_0715185115_2.bgColor='#000000';
  window.mm_menu_0715182623_0 = new Menu("root",109,17,"Verdana, Arial, Helvetica, sans-serif",11,"#cccccc","#ffffff","#000000","#000000","center","middle",3,0,1000,-5,7,true,true,false,0,true,true);
  mm_menu_0715182623_0.addMenuItem("Domestic&nbsp;Sales","window.open('contact_domestic_sales.html', '_self');");
  mm_menu_0715182623_0.addMenuItem("Export&nbsp;Sales","window.open('contact_export_sales.html', '_self');");
  mm_menu_0715182623_0.addMenuItem("Marketing","window.open('contact_marketing.html', '_self');");
  mm_menu_0715182623_0.addMenuItem("Warehousing","window.open('contact_warehousing.html', '_self');");
   mm_menu_0715182623_0.bgImageUp="images/mmmenu1_109x17_up.gif";
   mm_menu_0715182623_0.bgImageOver="images/mmmenu1_109x17_over.gif";
   mm_menu_0715182623_0.fontWeight="bold";
   mm_menu_0715182623_0.hideOnMouseOut=true;
   mm_menu_0715182623_0.bgColor='#000000';

  mm_menu_0715182623_0.writeMenus();
} // mmLoadMenus()

function drawDomesticPartnerPortfolioData(tbody) {
	
    var im, tr, td, txtfrag_Partner, txtfrag_TagLine, txtfrag_Desc, wineitems;
	var oneRecord, td_item;
	var Partner_URL1, txtfrag_Partner_URL1, txtfrag_Partner_URL2;
    tbody = document.getElementById(tbody);
    var frag = document.createDocumentFragment();
    var data = ydoc.getElementsByTagName("range")[0];
	var pagevar = xdoc.getElementsByTagName("varpage");
	
	if (pagevar[0].firstChild.nodeValue == hereName) {	
	for (var i = 0; i < data.childNodes.length; i++) {
		if (data.childNodes[i].nodeType == 1) {
		oneRecord = data.childNodes[i];

		tr = document.createElement("tr");
		wineitems = document.createDocumentFragment();
		td_item = document.createElement("<td valign='top' align='left'>");

		var the_image =	document.createElement("img");
		the_image.setAttribute('src', oneRecord.getElementsByTagName("bottleshot")[i].firstChild.nodeValue);
		the_image.setAttribute('border','0');
		the_image.setAttribute('align','center');
		td_item.appendChild(the_image);
//		
//		Partner_URL1.appendChild(i1);
//		td_Image.appendChild(Partner_URL1);
		tr.appendChild(td_item);
		frag.appendChild(tr);

		}
        tbody.appendChild(frag);		
    } }
}