﻿// JavaScript Document

var m_intfileextensionlength = 7;

var m_objCurrentTreatmentDescription;

var m_strcurrentpageaddress = IdentifyCurrentPageAddress();

var m_objdirections;

var m_objmap;

var m_objmarker = null;

function DisplayDirections(address)
	{
  
	directions.load("from: " + address + " to: 67 Southchurch Boulevard,Southend On Sea, Essex, England, SS2 4UL");
	}

function ConstructMenu(currentmenuoption)

{
	var objMenu;
	
	var strdirectory;

	var strhtml;
			
	SelectStyleSheets();

	if (m_strcurrentpageaddress == "" || m_strcurrentpageaddress == "index.htm")

       {
       strdirectory = "Pages\/";
	   }

	objMenu = document.getElementById("menu");

	strhtml = "<ul id = 'tabmenu'>";

	strhtml = strhtml + CreateMenuOption('../',
                                         'index.htm',
                                         'Home Page',
					                     currentmenuoption,
					                     'Select to return to this sites home page');
	
	strhtml = strhtml + CreateMenuOption(strdirectory,
                                         'products.htm',
                                         'Products',
					                     currentmenuoption,
					                     'Select to access details of the products that we have available for sale');
    					                     
	strhtml = strhtml + CreateMenuOption(strdirectory,
                                         'pricelist.xml',
                                         'Price List',
                                         currentmenuoption,
					                     'Select to view our product and services price list');	
	                                          
	strhtml = strhtml + CreateMenuOption(strdirectory,
                                         'contact.htm',
                                         'Contact Us',
                                         currentmenuoption,
					                     'Select to get information about how to contact us');
                                             
	                                             
	strhtml = strhtml + "</ul>";

	objMenu.innerHTML = strhtml;
	
	m_objCurrentTreatmentDescription = document.getElementById("treatmentwelcome");
	
	m_objCurrentBeautyTreatmentDescription = document.getElementById("beautytreatmentwelcome");
}

function ConstructPriceListMenu(currentmenuoption)

{
	var objMenu;
	
	var strdirectory;

	var strhtml;

	if (m_strcurrentpageaddress == "" || m_strcurrentpageaddress == "index.htm")

       {
       strdirectory = "Pages\/";
	   }

	objMenu = document.getElementById("pricelistmenu");

	strhtml = "<ul id = 'tabmenu'>";

	strhtml = strhtml + CreateMenuOption('../',
                                         'index.htm',
                                         'Home Page',
					                     currentmenuoption,
					                     'Select to return to this sites home page');
	
	strhtml = strhtml + CreateMenuOption(strdirectory,
                                         'products.htm',
                                         'Products',
					                     currentmenuoption,
					                     'Select to access details of the products that we have available for sale');
    					                     
	strhtml = strhtml + CreateMenuOption(strdirectory,
                                         'PriceList.xml',
                                         'Price List',
                                         currentmenuoption,
					                     'Select to view our product and services price list');	
	                                          
	strhtml = strhtml + CreateMenuOption(strdirectory,
                                         'contact.htm',
                                         'Contact Us',
                                         currentmenuoption,
					                     'Select to get information about how to contact us');
                                             
	                                             
	strhtml = strhtml + "</ul>";

	objMenu.innerHTML = strhtml;
	
	m_objCurrentTreatmentDescription = document.getElementById("treatmentwelcome");
	
	m_objCurrentBeautyTreatmentDescription = document.getElementById("beautytreatmentwelcome");
}

function CreateMenuOption (directory,pagename,caption,currentmenuoption,message)

{
    var blnlistitemcreated = false;

	var straddress = pagename;

	var strhtml = "";

	var strpath = directory;

	if (m_strcurrentpageaddress == "index.htm")

       {

       if (straddress == "index.htm") 

          {
          strpath = null;
          }  
       }   

    if (strpath != null)
  
       {
       straddress = strpath + straddress;
       }	

	if (pagename == "index.htm")
	
	   {
	      strhtml = "<li><a href = 'index.htm'" ;

	      strhtml = strhtml + " onmouseout = \"window.status = \'\';return true\" ";

	      strhtml = strhtml + "onmouseover = \"window.status = '" + message + "';return true\" ";

	      strhtml = strhtml + ">" + caption + "</a></li>";

          blnlistitemcreated = true;

	   } 

	if (straddress != m_strcurrentpageaddress) 
 
       {
       
       if (currentmenuoption != caption)

          {
       
   	      strhtml = "<li><a href = '" + straddress;

	      strhtml = strhtml + "' onmouseout = \"window.status = \'\';return true\" ";

	      strhtml = strhtml + "onmouseover = \"window.status = '" + message + "';return true\" ";

	      strhtml = strhtml + ">" + caption + "</a></li>";

          blnlistitemcreated = true;

          }
                
       }

    if (blnlistitemcreated == false)

       {

       strhtml = "<li class = 'selected'>" + caption + "</li>";

      } 		
		
	return strhtml;
}

function DisplayDirections(address)
	{  
	
	if (m_objmarker != null)
	   {
	   m_objmap.removeOverlay(m_objmarker);
	   m_objmarker = null;
	   }
	
	m_objdirections.load("from: " + address + " to: 67 Southchurch Boulevard,Southend On Sea, Essex, England, SS2 4UL");
	}


function DisplayPage (pagename)

{
   parent.location.href = pagename;    
}

function DisplayTreatmentDescription(Treatment)
{
	
	m_objCurrentTreatmentDescription.style.visibility = "hidden";
	
	m_objCurrentTreatmentDescription = document.getElementById(Treatment);
		
	m_objCurrentTreatmentDescription.style.visibility = "visible";

}

function IdentifyCurrentPageAddress()

{
   	var strcurrentpageaddress;
   	var intdataindicator;

   	strcurrentpageaddress = window.location;

   	var objstring = new String(strcurrentpageaddress)

   	// Remove any extra file path information

   	intlastforwardslash = objstring.lastIndexOf("/")

   	if (intlastforwardslash > 0)

       {
       strcurrentpageaddress = objstring.slice(intlastforwardslash + 1)
       }

   	// Remove any data content

   	objstring = new String(strcurrentpageaddress)

   	intdataindicator = objstring.indexOf("?")

   	if (intdataindicator > 0)

  	   {
   	   strcurrentpageaddress = objstring.slice(0,intdataindicator)
       }	
 
    return strcurrentpageaddress;
}

function InitialiseMap()
	{
 	if (GBrowserIsCompatible())
 	   {
       m_objmap = new GMap2(document.getElementById("map"));

       m_objmap.setCenter(new GLatLng(51.542536,0.742456), 15); 
    
	   m_objmap.setUIToDefault();

       directionsPanel = document.getElementById("route");
       
       m_objdirections = new GDirections(m_objmap, directionsPanel);

       point = new GLatLng(51.542536,0.742456);
       
       m_objmarker = new GMarker(point)
       
       m_objmap.addOverlay(m_objmarker);  
          
       }
	}

function SelectStyleSheets()
	{
	
    var stylesheetie6 = document.styleSheets[2];
    
    var blninternetexplorer = navigator.appName.indexOf("Microsoft") !=-1;
    
    var IE6 = navigator.userAgent.indexOf("MSIE 6") !=-1;

    stylesheetie6.disabled = true;

    if (blninternetexplorer == true)	
	
       {
       
       if (IE6)
          {
          stylesheetie6.disabled = false;		       
          }
       }

	}
	
	
	
	
