/* 
(web site development : Codaich Solutions 2004, www.codaich.com)  
This script defines all the extra functionality required for the site, namely: 
   The page navigation has methods for moving between the site. 
    The pop up menu functionality, requires : 
        An image of class popupImage, named menuBackgroundImage 
        a div called homeMenuLinks of class popupTextArea 
    The header element for every page, requires 3 div elements to be set up  
    in the page (to allow for the header and menus to appear) :  
        headerText of class headerArea 
        headerBackdrop of class headerBack 
        headerMenus of class headerMenus 
*/ 
/*This section deals with page navigation------------------------------------------------*/ 
var theOtherWindow; 
/*Takes us to the home page, adding the frame if it`s not there*/ 
function checkHome(){ 
    if (window.parent == window){ 
        /*We are not using the frame set for the site so it should be shown*/ 
        window.location = '../index.html'; 
    }else{ 
        window.location = '../home/home.html'; 
    } 
} 
/*This alows us to pop up another window for displaying pictures. It  
will be smart and hold on to the reference if one is already open, unless  
it`s a walkthrough in which case it will close it and re-open a new one. 
Opens the new window with the specified URL, also gives it focus*/     
function newWindow(URL,description,walkthrough,width,height){ 
    if (theOtherWindow != null && theOtherWindow.closed){ 
        theOtherWindow = null; 
    } 
    if (walkthrough){ 
        if (theOtherWindow != null && theOtherWindow.name != 'walkthrough'){ 
            theOtherWindow.close(); 
        } 
        theOtherWindow = window.open 
            (URL,"walkthrough","menubar=no scrollbars=yes status=yes resizable=yes width=" + width + " height=" + height,true); 
    }else{ 
        if (theOtherWindow != null && theOtherWindow.name == 'walkthrough'){ 
            theOtherWindow.close(); 
        } 
        theOtherWindow = window.open 
            (URL,"normal","menubar=no scrollbars=yes status=yes resizable=yes width=" + width + " height=" + height,true); 
    } 
    theOtherWindow.defaultStatus=description; 
    theOtherWindow.focus(); 
    theOtherWindow.onClose 
} 
/*This section deals with the pop up menus-----------------------------------------------*/ 
/*This defines the functions that allow us to have the  
pop up menus in the main display frame. All pages to go  
in the main display frame should include this script*/ 
/*This will be defined if we are counting down to removal of the menu*/ 
var disposePending = null; 
/*Returns the Y position of the given object*/ 
function findYPos(obj){ 
    var current = 0; 
    if (obj.offsetParent){ 
        while (obj.offsetParent){ 
            current += obj.offsetTop 
            obj = obj.offsetParent; 
        } 
    }else if (obj.x){ 
        current += obj.x; 
    } 
    return current; 
} 
/*Returns the x position of the given object*/ 
function findXPos(obj){ 
    var current = 0; 
    if (obj.offsetParent){ 
        while (obj.offsetParent){ 
            current += obj.offsetLeft 
            obj = obj.offsetParent; 
        } 
    }else if (obj.x){ 
        current += obj.x; 
    } 
    return current; 
} 
/*Shows the home menu*/ 
function showPopup(oneToShow, pos){ 
/*    document.menuBackgroundImage.style.visibility='visible';*/ 
    mouseOverButton(); 
    /*think this is IE specific!*/ 
    yOffset = findYPos(document.all.item("homeButton")) + 18; 
    document.menuBackgroundImage.style.top = yOffset; 
    homeMenuLinks.style.top = yOffset; 
    if (oneToShow == 'home'){ 
        document.menuBackgroundImage.style.left = pos - 5; 
        document.menuBackgroundImage.style.clip = 'rect(0px 70px 70px 0px)'; 
        homeMenuLinks.style.left = pos - 5; 
        homeMenuLinks.innerHTML=getCurrentHomeMenuText(); 
    }else if (oneToShow == 'specialist'){ 
        document.menuBackgroundImage.style.left = pos; 
        document.menuBackgroundImage.style.clip = 'rect(0px 150px 170px 0px)'; 
        homeMenuLinks.style.left = pos; 
        homeMenuLinks.innerHTML=getCurrentSpecialistMenuText(); 
    } 
} 
/*Called when the user moves the mouse on to one of the links in the menu*/ 
function mouseOverLink(pos){ 
    clearTimeout(disposePending); 
    if (pos == 1){ 
        homeMenuItem.style.color="#0000FF"; 
    }else if (pos == 2){ 
        contactMenuItem.style.color="#0000FF"; 
    }else if (pos == 3){ 
        traditionalMenuItem.style.color="#0000FF"; 
    }else if (pos == 4){ 
        virtualMenuItem.style.color="#0000FF"; 
    }else if (pos == 5){ 
        exhibitionMenuItem.style.color="#0000FF"; 
    }else if (pos == 6){ 
        kershawMenuItem.style.color="#0000FF"; 
    }else if (pos == 7){ 
        WoodgrainingMenuItem.style.color="#0000FF"; 
    }else if (pos == 8){ 
        MarblingMenuItem.style.color="#0000FF"; 
    }else if (pos == 9){ 
        Trompe_L_OeilMenuItem.style.color="#0000FF"; 
    }else if (pos == 10){ 
        GildingMenuItem.style.color="#0000FF"; 
    }else if (pos == 11){ 
        Courses_and_MasterclassesMenuItem.style.color="#0000FF"; 
    } 
} 
/*Called when the mouse moves off a menu item, or used to re-set to defaults*/ 
function mouseOffLink(pos){ 
    if (pos == 1){ 
        homeMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 2){ 
        contactMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 3){ 
        traditionalMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 4){ 
        virtualMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 5){ 
        exhibitionMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 6){ 
        kershawMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 7){ 
        WoodgrainingMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 8){ 
        MarblingMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 9){ 
        Trompe_L_OeilMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 10){ 
        GildingMenuItem.style.color="#FFFFFF"; 
    }else if (pos == 11){ 
        Courses_and_MasterclassesMenuItem.style.color="#FFFFFF"; 
    } 
    mouseOffButton(); 
} 
/*Hides the menus*/ 
function hidePopup(){ 
/*    document.menuBackgroundImage.style.visibility='hidden';*/ 
    homeMenuLinks.innerHTML=''; 
} 
/*Called when the user moves off one of the popup buttons*/ 
function mouseOffButton(){ 
    disposePending = setTimeout('hidePopup()',500); 
} 
/*Called when the mouse is moved over one of the popup buttons*/ 
function mouseOverButton(){ 
    clearTimeout(disposePending); 
} 
function mouseOverMenu(){ 
    mouseOverButton(); 
} 
function mouseOutMenu(){ 
    mouseOffButton(); 
} 
/*This will show the given page-->*/ 
function showPage(currentWindow,pageToShow){ 
    if (pageToShow != 'none'){ 
        currentWindow.location=pageToShow; 
    } 
} 
/*shows the given button as inset and shows a menu if required*/ 
function showMenu(currentWindow,oneToShow){  
    if (oneToShow == 'home'){ 
        currentWindow.showPopup('home', 
            findXPos(currentWindow.document.all.item("homeButton"))); 
    }else if (oneToShow == 'specialist'){ 
        currentWindow.showPopup('specialist', 
            findXPos(currentWindow.document.all.item("specialistButton"))); 
    } 
} 
/*Sets the button back to outset*/ 
function hideMenu(currentWindow,oneToHide){ 
    if (oneToHide == 'home'){ 
        currentWindow.mouseOffButton(); 
    }else if (oneToHide == 'specialist'){ 
        currentWindow.mouseOffButton(); 
    } 
} 
/*This final section deals with display of the header on every page----------------------*/ 
/*  This function will add the header to a page that has a div element called 
    headerText and headerBackdrop set up*/ 
function setUpHeader(){ 
    headerBackdrop.innerHTML = getHeaderBackdropText(); 
    headerText.innerHTML = getHeaderText(); 
    headerMenus.innerHTML = getHeaderMenuText(); 
} 
/*Returns the html to display the header background*/ 
function getHeaderBackdropText(){ 
    return  "<table width=700px align=center><tr><td>" + 
            "<img src='../header/headerBackground.gif' name='headerBackgroundImage' align=left>" +  
            "</td></tr></table>"; 
} 
/*Returns the text to draw the header*/ 
function getHeaderText(){ 
	return ""; 
} 
/*Returns the text to draw the header menus*/ 
function getHeaderMenuText(){ 
    return "<table width=100%><tr><td>" +  
        "<table width=700px align=center cellspacing=0 border=0 class=\"headerMenuTable\"> " +  
        "<tr><td> " +  
        "	<a 	name=\"homeButton\" " + 
        "		class=\'menuItem\' " + 
        "		onMouseOver=\"showMenu(window,'home');\" " +  
        "       onMouseOut=\"hideMenu(window,'home');\"> " + 
        "       	Home " +  
    	 "	</a> " +  
        "</td><td> " + 
        "	<a 	align=center " +  
        "		class=\'menuItem\' " + 
		 "		name=\"traditionalMenuItem\" " +  
        "       onClick=\"showPage(window,'../traditional/traditional.html');\" " +  
        "       onMouseOver=\"mouseOverLink(3);\" " +   
        "       onMouseOut=\"mouseOffLink(3);\"> " +   
        "           Traditional decorating " +  
        "	</a> " +  
        "</td><td> " + 
        "	<a	align=center class=\'menuItem\' " + 
        "       name=\"virtualMenuItem\"  " +  
        "       onClick=\"showPage(window,'../virtual/virtual.html');\" " +  
        "       onMouseOver=\"mouseOverLink(4);\"  " +  
        "       onMouseOut=\"mouseOffLink(4);\"> " +  
        "           Virtual decorating " +  
        "	</a>" +  
        "</td><td> " +  
        "	<a 	align=center class=\'menuItem\' " + 
        "       name=\"specialistButton\"  " +  
        "       onMouseOver=\"showMenu(window,'specialist');\"  " +  
        "       onMouseOut=\"hideMenu(window,'specialist');\"> " +  
        "           Specialist decorating " +  
        "   </a> " +  
        "</td></tr></table>" +  
        "</td></tr></table>"; 
} 
/*Returns the text to display in the home menu*/ 
function getCurrentHomeMenuText(){ 
    return '<table class="menuTable" width="60" cellpadding="5">'+ 
        '<tr><td>' + 
            '<a class="menuItem" ' + 
                'name=\'homeMenuItem\' ' + 
                'onClick=\"showPage(window,\'../home/home.html\');\" ' +  
                'onMouseOver="mouseOverLink(1);"' + 
                'onMouseOut="mouseOffLink(1);">' +  
                'Profile</a>' + 
        '</td></tr>' + 
        '<tr><td>' +  
            '<a class="menuItem" ' +  
                'name=\'contactMenuItem\' ' + 
                'onClick=\"showPage(window,\'../contact/contact.html\');\" ' +  
                'onMouseOver="mouseOverLink(2);" ' +   
                'onMouseOut="mouseOffLink(2);">' +   
                'Contact</a> ' + 
        '</td></tr>' + 
    '</table>' 
} 
/*Returns the text to display in the specialist menu*/ 
function getCurrentSpecialistMenuText(){ 
    return '<table class="menuTable" width="150" cellpadding="5">'+ 
        '<tr><td width="130">' + 
            '<a class="menuItem" ' + 
                'name=\'exhibitionMenuItem\' ' + 
                'onClick=\"showPage(window,\'../exhibition/exhibition.html\');\" ' +  
                'onMouseOver="mouseOverLink(5);" ' +   
                'onMouseOut="mouseOffLink(5);">' +   
                'Exhibition work</a> ' + 
        '</td></tr>' + 
        '<tr><td>' +  
            '<a class="menuItem" ' + 
                'name=\'kershawMenuItem\' ' + 
                'onClick=\"showPage(window,\'../kershaw/kershaw.html\');\" ' +  
                'onMouseOver="mouseOverLink(6);" ' +   
                'onMouseOut="mouseOffLink(6);">' +   
                'Thomas Kershaw</a> ' + 
        '</td></tr>' + 
        '<tr><td>' +  
            '<div>' + 
            '<a class="menuItem" ' + 
                'name=\'WoodgrainingMenuItem\'' + 
                'onClick=\"showPage(window,\'../Woodgraining/Woodgraining.html\');\" ' +  
                'onMouseOver="mouseOverLink(7);"' + 
                'onMouseOut="mouseOffLink(7);">' +  
                'Woodgraining</a>' + 
            '<div>' +  
        '</td></tr>' + 
        '<tr><td>' +  
            '<div>' + 
            '<a class="menuItem" ' + 
                'name=\'MarblingMenuItem\'' + 
                'onClick=\"showPage(window,\'../Marbling/Marbling.html\');\" ' +  
                'onMouseOver="mouseOverLink(8);"' + 
                'onMouseOut="mouseOffLink(8);">' +  
                'Marbling</a>' + 
            '<div>' +  
        '</td></tr>' + 
        '<tr><td>' +  
            '<div>' + 
            '<a class="menuItem" ' + 
                'name=\'Trompe_L_OeilMenuItem\'' + 
                'onClick=\"showPage(window,\'../Trompe_L_Oeil/Trompe_L_Oeil.html\');\" ' +  
                'onMouseOver="mouseOverLink(9);"' + 
                'onMouseOut="mouseOffLink(9);">' +  
                'Trompe L`Oeil</a>' + 
            '<div>' +  
        '</td></tr>' + 
        '<tr><td>' +  
            '<div>' + 
            '<a class="menuItem" ' + 
                'name=\'GildingMenuItem\'' + 
                'onClick=\"showPage(window,\'../Gilding/Gilding.html\');\" ' +  
                'onMouseOver="mouseOverLink(10);"' + 
                'onMouseOut="mouseOffLink(10);">' +  
                'Gilding</a>' + 
            '<div>' +  
        '</td></tr>' + 
        '<tr><td>' +  
            '<div>' + 
            '<a class="menuItem" ' + 
                'name=\'Courses_and_MasterclassesMenuItem\'' + 
                'onClick=\"showPage(window,\'../Courses_and_Masterclasses/Courses_and_Masterclasses.html\');\" ' +  
                'onMouseOver="mouseOverLink(11);"' + 
                'onMouseOut="mouseOffLink(11);">' +  
                'Courses and Masterclasses</a>' + 
            '<div>' +  
        '</td></tr>' + 
    '</table>'; 
} 
/*IE 5 and 6 do not render png transparent images correctly, unless this is called*/ 
var arVersion = navigator.appVersion.split("MSIE") 
var version = parseFloat(arVersion[1]) 
function fixPNG(myImage)  
{ 
    if ((version >= 5.5) && (version < 7) && (document.body.filters))  
    { 
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "" 
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "" 
	   var imgTitle = (myImage.title) ?  
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' " 
	   var imgStyle = "display:inline-block;" + myImage.style.cssText 
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle 
                  + " style=\"" + "width:" + myImage.width  
                  + "px; height:" + myImage.height  
                  + "px;" + imgStyle + ";" 
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>" 
	   myImage.outerHTML = strNewHTML	   
    } 
} 